:root {
  --bg: #f4f1ea;
  --ink: #1c2430;
  --muted: #687181;
  --line: #d9d2c6;
  --panel: #fffdf8;
  --green: #1f7a57;
  --blue: #245f9f;
  --red: #b9443f;
  --amber: #b87824;
  --shadow: 0 18px 50px rgba(34, 30, 24, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  display: grid;
  grid-template-columns: 280px 1fr;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #20252d;
  color: white;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #d7ad5f;
  color: #1c2430;
  font-weight: 900;
}

.brand strong, .brand span, .sidebar-footer strong, .sidebar-footer span { display: block; }

.brand span, .sidebar-footer span {
  color: rgba(255,255,255,0.62);
  font-size: 13px;
  margin-top: 3px;
}

.nav { display: grid; gap: 6px; }

.nav-item {
  width: 100%;
  border: 0;
  color: rgba(255,255,255,0.72);
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,0.11); }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 18px;
}

.shell { padding: 26px; max-width: 1500px; width: 100%; }

.topbar, .section-head, .panel-head, .modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.topbar h1, .section-head h2, .panel h2, .panel h3 { margin: 0; }
.topbar h1 { font-size: 34px; }

.eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 4px;
}

.top-actions, .filters { display: flex; align-items: center; gap: 10px; }

.primary-button, .secondary-button, .icon-button, .danger-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 40px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button { padding: 0 16px; background: var(--green); color: white; }
.secondary-button { padding: 0 14px; background: #fff; color: var(--ink); border-color: var(--line); }
.danger-button { padding: 0 14px; background: #fff; color: var(--red); border-color: #e7c2c0; }
.danger-button:hover { background: #fdf0ef; }
.icon-button { width: 40px; background: #fff; border-color: var(--line); }

a.download-link, label.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}

.project-strip {
  margin: 22px 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.48);
  border-radius: 8px;
  overflow: hidden;
}

.project-strip div { padding: 14px 16px; border-right: 1px solid var(--line); }
.project-strip div:last-child { border-right: 0; }
.project-strip span { display: block; color: var(--muted); font-size: 12px; }

.section { display: none; }
.section.active { display: block; }

.kpi-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(0, 2fr);
  gap: 14px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(34, 30, 24, 0.06);
  text-align: left;
}

.kpi span { color: var(--muted); font-size: 13px; }
.kpi strong { display: block; margin-top: 8px; font-size: 24px; }
.kpi small { color: var(--green); font-weight: 800; }
.kpi strong.negative { color: var(--red); }

.kpi-total {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-color: rgba(31, 122, 87, 0.28);
  background: linear-gradient(180deg, #fffdf8, #f6fbf7);
}

.kpi-total strong {
  font-size: 44px;
  line-height: 1;
  margin: 12px 0;
}

.kpi-stack { display: grid; gap: 12px; }
.kpi-subgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.kpi-status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi-detail, .kpi-status { padding: 12px; box-shadow: none; }
.kpi-detail strong { font-size: 19px; }
.kpi-status strong { font-size: 22px; }

.clickable-card { width: 100%; color: inherit; cursor: pointer; }

.clickable-card:hover, .clickable-row:hover, .text-link:hover, .amount-link:hover {
  border-color: rgba(31, 122, 87, 0.55);
  box-shadow: 0 12px 28px rgba(31, 122, 87, 0.12);
}

.content-grid { display: grid; grid-template-columns: 1.5fr 0.9fr; gap: 18px; }
.dashboard-grid { grid-template-columns: minmax(360px, 1.35fr) minmax(240px, 0.82fr) minmax(240px, 0.82fr); }
.wide { grid-column: span 1; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel select, .filters input, .filters select, label input, label select, label textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px 12px;
  min-height: 40px;
  color: var(--ink);
}

.bar-chart { display: grid; gap: 12px; margin-top: 18px; }

.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 84px;
  gap: 12px;
  align-items: center;
}

button.bar-row {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  padding: 8px;
  text-align: left;
  cursor: pointer;
}

.bar-track { height: 12px; background: #ece5d9; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--green)); }

.badge { border-radius: 999px; padding: 5px 10px; font-weight: 900; }
.danger { background: #ffe1df; color: var(--red); }
.ok { background: #ddf1e8; color: var(--green); }
.warn { background: #fff1d6; color: var(--amber); }

.alert-list, .account-list { display: grid; gap: 10px; margin-top: 16px; }

.alert, .account-row {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: #f7f3eb;
}

.alert.alert-warn { background: #fff1d6; }
.alert strong, .account-row strong { font-size: 14px; }
.alert span, .account-row span { color: var(--muted); font-size: 13px; }

/* Cajas del dashboard: compactas para que entren todas sin scroll,
   ordenadas de mayor a menor saldo desde el render. */
.dashboard-cash-list { gap: 6px; max-height: 420px; overflow: auto; padding-right: 2px; }
.dashboard-cash-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name amount" "meta amount";
  align-items: center;
  column-gap: 10px;
  row-gap: 0;
  padding: 8px 10px;
  text-align: left;
  border: 1px solid transparent;
  color: inherit;
  cursor: pointer;
}
.dashboard-cash-row span { grid-area: name; font-size: 13px; color: var(--text); }
.dashboard-cash-row small { grid-area: meta; color: var(--muted); font-size: 11px; }
.dashboard-cash-row strong { grid-area: amount; margin: 0; font-size: 16px; white-space: nowrap; }
.dashboard-partner-summary { display: grid; gap: 10px; margin-top: 16px; }
.summary-metric {
  display: grid;
  gap: 3px;
  padding: 12px;
  border-radius: 8px;
  background: #f7f3eb;
}
.summary-metric span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.summary-metric strong { font-size: 22px; }
.summary-metric small { color: var(--green); font-weight: 800; }
.account-card .account-balance {
  display: block;
  font-size: 34px;
  line-height: 1;
  margin: 12px 0 8px;
}
.balance-positive { color: var(--green); }
.balance-negative { color: var(--red); }
.balance-zero { color: var(--ink); }

.table-wrap {
  margin-top: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  overflow: auto;
  max-width: 100%;
}

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

th, td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.text-link, .amount-link {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--green);
  cursor: pointer;
  font-weight: 900;
  padding: 3px 5px;
  text-align: left;
}

.amount-link { color: var(--blue); }

th {
  color: var(--muted);
  background: #f7f3eb;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

td { font-size: 14px; }
tr:last-child td { border-bottom: 0; }
td .negative { color: var(--red); }

.progress { display: flex; align-items: center; gap: 9px; }
.mini-track { width: 92px; height: 8px; background: #ece5d9; border-radius: 999px; overflow: hidden; }
.mini-fill { height: 100%; background: var(--green); }
.mini-fill.over { background: var(--red); }

.cards-grid, .rule-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.data-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(34, 30, 24, 0.06);
}

.data-card h3 { margin: 0 0 10px; }
.data-card p { margin: 0; color: var(--muted); }

.metric-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; }
.metric-row .negative { color: var(--red); }

.donut { margin-top: 20px; display: flex; align-items: center; gap: 18px; }

.donut-ring {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0 0%, #e9e1d5 0% 100%);
  position: relative;
  flex-shrink: 0;
}

.donut-ring::after {
  content: "";
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: var(--panel);
}

.donut strong { display: block; font-size: 34px; }
.donut span { color: var(--muted); }

.rule {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.rule input { margin-top: 4px; accent-color: var(--green); }

.config-rule { display: grid; grid-template-columns: 1fr 110px; align-items: center; }
.config-rule input { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 40px; }

.config-extra { margin-top: 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.config-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.config-note { margin-top: 10px; font-size: 13px; color: var(--amber); font-weight: 700; }
.config-note.ok { color: var(--green); }

dialog {
  border: 0;
  padding: 0;
  border-radius: 8px;
  max-width: 980px;
  width: min(980px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(28,36,48,0.48); }

.modal { padding: 20px; background: var(--panel); }

.form-error {
  margin-top: 14px;
  border: 1px solid #e7c2c0;
  background: #fdf0ef;
  color: var(--red);
  border-radius: 8px;
  padding: 12px;
  font-weight: 700;
  font-size: 14px;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.detail-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f7f3eb;
}

.detail-summary span { display: block; color: var(--muted); font-size: 12px; }
.detail-summary strong { display: block; margin-top: 6px; font-size: 22px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 18px 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.full { grid-column: 1 / -1; }
.hidden-field { display: none !important; }

.subrubro-inline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.subrubro-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdfbf6;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 3px;
  padding: 10px;
  text-align: left;
}

.subrubro-chip span, .subrubro-chip small,
.movement-card span, .movement-card small { color: var(--muted); font-size: 12px; }

.subrubro-chip:hover { border-color: rgba(31, 122, 87, 0.55); }

button.account-row { border: 0; color: inherit; cursor: pointer; text-align: left; }

.active-filter {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #c7e0d2;
  background: #eef6f1;
  color: var(--green);
  border-radius: 999px;
  padding: 8px 8px 8px 14px;
  font-weight: 800;
  font-size: 13px;
}

.active-filter button {
  border: 0;
  background: rgba(31,122,87,0.14);
  color: var(--green);
  border-radius: 999px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-weight: 900;
}

.movement-list { display: block; margin-top: 16px; }

.movement-card {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(140px, 0.8fr) minmax(140px, 0.8fr) auto;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(34, 30, 24, 0.06);
}

.movement-card span, .movement-card small, .movement-card strong { display: block; }
.movement-card strong { margin-top: 3px; }
.movement-card .movement-amount.income { color: var(--green); }
.movement-card .movement-amount.expense { color: var(--red); }

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

.compact-table {
  border-radius: 6px;
}

.compact-table table {
  min-width: 0;
}

.compact-table th,
.compact-table td {
  padding: 9px 10px;
  vertical-align: middle;
}

.compact-table tbody tr:hover {
  background: #fbf7ef;
}

/* La tabla de movimientos entra completa en pantalla: ancho fijo por columna
   y contenido recortado con elipsis. El texto completo se ve en el tooltip. */
.movement-table-wrap { overflow-x: hidden; }
.movement-table { table-layout: fixed; width: 100%; }

.movement-table th,
.movement-table td {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movement-table col.c-fecha    { width: 76px; }
.movement-table col.c-tipo     { width: 104px; }
.movement-table col.c-rubro    { width: 13%; }
.movement-table col.c-subrubro { width: 13%; }
.movement-table col.c-detalle  { width: auto; }
.movement-table col.c-caja     { width: 11%; }
.movement-table col.c-importe  { width: 106px; }
.movement-table col.c-usd      { width: 88px; }
.movement-table col.c-acciones { width: 132px; }

.detail-cell strong,
.detail-cell small,
.movement-table td small {
  display: block;
}

/* El detalle se recorta en una sola linea; el title muestra todo al pasar el mouse. */
.detail-cell strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
}

.detail-cell small,
.movement-table td small {
  color: var(--muted);
  margin-top: 2px;
}

.type-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef1f4;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.type-pill.income { background: #e7f4ed; color: var(--green); }
.type-pill.expense { background: #fbeceb; color: var(--red); }

.row-actions {
  white-space: nowrap;
  text-align: right;
}

.row-actions .mini-button + .mini-button {
  margin-left: 6px;
}

.mini-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  min-height: 30px;
  padding: 0 9px;
}

.danger-mini {
  color: var(--red);
  border-color: #e7c2c0;
}

.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  margin-top: 16px;
}

.investment-detail-list {
  margin-top: 16px;
  max-height: 52vh;
  overflow: auto;
}

.parent-row {
  background: #f7f3eb;
  font-weight: 800;
}

.subrow-link {
  margin-left: 18px;
  color: var(--ink);
  font-weight: 700;
}

.investment-detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.investment-detail-main {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 14px;
  align-items: center;
  text-align: left;
  padding: 0;
}

.investment-detail-main span { color: var(--muted); font-size: 13px; }

.partner-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; margin-top: 16px; }
.partner-grid { margin-top: 0; grid-template-columns: 1fr; }

.partner-table th,
.partner-table td,
.capital-table th,
.capital-table td {
  font-size: 13px;
}

.partner-table td strong,
.partner-table td small,
.capital-table td strong,
.capital-table td small {
  display: block;
}

.partner-table td small,
.capital-table td small {
  color: var(--muted);
  margin-top: 1px;
  font-size: 11px;
}

.editable-value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pencil-button {
  width: 24px;
  height: 24px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
  line-height: 1;
}

.pencil-button:hover {
  color: var(--green);
  border-color: var(--line);
  background: #fff;
}

.partner-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }

.partner-input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 40px;
}

.partner-input[readonly] { background: #f7f3eb; color: var(--muted); }

.capital-detail {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

#capitalSourceCards { grid-template-columns: 1fr; gap: 0; margin-top: 10px; }
.capital-partner-card { display: grid; gap: 12px; }

.capital-detail-table-wrap th,
.capital-detail-table-wrap td {
  padding: 6px 8px;
}

.capital-detail-table-wrap table {
  min-width: 980px;
}

.tight-input {
  min-height: 28px;
  padding: 4px 7px;
}

.tight-number {
  min-height: 28px;
  padding: 4px 7px;
  max-width: 108px;
}

.flat-section {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  overflow: hidden;
}

.flat-section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: #f7f3eb;
  border-bottom: 1px solid var(--line);
}

.flat-section-head h3 {
  margin: 0;
}

.flat-section-head span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.table-input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  background: #fff;
}

.number-input {
  max-width: 130px;
}

.small-input {
  max-width: 70px;
}

.capital-total-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f3eb;
  padding: 9px 10px;
  font-size: 13px;
}

.capital-total-row span, .capital-source-title span { color: var(--muted); }

.capital-source {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(140px, 0.8fr) minmax(100px, 0.55fr) minmax(130px, 0.75fr) minmax(130px, 0.75fr);
  gap: 8px;
  align-items: end;
  border: 1px solid #e5ded2;
  border-radius: 6px;
  background: #fff;
  padding: 9px 10px;
}

.capital-source input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 32px;
  padding: 6px 8px;
}

.capital-source .metric-row strong { color: var(--green); }
.capital-source-title { display: grid; gap: 2px; }
.capital-source-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.capital-source .metric-row { margin-top: 0; display: grid; gap: 2px; }
.capital-source .metric-row span { color: var(--muted); font-size: 12px; }

.labor-control { display: grid; gap: 16px; margin-top: 16px; }
.labor-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

.toggle-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }

.labor-rates { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }

.labor-rates span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.labor-rates strong { color: var(--ink); }

.labor-days { display: grid; gap: 10px; max-height: 62vh; overflow: auto; padding-right: 4px; }

.labor-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.labor-day-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.labor-day-head span { color: var(--green); font-weight: 900; }

.labor-day-double { border-color: var(--orange, #d1730c); background: rgba(209, 115, 12, 0.06); }

button[data-labor-double] { margin-bottom: 10px; width: 100%; }
button[data-labor-double].active {
  background: var(--orange, #d1730c);
  border-color: var(--orange, #d1730c);
  color: #fff;
  font-weight: 700;
}

.labor-role-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.labor-role-grid label { font-size: 12px; }

/* Doble jornada individual por rol */
.labor-role-cell { display: grid; gap: 4px; }
.labor-role-cell.is-double .labor-role-name { color: #d1730c; font-weight: 700; }
.x2-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 0;
  cursor: pointer;
}
.x2-btn:hover { background: #f4f1ea; }
.x2-btn.active { background: #d1730c; border-color: #d1730c; color: #fff; }

.labor-role-grid input {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 8px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  background: #20252d;
  color: white;
  border-radius: 8px;
  padding: 14px 18px;
  font-weight: 700;
  box-shadow: var(--shadow);
  max-width: 380px;
}

.toast.error { background: var(--red); }

@media (max-width: 1080px) {
  body {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
    gap: 14px;
  }

  .brand {
    align-items: flex-start;
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .nav-item {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 10px 12px;
  }

  .sidebar-footer {
    display: none;
  }

  .shell {
    max-width: none;
  }

  .kpi-grid, .project-strip, .cards-grid, .rule-grid, .config-extra {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-subgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
  .partner-layout { grid-template-columns: 1fr; }
  .labor-summary, .labor-rates, .labor-role-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  .movement-table,
  .partner-table,
  .capital-table {
    min-width: 860px;
  }

  .capital-detail-table-wrap table {
    min-width: 880px;
  }
}

@media (max-width: 700px) {
  .sidebar {
    padding: 12px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand strong {
    font-size: 14px;
  }

  .brand span {
    font-size: 12px;
  }

  .nav-item {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .shell {
    padding: 12px;
  }

  .topbar, .section-head, .panel-head {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .topbar h1 {
    font-size: 26px;
    line-height: 1.12;
  }

  .section-head h2,
  .panel h2 {
    font-size: 21px;
  }

  .top-actions, .filters {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .filters input {
    grid-column: 1 / -1;
  }

  .filters input,
  .filters select,
  .top-actions button,
  .top-actions a,
  .primary-button,
  .secondary-button {
    width: 100%;
    min-width: 0;
    min-height: 42px;
  }

  .kpi-grid, .project-strip, .cards-grid, .rule-grid, .form-grid, .detail-summary, .config-extra {
    grid-template-columns: 1fr;
  }

  .kpi-subgrid,
  .kpi-status-grid {
    grid-template-columns: 1fr;
  }

  .kpi-total {
    min-height: auto;
  }

  .kpi-total strong,
  .account-card .account-balance {
    font-size: 30px;
  }

  .labor-summary, .labor-rates, .labor-role-grid { grid-template-columns: 1fr; }

  .project-strip div { border-right: 0; border-bottom: 1px solid var(--line); }
  .project-strip div:last-child { border-bottom: 0; }

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

  .panel,
  .data-card {
    padding: 14px;
    box-shadow: 0 8px 24px rgba(34, 30, 24, 0.06);
  }

  .kpi {
    padding: 13px;
  }

  .kpi strong {
    font-size: 22px;
  }

  .donut {
    align-items: flex-start;
  }

  .donut-ring {
    width: 92px;
    height: 92px;
  }

  .donut-ring::after {
    inset: 17px;
  }

  .donut strong {
    font-size: 26px;
  }

  dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .modal {
    min-height: 100dvh;
    padding: 14px;
    overflow: auto;
  }

  .modal-actions {
    position: sticky;
    bottom: -14px;
    background: var(--panel);
    border-top: 1px solid var(--line);
    padding-top: 10px;
    display: grid;
    grid-template-columns: 1fr;
  }

  .detail-summary div {
    padding: 10px;
  }

  .detail-summary strong {
    font-size: 19px;
  }

  table {
    min-width: 760px;
  }

  .table-wrap::after {
    content: "Deslizá para ver más";
    position: sticky;
    left: 0;
    display: block;
    padding: 6px 10px;
    color: var(--muted);
    background: #f7f3eb;
    border-top: 1px solid var(--line);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .movement-table {
    min-width: 780px;
  }

  .partner-table {
    min-width: 760px;
  }

  .capital-table,
  .capital-detail-table-wrap table {
    min-width: 820px;
  }

  th, td {
    padding: 9px 10px;
  }

  input, select, textarea {
    font-size: 16px;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}

@media (max-width: 420px) {
  .top-actions, .filters {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 23px;
  }

  .eyebrow {
    font-size: 11px;
  }

  .project-strip div,
  .alert,
  .account-row {
    padding: 10px;
  }

  .mini-button {
    min-height: 28px;
    padding: 0 7px;
  }

  .active-filter {
    border-radius: 8px;
    width: 100%;
    justify-content: space-between;
  }
}
