:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d252d;
  --muted: #66717c;
  --line: #d9dee5;
  --accent: #176b4d;
  --accent-dark: #0f4f39;
  --danger-bg: #fff1f0;
  --danger-text: #8a1f12;
}

.commercial-import-grid {
  grid-template-columns: minmax(220px, .8fr) minmax(260px, 1.2fr) minmax(260px, 1fr);
}

.commercial-import-summary {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.commercial-import-preview table {
  min-width: 1900px;
}

.status-validado,
.status-valido,
.status-confirmado,
.status-importado {
  background: #dff3e7;
  color: #155d37;
}

.status-con_advertencias,
.status-advertencia,
.status-omitido {
  background: #fff1c9;
  color: #6d4b00;
}

.status-con_errores,
.status-error {
  background: #fde2e2;
  color: #8d2020;
}

@media (max-width: 760px) {
  .commercial-import-grid,
  .commercial-import-summary {
    grid-template-columns: minmax(0, 1fr);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

a { color: inherit; }

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand {
  align-items: center;
  display: inline-flex;
  text-decoration: none;
}

.brand img {
  display: block;
  height: 38px;
  width: auto;
}

.topbar nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.nav-form { display: inline-flex; }
.nav-button {
  background: transparent;
  border: 0;
  color: var(--muted);
  min-height: auto;
  padding: 0;
}
.nav-button:hover { background: transparent; color: var(--text); }

.auth-page { min-height: 100vh; display: grid; place-items: center; }
.auth-shell { width: min(420px, calc(100% - 32px)); }
.auth-logo { display: block; height: 54px; margin: 0 auto 18px; width: auto; }
.auth-panel { margin: 0; }
.auth-panel .form { max-width: none; }
.narrow-panel { max-width: 620px; margin-left: auto; margin-right: auto; }
.inline-user-form { align-items: center; display: flex; gap: 6px; min-width: 520px; }
.inline-user-form input, .inline-user-form select { min-width: 160px; }

.users-table {
  min-width: 1500px;
}

.users-role-cell {
  min-width: 540px;
}

.users-last-login {
  min-width: 210px;
  overflow-wrap: normal;
  white-space: nowrap;
}

.legal-header {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px max(20px, calc((100% - 920px) / 2));
}
.legal-header img { height: 42px; width: auto; }
.legal-header nav { display: flex; gap: 16px; }
.legal-header a { color: var(--accent); font-weight: 700; text-decoration: none; }
.legal-page { margin: 28px auto 56px; padding: 0 20px; width: min(920px, 100%); }
.legal-document { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: clamp(20px, 4vw, 42px); }
.legal-document h1 { font-size: 28px; }
.legal-document h2 { font-size: 17px; margin-top: 28px; }
.legal-document p { color: var(--text); line-height: 1.65; }
.legal-document a { color: var(--accent); }
.disconnected-message { margin-top: 10vh; text-align: center; }

@media (max-width: 640px) {
  .legal-header { align-items: flex-start; gap: 12px; padding: 10px 16px; }
  .legal-header nav { flex-direction: column; gap: 5px; text-align: right; }
  .legal-document h1 { font-size: 23px; }
}

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
}

.page {
  width: min(1280px, calc(100% - 32px));
  margin: 24px auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { color: var(--muted); }

.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.action {
  display: block;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
}

.action span {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

.action small {
  color: var(--muted);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.title-row {
  align-items: center;
  display: flex;
  gap: 10px;
}

.title-row h1 {
  margin-bottom: 0;
}

.title-row + p {
  margin-top: 6px;
}

.form {
  display: grid;
  gap: 14px;
  max-width: 720px;
}

.block-form {
  max-width: none;
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-grid > label {
  min-width: 0;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  min-width: 0;
  width: 100%;
}

.report-generator-form [data-report-block] {
  display: block;
  max-width: 100%;
}

.report-generator-form .form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.report-generator-form .form-grid > label {
  overflow: hidden;
}

.report-generator-form .report-block-field {
  grid-column: 1 / -1;
}

.form-field-hidden {
  display: none;
}

.form-actions {
  align-items: center;
  display: flex;
  gap: 12px;
}

.plain-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.report-open-col,
.report-open-col .plain-link {
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
}

th.report-open-col,
td.report-open-col {
  min-width: 84px;
  width: 84px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

input, select, button, textarea {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}

textarea {
  resize: vertical;
}

button {
  width: fit-content;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  background: #9aa3ad;
  border-color: #9aa3ad;
  cursor: not-allowed;
}

.environment-badge {
  background: #eef2f6;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 9px;
  text-transform: uppercase;
}
.connection-actions { display: flex; flex-wrap: wrap; gap: 14px; }
.connection-actions form { align-items: flex-start; display: flex; flex-direction: column; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  min-height: auto;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.summary div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.payments-company-form,
.payments-config-actions,
.payments-config-form {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.payments-company-form label {
  min-width: min(420px, 100%);
}

.payments-config-actions {
  justify-content: space-between;
}

.payments-config-form .check {
  align-self: center;
}

.debt-balance-table {
  min-width: 1780px;
}

.debt-balance-table th:not(:first-child),
.debt-balance-table td:not(:first-child) {
  text-align: right;
  white-space: nowrap;
}

.debt-balance-table tbody tr:nth-child(even) td {
  background: #f8fafb;
}

.debt-balance-table tfoot td {
  background: #e8eaed;
  font-weight: 800;
}

.debt-alert {
  color: #7b4d00;
  font-weight: 700;
}

.debt-overdue {
  color: var(--danger-text);
  font-weight: 800;
}

.subcustomer-label {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 3px;
}

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

.export-comparison-header {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.comparison-band-field,
.comparison-sales-band-field {
  grid-column: auto;
}

.comparison-agreed-price {
  color: #704800;
  font-weight: 800;
}

.comparison-agreed-price input {
  background: #fff4c2;
  border-color: #b47700;
  box-shadow: 0 0 0 2px rgba(180, 119, 0, 0.12);
  color: #3f2b00;
  font-weight: 800;
}

.comparison-agreed-price input:focus {
  border-color: #825600;
  outline: 2px solid rgba(180, 119, 0, 0.25);
}

.price-calculator {
  max-width: 980px;
}

.calculator-head-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.calculator-save-dialog {
  width: min(520px, calc(100% - 32px));
}

.calculator-save-dialog label {
  margin-top: 16px;
}

.calculator-history {
  margin-top: 18px;
}

.calculation-detail-table {
  min-width: 860px;
}

.calculator-band-field {
  max-width: 620px;
}

.calculator-band-field .select-with-action {
  align-items: center;
  display: flex;
  gap: 8px;
}

.calculator-band-field select {
  flex: 1 1 auto;
  min-width: 0;
}

.calculator-band-editor-table {
  min-width: 480px !important;
}

.calculator-band-editor-table th,
.calculator-band-editor-table td {
  text-align: right;
}

.calculator-band-editor-table th:first-child,
.calculator-band-editor-table td:first-child {
  text-align: left;
}

.calculator-results {
  margin-top: 18px;
}

.calculator-status {
  border: 1px solid;
  border-radius: 6px;
  font-weight: 800;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.calculator-status.warning {
  background: #fff8e6;
  border-color: #d7a927;
  color: #704800;
}

.calculator-status.success {
  background: #edf8f3;
  border-color: #4d9b77;
  color: #146044;
}

.calculator-table {
  min-width: 680px;
  table-layout: fixed;
}

.calculator-table th,
.calculator-table td {
  text-align: right;
  white-space: nowrap;
}

.calculator-table th:first-child,
.calculator-table td:first-child {
  text-align: left;
  width: 16%;
}

.calculator-table input {
  min-height: 34px;
  padding: 5px 7px;
  text-align: right;
  width: 100%;
}

.calculator-table input:disabled {
  background: #eef1f3;
  border-color: #d7dde2;
}

.calculator-table tbody tr:nth-child(even) td {
  background: #f8fafb;
}

.calculator-table tfoot td {
  background: #202a32;
  color: #fff;
  font-weight: 800;
}

.calculator-national {
  margin-top: 16px;
}

.calculator-national h2 {
  font-size: 16px;
  margin-bottom: 8px;
}

.calculator-national-table {
  min-width: 520px;
  width: 100%;
}

.calculator-national-table th:not(:first-child),
.calculator-national-table td:not(:first-child) {
  text-align: right;
}

.calculator-national-table input {
  min-height: 34px;
  padding: 5px 7px;
  text-align: right;
  width: 100%;
}

.calculator-national-table tbody tr:nth-child(even) td {
  background: #f8fafb;
}

.calculator-grand-total {
  align-items: center;
  background: #202a32;
  color: #fff;
  display: grid;
  font-weight: 800;
  gap: 12px;
  grid-template-columns: 1fr auto auto;
  margin-top: 12px;
  padding: 11px 12px;
}

.calculator-grand-total .calculator-percentage-total {
  min-width: 110px;
  text-align: right !important;
}

.calculator-grand-total .calculator-price-total {
  min-width: 110px;
  text-align: right;
}

.calculator-national-editor table {
  min-width: 480px;
}

.calculator-percentage-total {
  text-align: center !important;
}

.calculator-price-total {
  color: #fff7c7 !important;
  font-size: 16px;
}

.block-progress-dialog {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 22px;
  width: min(620px, calc(100% - 32px));
}

.block-progress-dialog::backdrop {
  background: rgba(29, 37, 45, 0.58);
}

.block-progress-head {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.block-progress-head h2 {
  margin-bottom: 4px;
}

.block-progress-head p {
  margin-bottom: 12px;
}

.block-progress-head strong {
  color: var(--accent);
  font-size: 20px;
}

.block-progress-dialog progress {
  accent-color: var(--accent);
  display: block;
  height: 16px;
  width: 100%;
}

.block-progress-current {
  color: var(--text);
  font-weight: 800;
  margin: 14px 0 8px;
}

.block-progress-operations {
  border: 1px solid var(--line);
  border-radius: 6px;
  list-style: none;
  margin: 0;
  max-height: 260px;
  min-height: 84px;
  overflow-y: auto;
  padding: 6px 10px;
}

.block-progress-operation {
  border-bottom: 1px solid #edf0f2;
  color: var(--muted);
  padding: 7px 4px 7px 24px;
  position: relative;
}

.block-progress-operation:last-child {
  border-bottom: 0;
}

.block-progress-operation::before {
  border: 2px solid var(--accent);
  border-radius: 50%;
  content: "";
  height: 8px;
  left: 5px;
  position: absolute;
  top: 12px;
  width: 8px;
}

.block-progress-operation.warning::before {
  border-color: #b47700;
}

.block-progress-operation.failed::before {
  border-color: var(--danger-text);
}

.block-progress-dialog > button {
  margin-top: 12px;
}

.select-with-action {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.select-with-action select {
  min-width: 0;
  width: 100%;
}

.secondary-button {
  background: #fff;
  border-color: var(--line);
  color: var(--accent);
}

.secondary-button:hover {
  background: #eef5f1;
  border-color: var(--accent);
}

.comparison-table-head {
  margin-top: 24px;
}

.comparison-save-actions {
  margin-top: 14px;
}

.export-comparison-table {
  min-width: 1220px;
}

.export-comparison-table th:nth-child(n+4),
.export-comparison-table td:nth-child(n+4) {
  text-align: right;
  white-space: nowrap;
}

.export-comparison-table input[type="number"] {
  min-width: 120px;
  text-align: right;
  width: 120px;
}

.export-comparison-table tbody tr:nth-child(even) td {
  background: #f8fafb;
}

.export-comparison-table tfoot td {
  background: #e8eaed;
  font-weight: 800;
}

.band-dialog {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  max-height: min(88vh, 900px);
  padding: 20px;
  width: min(980px, calc(100% - 32px));
}

.band-dialog::backdrop {
  background: rgba(29, 37, 45, 0.52);
}

.band-dialog form {
  display: grid;
  gap: 14px;
}

.commercial-control-dialog {
  width: min(620px, calc(100% - 32px));
}

.commercial-invoice-dialog {
  width: min(780px, calc(100% - 32px));
}

.commercial-movement-dialog {
  width: min(920px, calc(100% - 32px));
}

.band-metadata {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.band-products-wrap {
  max-height: 56vh;
}

.band-products-wrap table {
  min-width: 680px;
}

.band-products-wrap thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.band-products-wrap input {
  min-width: 130px;
  text-align: right;
  width: 100%;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 4px 0 0;
  font-weight: 700;
}

.error {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.notice {
  border-radius: 6px;
  margin: 12px 0;
  padding: 10px 12px;
  font-weight: 600;
}

.success {
  background: #edf8f3;
  color: #146044;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.tabs a {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  text-decoration: none;
  color: var(--muted);
}

.tabs a.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.search {
  display: flex;
  gap: 8px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.document-picker {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.document-picker-head {
  align-items: center;
  background: #f0f3f6;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 12px;
}

.document-picker-head span {
  color: var(--muted);
  font-size: 12px;
}

.document-list {
  display: grid;
  max-height: 360px;
  overflow: auto;
}

.document-option {
  align-items: flex-start;
  border-top: 1px solid var(--line);
  cursor: pointer;
  display: flex;
  font-weight: 500;
  gap: 10px;
  padding: 9px 12px;
}

.document-option input {
  flex: 0 0 auto;
  margin-top: 2px;
  min-height: auto;
}

.document-option span {
  overflow-wrap: anywhere;
}

.document-empty {
  color: var(--muted);
  padding: 14px 12px;
}

.muted-text {
  color: var(--muted);
  display: block;
  font-weight: 400;
  margin-top: 4px;
}

.cal-rangel-heading {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: flex-start;
}

.cal-rangel-heading > div {
  min-width: 0;
}

.cal-rangel-app-icon {
  border: 1px solid var(--line);
  border-radius: 16px;
  flex: 0 0 72px;
  height: 72px;
  object-fit: cover;
  width: 72px;
}

.cal-rangel-platforms {
  display: grid;
  margin-top: 8px;
}

.cal-rangel-platform {
  align-items: start;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 16px 24px;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 220px);
  padding: 20px 0;
}

.cal-rangel-platform:first-child {
  border-top: 0;
}

.cal-rangel-platform-copy {
  min-width: 0;
  padding-top: 8px;
}

.cal-rangel-platform-copy .muted-text {
  overflow-wrap: break-word;
}

.cal-rangel-android-copy {
  align-items: center;
  display: flex;
  gap: 14px;
  padding-top: 0;
}

.cal-rangel-platform-logo {
  flex: 0 0 52px;
  height: 40px;
  object-fit: contain;
  object-position: center bottom;
  width: 52px;
}

.cal-rangel-platform-action {
  align-items: stretch;
  display: flex;
  flex-direction: column;
  gap: 14px;
  justify-self: end;
  min-width: 0;
  width: 100%;
}

.cal-rangel-app-store-link {
  align-self: flex-end;
  display: block;
  max-width: 100%;
  width: 180px;
}

.cal-rangel-app-store-link img {
  display: block;
  height: auto;
  max-width: 100%;
  width: 100%;
}

.cal-rangel-android-button {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: center;
  min-height: 54px;
  overflow: hidden;
  width: 100%;
}

.cal-rangel-android-button img {
  border-radius: 7px;
  flex: 0 0 32px;
  height: 32px;
  width: 32px;
}

.cal-rangel-android-button span {
  min-width: 0;
  white-space: nowrap;
}

.cal-rangel-install-note {
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
  overflow-wrap: break-word;
}

.cal-rangel-android-attribution {
  color: var(--muted);
  font-size: 11px;
  margin: 10px 0 0;
}

@media (max-width: 620px) {
  .cal-rangel-platform {
    grid-template-columns: 1fr;
    padding: 18px 0;
  }

  .cal-rangel-platform-copy {
    padding-top: 0;
  }

  .cal-rangel-platform-action {
    justify-self: stretch;
    width: 100%;
  }

  .cal-rangel-app-store-link {
    align-self: flex-start;
  }
}

@media (max-width: 380px) {
  .cal-rangel-heading {
    align-items: flex-start;
  }

  .cal-rangel-app-icon {
    border-radius: 12px;
    flex-basis: 56px;
    height: 56px;
    width: 56px;
  }

  .cal-rangel-android-button {
    font-size: 14px;
  }
}

.report-table-wrap {
  margin-top: 12px;
}

.report-table {
  min-width: max-content;
  table-layout: auto;
}

.report-table th {
  text-align: center;
}

.report-table th:first-child,
.report-table td:first-child {
  min-width: 0;
  width: auto;
}

.report-table th:not(:first-child),
.report-table td:not(:first-child) {
  min-width: 0;
}

.folio-cell {
  font-weight: 700;
  width: 1%;
  white-space: nowrap;
}

.folio-cell > span {
  display: inline-block;
  text-align: left;
  white-space: nowrap;
}

.group-toggle {
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  font-weight: 800;
  min-height: 24px;
  padding: 0 4px;
  width: 100%;
}

.group-toggle:hover,
.group-toggle.collapsed {
  background: transparent;
  color: var(--accent);
}

.group-toggle::after {
  content: " -";
}

.group-toggle.collapsed::after {
  content: " +";
}

.group-summary-col {
  display: none;
}

.group-summary-visible {
  display: table-cell;
}

.group-collapsed {
  display: none;
}

.report-table td:not(:first-child),
.report-table tfoot td:not(:first-child) {
  text-align: right;
  white-space: nowrap;
}

.report-table tbody tr:nth-child(even) td {
  background: #f8fafb;
}

.report-table tbody tr:nth-child(odd) td {
  background: #fff;
}

.report-table tfoot td {
  background: #e8eaed;
  font-weight: 800;
}

.inventory-total-row td {
  background: #e8eaed;
  font-weight: 800;
}

.diff-alert {
  color: var(--danger-text);
  font-weight: 800;
}

.reconciliation-form-panel { max-width: 920px; }
.reconciliation-table { min-width: 1320px; }
.reconciliation-table thead th {
  background: #dfe5e8;
  border-bottom: 2px solid #a8b3bc;
  color: #26323a;
}
.reconciliation-table .sortable-header-button {
  color: #26323a;
  font-weight: 800;
}
.reconciliation-table .sortable-header-button:hover,
.reconciliation-table .sortable-header-button:focus-visible {
  color: #0f4f39;
}
.reconciliation-table .sortable-header-button.active {
  color: #0f4f39;
}
.reconciliation-table .sort-indicator.muted {
  color: #596772;
}
.reconciliation-table .numeric-cell,
.numeric-cell { text-align: right; white-space: nowrap; }
.diff-positive { color: #9a4b00; font-weight: 800; }
.diff-negative { color: #28609b; font-weight: 800; }
.diff-zero { color: var(--accent); font-weight: 800; }
.field-disabled { color: var(--muted); opacity: 0.65; }
.movement-actions form + form { margin-left: 5px; }
.status-badge {
  border: 1px solid var(--line);
  border-radius: 5px;
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 6px;
}
.status-confirmado { background: #edf8f3; color: #146044; }
.status-borrador { background: #fff8e6; color: #805b00; }
.status-abierto { background: #eef6ff; color: #175b8f; }
.status-liquidado { background: #edf8f3; color: #146044; }
.status-activo, .status-abierto, .status-conciliada_qbo, .status-pagada { background: #edf8f3; color: #146044; }
.status-registrada { background: #eef6ff; color: #175b8f; }
.status-cancelado { background: #f0f2f4; color: var(--muted); }
.status-coincidencia-exacta, .status-aprobado, .status-consolidado, .status-completed {
  background: #edf8f3;
  color: #146044;
}
.status-requiere-revision, .status-observado, .status-nuevo {
  background: #fff8e6;
  color: #704800;
}
.status-aprobado-pendiente-documento { background: #fff1c9; color: #6d4b00; }
.status-sin-documento, .status-duplicado, .status-modificado-en-origen, .status-failed {
  background: var(--danger-bg);
  color: var(--danger-text);
}
.status-rechazado { background: #f0f2f4; color: var(--muted); }

.tanim-summary { margin-top: 14px; }
.tanim-header-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }
.tanim-header-actions .button-link { align-items: center; display: inline-flex; gap: 8px; min-height: 38px; }
.tanim-header-actions .button-link.secondary-button { color: var(--accent); }
.tanim-header-actions svg { fill: none; height: 18px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; width: 18px; }
.tanim-groups-wrap table { min-width: 1500px; }
.tanim-review-wrap table { min-width: 1900px; }
.tanim-links-wrap table { min-width: 1380px; }
.tanim-review-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tanim-source-summary { margin: 4px 0 18px; }
.tanim-review-actions { display: flex; gap: 10px; margin-top: 14px; }
.tanim-review-actions form { margin: 0; }
.tanim-warning {
  background: #fff8e6;
  border: 1px solid #d7a927;
  color: #704800;
}

@media (max-width: 760px) {
  .tanim-header-actions { align-items: stretch; margin-top: 12px; }
  .tanim-header-actions form,
  .tanim-header-actions button,
  .tanim-header-actions .button-link { justify-content: center; width: 100%; }
  .tanim-review-grid { grid-template-columns: minmax(0, 1fr); }
  .tanim-review-actions { align-items: stretch; flex-direction: column; }
  .tanim-review-actions button { width: 100%; }
}

.commercial-control-create-grid { grid-template-columns: minmax(320px, 2fr) minmax(180px, 1fr) minmax(160px, .7fr); }
.commercial-summary { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); }
.commercial-pallet-table {
  min-width: 860px;
  table-layout: fixed;
}
.commercial-pallet-table .pallet-col { width: 70px; }
.commercial-pallet-table .reference-col { width: auto; }
.commercial-pallet-table .class-col { width: auto; }
.commercial-pallet-table .caliber-col { width: 74px; }
.commercial-pallet-table .detail-count-col { width: 96px; }
.commercial-pallet-table .physical-col { width: 82px; }
.commercial-pallet-table .assigned-col { width: 90px; }
.commercial-pallet-table .available-col { width: 96px; }
.commercial-pallet-table .assign-col { width: 88px; }
.commercial-pallet-table th,
.commercial-pallet-table td {
  overflow-wrap: normal;
  white-space: nowrap;
}
.commercial-pallet-table .action-col {
  width: auto;
}
.commercial-pallet-table .muted-text {
  display: inline;
  margin-top: 0;
  white-space: nowrap;
}
.commercial-invoices-table {
  min-width: 1420px;
  table-layout: fixed;
}
.commercial-invoices-table .invoice-status-col { width: 118px; }
.commercial-invoices-table .invoice-number-col { width: 132px; }
.commercial-invoices-table .invoice-date-col { width: 104px; }
.commercial-invoices-table .invoice-client-col { width: auto; }
.commercial-invoices-table .invoice-po-col { width: auto; }
.commercial-invoices-table .invoice-boxes-col { width: 114px; }
.commercial-invoices-table .invoice-total-col { width: 116px; }
.commercial-invoices-table .invoice-producer-col { width: 142px; }
.commercial-invoices-table .invoice-difference-col { width: 110px; }
.commercial-invoices-table .invoice-balance-col { width: 112px; }
.commercial-invoices-table .invoice-edit-col { width: 72px; }
.commercial-invoices-table .invoice-delete-col { width: 76px; }
.commercial-invoices-table th,
.commercial-invoices-table td {
  overflow-wrap: normal;
  white-space: nowrap;
}
.commercial-invoices-table th:nth-child(4),
.commercial-invoices-table td:nth-child(4),
.commercial-invoices-table th:nth-child(5),
.commercial-invoices-table td:nth-child(5) {
  overflow-wrap: anywhere;
  white-space: normal;
}
.commercial-invoices-table .action-col { width: auto; }
.commercial-movements-wrap table { min-width: 1840px; }
.commercial-movements-wrap { max-height: 68vh; }
.commercial-movements-wrap thead { position: sticky; top: 0; z-index: 1; }
.commercial-drive-col { min-width: 90px; white-space: nowrap; }

@media (max-width: 720px) {
  .commercial-control-create-grid { grid-template-columns: 1fr; }
  .commercial-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.status-listo, .status-importado { background: #edf8f3; color: #146044; }
.status-importado-warn, .status-requiere-revision, .status-requiere-dccl { background: #fff8e6; color: #805b00; }
.status-vinculado, .status-utilizado { background: #edf8f3; color: #146044; }
.status-duplicado, .status-rechazado { background: #f0f2f4; color: var(--muted); }
.status-error-validacion, .status-error-importacion { background: var(--danger-bg); color: var(--danger-text); }

.reception-upload {
  align-items: end;
  display: grid;
  grid-template-columns: minmax(280px, 620px) auto;
  margin-top: 16px;
  max-width: none;
}

.reception-table { min-width: 1180px; }
.clarification-block-form { grid-template-columns: minmax(280px, 720px) auto; align-items: end; max-width: 930px; }
.clarification-form { max-width: none; }
.clarification-description { grid-column: span 2; }
.clarification-candidates-wrap { max-height: 62vh; }
.clarification-table { min-width: 1180px; }
.clarification-table thead { position: sticky; top: 0; z-index: 1; }
.clarification-table thead th { background: #f0f3f6; }
.clarification-table input[type="checkbox"] { min-height: auto; }
.table-number-input { min-height: 34px; padding: 5px 7px; text-align: right; width: 112px; }
.clarification-selected td { background: #fffbea !important; }
.clarification-status-form { max-width: none; }
.trace-table-wrap table { min-width: 1500px; }
.supplier-trace-summary { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); margin-top: 14px; }
.supplier-trace-filters { align-items: end; grid-template-columns: minmax(180px, 1fr) minmax(260px, 2fr) minmax(180px, 1fr) auto; max-width: none; }
.supplier-trace-table-wrap table { min-width: 1900px; }
.supplier-header-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }
.supplier-header-actions .secondary-button { align-items: center; display: inline-flex; gap: 8px; }
.supplier-header-actions svg { fill: none; height: 18px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; width: 18px; }
.supplier-dialog { width: min(640px, calc(100% - 32px)); }
.supplier-dialog-head { align-items: flex-start; }
.supplier-dialog-head h2 { margin-bottom: 4px; }
.supplier-dialog-head p { margin: 0; }
.supplier-dialog textarea { min-height: 132px; }

.orchard-summary { grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); }

.packing-house-summary { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); }
.packing-house-filters { align-items: end; margin-bottom: 16px; }
.packing-house-filters .check { align-self: center; }
.packing-assign-form,
.packing-signature-row form {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 250px;
}
.packing-assign-form select,
.packing-signature-row select { min-width: 145px; }
.packing-signatures summary { cursor: pointer; white-space: nowrap; }
.packing-signature-row {
  display: grid;
  grid-template-columns: 72px minmax(150px, 1fr);
  gap: 6px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #e5e7eb;
}
.packing-signature-row:last-child { border-bottom: 0; }
.packing-signature-row code { font-size: 0.75rem; }
.packing-signature-row img {
  width: 64px;
  height: 52px;
  object-fit: contain;
  background: #fff;
  border: 1px solid #d8ddd9;
}
.packing-signature-row form { grid-column: 1 / -1; }
.packing-house-dialog { width: min(760px, calc(100vw - 24px)); }
.orchard-filters { align-items: end; grid-template-columns: minmax(260px, 2fr) minmax(180px, 1fr) auto; }
.orchard-filters button { min-width: 110px; }
.orchard-table-wrap table { min-width: 1320px; }
.orchard-evidence-wrap table { min-width: 1500px; }
.orchard-actions { display: flex; gap: 6px; white-space: nowrap; }
.orchard-dialog { width: min(820px, calc(100% - 32px)); }
.orchard-dialog textarea { width: 100%; }
.orchard-file-input { display: none; }
.orchard-import-status { min-height: 20px; margin: 0; }
.orchard-import-status.error-text { color: var(--danger-text); }
.orchard-dialog [data-import-orchard-file] { align-items: center; display: inline-flex; gap: 7px; }
.orchard-dialog [data-import-orchard-file] svg {
  fill: none; height: 18px; stroke: currentColor; stroke-linecap: round;
  stroke-linejoin: round; stroke-width: 2; width: 18px;
}

@media (max-width: 760px) {
  .orchard-filters { grid-template-columns: minmax(0, 1fr); }
  .orchard-filters button { width: 100%; }
  .orchard-dialog { width: calc(100% - 20px); }
  .orchard-dialog .form-actions button { width: 100%; }
}
.supplier-assignment-count { background: #f4f7f5; border-left: 3px solid var(--accent); margin: 0; padding: 10px 12px; }
.packing-purchases-wrap table { min-width: 1320px; }
.packing-purchase-dialog { width: min(1120px, calc(100% - 32px)); }
.packing-purchase-dialog h3 { margin: 0 0 4px; }
.packing-purchase-dialog h3 + p { margin: 0; }
.packing-purchase-parties { grid-template-columns: repeat(3,minmax(0,1fr)); }
.packing-purchase-values { grid-template-columns: repeat(4,minmax(0,1fr)); }
.packing-purchase-detail-head { align-items: end; }
.packing-purchase-candidates { max-height: 42vh; }
.packing-purchase-candidates table { min-width: 900px; }
.packing-purchase-candidates thead { position: sticky; top: 0; z-index: 1; }
.packing-purchase-candidates input[type="checkbox"] { min-height: auto; }
.packing-purchase-candidates input[type="number"] { min-width: 105px; text-align: right; width: 105px; }
.packing-purchase-totals { background: #f4f7f5; display: flex; flex-wrap: wrap; gap: 18px; justify-content: flex-end; padding: 10px 12px; }
.packing-purchase-evidence { grid-template-columns: repeat(2,minmax(0,1fr)); }
.supplier-confirm-form { display: grid; gap: 6px; min-width: 250px; }
.supplier-confirm-form select,
.supplier-confirm-form input { min-height: 34px; width: 100%; }
.status-confirmado, .status-confirmado-manual { background: #edf8f3; color: #146044; }
.status-confirmado-compra { background: #e7f4ed; color: #0d5a3c; }
.status-confirmado-prestamo { background: #e8f4f8; color: #18566d; }
.status-confirmada { background: #edf8f3; color: #146044; }
.status-cancelada { background: #f0f2f4; color: var(--muted); }
.status-probable { background: #eaf3fb; color: #285d88; }
.status-requiere-revision { background: #fff8e6; color: #805b00; }
.status-sin-sustento { background: var(--danger-bg); color: var(--danger-text); }

@media (max-width: 720px) {
  .supplier-trace-filters { grid-template-columns: 1fr; }
  .supplier-header-actions { align-items: stretch; margin-top: 12px; }
  .supplier-header-actions form,
  .supplier-header-actions button { width: 100%; }
  .supplier-header-actions button { justify-content: center; }
  .supplier-basic-fields { grid-template-columns: 1fr; }
  .packing-purchase-parties,
  .packing-purchase-values,
  .packing-purchase-evidence { grid-template-columns: 1fr; }
  .packing-purchase-detail-head button { margin-top: 10px; width: 100%; }
  .packing-purchase-totals { justify-content: space-between; }
}
.button-link { background: var(--accent); border-radius: 5px; color: #fff; font-weight: 700; padding: 9px 12px; text-decoration: none; white-space: nowrap; }
.status-abierta { background: #fff8e6; color: #805b00; }
.status-enviada, .status-en-revision { background: #eaf3fb; color: #285d88; }
.status-aclarada, .status-ajuste-autorizado, .status-cerrada { background: #edf8f3; color: #146044; }
.status-cancelada { background: #f0f2f4; color: var(--muted); }
.reception-date { white-space: nowrap; }
.reception-actions { white-space: nowrap; }
.reception-actions form { margin: 0 2px; }
.reception-dccl-dialog { width: min(620px, calc(100% - 32px)); }
.reception-dccl-dialog input[type="file"] { width: 100%; }
.inline-revalidate { align-items: center; display: flex; gap: 6px; }
.inline-revalidate select { min-width: 210px; }
.validation-cell { min-width: 250px; }
.validation-cell details + details { margin-top: 5px; }
.validation-cell summary { cursor: pointer; font-weight: 700; }
.validation-cell ul { margin: 7px 0; padding-left: 18px; }
.muted-link { color: var(--muted); display: block; font-size: 12px; margin-top: 4px; }

.warning-list {
  color: inherit;
  font: inherit;
  margin: 8px 0 0;
  white-space: pre-wrap;
}

.column-settings {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 34px rgba(29, 37, 45, 0.12);
  margin: 12px 0;
  max-width: 760px;
  overflow: hidden;
  padding: 14px;
}

.column-settings-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.plain-button {
  background: #fff;
  border-color: var(--line);
  color: var(--muted);
  min-height: 32px;
  padding: 5px 9px;
}

.plain-button:hover {
  background: #f0f3f6;
  color: var(--text);
}

.column-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  max-height: min(520px, 62vh);
  overflow: auto;
}

.column-option {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  position: relative;
}

.column-option input {
  opacity: 0;
  pointer-events: none;
  position: absolute;
}

.column-option span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eye-icon {
  align-items: center;
  color: var(--accent);
  display: inline-flex;
  flex: 0 0 auto;
  height: 18px;
  justify-content: center;
  width: 18px;
}

.eye-icon svg {
  display: block;
  flex: 0 0 18px;
  fill: none;
  height: 18px;
  max-height: 18px;
  max-width: 18px;
  min-height: 18px;
  min-width: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

.eye-icon .eye-closed {
  display: none;
}

.column-option input:checked + .eye-icon .eye-open {
  display: block;
}

.column-option input:checked + .eye-icon .eye-closed {
  display: none;
}

.column-option input:not(:checked) + .eye-icon {
  color: #9aa3ad;
}

.column-option input:not(:checked) + .eye-icon .eye-open {
  display: none;
}

.column-option input:not(:checked) + .eye-icon .eye-closed {
  display: block;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0f3f6;
  font-size: 12px;
  color: var(--muted);
}

.sort-link {
  align-items: center;
  color: inherit;
  display: inline-flex;
  gap: 6px;
  min-height: 22px;
  text-decoration: none;
}

.sort-link.active {
  color: var(--text);
}

.sortable-header-button {
  background: transparent;
  border: 0;
  border-radius: 0;
  color: inherit;
  font: inherit;
  justify-content: flex-start;
  min-height: 22px;
  padding: 0;
  width: 100%;
}

.sortable-header-button:hover,
.sortable-header-button:focus-visible {
  background: transparent;
  color: var(--text);
}

.sort-indicator {
  color: var(--accent);
  font-size: 12px;
  line-height: 1;
}

.sort-indicator.muted {
  color: #9aa3ad;
}

td {
  max-width: 360px;
  overflow-wrap: anywhere;
}

.action-col {
  width: 72px;
  text-align: center;
}

.action-col form {
  display: inline-flex;
}

.icon-button {
  align-items: center;
  display: inline-flex;
  background: #fff;
  color: var(--accent);
  height: 34px;
  justify-content: center;
  min-height: 34px;
  padding: 0;
  text-decoration: none;
  width: 34px;
}

.icon-button:hover {
  background: #edf8f3;
}

.icon-button svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

.danger-button {
  background: #fff;
  border-color: #d9a39b;
  color: var(--danger-text);
}

.danger-button:hover {
  background: var(--danger-bg);
}

.default-hidden,
.column-hidden {
  display: none;
}

.pager {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.pager a {
  color: var(--accent);
  font-weight: 700;
}

.read-only-notice {
  border-left: 4px solid #8a6500;
  margin-bottom: 14px;
}

.permission-role-panel h2 {
  margin-bottom: 2px;
}

.permissions-table th:nth-child(2),
.permissions-table th:nth-child(3),
.permissions-table td:nth-child(2),
.permissions-table td:nth-child(3) {
  text-align: center;
  width: 110px;
}

.permissions-table input[type="checkbox"] {
  accent-color: #176b4d;
  height: 20px;
  min-height: 0;
  width: 20px;
}

.permissions-table input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

@media (max-width: 760px) {
  .block-progress-dialog {
    max-height: calc(100dvh - 24px);
    padding: 16px;
    width: calc(100% - 16px);
  }

  .block-progress-head p {
    font-size: 12px;
  }

  .block-progress-operations {
    max-height: min(42dvh, 300px);
  }

  .page:has(.price-calculator) {
    margin: 10px auto;
    width: calc(100% - 12px);
  }

  .price-calculator {
    padding: 10px;
  }

  .price-calculator .section-head {
    align-items: center;
    display: flex;
    gap: 8px;
  }

  .price-calculator .section-head > div {
    min-width: 0;
  }

  .price-calculator .section-head h1 {
    font-size: 19px;
    margin-bottom: 2px;
  }

  .price-calculator .section-head p {
    font-size: 12px;
    margin-bottom: 8px;
  }

  .price-calculator .section-head button {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 6px 9px;
  }

  .calculator-head-actions {
    gap: 5px;
  }

  .calculator-save-dialog {
    width: 100%;
  }

  .calculator-band-field {
    max-width: none;
  }

  .calculator-band-field select {
    max-width: 100%;
    width: 100%;
  }

  .calculator-results {
    margin-top: 12px;
  }

  .calculator-status {
    font-size: 11px;
    margin-bottom: 8px;
    padding: 7px 8px;
  }

  .calculator-results .table-wrap {
    overflow: visible;
    width: 100%;
  }

  .calculator-table {
    min-width: 0;
    table-layout: fixed;
    width: 100%;
  }

  .calculator-table th,
  .calculator-table td {
    font-size: 11px;
    overflow: hidden;
    padding: 6px 3px;
    text-overflow: clip;
  }

  .calculator-table th:nth-child(1) { width: 15%; }
  .calculator-table th:nth-child(2),
  .calculator-table th:nth-child(4) { width: 14%; }
  .calculator-table th:nth-child(3),
  .calculator-table th:nth-child(5) { width: 18%; }
  .calculator-table th:nth-child(6) { width: 21%; }

  .calculator-table input {
    font-size: 16px;
    min-height: 32px;
    min-width: 0;
    padding: 3px 2px;
  }

  .calculator-band-editor-table {
    min-width: 0 !important;
    table-layout: fixed;
    width: 100%;
  }

  .calculator-band-editor-table input {
    min-width: 0;
    width: 100%;
  }

  .calculator-national-table,
  .calculator-national-editor table {
    min-width: 0;
    table-layout: fixed;
    width: 100%;
  }

  .calculator-national-table th,
  .calculator-national-table td {
    font-size: 11px;
    padding: 6px 3px;
  }

  .calculator-national-table input {
    font-size: 16px;
    min-width: 0;
    padding: 3px 2px;
  }

  .calculator-grand-total {
    font-size: 12px;
    grid-template-columns: 1fr auto auto;
    padding: 9px 7px;
  }

  .calculator-grand-total .calculator-percentage-total,
  .calculator-grand-total .calculator-price-total {
    min-width: 76px;
  }

  .calculator-table tfoot td {
    padding-bottom: 8px;
    padding-top: 8px;
  }

  .calculator-price-total {
    font-size: 12px;
  }

  .export-comparison-header,
  .band-metadata { grid-template-columns: minmax(0, 1fr); }
  .comparison-band-field { grid-column: auto; }
  .comparison-table-head { display: grid; gap: 10px; }
  .band-dialog {
    border-radius: 8px 8px 0 0;
    bottom: 0;
    margin: auto 0 0;
    max-height: 92vh;
    padding: 16px;
    width: 100%;
  }
  .payment-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .payments-company-form,
  .payments-config-actions,
  .payments-config-form {
    align-items: stretch;
    flex-direction: column;
  }
  .payments-company-form label { min-width: 0; }
  .payments-company-form button,
  .payments-config-actions button { width: 100%; }
  .clarification-block-form { grid-template-columns: minmax(0, 1fr); }
  .clarification-description { grid-column: auto; }
  .reception-upload { align-items: stretch; grid-template-columns: minmax(0, 1fr); }
  .reception-upload button { width: 100%; }
  .report-generator-form .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar {
    height: auto;
    padding: 12px 16px;
    align-items: flex-start;
    gap: 10px;
    flex-direction: column;
  }

  .section-head {
    display: block;
  }

  .topbar nav {
    gap: 10px 14px;
    width: 100%;
  }

  .search {
    margin-top: 10px;
  }

  .title-row {
    align-items: flex-start;
  }

  .title-row h1 {
    line-height: 1.2;
  }

  .column-settings {
    border-radius: 12px 12px 0 0;
    bottom: 0;
    box-shadow: 0 -16px 34px rgba(29, 37, 45, 0.18);
    left: 0;
    margin: 0;
    max-height: 78vh;
    max-width: none;
    overflow: hidden;
    padding: 14px 16px 18px;
    position: fixed;
    right: 0;
    z-index: 20;
  }

  .column-settings-head {
    background: #fff;
    margin: -2px 0 10px;
    position: sticky;
    top: 0;
    z-index: 1;
  }

  .column-grid {
    grid-template-columns: 1fr;
    max-height: calc(78vh - 74px);
    overflow-y: auto;
    padding-right: 2px;
  }

  .column-option {
    min-height: 42px;
  }
}
