:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #101827;
  --muted: #58657a;
  --line: #aab4c4;
  --line-strong: #6b7280;
  --soft: #f5f7fb;
  --brand: #a40f3a;
  --brand-dark: #7f1030;
  --blue: #2563eb;
  --green: #16a34a;
  --danger: #be123c;
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(159, 18, 57, 0.13), transparent 34%),
    linear-gradient(90deg, rgba(159, 18, 57, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(159, 18, 57, 0.05) 1px, transparent 1px),
    #fff;
  background-size: auto, 32px 32px, 32px 32px, auto;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

button:hover,
.app-header nav a:hover {
  filter: brightness(0.97);
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  overflow: hidden;
}

.login-shell {
  position: relative;
  display: grid;
  width: min(100%, 1160px);
  min-height: 100svh;
  padding: 22px 20px;
  place-items: center;
}

.login-card {
  width: min(100%, 440px);
  padding: 30px 34px 34px;
  border: 1px solid rgba(159, 18, 57, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 48px rgba(86, 24, 46, 0.13);
}

.login-logo {
  display: block;
  width: 154px;
  margin: 0 auto 24px;
}

.login-kicker,
.kicker {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid #f4a3b8;
  border-radius: 6px;
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-card h1 {
  margin: 18px 0 10px;
  color: var(--brand);
  font-size: clamp(2.15rem, 4.5vw, 3.05rem);
  line-height: 1.03;
}

.login-card p {
  margin: 0 0 24px;
  color: #704556;
  font-size: 1.05rem;
  line-height: 1.45;
}

.login-card label,
.toolbar-field,
.rules-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.login-card label {
  margin-top: 14px;
  color: #694453;
}

.login-card input,
.toolbar-field input,
.toolbar-field select,
.rules-form input,
.rules-form select,
textarea {
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid #c9d3e3;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

.login-card button {
  width: 100%;
  min-height: 48px;
  margin-top: 16px;
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.login-alert {
  padding: 14px 16px;
  border: 1px solid #fecdd3;
  border-radius: 12px;
  color: #be123c;
  background: #fff1f2;
  font-weight: 800;
}

.login-runner {
  position: absolute;
  pointer-events: none;
  user-select: none;
}

.login-runner-cat {
  left: 21%;
  bottom: 9%;
  width: 76px;
  filter: drop-shadow(0 18px 26px rgba(47, 16, 29, 0.18));
}

.app-page {
  height: 100vh;
  overflow: hidden;
  background: #eef2f7;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 8px clamp(12px, 2vw, 42px);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.app-brandline {
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand img {
  display: block;
  width: 104px;
}

.app-brandline strong {
  color: var(--brand);
  font-size: 1.25rem;
  font-weight: 900;
}

.app-header nav,
.view-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-actions button {
  min-height: 34px;
}

.app-header a {
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
}

.view-tab,
.app-header nav a {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.view-tab.is-active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.sheet-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(100vh - 64px);
  padding: 0;
  overflow: hidden;
}

.sheet-topline {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.sheet-topline h1 {
  margin: 5px 0 0;
  color: var(--brand);
  font-size: 1.65rem;
  line-height: 1;
}

.sheet-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.sheet-stats span,
.sheet-stats strong,
.save-status {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid #d9b8c4;
  border-radius: 999px;
  background: #fff;
  color: var(--brand);
  padding: 0 13px;
  font-size: 0.86rem;
  font-weight: 900;
}

.sheet-stats strong {
  border-color: transparent;
  color: var(--ink);
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 8px;
  min-height: 58px;
  padding: 8px 10px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
}

.toolbar button {
  min-width: max-content;
}

.presence-inline {
  display: flex;
  min-width: max-content;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.presence-pill {
  border-radius: 999px;
  background: #eef2ff;
  color: #312e81;
  padding: 6px 9px;
  font-size: 0.78rem;
  font-weight: 900;
}

.toolbar-field {
  min-width: 190px;
}

.toolbar-field-small {
  min-width: 160px;
}

.paint-tools {
  display: inline-flex;
  min-width: max-content;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #f8fafc;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 900;
}

.paint-swatch {
  width: 26px;
  height: 26px;
  min-width: 26px !important;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: var(--swatch);
  padding: 0;
}

.paint-swatch.is-active {
  border-color: #0f172a;
  box-shadow: 0 0 0 2px #f59e0b;
}

.icon-button {
  width: 34px;
  min-width: 34px !important;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  line-height: 1;
}

.icon-button:disabled {
  color: #94a3b8;
  cursor: not-allowed;
  opacity: 0.55;
}

.icon-button.is-active {
  border-color: #f59e0b;
  background: #fffbeb;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.save-status {
  margin-left: auto;
  border-color: transparent;
  background: #ecfdf5;
  color: #166534;
}

.save-status.is-saving {
  background: #eff6ff;
  color: #1d4ed8;
}

.save-status.is-error {
  background: #fff1f2;
  color: #be123c;
}

.sheet-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

.sheet-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
}

.sheet-table th,
.sheet-table td {
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.sheet-table th {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 42px;
  background: #f8fafc;
  color: #1f2937;
  font-size: 0.86rem;
  font-weight: 900;
  text-align: center;
}

.sheet-table th span {
  display: inline-flex;
  max-width: calc(100% - 22px);
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.filter-button {
  width: 22px;
  min-width: 22px !important;
  height: 22px;
  min-height: 22px;
  margin-left: 5px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  vertical-align: middle;
}

.filter-button::before {
  content: "";
  display: block;
  width: 13px;
  height: 13px;
  margin: 4px auto;
  background: #64748b;
  clip-path: polygon(10% 15%, 90% 15%, 58% 52%, 58% 90%, 42% 90%, 42% 52%);
}

.filter-button:hover,
.filter-button.is-active {
  background: #e0e7ff;
}

.filter-button.is-active::before {
  background: var(--brand);
}

.sheet-table th:first-child,
.row-index {
  position: sticky;
  left: 0;
  z-index: 5;
  width: 52px;
  min-width: 52px;
  max-width: 52px;
  text-align: center;
  background: #f8fafc;
  color: #546179;
  font-weight: 900;
}

.sheet-table th:first-child {
  z-index: 8;
}

.sheet-table td {
  position: relative;
  height: 44px;
  background: #fff;
}

.sheet-cell.is-selected::before,
.sheet-cell.is-active-cell::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 2;
  pointer-events: none;
}

.sheet-cell.is-selected::before {
  border: 2px solid rgba(29, 78, 216, 0.9);
  background: rgba(37, 99, 235, 0.22);
  box-shadow: inset 0 0 0 1px rgba(29, 78, 216, 0.28);
}

.sheet-cell.is-active-cell::before {
  border: 2px solid #f59e0b;
  background: transparent;
}

.sheet-cell.is-fill-preview::after {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 4;
  pointer-events: none;
  border: 3px solid #ea580c;
  background: rgba(251, 146, 60, 0.26);
  box-shadow:
    inset 0 0 0 2px rgba(124, 45, 18, 0.5),
    0 0 0 1px rgba(234, 88, 12, 0.45);
}

.fill-handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  z-index: 6;
  width: 15px;
  height: 15px;
  border: 2px solid #fff;
  border-radius: 3px;
  background: #f59e0b;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.28);
  cursor: crosshair;
  pointer-events: auto;
}

body.is-fill-dragging,
body.is-fill-dragging * {
  cursor: crosshair !important;
  user-select: none;
}

.sheet-input {
  width: 100%;
  min-width: 0;
  height: 43px;
  border: 0;
  background: transparent;
  padding: 6px 9px;
  outline: none;
  color: #0f172a;
  font-size: 20px;
  font-weight: 800;
  text-align: center;
}

.sheet-input::placeholder {
  color: #0f172a;
  opacity: 1;
  font-weight: 900;
}

.sheet-input:focus {
  box-shadow: inset 0 0 0 2px #f59e0b;
  background: #fff;
}

.sheet-input.is-readonly {
  cursor: default;
  color: #0f172a;
}

.sheet-cell.has-remote-presence {
  outline: 3px solid var(--remote-color, #2563eb);
  outline-offset: -3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.75);
}

.sheet-cell.has-remote-presence.is-remote-editing {
  outline-width: 4px;
}

.remote-presence-badge {
  position: absolute;
  top: -15px;
  left: 7px;
  z-index: 8;
  max-width: min(180px, calc(100% - 12px));
  border: 1px solid color-mix(in srgb, var(--remote-color, #2563eb) 70%, #ffffff);
  border-radius: 999px;
  background: var(--remote-color, #2563eb);
  color: #fff;
  padding: 2px 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.65rem;
  font-weight: 900;
  line-height: 1.2;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
  pointer-events: none;
}

.has-conflict {
  box-shadow: inset 0 0 0 3px #ef4444 !important;
}

.has-conflict::after {
  content: "conflito";
  position: absolute;
  top: 2px;
  right: 4px;
  z-index: 7;
  border-radius: 999px;
  background: #fee2e2;
  color: #991b1b;
  padding: 1px 6px;
  font-size: 0.65rem;
  font-weight: 900;
  pointer-events: none;
}

.col-fornecedor-1,
.col-fornecedor-7 {
  background: #fff6cf;
}

.col-fornecedor-2 {
  background: #eaf4ff;
}

.col-fornecedor-3 {
  background: #edf9f0;
}

.col-fornecedor-4 {
  background: #fff0f6;
}

.col-fornecedor-5 {
  background: #f3eeff;
}

.col-fornecedor-6 {
  background: #fff1dc;
}

.col-winner {
  background: #f9fbff;
}

.is-winning-price,
.is-best-price {
  background: #dbeafe !important;
  box-shadow: inset 0 0 0 2px #3b82f6;
}

.is-computed .sheet-input {
  color: #0f172a;
  font-weight: 950;
}

tr.is-filtered {
  display: none;
}

.sheet-footer {
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--line-strong);
  background: #fff;
  padding: 8px;
}

.sheet-footer button {
  min-width: 220px;
}

.context-menu {
  position: fixed;
  z-index: 240;
  display: grid;
  min-width: 230px;
  max-height: calc(100vh - 16px);
  overflow: auto;
  gap: 2px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 6px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
}

.context-menu[hidden] {
  display: none;
}

.context-menu button {
  min-height: 34px;
  justify-content: flex-start;
  border: 0;
  background: transparent;
  color: #0f172a;
  text-align: left;
}

.context-menu button:hover:not(:disabled) {
  background: #f1f5f9;
}

.context-menu button:disabled {
  color: #94a3b8;
  cursor: not-allowed;
}

.context-divider {
  height: 1px;
  margin: 3px 0;
  background: #e2e8f0;
}

.filter-menu {
  position: fixed;
  z-index: 250;
  display: grid;
  width: min(420px, calc(100vw - 16px));
  max-height: min(520px, calc(100vh - 20px));
  gap: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
}

.filter-menu[hidden] {
  display: none;
}

.filter-menu strong {
  color: #111827;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.filter-options {
  display: grid;
  max-height: 330px;
  overflow: auto;
  gap: 6px;
  padding: 2px;
}

.filter-options label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  color: #111827;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.filter-options input {
  width: 16px;
  height: 16px;
}

.filter-section-title {
  color: #475569;
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.filter-color-options label {
  grid-template-columns: 18px 18px minmax(0, 1fr);
  align-items: center;
}

.filter-color-swatch {
  width: 16px;
  height: 16px;
  border: 1px solid #64748b;
  border-radius: 4px;
  background: var(--filter-color);
}

.filter-color-swatch.is-empty {
  background:
    linear-gradient(135deg, transparent 45%, #ef4444 46%, #ef4444 54%, transparent 55%),
    #fff;
}

dialog {
  width: min(760px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.22);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog-card {
  display: grid;
  gap: 14px;
  padding: 22px;
  color: #111827;
}

.dialog-card h2 {
  margin: 0;
}

.dialog-card p {
  margin: 0;
  color: #374151;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.cell-history-list {
  display: grid;
  max-height: min(54vh, 460px);
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.history-row {
  display: grid;
  gap: 10px;
  border: 1px solid #dbe4f0;
  border-radius: 10px;
  padding: 12px;
  background: #f8fafc;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: #475569;
  font-size: 0.82rem;
  font-weight: 800;
}

.history-meta strong {
  color: #111827;
}

.history-flag {
  border: 1px solid #fed7aa;
  border-radius: 999px;
  background: #fff7ed;
  color: #9a3412;
  padding: 2px 8px;
  font-size: 0.74rem;
}

.history-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.history-values span {
  display: grid;
  min-height: 56px;
  align-content: start;
  gap: 4px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  color: #111827;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.history-values b {
  color: #64748b;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.history-actions {
  display: flex;
  justify-content: flex-end;
}

.history-actions button {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.diagnostics-grid section {
  display: grid;
  gap: 8px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #f8fafc;
}

.diagnostics-grid h3 {
  margin: 0;
  font-size: 0.95rem;
}

.diagnostics-grid select {
  width: 100%;
  min-height: 34px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 6px 8px;
}

.diagnostics-output {
  max-height: 300px;
  overflow: auto;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 12px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.8rem;
  white-space: pre-wrap;
}

.dialog-danger {
  border-color: #fecdd3;
  background: #fff1f2;
  color: var(--danger);
}

#rulesDialog {
  width: min(980px, calc(100vw - 28px));
}

.rules-dialog-card {
  gap: 16px;
  padding: 24px;
}

.rules-dialog-card h2 {
  color: #111827;
  font-size: 1.35rem;
  line-height: 1.1;
}

.rules-dialog-card > p {
  max-width: 680px;
  color: #475569;
  line-height: 1.35;
}

.rules-form {
  display: grid;
  grid-template-columns: minmax(132px, 0.9fr) minmax(120px, 0.82fr) minmax(164px, 1.08fr) 76px minmax(112px, 0.7fr) 112px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid #dbe4f0;
  border-radius: 10px;
  background: #f8fafc;
}

.rules-form label,
.rule-row label {
  display: grid;
  gap: 5px;
  color: #475569;
  font-size: 0.72rem;
  font-weight: 950;
}

.rules-form input,
.rules-form select,
.rule-row input,
.rule-row select {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid #c9d3e3;
  border-radius: 7px;
  background: #fff;
  color: #111827;
  font-size: 0.82rem;
}

.rules-form input[type="color"],
.rule-row input[type="color"] {
  padding: 3px;
}

#addRuleButton {
  min-height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}

.rules-list {
  display: grid;
  max-height: min(44vh, 340px);
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.rule-row {
  display: grid;
  grid-template-columns: minmax(132px, 0.9fr) minmax(120px, 0.82fr) minmax(164px, 1.08fr) 76px minmax(112px, 0.7fr) minmax(146px, 0.9fr);
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid #dbe4f0;
  border-radius: 10px;
  background: #fff;
  color: #111827;
  font-size: 0.9rem;
  line-height: 1.35;
}

.rules-form .rule-check,
.rule-row .rule-check {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
  border: 1px solid #c9d3e3;
  border-radius: 7px;
  background: #fff;
  color: #111827;
}

.rules-form .rule-check input,
.rule-row .rule-check input {
  width: 15px;
  min-height: 15px;
}

.rule-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.rule-row button {
  min-height: 34px;
  padding: 0 10px;
}

.rule-row .rule-save {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.rule-row .rule-delete {
  border-color: #fecdd3;
  background: #fff1f2;
  color: var(--danger);
}

/* Cotacao V2 operational polish */
:root {
  --surface: #ffffff;
  --surface-soft: #f7f9fd;
  --surface-rail: #eef3fa;
  --grid-line: #6b7280;
  --grid-line-soft: #9ca3af;
  --text-strong: #111827;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --amber: #f59e0b;
}

body {
  background: var(--surface-rail);
}

button,
.app-header nav a {
  min-height: 32px;
  border-radius: 6px;
  border-color: #c7d2e3;
  background: linear-gradient(#fff, #f8fafc);
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.04);
  font-size: 0.82rem;
}

button svg {
  width: 18px;
  height: 18px;
  display: block;
}

.app-header {
  min-height: 56px;
  padding: 8px 18px;
  border-bottom-color: #d9e1ee;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
}

.app-brandline {
  gap: 18px;
}

.brand img {
  width: 92px;
}

.app-brandline strong {
  color: #9f1239;
  font-size: 1.05rem;
}

.sheet-shell {
  height: calc(100vh - 56px);
}

.sheet-topline {
  min-height: 48px;
  padding: 6px 10px;
  background: #f7f9fd;
}

.kicker {
  min-height: 24px;
  padding: 2px 8px;
  border-color: #fecdd3;
  background: #fff;
  font-size: 0.66rem;
  letter-spacing: 0.07em;
}

.sheet-topline p {
  display: none;
}

.sheet-stats {
  gap: 8px;
}

.sheet-stats span,
.sheet-stats strong,
.save-status {
  min-height: 28px;
  padding: 0 10px;
  border-color: #e2e8f0;
  font-size: 0.78rem;
}

.top-history-button {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid #d9b8c4;
  border-radius: 999px;
  background: #fff;
  color: var(--brand);
  padding: 0 11px;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
}

.top-history-button:hover {
  border-color: #9f1239;
  background: #fff1f2;
}

.presence-top {
  gap: 5px;
}

.presence-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #dbe4ff;
  background: #eef4ff;
  color: #1e3a8a;
  padding: 4px 8px;
  font-size: 0.75rem;
}

.presence-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--presence-color, #2563eb);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.presence-pill.is-you {
  border-color: #fbcfe8;
  background: #fff1f2;
  color: var(--brand);
}

.toolbar {
  min-height: 48px;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 0;
  background: #fbfcff;
}

.toolbar-field {
  min-width: 185px;
}

.toolbar-field input {
  min-height: 31px;
  border-radius: 6px;
  font-size: 0.78rem;
}

.paint-tools {
  position: static;
  min-width: auto;
  padding: 0;
  border: 0;
  background: transparent;
}

.paint-palette {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 260;
  display: grid;
  grid-template-columns: repeat(7, 24px);
  gap: 6px;
  max-width: calc(100vw - 16px);
  max-height: min(360px, calc(100vh - 16px));
  overflow: auto;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.18);
}

.paint-palette[hidden] {
  display: none;
}

.paint-swatch {
  width: 24px;
  height: 24px;
  min-width: 24px !important;
  border-radius: 6px;
}

.icon-button {
  width: 32px;
  min-width: 32px !important;
  min-height: 32px;
}

.sheet-table {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.sheet-table th,
.sheet-table td {
  border-right-color: var(--grid-line);
  border-bottom-color: var(--grid-line);
}

.sheet-table th {
  height: 36px;
  background: #f4f7fb;
  color: #111827;
  font-size: 0.78rem;
  letter-spacing: 0;
}

.sheet-table th span.column-title {
  max-width: calc(100% - 28px);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.1;
}

.column-title-editor {
  width: calc(100% - 28px);
  min-height: 28px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  padding: 3px 6px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 900;
  outline: none;
}

.resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  z-index: 12;
  width: 8px;
  min-width: 8px !important;
  height: 100%;
  min-height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: col-resize;
}

.resize-handle:hover,
body.is-resizing-column .resize-handle {
  background: rgba(37, 99, 235, 0.14);
}

body.is-resizing-column {
  cursor: col-resize;
  user-select: none;
}

.column-resize-guide {
  position: fixed;
  z-index: 80;
  width: 0;
  border-left: 3px solid #ea580c;
  pointer-events: none;
  filter: drop-shadow(0 0 2px rgba(124, 45, 18, 0.45));
}

.column-resize-badge {
  position: fixed;
  z-index: 81;
  min-width: 124px;
  padding: 7px 10px;
  border: 1px solid rgba(124, 45, 18, 0.28);
  border-radius: 7px;
  background: #fff7ed;
  color: #7c2d12;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
  font-size: 0.78rem;
  font-weight: 950;
  text-align: center;
  pointer-events: none;
}

.sheet-table td {
  height: auto;
  min-height: 42px;
  vertical-align: top;
  background: #fff;
}

.sheet-input {
  display: block;
  min-height: 42px;
  height: auto;
  overflow: hidden;
  resize: none;
  padding: 7px 9px;
  line-height: 1.22;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-strong);
  font-size: 18px;
  font-weight: 800;
}

.is-computed .sheet-input {
  font-size: 17px;
  line-height: 1.22;
}

.sheet-cell.is-selected::before {
  border-color: rgba(29, 78, 216, 0.9);
  background: rgba(37, 99, 235, 0.22);
  box-shadow: inset 0 0 0 1px rgba(29, 78, 216, 0.28);
}

.sheet-cell.is-active-cell::before {
  border-color: var(--amber);
}

.sheet-table th.is-selected-header,
.row-index.is-selected-row {
  background: #dbeafe;
  color: #1d4ed8;
}

.sheet-table th.row-index.is-active-row-header {
  background: #16a34a;
  color: #fff;
  box-shadow:
    inset 0 0 0 2px #047857,
    0 0 0 1px rgba(5, 150, 105, 0.35);
}

.filter-button {
  width: 20px;
  min-width: 20px !important;
  height: 20px;
  min-height: 20px;
}

.filter-button::before {
  width: 12px;
  height: 12px;
}

.sheet-footer {
  min-width: 100%;
  padding: 14px 12px 28px;
  border-top: 1px solid var(--grid-line-soft);
  background: #fbfcff;
}

.sheet-footer button {
  min-width: 210px;
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

@media (max-width: 860px) {
  .app-page {
    overflow: auto;
  }

  .app-header,
  .app-brandline,
  .view-tabs,
  .toolbar,
  .sheet-topline,
  .sheet-stats {
    display: grid;
  }

  .app-header {
    position: static;
  }

  .sheet-shell {
    height: auto;
    min-height: calc(100vh - 88px);
  }

  .save-status {
    margin-left: 0;
  }

  .diagnostics-grid {
    grid-template-columns: 1fr;
  }

  .rules-form {
    grid-template-columns: 1fr;
  }

  .rule-row {
    grid-template-columns: 1fr;
  }

  .rule-actions {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 36px 24px;
  }
}
