:root {
  --primary: #31b7a8;
  --title: #173777;
  --ink: #1c2b49;
  --muted: #68758a;
  --canvas: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --line: #dce4ef;
  --line-strong: #bcc8d8;
  --shadow: 0 12px 30px rgba(23, 55, 119, 0.07);
  --radius: 18px;
  --radius-small: 11px;
  --success: #167144;
  --danger: #b4233f;
  --warning: #8a5a00;
}

.treasury-import-card { max-width: 980px; margin-inline: auto; }
.treasury-import-form { margin-top: 22px; }
.pnl-forecast-head { align-items: end; gap: 24px; }
.pnl-year-form label { min-width: 120px; }
.pnl-year-form select { width: 100%; }
.pnl-table { min-width: 900px; width: 100%; table-layout: fixed; }
.pnl-table .pnl-concept-column { width: 30%; }
.pnl-table .pnl-period-column { width: 14%; }
.pnl-table th:not(:first-child), .pnl-table td {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pnl-table th:first-child { text-align: left; }
.pnl-result-row th, .pnl-result-row td {
  color: var(--title);
  font-weight: 800;
  border-top-width: 2px;
}
.pnl-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 8px; }
.pnl-actual-dot, .pnl-forecast-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.pnl-actual-dot { background: #23824d; }
.pnl-forecast-dot { background: var(--primary); }
.warning-text { color: #9a5a00; }

@media screen and (max-width: 700px) {
  .pnl-forecast-head { align-items: stretch; }
  .pnl-year-form label { width: 100%; }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 15px/1.5 Arial, Helvetica, sans-serif;
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--title);
  text-underline-offset: 2px;
}

a:hover {
  color: color-mix(in srgb, var(--title) 78%, #000);
}

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

button {
  appearance: none;
}

img {
  max-width: 100%;
}

.site-header {
  height: 92px;
  display: flex;
  align-items: center;
  padding: 14px max(24px, calc((100vw - 1560px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--title);
  font-size: 29px;
  font-weight: 800;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.brand:hover {
  color: var(--title);
}

.brand-logo {
  width: 60px;
  height: 60px;
  flex: 0 0 auto;
  object-fit: contain;
}

.main-nav {
  min-height: 58px;
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(23, 55, 119, 0.08);
}

.nav-toggle {
  display: none;
  min-height: 40px;
  margin: 9px 16px;
  padding: 8px 14px;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 10px;
  cursor: pointer;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  width: min(1560px, 100%);
  min-height: 58px;
  margin: 0 auto;
  padding: 0 12px;
}

.nav-links a {
  display: flex;
  min-height: 48px;
  align-items: center;
  padding: 0 17px;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}

.nav-links a:hover,
.nav-links a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
  border-bottom-color: rgba(255, 255, 255, 0.88);
}

.nav-links .nav-logout {
  margin-left: auto;
}

.page-shell {
  width: min(1560px, calc(100% - 40px));
  max-width: 1560px;
  min-height: calc(100vh - 245px);
  margin: 32px auto 0;
}

.auth-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(500px, calc(100% - 28px));
  margin-top: 7vh;
}

.site-footer {
  padding: 34px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.card {
  margin-bottom: 24px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card h1,
.page-title {
  margin: 0;
  color: var(--title);
  font-size: clamp(32px, 3vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.card h2,
.card h3 {
  color: var(--title);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-head > * {
  min-width: 0;
}

.page-head p {
  max-width: 850px;
  margin: 7px 0 0;
  color: var(--muted);
}

.section-title {
  margin: 0 0 16px;
  color: var(--title);
  font-size: 23px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.form-grid > .section-title {
  margin-top: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.form-grid > .section-title:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.section-space {
  margin-top: 30px;
}

.block-space {
  margin-top: 24px;
}

.button,
button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 19px;
  color: #fff;
  font-weight: 800;
  line-height: 1.05;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  background: var(--primary);
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  box-shadow: 0 5px 12px color-mix(in srgb, var(--primary) 16%, transparent);
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.button:hover,
button.button:hover {
  color: #fff;
  filter: brightness(0.96);
  box-shadow: 0 7px 16px color-mix(in srgb, var(--primary) 22%, transparent);
  transform: translateY(-1px);
}

.button:active,
button.button:active {
  transform: translateY(0);
}

.button:focus-visible,
button.button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent);
  outline-offset: 2px;
}

.button-secondary,
button.button-secondary {
  color: #fff;
  background: #64748b;
  box-shadow: 0 5px 12px rgba(71, 85, 105, 0.15);
}

.button-danger,
button.button-danger,
.item-remove {
  color: #fff;
  background: var(--danger);
  box-shadow: 0 5px 12px rgba(180, 35, 63, 0.14);
}

.button-purple,
button.button-purple {
  color: #fff;
  background: #7c6590;
}

.button-ghost,
button.button-ghost {
  color: var(--title);
  background: #fff;
  border-color: var(--line-strong);
  box-shadow: none;
}

.button-ghost:hover,
button.button-ghost:hover {
  color: var(--title);
  background: var(--surface-soft);
}

.button-small,
button.button-small {
  min-height: 36px;
  height: 36px;
  padding: 7px 13px;
  border-radius: 9px;
  font-size: 13px;
}

.button-block {
  width: 100%;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.button-row form {
  display: inline-flex;
  margin: 0;
}

.auth-card {
  width: 100%;
  padding: 36px 32px;
  text-align: center;
}

.auth-card h1 {
  margin: 9px 0;
  font-size: 36px;
}

.auth-card h2 {
  margin: 0 0 22px;
  font-size: 23px;
}

.auth-logo {
  display: block;
  width: 82px;
  height: 82px;
  margin: 0 auto;
  object-fit: contain;
}

.auth-link {
  display: inline-block;
  margin-top: 18px;
}

.stack-form {
  display: grid;
  gap: 17px;
  text-align: left;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px 18px;
}

.stack-form label,
.form-grid label,
.filters label,
.inline-form label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--title);
  font-size: 14px;
  font-weight: 800;
}

.form-grid .span-2 {
  grid-column: span 2;
}

.form-grid .span-3 {
  grid-column: 1 / -1;
}

.form-action {
  display: flex;
  align-items: end;
}

.client-editor-card {
  padding: 22px 24px;
}

.client-editor-card > .page-head {
  margin-bottom: 16px;
}

.client-editor-form {
  gap: 12px 14px;
}

.client-editor-form label {
  align-content: start;
  gap: 5px;
  font-size: 13px;
}

.client-editor-form input:not([type="checkbox"]),
.client-editor-form select {
  height: 40px;
  min-height: 40px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.client-editor-form .help {
  margin-top: -1px;
  font-size: 11px;
  line-height: 1.25;
}

.client-editor-form .client-address-field textarea {
  height: 40px;
  min-height: 40px;
}

.client-editor-form .client-notes-field textarea {
  height: 80px;
  min-height: 80px;
}

.client-form-footer {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-top: 2px;
}

.client-form-footer .checkbox-inline {
  min-height: 38px;
  padding: 5px 0;
}

.client-form-footer .button {
  min-width: 160px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  color: #111827;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.025);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

input,
select {
  min-height: 44px;
  padding: 10px 12px;
}

textarea {
  min-height: 112px;
  padding: 11px 12px;
  line-height: 1.45;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #8b97a8;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #9eadc2;
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}

input:disabled,
select:disabled,
textarea:disabled {
  color: #667085;
  background: #eef2f6;
  cursor: not-allowed;
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

input[type="color"] {
  padding: 5px;
  cursor: pointer;
}

input[type="file"] {
  padding: 7px;
}

input[type="file"]::file-selector-button {
  min-height: 30px;
  margin-right: 10px;
  padding: 5px 10px;
  color: var(--title);
  font-weight: 800;
  background: #edf2f7;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 9px 0;
  color: var(--ink);
  font-weight: 700;
}

.checkbox-inline input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(128px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin: 22px 0;
  padding: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.filters-invoices {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.filters-invoices .filter-search {
  grid-column: span 4;
}

.invoice-more-filters {
  grid-column: 1 / -1;
  min-width: 0;
  margin-top: 1px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.invoice-more-filters summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--title);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}

.invoice-more-filters summary::-webkit-details-marker {
  display: none;
}

.invoice-more-filters summary::before {
  content: '+';
  display: inline-grid;
  width: 19px;
  height: 19px;
  place-items: center;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  background: var(--title);
  border-radius: 50%;
}

.invoice-more-filters[open] summary::before {
  content: '−';
}

.invoice-more-filters summary span {
  color: var(--muted);
  font-weight: 600;
}

.invoice-more-filters-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) minmax(220px, 1fr) minmax(150px, .6fr);
  gap: 12px;
  max-width: 850px;
  margin-top: 11px;
}

.invoice-list-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -8px 2px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.invoice-list-summary a {
  color: var(--title);
  font-weight: 800;
}

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

.internal-classification {
  margin: 0 0 26px;
  padding: 14px 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.internal-classification .inline-form > .help {
  align-self: center;
  max-width: 330px;
}

.filters-compact {
  grid-template-columns: minmax(260px, 2fr) minmax(150px, 1fr) auto;
}

.filters-period {
  grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
}

.filters-treasury {
  grid-template-columns: repeat(3, minmax(170px, 1fr)) auto;
}

.filters .button {
  box-shadow: none;
}

.filters.fixed-assets-filters {
  grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(128px, 1fr)) minmax(0, 1fr) auto;
}

.fixed-assets-filters input,
.fixed-assets-filters select,
.fixed-assets-filters > .button {
  height: 44px;
  min-height: 44px;
}

.fixed-assets-filters > .button {
  grid-column: 5;
  min-width: 150px;
  justify-self: end;
}

.alert {
  margin: 0 0 18px;
  padding: 13px 15px;
  border: 1px solid transparent;
  border-radius: 11px;
}

.alert-success {
  color: #126a43;
  background: #e7f8ef;
  border-color: #a5e2c2;
}

.alert-error {
  color: #991b1b;
  background: #fff0f0;
  border-color: #fecaca;
}

.alert-warning {
  color: #854d0e;
  background: #fff8dd;
  border-color: #fde68a;
}

.alert-info {
  color: #1e4f91;
  background: #edf5ff;
  border-color: #bfdbfe;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  scrollbar-color: #aab6c6 #eef2f7;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.table-wrap::-webkit-scrollbar {
  height: 9px;
}

.table-wrap::-webkit-scrollbar-track {
  background: #eef2f7;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: #aab6c6;
  border: 2px solid #eef2f7;
  border-radius: 999px;
}

.data-table,
.line-items {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
}

.data-table {
  min-width: 100%;
}

.table-wrap > .data-table {
  min-width: 720px;
}

.data-table th,
.data-table td {
  padding: 13px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid #e5eaf1;
}

.data-table thead th,
.line-items thead th {
  color: var(--title);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  white-space: nowrap;
  background: #eef3f8;
}

.data-table tbody tr:nth-child(even),
.line-items tbody tr:nth-child(even) {
  background: #fbfcfe;
}

.data-table tbody tr:last-child td,
.data-table tbody tr:last-child th,
.line-items tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover,
.line-items tbody tr:hover {
  background: #f7fbfd;
}

.data-table td a strong {
  color: var(--title);
}

.data-table td .muted {
  margin-top: 3px;
  font-size: 12px;
}

.data-table .button-row {
  flex-wrap: nowrap;
}

.data-table td form {
  margin: 0;
}

.clients-table th,
.clients-table td {
  padding-top: 8px;
  padding-bottom: 8px;
}

.clients-table .button-small {
  min-height: 32px;
  height: 32px;
  padding-top: 5px;
  padding-bottom: 5px;
}

.table-wrap > .invoices-list-table {
  min-width: 1235px;
  table-layout: fixed;
}

.invoices-list-table col.invoice-no { width: 120px; }
.invoices-list-table col.invoice-date { width: 90px; }
.invoices-list-table col.invoice-client { width: 140px; }
.invoices-list-table col.invoice-project { width: 200px; }
.invoices-list-table col.invoice-category { width: 125px; }
.invoices-list-table col.invoice-money { width: 95px; }
.invoices-list-table col.invoice-margin { width: 95px; }
.invoices-list-table col.invoice-status { width: 95px; }
.invoices-list-table col.invoice-action { width: 84px; }

.invoices-list-table th,
.invoices-list-table td {
  padding: 9px 10px;
  font-size: 13px;
}

.invoices-list-table td {
  line-height: 1.3;
}

.invoices-list-table .invoice-date-value,
.invoices-list-table .invoice-money-value,
.invoices-list-table .invoice-margin-value {
  white-space: nowrap;
}

.invoices-list-table .invoice-money-value,
.invoices-list-table .invoice-margin-value,
.invoices-list-table .invoice-numeric-heading {
  text-align: right;
}

.invoices-list-table .invoice-numeric-heading {
  white-space: nowrap;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 18px;
}

.pagination span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 600px) {
  .pagination {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .client-form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .client-form-footer .button {
    width: 100%;
  }
}

.invoices-list-table .invoice-client-value,
.invoices-list-table .invoice-project-value {
  overflow-wrap: anywhere;
}

.invoices-list-table .invoice-category-value strong,
.invoices-list-table .invoice-category-value span {
  display: block;
}

.invoices-list-table .actions-cell {
  text-align: center;
}

.invoices-list-table .actions-cell .button {
  width: 64px;
  padding-right: 8px;
  padding-left: 8px;
}

.invoices-list-table .invoice-category-value span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.actions-cell {
  width: 1%;
  white-space: nowrap;
}

.quotes-list-table .actions-cell {
  width: auto;
}

.table-wrap > .quotes-list-table {
  width: 100%;
  min-width: 1235px;
  table-layout: fixed;
}

.quotes-list-table col.quote-no { width: 9%; }
.quotes-list-table col.quote-client { width: 17.5%; }
.quotes-list-table col.quote-project { width: 22.5%; }
.quotes-list-table col.quote-date { width: 9%; }
.quotes-list-table col.quote-concept { width: 11%; }
.quotes-list-table col.quote-total { width: 9%; }
.quotes-list-table col.quote-status { width: 7.5%; }
.quotes-list-table col.quote-actions { width: 14.5%; }

.quotes-list-table th,
.quotes-list-table td {
  padding: 9px 10px;
  font-size: 13px;
  line-height: 1.3;
}

.quotes-list-table .quote-client-value,
.quotes-list-table .quote-project-value {
  overflow-wrap: anywhere;
}

.quotes-list-table .quote-number-value {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}

.quotes-list-table .quote-number-value a,
.quotes-list-table .quote-number-value strong {
  display: inline-block;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}

.quotes-list-table .quote-date-value,
.quotes-list-table .quote-total-value {
  white-space: nowrap;
}

.quotes-list-table .quote-total-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.quotes-list-table .quote-concept-value strong,
.quotes-list-table .quote-concept-value span {
  display: block;
}

.quotes-list-table .quote-concept-value span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.quotes-list-table .actions-cell .button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  width: 100%;
  max-width: 190px;
}

.quotes-list-table .actions-cell .button {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  height: 34px;
  padding-right: 5px;
  padding-left: 5px;
  text-align: center;
  font-size: 11px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  color: #23417f;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
  background: #edf2ff;
  border-radius: 999px;
}

.status-paid,
.status-approved,
.status-active,
.status-imported,
.status-invoiced {
  color: var(--success);
  background: #e4f7ed;
}

.status-overdue,
.status-rejected,
.status-cancelled,
.status-error,
.status-expired {
  color: #a71932;
  background: #feecec;
}

.status-draft,
.status-pending,
.status-warning,
.status-partially_paid {
  color: var(--warning);
  background: #fff4cf;
}

.status-issued,
.status-sent,
.status-finished,
.status-archived {
  color: #315b8a;
  background: #eaf2fb;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

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

.kpi {
  min-width: 0;
  padding: 20px;
  background: linear-gradient(180deg, #fff 0%, #fbfcfe 100%);
  border: 1px solid var(--line);
  border-radius: 15px;
}

.kpi-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.kpi-value {
  margin-top: 6px;
  overflow-wrap: anywhere;
  color: var(--title);
  font-size: clamp(22px, 2.2vw, 29px);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

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

.grid-2 > * {
  min-width: 0;
}

.grid-2 > div > .data-table {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.project-profitability-card {
  min-width: 0;
}

.project-profitability-card .table-wrap {
  border-radius: 13px;
}

.table-wrap > .project-profitability-table {
  width: 100%;
  min-width: 640px;
  table-layout: fixed;
}

.project-profitability-table col.profit-project {
  width: 49%;
}

.project-profitability-table col.profit-money {
  width: 17%;
}

.project-profitability-table th:not(:first-child),
.project-profitability-table .profit-money-value {
  text-align: right;
  white-space: nowrap;
}

.table-sort {
  padding: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.table-sort:hover,
.table-sort:focus-visible { color: var(--primary); }

.table-sort:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 3px;
}

.table-sort-indicator {
  display: inline-block;
  width: 1em;
  margin-left: 4px;
  text-align: center;
}

.project-title-ellipsis {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.text-right {
  text-align: right;
}

.nowrap {
  white-space: nowrap;
}

.positive {
  color: var(--success);
}

.negative {
  color: var(--danger);
}

.document {
  max-width: 980px;
  margin: 0 auto;
}

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

.document-top > div:last-child {
  padding: 22px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.document-logo {
  width: auto;
  max-width: 130px;
  max-height: 90px;
  object-fit: contain;
}

.document-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: #002c75;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.document-brand .document-logo {
  width: 190px;
  max-width: 100%;
  height: auto;
  max-height: 70px;
  border-radius: 0;
}

.document-company h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.document-company h2 span {
  display: block;
}

.document-company > div:not(.document-brand) {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.document-recipient h1 {
  margin: 0 0 16px;
  color: #002c75;
  font-size: 28px;
}

.document-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.document-meta p {
  margin: 0;
}

.document-meta span,
.document-client > span,
.document-project span {
  display: block;
  margin-bottom: 3px;
  color: #0056b8;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.document-client {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 2px solid #2adac3;
}

.document-client strong,
.document-client b {
  display: block;
  margin-bottom: 3px;
}

.document-project {
  margin-top: 22px;
  padding: 10px 14px;
  color: #002c75;
  font-size: 18px;
  background: #f2f7fb;
  border-left: 5px solid #2adac3;
  border-radius: 8px;
}

.document-payment,
.document-notes {
  margin-top: 18px;
  padding: 12px 14px;
  background: #f5f8fb;
  border-left: 4px solid #00a2e1;
  border-radius: 8px;
}

.document-payment {
  display: flex;
  gap: 18px;
}

.document-payment > strong,
.document-notes > strong {
  color: #002c75;
}

.document-notes p {
  margin: 5px 0 0;
}

.document-print-footer {
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 8px;
  color: #64748b;
  font-size: 9px;
  border-top: 1px solid #b8d9e7;
}

.document-closing {
  display: contents;
}

.quote-main-page,
.invoice-main-page {
  display: contents;
}

.quote-license-page,
.invoice-license-page {
  margin-top: 28px;
  padding: 24px;
  color: #002c75;
  background: #f5f8fb;
  border-radius: 14px;
}

.quote-license-page header,
.quote-license-page footer,
.invoice-license-page header,
.invoice-license-page footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.quote-license-page header img,
.invoice-license-page header img {
  width: 155px;
  height: auto;
}

.quote-license-page header div,
.invoice-license-page header div {
  display: grid;
  text-align: right;
}

.quote-license-page h2,
.invoice-license-page h2 {
  margin: 28px 0 18px;
}

.quote-license-copy {
  color: #17335f;
  line-height: 1.48;
}

.quote-license-page footer,
.invoice-license-page footer {
  margin-top: 24px;
  padding-top: 10px;
  color: #0056b8;
  font-size: 11px;
  border-top: 1px solid #00a2e1;
}

textarea[data-quote-license-terms] {
  min-height: 360px;
}

.document-lines {
  margin-top: 28px;
}

.document-total {
  width: min(420px, 100%);
  margin: 22px 0 0 auto;
  padding: 7px 0;
  background: var(--surface-soft);
  border-radius: 12px;
}

.document-total div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 12px;
}

.document-total .grand-total {
  margin-top: 4px;
  padding-top: 12px;
  font-size: 21px;
  font-weight: 900;
  border-top: 2px solid var(--title);
}

.line-items {
  min-width: 860px;
}

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

.line-items input,
.line-items select {
  min-height: 40px;
  padding: 8px 9px;
}

.line-items textarea {
  min-height: 74px;
  padding: 8px 9px;
}

.line-items .desc {
  min-width: 270px;
}

.line-items .item-remove {
  width: 36px;
  padding: 0;
  font-size: 20px;
}

.invoice-editor {
  display: grid;
  gap: 0;
}

.invoice-editor-card {
  padding: 22px 24px;
}

.invoice-editor-card > .page-head {
  margin-bottom: 16px;
}

.invoice-editor-card > .page-head p {
  margin-top: 4px;
  font-size: 12px;
}

.invoice-editor .invoice-main-grid,
.invoice-editor > .form-grid {
  gap: 12px 14px;
}

.invoice-editor .form-grid label {
  align-content: start;
  gap: 5px;
  font-size: 13px;
}

.invoice-editor .form-grid input:not([type="checkbox"]),
.invoice-editor .form-grid select {
  height: 40px;
  min-height: 40px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.invoice-editor .form-grid .help {
  margin-top: -1px;
  font-size: 11px;
  line-height: 1.25;
}

.invoice-main-grid > .section-title {
  grid-column: 1 / -1;
  margin-bottom: 0;
  margin-top: 2px;
  padding-top: 10px;
  font-size: 18px;
}

.invoice-main-grid > .section-title:first-of-type {
  margin-top: 0;
  padding-top: 0;
}

.invoice-main-grid textarea {
  height: 40px;
  min-height: 40px;
}

.invoice-date-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.invoice-template-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(300px, 0.85fr) auto;
  align-items: end;
  gap: 12px 18px;
  margin-top: 16px;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.invoice-template-panel .section-title {
  margin-bottom: 3px;
  font-size: 17px;
}

.invoice-template-panel p {
  margin: 0;
}

.invoice-template-panel label {
  display: grid;
  gap: 5px;
  color: var(--title);
  font-size: 13px;
  font-weight: 800;
}

.invoice-template-panel select {
  height: 40px;
  min-height: 40px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.invoice-template-panel > .help {
  grid-column: 2 / -1;
}

.line-items col.item-description { width: 52%; }
.line-items col.item-quantity { width: 10%; }
.line-items col.item-price { width: 15%; }
.line-items col.item-discount,
.line-items col.item-tax { width: 9%; }
.line-items col.item-action { width: 4%; }

.invoice-editor .line-items textarea {
  height: auto;
  min-height: 40px;
  line-height: 1.35;
  overflow: hidden;
  resize: none;
}

.invoice-editor > .section-title.section-space {
  margin: 18px 0 10px;
  font-size: 19px;
}

.invoice-editor > .block-space,
.invoice-editor > .form-grid.block-space {
  margin-top: 14px;
}

.invoice-editor > .form-grid.block-space textarea {
  height: 80px;
  min-height: 80px;
}

.invoice-editor > .button-row:last-child {
  justify-content: flex-end;
}

.invoice-editor .line-items td:not(:first-child) input {
  text-align: right;
}

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

.document-lines th:first-child,
.document-lines td:first-child {
  width: 58%;
}

/* Cantidades y porcentajes se leen mejor centrados; importes, a la derecha. */
.invoice-document-lines th:nth-child(2),
.invoice-document-lines td:nth-child(2),
.invoice-document-lines th:nth-child(4),
.invoice-document-lines td:nth-child(4),
.quote-document-lines th:nth-child(3),
.quote-document-lines td:nth-child(3) {
  text-align: center;
}

@media (max-width: 900px) {
  .invoice-date-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .invoice-template-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .invoice-template-panel > .help {
    grid-column: auto;
  }

  .invoice-template-panel .button {
    width: 100%;
  }
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding: 5px;
  background: #eaf0f7;
  border-radius: 12px;
}

.tabs a {
  padding: 8px 12px;
  color: var(--title);
  font-weight: 800;
  text-decoration: none;
  border-radius: 8px;
}

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

.chart-bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(105px, 150px) minmax(120px, 1fr) minmax(90px, 130px);
  gap: 12px;
  align-items: center;
}

.bar-track {
  height: 16px;
  overflow: hidden;
  background: #e5eaf1;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}

.badge-warning {
  display: inline-block;
  padding: 3px 7px;
  color: #825000;
  font-size: 12px;
  font-weight: 800;
  background: #fff0c2;
  border-radius: 7px;
}

.help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}

.inline-form label {
  min-width: 150px;
}

.inline-form > input:not([type="hidden"]) {
  width: min(190px, 100%);
}

.invoice-payment-actions > .button-row {
  align-items: flex-end;
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.print-only {
  display: none;
}

.crm-origin {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  font-size: 12px;
}

.crm-source-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.crm-source-grid > div {
  min-width: 0;
  padding: 13px;
  overflow-wrap: anywhere;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.crm-source-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.crm-source-grid .span-all {
  grid-column: 1 / -1;
}

.crm-contacts-title {
  margin-top: 26px !important;
}

.dashboard-page-head .dashboard-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: calc((100% - 48px) / 4);
  min-width: 0;
}

.dashboard-actions .button {
  width: 100%;
  min-width: 0;
  padding-right: 6px;
  padding-left: 6px;
  font-size: clamp(12px, 1vw, 15px);
}

.dashboard-lists {
  align-items: start;
}

.dashboard-lists > .card {
  min-width: 0;
}

.dashboard-recent-card .table-wrap {
  max-width: 100%;
}

.table-wrap > .dashboard-recent-table {
  width: 100%;
  min-width: 0;
  table-layout: auto;
}

.dashboard-quotes-card .table-wrap {
  width: 100%;
  max-width: 100%;
}

.table-wrap > .dashboard-quotes-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.dashboard-quotes-table col.quote-number {
  width: 24%;
}

.dashboard-quotes-table col.quote-client {
  width: 35%;
}

.dashboard-quotes-table col.quote-total {
  width: 23%;
}

.dashboard-quotes-table col.quote-status {
  width: 18%;
}

.dashboard-quotes-table th,
.dashboard-quotes-table td {
  overflow-wrap: anywhere;
}

.dashboard-quotes-table .dashboard-quote-total {
  white-space: nowrap;
}

.dashboard-recent-table col.invoice-number {
  width: 23ch;
}

.dashboard-recent-table col.invoice-client {
  width: auto;
}

.dashboard-recent-table col.invoice-total {
  width: 14ch;
}

.dashboard-recent-table col.invoice-status {
  width: 12ch;
}

.dashboard-recent-table th,
.dashboard-recent-table td {
  padding-right: 10px;
  padding-left: 10px;
  overflow-wrap: anywhere;
}

.dashboard-recent-table th:first-child,
.dashboard-recent-table td:first-child {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.dashboard-recent-table .dashboard-invoice-total {
  white-space: nowrap;
}

.billing-report-card {
  --report-aqua: #2adac3;
  --report-sky: #00a2e1;
  --report-mid: #0056b8;
  --report-blue: #002c75;
}

.billing-report-head {
  align-items: flex-start;
}

.billing-report-head .button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(145px, 1fr));
}

.billing-report-filters {
  grid-template-columns: 115px 115px 300px minmax(390px, 1fr) 150px;
  align-items: end;
}

.billing-quotes-toggle {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.billing-forecast-title {
  display: block;
  margin-bottom: 7px;
  color: var(--title);
  font-weight: 800;
}

.billing-forecast-options {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 44px;
  align-content: center;
}

.billing-quotes-toggle .checkbox-inline {
  min-height: 21px;
  padding: 0;
  line-height: 1.25;
  white-space: nowrap;
}

.billing-quotes-toggle .checkbox-inline + input[type="hidden"] + .checkbox-inline {
  border: 0;
}

.billing-report-filters > .button {
  min-height: 44px;
  align-self: end;
}

.billing-report-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 22px;
}

.billing-report-kpi {
  min-height: 112px;
  padding: 18px;
  color: #fff;
  background: var(--report-blue);
  border-radius: 14px;
}

.billing-report-kpi.accent {
  background: var(--report-aqua);
}

.billing-report-kpi small,
.billing-report-kpi strong,
.billing-report-kpi span {
  display: block;
}

.billing-report-kpi small {
  min-height: 22px;
  opacity: 0.82;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.billing-report-kpi strong {
  margin-top: 7px;
  overflow-wrap: anywhere;
  font-size: clamp(21px, 2vw, 28px);
  line-height: 1.1;
}

.billing-report-kpi span {
  margin-top: 7px;
  opacity: 0.78;
  font-size: 12px;
  font-weight: 700;
}

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

.billing-report-panel {
  min-width: 0;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 15px;
}

.billing-report-panel.wide {
  grid-column: 1 / -1;
}

.billing-report-panel h2 {
  margin: 0 0 6px;
  color: var(--report-blue);
  font-size: 21px;
}

.billing-panel-head p,
.billing-chart-note {
  margin: 0 0 17px;
  color: var(--muted);
  font-size: 13px;
}

.billing-line-scroll {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-color: #aab6c6 #eef2f7;
  scrollbar-width: thin;
}

.billing-line-chart {
  display: block;
  width: 100%;
  min-width: 720px;
  height: auto;
  font-family: Arial, Helvetica, sans-serif;
}

.billing-chart-grid {
  stroke: #dbe5ee;
  stroke-width: 1;
}

.billing-chart-tick {
  fill: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.billing-chart-area {
  stroke: none;
}

.billing-chart-line {
  fill: none;
  stroke: var(--report-sky);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.billing-chart-point circle {
  fill: #fff;
  stroke: var(--report-mid);
  stroke-width: 4;
}

.billing-chart-value {
  fill: var(--report-blue);
  font-size: 12px;
  font-weight: 900;
}

.billing-chart-year {
  fill: #52627b;
  font-size: 12px;
  font-weight: 900;
}

.billing-year-values {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.billing-year-values div {
  padding: 9px 10px;
  text-align: center;
  background: var(--surface-soft);
  border-radius: 9px;
}

.billing-year-values span,
.billing-year-values strong {
  display: block;
}

.billing-year-values span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.billing-year-values strong {
  margin-top: 2px;
  color: var(--report-blue);
  font-size: 13px;
}

.billing-donut-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: center;
}

.billing-donut {
  position: relative;
  width: min(270px, 100%);
  aspect-ratio: 1;
  margin: auto;
  background: var(--billing-donut);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 44, 117, 0.08);
}

.billing-donut::after {
  content: "";
  position: absolute;
  inset: 25%;
  background: #fff;
  border-radius: 50%;
}

.billing-donut-total {
  position: absolute;
  z-index: 1;
  inset: 30%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--report-blue);
  text-align: center;
}

.billing-donut-total strong {
  font-size: clamp(14px, 1.4vw, 19px);
  line-height: 1.1;
}

.billing-donut-total small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

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

.billing-donut-row {
  display: grid;
  grid-template-columns: 11px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  padding: 8px 9px;
  background: #f3f7fa;
  border-radius: 9px;
}

.billing-donut-row i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.billing-donut-row > span {
  overflow: hidden;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.billing-donut-row strong {
  color: var(--report-blue);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.billing-donut-row strong small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
}

.billing-chart-empty {
  margin: 0;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-soft);
  border-radius: 10px;
}

.billing-chart-footnote {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.billing-report-note {
  margin-top: 18px;
  padding: 14px 16px;
  color: #536587;
  font-size: 13px;
  background: #f3f6f9;
  border-left: 4px solid var(--report-aqua);
  border-radius: 10px;
}

.billing-filter-summary {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.financial-report-card > .page-head {
  align-items: flex-start;
}

@media (max-width: 1240px) {
  .billing-report-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .billing-donut-layout {
    grid-template-columns: 1fr;
  }

  .billing-donut-legend {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .billing-report-grid {
    grid-template-columns: 1fr;
  }

  .billing-report-panel.wide {
    grid-column: auto;
  }

  .billing-donut { width: min(245px, 100%); }
}

@media (max-width: 700px) {
  .billing-report-filters,
  .billing-report-kpis {
    grid-template-columns: 1fr;
  }

  .billing-report-head .button-row {
    grid-template-columns: 1fr;
  }

  .billing-donut-layout {
    grid-template-columns: 1fr;
  }

  .billing-donut-legend {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1280px) {
  .filters:not(.filters-compact):not(.filters-period):not(.filters-treasury):not(.filters-invoices):not(.fixed-assets-filters) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filters:not(.filters-compact):not(.filters-period):not(.filters-treasury):not(.filters-invoices):not(.fixed-assets-filters) .button {
    width: 100%;
  }

  .filters-invoices {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filters-invoices .filter-search {
    grid-column: span 2;
  }
}

@media (max-width: 1120px) {
  .site-header {
    height: 82px;
    padding: 11px 20px;
  }

  .brand {
    font-size: 25px;
  }

  .brand-logo {
    width: 54px;
    height: 54px;
  }

  .main-nav {
    min-height: 58px;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    padding: 0 10px 10px;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    min-height: 46px;
    padding: 0 14px;
    border-bottom: 0;
    border-radius: 8px;
  }

  .nav-links .nav-logout {
    margin-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 0;
  }

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

  .form-grid .span-3 {
    grid-column: 1 / -1;
  }

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

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

  .dashboard-page-head .dashboard-actions {
    width: calc((100% - 16px) / 2);
    min-width: 0;
  }

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

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 24px, 1560px);
    margin-top: 22px;
  }

  .card {
    padding: 22px;
  }

  .page-head {
    align-items: flex-start;
  }

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

  .filters,
  .filters-compact,
  .filters-period,
  .filters-treasury {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters-invoices .filter-search {
    grid-column: auto;
  }

  .invoice-more-filters-grid {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .filters .button {
    width: 100%;
  }

  .filters.fixed-assets-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fixed-assets-filters > .button {
    grid-column: 2;
    justify-self: stretch;
  }

  .document-top {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .invoice-date-row {
    grid-template-columns: 1fr;
  }

  body {
    font-size: 14px;
  }

  .site-header {
    height: 76px;
    padding: 10px 15px;
  }

  .brand {
    gap: 10px;
    font-size: 23px;
  }

  .brand-logo {
    width: 50px;
    height: 50px;
  }

  .page-shell,
  .auth-shell {
    width: min(100% - 18px, 1560px);
    margin-top: 16px;
  }

  .card {
    margin-bottom: 16px;
    padding: 18px 15px;
    border-radius: 15px;
  }

  .page-head {
    flex-direction: column;
    gap: 14px;
    margin-bottom: 19px;
  }

  .page-head .button-row,
  .page-head > .button,
  .page-head > form {
    width: 100%;
  }

  .page-head .button-row .button,
  .page-head > .button,
  .page-head > form .button {
    flex: 1 1 auto;
  }

  .dashboard-page-head .dashboard-actions {
    width: 100%;
  }

  .table-wrap > .dashboard-recent-table {
    min-width: 540px;
  }

  .dashboard-quotes-card .page-head {
    flex-direction: row;
    align-items: center;
  }

  .dashboard-quotes-card .table-wrap {
    width: 100%;
    margin-right: 0;
    margin-left: 0;
    overflow-x: hidden;
  }

  .table-wrap > .dashboard-quotes-table {
    min-width: 0;
    font-size: 12px;
  }

  .dashboard-quotes-table th,
  .dashboard-quotes-table td {
    padding: 10px 7px;
  }

  .dashboard-quotes-table .status {
    padding: 5px 7px;
    font-size: 11px;
  }

  .dashboard-quotes-table .dashboard-quote-total {
    white-space: normal;
    overflow-wrap: normal;
  }

  .form-grid,
  .filters,
  .filters-compact,
  .filters-period,
  .filters-treasury,
  .kpi-grid,
  .kpi-grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .form-grid .span-2,
  .form-grid .span-3 {
    grid-column: auto;
  }

  .filters {
    margin: 18px 0;
    padding: 13px;
  }

  .filters .button,
  .form-grid > .button-row .button {
    width: 100%;
  }

  .filters.fixed-assets-filters {
    grid-template-columns: 1fr;
  }

  .fixed-assets-filters > .button {
    grid-column: 1;
  }

  .button-row {
    align-items: stretch;
  }

  .button-row .button {
    flex: 1 1 auto;
  }

  .table-wrap {
    width: calc(100% + 12px);
    margin-right: -6px;
    margin-left: -6px;
    border-radius: 10px;
  }

  .table-wrap > .data-table {
    min-width: 680px;
    font-size: 13px;
  }

  .data-table th,
  .data-table td {
    padding: 11px 12px;
  }

  .kpi {
    padding: 17px;
  }

  .kpi-value {
    font-size: 25px;
  }

  .bar-row {
    grid-template-columns: 92px minmax(100px, 1fr);
  }

  .bar-row strong {
    grid-column: 2;
  }

  .document-top > div:last-child {
    padding: 16px;
  }

  .auth-card {
    padding: 28px 20px;
  }

  .crm-source-grid {
    grid-template-columns: 1fr;
  }

  .crm-source-grid .span-all {
    grid-column: auto;
  }

  .site-footer {
    padding: 26px 12px;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 11mm 12mm 12mm;
  }

  html,
  body {
    color: #111;
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .site-header,
  .main-nav,
  .site-footer,
  .no-print,
  .alert,
  .button-row {
    display: none !important;
  }

  .page-shell {
    width: auto;
    max-width: 100%;
    min-height: 0;
    margin: 0;
  }

  .card {
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .document {
    width: calc(100% - 2mm);
    max-width: none;
    min-height: 268mm;
    margin-right: 2mm;
    color: #002c75;
    font-size: 10.5pt;
    line-height: 1.35;
    display: flex;
    flex-direction: column;
  }

  .document-company > div:not(.document-brand) {
    color: #0056b8;
  }

  .document::before {
    display: block;
    height: 5px;
    margin-bottom: 8mm;
    content: "";
    background: linear-gradient(90deg, #2adac3 0 25%, #00a2e1 25% 50%, #0056b8 50% 75%, #002c75 75% 100%);
    border-radius: 999px;
  }

  .document-top {
    grid-template-columns: minmax(0, 2fr) minmax(0, 2.4fr);
    gap: 6mm;
    align-items: start;
    width: 100%;
  }

  .document-top > div {
    min-width: 0;
    max-width: 100%;
  }

  .document-brand {
    margin-bottom: 5mm;
    font-size: 17pt;
  }

  .document-brand .document-logo {
    width: 48mm;
    max-height: 16mm;
    height: auto;
    border-radius: 0;
  }

  .document-company h2 {
    font-size: 12pt;
  }

  .document-recipient h1 {
    margin-bottom: 5mm;
    color: #002c75;
    font-size: 21pt;
  }

  .document-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3mm;
  }

  .document-due-date {
    display: none;
  }

  .document-exchange-rate {
    display: none !important;
  }

  .document-accounting-equivalence {
    display: none !important;
  }

  .document-paid-total {
    display: none !important;
  }

  .document-meta span,
  .document-client > span,
  .document-project span {
    color: #0056b8;
    font-size: 7.5pt;
  }

  .document-client {
    margin-top: 5mm;
    padding-top: 4mm;
    border-top-color: #2adac3;
  }

  .document-top > div:last-child {
    padding: 6mm;
    background: #f3f7fb;
    border: 0;
    border-radius: 4mm;
  }

  .document-project {
    margin: 6mm 0 0;
    padding: 3.5mm 4.5mm;
    background: #f2f7fb;
    border-left-color: #2adac3;
  }

  .document-lines {
    width: 100%;
    margin-top: 5mm;
    overflow: visible;
    box-sizing: border-box;
    background: transparent;
    border: 0;
    border-radius: 0;
  }

  .document-lines .data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 0;
  }

  .document-lines .data-table thead th {
    padding: 3.5mm;
    color: #002c75;
    background: #edf4f9;
  }

  .document-lines .data-table thead th:first-child {
    border-radius: 3mm 0 0 0;
  }

  .document-lines .data-table thead th:last-child {
    border-radius: 0 3mm 0 0;
  }

  .document-lines .data-table td {
    padding: 3.5mm;
    background: #f8fbfd;
    border-bottom-color: #d7e2ec;
  }

  .document-lines .data-table tbody tr:last-child td {
    border-bottom: 0;
  }

  .document-lines .data-table tbody tr:last-child td:first-child {
    border-radius: 0 0 0 3mm;
  }

  .document-lines .data-table tbody tr:last-child td:last-child {
    border-radius: 0 0 3mm 0;
  }

  .document-lines .data-table tbody tr:nth-child(even) {
    background: #f3f8fc;
  }

  .document-lines .data-table tbody tr:nth-child(even) td {
    background: #f3f8fc;
  }

  .document-total {
    width: 76mm;
    margin-top: 6mm;
    background: #f3f7fb;
    border: 0;
    border-radius: 4mm;
    overflow: hidden;
  }

  .document-total div {
    padding: 3mm 4.5mm;
  }

  .document-total .grand-total {
    font-size: 13pt;
    color: #002c75;
    background: #f5f8fb;
    border-top: 2px solid #002c75;
    border-radius: 0;
  }

  .document-payment,
  .document-notes {
    width: 100%;
    margin-top: 4mm;
    padding: 4mm 4.5mm;
    background: #f3f7fb;
    border: 0;
    border-radius: 4mm;
  }

  .document-closing {
    display: flex;
    flex: 1 0 auto;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 18mm;
    margin-top: 5mm;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .quote-main-page,
  .invoice-main-page {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    box-sizing: border-box;
    min-height: 258mm;
  }

  .document.document-has-license {
    display: block;
  }

  .invoice-main-page-with-license {
    break-after: page;
    page-break-after: always;
  }

  .document-print-footer {
    display: flex !important;
    flex: 0 0 auto;
    margin-top: 4mm;
    color: #0056b8;
    border-top-color: #00a2e1;
  }

  .quote-license-page,
  .invoice-license-page {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-height: 268mm;
    margin: 0;
    padding: 0;
    color: #002c75;
    background: #fff;
    border: 0;
    border-radius: 0;
    break-before: page;
    page-break-before: always;
  }

  .quote-license-page::before,
  .invoice-license-page::before {
    display: block;
    height: 5px;
    margin-bottom: 8mm;
    content: "";
    background: linear-gradient(90deg, #2adac3 0 25%, #00a2e1 25% 50%, #0056b8 50% 75%, #002c75 75% 100%);
    border-radius: 999px;
  }

  .quote-license-page header img,
  .invoice-license-page header img {
    width: 42mm;
    max-height: 14mm;
  }

  .quote-license-page header,
  .invoice-license-page header {
    padding-bottom: 5mm;
    border-bottom: 1px solid #d7e2ec;
  }

  .quote-license-page h2,
  .invoice-license-page h2 {
    margin: 7mm 0 5mm;
    font-size: 18pt;
  }

  .quote-license-copy {
    font-size: 9.25pt;
    line-height: 1.38;
  }

  .quote-license-page footer,
  .invoice-license-page footer {
    flex: 0 0 auto;
    margin-top: auto;
    padding-top: 3mm;
    color: #0056b8;
    font-size: 8pt;
    border-top: 1px solid #00a2e1;
  }

  .document-print-dense {
    font-size: 9.25pt;
    line-height: 1.28;
  }

  .document-print-dense::before {
    height: 4px;
    margin-bottom: 4mm;
  }

  .document-print-dense .document-top {
    gap: 4mm;
  }

  .document-print-dense .document-brand {
    margin-bottom: 3mm;
  }

  .document-print-dense .document-brand .document-logo {
    width: 42mm;
    max-height: 13mm;
  }

  .document-print-dense .document-company h2 {
    margin-bottom: 2.5mm;
    font-size: 10pt;
  }

  .document-print-dense .document-recipient {
    padding: 4mm;
    border-radius: 3mm;
  }

  .document-print-dense .document-recipient h1 {
    margin-bottom: 3mm;
    font-size: 17pt;
  }

  .document-print-dense .document-client {
    margin-top: 3mm;
    padding-top: 3mm;
  }

  .document-print-dense .document-project {
    margin-top: 4mm;
    padding: 2.5mm 3mm;
    font-size: 12pt;
  }

  .document-print-dense .document-lines {
    margin-top: 3mm;
  }

  .document-print-dense .document-lines .data-table {
    font-size: 8.75pt;
    line-height: 1.24;
  }

  .document-print-dense .document-lines .data-table th,
  .document-print-dense .document-lines .data-table td {
    padding: 2.25mm;
  }

  .document-print-dense .document-total {
    margin-top: 3mm;
  }

  .document-print-dense .document-total div {
    padding: 1.8mm 3mm;
  }

  .document-print-dense .document-total .grand-total {
    font-size: 12.5pt;
  }

  .document-print-dense .document-payment,
  .document-print-dense .document-notes {
    margin-top: 3mm;
    padding: 2.5mm 3mm;
  }

  .document-print-dense .document-print-footer {
    margin-top: 4mm;
  }

  .table-wrap {
    overflow: visible;
    border-color: #ccc;
  }

  .data-table,
  .table-wrap > .data-table,
  .line-items {
    min-width: 0;
    max-width: 100%;
  }

  .data-table thead,
  .line-items thead {
    display: table-header-group;
  }

  .data-table tr,
  .line-items tr,
  .kpi,
  .document-total {
    break-inside: avoid;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .print-only {
    display: block;
  }
}

@media screen and (max-width: 700px) {
  .filters.billing-report-filters {
    grid-template-columns: 1fr;
  }

  .billing-forecast-options {
    flex-wrap: wrap;
    gap: 3px 14px;
  }

  .table-wrap > .quotes-list-table {
    min-width: 900px;
  }
}

@media screen and (min-width: 701px) and (max-width: 1280px) {
  .filters.billing-report-filters {
    grid-template-columns: 105px 105px 195px minmax(315px, 1fr) 135px;
  }

  .billing-forecast-options {
    gap: 12px;
  }

  .billing-quotes-toggle .checkbox-inline {
    font-size: 12px;
  }
}

/* Rejilla contable del P&L: se declara al final para prevalecer sobre la tabla genérica. */
.financial-report-card .pnl-table {
  width: 100%;
  min-width: 960px;
  table-layout: fixed;
}

.financial-report-card .pnl-table col.pnl-concept-column { width: 24%; }
.financial-report-card .pnl-table col.pnl-period-column { width: 15.2%; }

.financial-report-card .pnl-table th,
.financial-report-card .pnl-table td {
  padding-block: 12px;
  padding-inline: 20px;
}

.financial-report-card .pnl-table thead th:not(:first-child),
.financial-report-card .pnl-table tbody td {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.financial-report-card .pnl-table thead th:not(:first-child),
.financial-report-card .pnl-table tbody td:not(:first-child) {
  border-left: 1px solid rgba(220, 228, 239, 0.72);
}

.financial-report-card .pnl-table th:first-child {
  text-align: left;
}

.financial-report-card .pnl-table th:last-child,
.financial-report-card .pnl-table td:last-child {
  background: rgba(238, 243, 248, 0.48);
}

.financial-report-card .pnl-table thead th:last-child {
  background: #e5edf6;
}

.pnl-forecast-intro {
  margin: 20px 0 14px;
}

.pnl-forecast-intro p {
  margin: 4px 0;
}

.kpi-percent {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pnl-amount,
.pnl-percentage {
  display: block;
}

.pnl-percentage {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.pnl-result-row .pnl-percentage {
  color: #60708a;
}

.financial-report-card .pnl-table .pnl-tax-total-row th,
.financial-report-card .pnl-table .pnl-tax-total-row td {
  border-top: 2px solid var(--line-strong);
  font-weight: 800;
}

.financial-report-card .pnl-table .pnl-tax-detail-row th {
  padding-left: 38px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.financial-report-card .pnl-table .pnl-tax-detail-row td {
  color: #566781;
  font-size: 12px;
}

.financial-report-card .monthly-results-table {
  width: 100%;
  table-layout: fixed;
}

.monthly-revenue-chart {
  margin-bottom: 18px;
  padding: 18px 20px 10px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff 0%, var(--surface-soft) 100%);
}

.monthly-revenue-chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  color: var(--title);
}

.monthly-revenue-chart-head span { color: var(--muted); font-size: 12px; font-weight: 600; }
.monthly-revenue-chart svg { display: block; width: 100%; min-width: 760px; height: 250px; color: var(--primary); }
.monthly-chart-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.monthly-chart-line { fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.monthly-chart-point { fill: #fff; stroke: currentColor; stroke-width: 3; vector-effect: non-scaling-stroke; }
.monthly-chart-value, .monthly-chart-month { fill: var(--muted); font-size: 12px; font-weight: 700; }
.cash-burn-help { margin: -8px 0 12px; }
.cash-burn-line, .cash-burn-point { color: var(--danger); }
.cash-burn-zero { stroke: var(--title); stroke-width: 1.5; stroke-dasharray: 6 5; opacity: 0.7; vector-effect: non-scaling-stroke; }
.financial-report-card .cash-burn-table th,
.financial-report-card .cash-burn-table td { padding-block: 11px; }
.chart-inline-legend { display: flex; align-items: center; gap: 18px; }
.chart-inline-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-inline-legend i { width: 10px; height: 10px; border-radius: 50%; }
.investment-dot { background: #00a2e1; }
.purchase-dot { background: #2adac3; }
.investment-chart-line { color: #00a2e1; }
.purchase-chart-line { color: #2adac3; }

.invoice-unlock-panel {
  margin: 0 0 20px;
  padding: 14px 18px;
  border: 1px solid #efb2bd;
  border-radius: 12px;
  background: #fff7f8;
}

.invoice-unlock-panel summary { cursor: pointer; color: var(--danger); font-weight: 800; }
.invoice-unlock-panel form { display: grid; gap: 12px; margin-top: 14px; }
.invoice-unlock-panel p { margin: 0; }
.invoice-unlock-panel .checkbox-inline { justify-content: flex-start; }
.invoice-unlock-panel .button { justify-self: start; }

.financial-report-card .monthly-results-table col.monthly-label-column { width: 24%; }
.financial-report-card .monthly-results-table col.monthly-value-column { width: 25.333%; }

.financial-report-card .monthly-results-table th:not(:first-child),
.financial-report-card .monthly-results-table td:not(:first-child) {
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.financial-report-card .monthly-results-table th:first-child,
.financial-report-card .monthly-results-table td:first-child {
  text-align: left;
}

.financial-report-card .monthly-results-table th:not(:first-child) .table-sort {
  width: 100%;
  text-align: center;
}

.financial-report-card .cash-burn-table {
  width: 100%;
  min-width: 1120px;
  table-layout: fixed;
  font-size: 14px;
}

.cash-burn-table .cash-burn-month-col { width: 10%; }
.cash-burn-table .cash-burn-amount-col { width: 12%; }
.cash-burn-table .cash-burn-operation-col { width: 16%; }
.cash-burn-table .cash-burn-special-col { width: 11%; }
.cash-burn-table .cash-burn-result-col { width: 13%; }
.cash-burn-table .cash-burn-change-col { width: 14%; }

.financial-report-card .cash-burn-table thead th {
  padding: 14px 12px;
  text-align: right;
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: bottom;
}

.financial-report-card .cash-burn-table tbody td {
  padding: 12px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.financial-report-card .cash-burn-table tr > :first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  white-space: nowrap;
  border-right: 1px solid var(--line);
}

.financial-report-card .cash-burn-table tbody th {
  padding: 12px;
  font-weight: 600;
  background: #fff;
}

.financial-report-card .cash-burn-table tbody tr:nth-child(even) th { background: #fbfcfe; }
.financial-report-card .cash-burn-table tbody tr:hover th { background: #f7fbfd; }
.cash-burn-table .cash-burn-result { border-left: 1px solid var(--line); font-weight: 700; }
.cash-burn-table .cash-burn-change { font-weight: 700; }
.cash-burn-table tbody .cash-burn-result,
.cash-burn-table tbody .cash-burn-change { background: rgba(0, 86, 184, 0.035); }

.cash-unallocated { margin: 16px 0 20px; padding: 0; }
.cash-unallocated > summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 22px;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
}
.cash-unallocated > summary::-webkit-details-marker { display: none; }
.cash-unallocated > summary::marker { content: ''; }
.cash-unallocated > summary:focus-visible,
.cash-burn-table-wrap:focus-visible,
.cash-unallocated-table-wrap:focus-visible { outline: 3px solid var(--title); outline-offset: 3px; }
.cash-unallocated-title { flex: 1 1 280px; font-weight: 700; }
.cash-unallocated-total { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cash-unallocated-toggle { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.cash-unallocated-chevron { width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); }
.cash-unallocated-hide,
.cash-unallocated[open] .cash-unallocated-show { display: none; }
.cash-unallocated[open] .cash-unallocated-hide { display: inline; }
.cash-unallocated[open] .cash-unallocated-chevron { transform: rotate(225deg) translate(-2px, -1px); }
.cash-unallocated[open] > summary { border-bottom: 1px solid #fde68a; }
.cash-unallocated-content { padding: 16px 20px 20px; }
.cash-unallocated-help { margin: 0 0 10px; font-size: 13px; line-height: 1.55; }
.cash-unallocated-table-wrap { margin-top: 14px; max-height: 440px; overflow: auto; }
.cash-unallocated-table-wrap > .cash-unallocated-table { min-width: 780px; color: var(--ink); font-size: 13px; }
.cash-unallocated-table thead th { position: sticky; top: 0; z-index: 1; white-space: normal; text-transform: none; letter-spacing: 0; }
.cash-unallocated-table th,
.cash-unallocated-table td { padding: 12px 14px; }
.cash-unallocated-table td:nth-child(2) { min-width: 220px; max-width: 420px; overflow-wrap: anywhere; }
.cash-unallocated-table .cash-unallocated-amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cash-unallocated-date,
.cash-unallocated-action { white-space: nowrap; }
.cash-unallocated-table .cash-unallocated-action { text-align: right; }
.cash-unallocated-invoice-link { font-weight: 800; white-space: nowrap; }
.cash-unallocated-client { font-weight: 600; }
.cash-unallocated-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; font-weight: 400; }
.cash-unallocated-action .button { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.cash-unallocated-table tfoot th,
.cash-unallocated-table tfoot td { border-top: 2px solid var(--line); border-bottom: 0; background: #eef3f8; font-weight: 800; }

@media screen and (max-width: 700px) {
  .cash-unallocated > summary { gap: 10px; padding: 15px; }
  .cash-unallocated-title { flex-basis: 100%; }
  .cash-unallocated-toggle { margin-left: auto; }
  .cash-unallocated-content { padding: 14px; }
}

.filters-financing {
  grid-template-columns: repeat(2, minmax(170px, 240px)) auto 1fr;
}

.filters-financing .button { grid-column: 3; }
.financing-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.financing-report-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.financing-status-value { font-size: clamp(22px, 2.3vw, 34px); }
.finance-cash-line { color: #16804c; }
.finance-debt-line { color: #b4233a; }
.finance-net-line { color: #0056b8; }
.finance-cash-dot { background: #16804c; }
.finance-debt-dot { background: #b4233a; }
.finance-net-dot { background: #0056b8; }
.financing-monthly-table { min-width: 1060px; }
.financing-monthly-table th:not(:first-child),
.financing-monthly-table td:not(:first-child) { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.financing-monthly-table th:last-child,
.financing-monthly-table td:last-child { text-align: center; }
.financing-monthly-table .is-selected-row { background: color-mix(in srgb, var(--primary) 8%, white); }
.financing-detail-grid {
  grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.22fr);
  align-items: start;
}
.financing-detail-grid .table-wrap > .financing-detail-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}
.financing-detail-grid .financing-detail-table th { white-space: normal; }
.financing-cash-table .finance-account-column { width: 61%; }
.financing-cash-table .finance-balance-column { width: 39%; }
.financing-products-table .finance-product-column { width: 38%; }
.financing-products-table .finance-type-column { width: 36%; }
.financing-products-table .finance-pending-column { width: 26%; }
.financing-detail-grid .financing-detail-table td { overflow-wrap: anywhere; }
.financing-detail-grid .data-table td:last-child {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.financing-detail-grid .data-table th:last-child {
  text-align: right;
  white-space: normal;
  line-height: 1.2;
}
.table-subline { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.finance-warnings { margin-top: 16px; padding: 13px 16px; border: 1px solid #fde68a; border-radius: 11px; background: #fff8dd; color: #854d0e; }
.finance-warnings summary { cursor: pointer; font-weight: 800; }
.finance-warnings ul { margin: 10px 0 0; padding-left: 22px; }
.financing-report-head { margin-bottom: 14px; }
.financing-report-head .section-title { margin-bottom: 4px; }
.balance-management-grid {
  align-items: start;
  gap: 16px;
}
.balance-management-grid .balance-table-wrap {
  width: 100%;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
}
.balance-management-grid .table-wrap > .balance-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}
.balance-table col.balance-label-column { width: 68%; }
.balance-table col.balance-amount-column { width: 32%; }
.balance-management-grid .balance-table th,
.balance-management-grid .balance-table td {
  padding: 10px 12px;
}
.balance-management-grid .balance-table th:first-child,
.balance-management-grid .balance-table td:first-child {
  white-space: normal;
  overflow-wrap: anywhere;
}
.balance-management-grid .balance-table thead th {
  white-space: normal;
}
.balance-management-grid .data-table th:last-child,
.balance-management-grid .data-table td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.balance-management-grid .data-table .balance-section-row th {
  padding-top: 9px;
  padding-bottom: 9px;
  color: var(--title);
  background: #f2f7fb;
  font-size: 11px;
  letter-spacing: .035em;
  text-align: left;
  text-transform: uppercase;
  white-space: normal;
}
.balance-management-grid .balance-equity-row td {
  color: var(--title);
  background: color-mix(in srgb, var(--primary) 10%, white);
  font-weight: 800;
}
.balance-management-grid .balance-subtotal-row th,
.balance-management-grid .balance-subtotal-row td {
  color: var(--title);
  background: #f7fafc;
  font-weight: 900;
}
.balance-ratios-wrap { margin-top: 20px; }
.balance-footnote {
  margin: 10px 2px 0;
  line-height: 1.45;
}

@media screen and (max-width: 1000px) {
  .financing-kpis,
  .financing-report-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .financing-detail-grid { grid-template-columns: 1fr; }
}

@media screen and (max-width: 820px) {
  .balance-management-grid { grid-template-columns: 1fr; }
}

@media screen and (max-width: 700px) {
  .filters-financing { grid-template-columns: 1fr; }
  .filters-financing .button { grid-column: auto; width: 100%; }
  .financing-kpis,
  .financing-report-kpis { grid-template-columns: 1fr; }
  .balance-management-grid .balance-table-wrap {
    width: 100%;
    margin-right: 0;
    margin-left: 0;
  }
  .balance-management-grid .table-wrap > .balance-table {
    min-width: 0;
    font-size: 12px;
  }
  .balance-management-grid .balance-table th,
  .balance-management-grid .balance-table td { padding: 9px 8px; }
  .financing-detail-grid .table-wrap > .financing-products-table { min-width: 560px; }
  .monthly-revenue-chart-head { align-items: flex-start; flex-direction: column; }
  .chart-inline-legend { flex-wrap: wrap; }
}

@media print {
  .financing-detail-grid { grid-template-columns: 1fr; }
  .financing-detail-grid .financing-detail-table th:last-child { white-space: normal; }
}

@media screen and (max-width: 1120px) {
  .table-wrap > .quotes-list-table {
    min-width: 1235px;
  }
}

/* Simulador anual: cierre previsional como base y proyección financiera futura. */
.simulator-page-head { align-items: flex-start; }
.simulator-card > .simulator-page-head { margin-bottom: 18px; }
.simulator-year-route {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  color: var(--title);
  font-size: 13px;
  background: #f2f7fb;
  border: 1px solid var(--line);
  border-radius: 11px;
}
.simulator-year-route b { color: var(--muted); font-size: 18px; }
.simulator-year-route strong { color: var(--title); }
.simulator-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.simulator-fieldset {
  --simulator-step-color: #2adac3;
  min-width: 0;
  margin: 0;
  padding: 0 17px 17px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 4px solid var(--simulator-step-color);
  border-radius: 13px;
  box-shadow: 0 8px 22px rgba(23, 55, 119, .045);
}

.simulator-fieldset:nth-child(2) { --simulator-step-color: #00a2e1; }
.simulator-fieldset:nth-child(3) { --simulator-step-color: #0056b8; }

.simulator-step-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 -17px 16px;
  padding: 13px 17px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--simulator-step-color) 11%, white), #fff 72%);
  border-bottom: 1px solid #edf1f6;
}

.simulator-step-number {
  display: inline-grid;
  flex: 0 0 33px;
  width: 33px;
  height: 33px;
  place-items: center;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  background: var(--simulator-step-color);
  border-radius: 10px;
}

.simulator-step-head h2 {
  margin: 0;
  color: var(--title);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.2;
}

.simulator-step-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.3;
}
.simulator-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.simulator-fields label,
.simulator-save-row > label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--title);
  font-size: 12px;
  font-weight: 800;
}
.simulator-fields input,
.simulator-fields select,
.simulator-save-row input { min-width: 0; height: 41px; padding-top: 8px; padding-bottom: 8px; }
.simulator-checkboxes { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; }
.simulator-checkboxes .checkbox-inline { min-height: 30px; padding: 3px 0; font-size: 12px; }
.simulator-fieldset > .help { margin: 8px 0 0; line-height: 1.35; }
.input-suffix { position: relative; }
.input-suffix input { width: 100%; padding-right: 34px; }
.input-suffix span {
  position: absolute;
  top: 50%;
  right: 13px;
  color: var(--muted);
  font-size: 12px;
  transform: translateY(-50%);
}
.simulator-save-row {
  display: grid;
  grid-template-columns: minmax(210px, .9fr) minmax(260px, 1.25fr) auto;
  gap: 14px;
  align-items: end;
  margin-top: 16px;
}
.simulator-save-row .button-row { flex-wrap: nowrap; }
.simulator-results-head { margin-bottom: 18px; }
.simulator-results-head .section-title { margin-bottom: 2px; }
.simulator-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.simulator-kpi-grid .kpi { padding: 16px 17px; }
.simulator-kpi-grid .kpi-value { font-size: clamp(21px, 2vw, 27px); }
.kpi-foot { margin-top: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.simulator-source-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}
.simulator-source-grid > div {
  min-width: 0;
  padding: 12px 13px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 11px;
}
.simulator-source-grid span,
.simulator-source-grid strong,
.simulator-source-grid small { display: block; overflow-wrap: anywhere; }
.simulator-source-grid span { color: var(--muted); font-size: 11px; font-weight: 800; }
.simulator-source-grid strong { margin-top: 4px; color: var(--title); font-size: 17px; }
.simulator-source-grid small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.simulator-source-grid .is-excluded { opacity: .62; background: #fbfcfd; }
.simulator-warning { margin: 0 0 14px; }
.simulator-tables {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(310px, .75fr);
  gap: 16px;
  align-items: start;
}
.simulator-tables > div { min-width: 0; }
.simulator-tables h3,
.simulator-cash-bridge h3 { margin: 0 0 9px; font-size: 16px; }
.simulator-table-wrap > .data-table { width: 100%; min-width: 0; table-layout: fixed; }
.simulator-comparison-table th:first-child { width: 34%; }
.simulator-comparison-table th:not(:first-child),
.simulator-comparison-table td:not(:first-child),
.simulator-finance-table th:not(:first-child),
.simulator-finance-table td:not(:first-child) {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.simulator-comparison-table th,
.simulator-comparison-table td,
.simulator-finance-table th,
.simulator-finance-table td { padding: 10px 11px; font-size: 12px; }
.simulator-comparison-table td:last-child small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}
.simulator-highlight-row th,
.simulator-highlight-row td { color: var(--title); background: #f5f9fc; font-weight: 900; }
.simulator-cash-bridge {
  margin-top: 14px;
  padding: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.simulator-cash-bridge dl { margin: 0; }
.simulator-cash-bridge dl > div { display: flex; justify-content: space-between; gap: 15px; padding: 7px 0; border-bottom: 1px solid #e5eaf1; }
.simulator-cash-bridge dt { color: var(--muted); font-size: 12px; }
.simulator-cash-bridge dd { margin: 0; color: var(--title); font-size: 12px; font-weight: 800; white-space: nowrap; }
.simulator-cash-bridge dl > .total { padding-top: 10px; border-bottom: 0; }
.simulator-cash-bridge .total dt,
.simulator-cash-bridge .total dd { color: var(--title); font-weight: 900; }
.simulator-method-note {
  margin: 18px 0 0;
  padding: 12px 14px;
  color: #4c607b;
  font-size: 11px;
  line-height: 1.45;
  background: #f2f7fb;
  border-radius: 10px;
}
.simulator-saved-card .page-head { margin-bottom: 14px; }
.simulator-saved-table { min-width: 900px; }
.simulator-saved-table td:not(:first-child) { white-space: nowrap; font-variant-numeric: tabular-nums; }
.simulator-saved-table td:first-child strong,
.simulator-saved-table td:first-child small { display: block; }
.simulator-saved-table td:first-child small { margin-top: 3px; color: var(--muted); font-size: 10px; }

@media screen and (max-width: 1120px) {
  .simulator-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .simulator-fieldset:last-child { grid-column: 1 / -1; }
  .simulator-fieldset:last-child .simulator-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .simulator-source-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .simulator-tables { grid-template-columns: 1fr; }
}

@media screen and (max-width: 820px) {
  .simulator-page-head { align-items: stretch; flex-direction: column; }
  .simulator-year-route { align-self: flex-start; }
  .simulator-form-grid { grid-template-columns: 1fr; }
  .simulator-fieldset:last-child { grid-column: auto; }
  .simulator-fieldset:last-child .simulator-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .simulator-save-row { grid-template-columns: 1fr; }
  .simulator-save-row .button-row { justify-content: flex-start; }
  .simulator-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media screen and (max-width: 560px) {
  .simulator-fields,
  .simulator-fieldset:last-child .simulator-fields,
  .simulator-kpi-grid,
  .simulator-source-grid { grid-template-columns: 1fr; }
  .simulator-save-row .button-row { flex-direction: column; }
  .simulator-save-row .button { width: 100%; }
  .simulator-year-route { width: 100%; justify-content: center; }
  .simulator-table-wrap > .simulator-comparison-table { min-width: 620px; }
}

/* Gastos, inmovilizado y manual financiero · 0.3.158 */
.expense-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}
.expense-totals > div {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f8fafc;
}
.expense-totals span,
.expense-totals strong,
.expense-totals small { display: block; }
.expense-totals span { color: var(--muted); font-size: 11px; font-weight: 800; }
.expense-totals strong { margin-top: 4px; color: var(--title); font-size: 20px; }
.expense-totals small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.expense-duplicate-review {
  margin: 0 0 14px;
  padding: 11px 13px;
  border: 1px solid #f0d8a1;
  border-radius: 10px;
  background: #fffaf0;
  color: #68512a;
  font-size: 12px;
}
.expense-duplicate-review summary { cursor: pointer; color: #6a4b08; font-weight: 900; }
.expense-duplicate-review p { margin: 9px 0 5px; line-height: 1.45; }
.expense-duplicate-review ul { margin: 7px 0 0; padding-left: 20px; }
.expense-duplicate-review li + li { margin-top: 4px; }
.expense-superseded-row { background: #fbfaf7; color: #6d7685; }
.expense-review-badge,
.asset-source-badge {
  display: block;
  width: max-content;
  max-width: 180px;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #fff1d6;
  color: #8a5a00;
  font-size: 9px;
  font-weight: 900;
  line-height: 1.25;
}
.expense-review-badge.verified { background: #eef1f5; color: #5b6575; }
.asset-source-badge.automatic { background: #e8f8f5; color: #177567; }
.asset-source-badge.manual { background: #edf4ff; color: #285f9e; }
.fixed-assets-auto-note { margin: -4px 0 14px; }
.expense-delete-impact { margin: 0 0 18px; padding: 12px 15px; border-radius: 10px; background: #f8fafc; }
.expense-delete-impact p { margin: 0; }
.expense-delete-impact ul { margin: 8px 0 0; padding-left: 20px; }

.manual-financial-hero .page-head { margin-bottom: 16px; }
.manual-financial-card h2 { margin: 0 0 14px; color: var(--title); font-size: 21px; }
.manual-financial-card h3 { margin: 0 0 9px; color: var(--title); font-size: 16px; }
.manual-financial-card p,
.manual-financial-card li { color: #43536b; line-height: 1.55; }
.manual-financial-card ul,
.manual-financial-card ol { margin-top: 8px; }
.manual-financial-card li + li { margin-top: 6px; }
.manual-decision-table { min-width: 980px; }
.manual-decision-table td:first-child { min-width: 190px; }
.manual-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.manual-grid-2 > div { padding: 14px 16px; border: 1px solid var(--line); border-radius: 11px; background: #f8fafc; }
.manual-grid-2 ul { margin-bottom: 0; padding-left: 20px; }
.manual-formula {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin: 14px 0;
  padding: 14px 16px;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #f1faf8;
}
.manual-formula span { color: var(--muted); font-size: 12px; font-weight: 800; }
.manual-formula strong { color: var(--title); text-align: right; }
.manual-steps { padding-left: 22px; }

@media screen and (max-width: 900px) {
  .expense-totals { grid-template-columns: 1fr; }
  .manual-grid-2 { grid-template-columns: 1fr; }
}

@media screen and (max-width: 560px) {
  .manual-formula { flex-direction: column; }
  .manual-formula strong { text-align: left; }
}
