/* Hub · sistema de diseño (0 dependencias). Tokens → componentes → vistas. Claro/oscuro por prefers-color-scheme o [data-theme]. */
:root {
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", ui-sans-serif, system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f9fafb; --surface-3: #f2f4f7; --border: #e6e8ec; --border-strong: #d5d9e0;
  --text: #101828; --text-2: #344054; --muted: #667085; --faint: #98a2b3;
  --primary: #4f46e5; --primary-600: #4338ca; --primary-50: #eef2ff; --primary-100: #e0e7ff; --on-primary: #fff; --ring: rgba(79, 70, 229, .28);
  --side: #fbfbfc; --side-text: #475467; --side-hover: #f2f4f7; --side-active: #eef2ff; --side-active-text: #3730a3;
  --green: #079455; --green-50: #ecfdf3; --amber: #b54708; --amber-50: #fffaeb; --red: #d92d20; --red-50: #fef3f2;
  --blue: #1570ef; --blue-50: #eff8ff; --purple: #7a5af8; --purple-50: #f4f3ff; --gray-50: #f2f4f7; --gray-300: #d0d5dd;
  --chart-in: var(--primary); --chart-out: #98a2b3;
  --radius: 12px; --radius-sm: 8px; --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18), 0 4px 8px -4px rgba(16, 24, 40, .06);
  --topbar-bg: rgba(246, 247, 249, .8);
  color-scheme: light;
}
/* El tema lo fija /js/theme.js antes de pintar (preferencia guardada o la del sistema) */
:root[data-theme="dark"] {
  --bg: #0b0d12; --surface: #12151c; --surface-2: #161a22; --surface-3: #1c2130; --border: #232838; --border-strong: #2f3547;
  --text: #f2f4f7; --text-2: #d0d5dd; --muted: #98a2b3; --faint: #667085;
  --primary: #818cf8; --primary-600: #a5b4fc; --primary-50: rgba(129, 140, 248, .12); --primary-100: rgba(129, 140, 248, .2); --on-primary: #0b0d12; --ring: rgba(129, 140, 248, .35);
  --side: #0f1218; --side-text: #98a2b3; --side-hover: #171b24; --side-active: rgba(129, 140, 248, .14); --side-active-text: #c7d2fe;
  --green: #47cd89; --green-50: rgba(71, 205, 137, .12); --amber: #fdb022; --amber-50: rgba(253, 176, 34, .12); --red: #f97066; --red-50: rgba(249, 112, 102, .12);
  --blue: #53b1fd; --blue-50: rgba(83, 177, 253, .12); --purple: #a48afb; --purple-50: rgba(164, 138, 251, .12); --gray-50: #1c2130; --gray-300: #3a4155;
  --chart-out: #475467;
  --shadow-xs: none; --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .6);
  --topbar-bg: rgba(11, 13, 18, .75);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.55 var(--font); color: var(--text); background: var(--bg); display: flex; min-height: 100vh; -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
a { color: inherit; }
h1, h2, h3, h4, h5 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
code { font: 12.5px var(--mono); background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .grow { flex: 1; } .ic { flex: none; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary-100); }
.kpi strong, .data td.r, .totals td, .pos-tag, .num { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.sidebar { width: 248px; flex: none; background: var(--side); border-right: 1px solid var(--border); color: var(--side-text); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; padding: 6px 10px 16px; letter-spacing: -.01em; }
.brand .logo { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #7c3aed); color: #fff; display: grid; place-items: center; font-weight: 800; box-shadow: 0 4px 12px -2px var(--ring); }
.brand span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo-tag { display: inline-block; margin: 0 10px 12px; font-size: 11px; font-weight: 600; background: var(--amber-50); color: var(--amber); padding: 2px 8px; border-radius: 99px; }
.nav-group { margin-bottom: 10px; }
.nav-title { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 8px 12px 4px; }
.nav-group a { position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 8px; text-decoration: none; font-weight: 500; transition: background .12s, color .12s; }
.nav-group a .ic { opacity: .8; }
.nav-group a:hover { background: var(--side-hover); color: var(--text); }
.nav-group a.active { background: var(--side-active); color: var(--side-active-text); font-weight: 600; }
.nav-group a.active .ic { opacity: 1; }
.nav-group a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 700; min-width: 20px; text-align: center; padding: 0 6px; border-radius: 99px; background: var(--red-50); color: var(--red); }
.side-foot { margin-top: auto; padding: 10px 6px 0; border-top: 1px solid var(--border); display: flex; gap: 6px; align-items: center; }
.side-foot small { color: var(--faint); }
.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 28px; background: var(--topbar-bg); backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--border); }
main { padding: 28px; max-width: 1440px; width: 100%; outline: none; margin: 0 auto; }
.topbar .only-mobile { display: none; }
.view { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.search { position: relative; width: min(440px, 100%); }
.search input { width: 100%; padding: 8px 52px 8px 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23667085' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") 11px center no-repeat; box-shadow: var(--shadow-xs); }
.search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font: 600 11px var(--font); color: var(--muted); border: 1px solid var(--border); background: var(--surface-2); border-radius: 6px; padding: 1px 6px; pointer-events: none; }
.search-results { position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; max-height: 60vh; overflow: auto; }
.search-results a { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; }
.search-results a:hover, .search-results a:focus { background: var(--surface-3); outline: none; }
.search-results p { margin: 8px; }
.tag { font-size: 11px; font-weight: 600; background: var(--surface-3); padding: 1px 7px; border-radius: 6px; color: var(--muted); }
.year-picker { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.year-picker select { width: auto; padding: 6px 28px 6px 10px; }
.dropdown { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; z-index: 30; animation: fade .12s ease-out; }
.menu a { display: block; padding: 8px 12px; border-radius: 8px; text-decoration: none; }
.menu a:hover { background: var(--surface-3); }

/* ---------- Componentes ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { margin: 6px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 13.5px var(--font); border-radius: 9px; padding: 8px 14px; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s, transform .06s; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.busy { cursor: progress; position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid var(--muted); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, .12); } .btn-primary:hover { background: var(--primary-600); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); box-shadow: var(--shadow-xs); } .btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--muted); } .btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--red); } .btn-danger-ghost:hover { background: var(--red-50); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 8px; cursor: pointer; color: var(--muted); display: inline-flex; text-decoration: none; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { background: var(--red-50); color: var(--red); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card > h2, .card-head h2 { font-size: 15px; font-weight: 650; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 small { font-weight: 500; margin-left: 4px; }
.card-link { cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .12s; }
.card-link:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 16px; }
.sec-title { font-size: 16px; font-weight: 650; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; box-shadow: var(--shadow); overflow: hidden; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi strong { font-size: 24px; font-weight: 700; letter-spacing: -.02em; color: var(--text); line-height: 1.2; }
.kpi small { font-size: 12px; }
.kpi.green strong { color: var(--green); } .kpi.red strong { color: var(--red); } .kpi.amber strong { color: var(--amber); }
.kpi.green::before, .kpi.red::before, .kpi.amber::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.kpi.green::before { background: var(--green); } .kpi.red::before { background: var(--red); } .kpi.amber::before { background: var(--amber); }
a.kpi { text-decoration: none; transition: border-color .12s, box-shadow .12s; } a.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px 2px 8px; border-radius: 99px; white-space: nowrap; line-height: 18px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-gray { background: var(--gray-50); color: var(--muted); } .badge-green { background: var(--green-50); color: var(--green); }
.badge-amber { background: var(--amber-50); color: var(--amber); } .badge-red { background: var(--red-50); color: var(--red); }
.badge-blue { background: var(--blue-50); color: var(--blue); } .badge-purple { background: var(--purple-50); color: var(--purple); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--surface-3); color: var(--muted); border: 1px solid var(--border); }
.pill.ok { background: var(--green-50); color: var(--green); border-color: transparent; }

.tabs { display: flex; gap: 2px; padding: 4px; background: var(--surface-3); border-radius: 11px; margin-bottom: 20px; overflow-x: auto; width: fit-content; max-width: 100%; }
.tabs a { padding: 6px 14px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 13.5px; border-radius: 8px; white-space: nowrap; transition: background .12s, color .12s; }
.tabs a:hover { color: var(--text); } .tabs a.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .chips { margin-bottom: 0; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 5px 12px; font: 600 13px var(--font); cursor: pointer; color: var(--muted); text-decoration: none; transition: all .12s; }
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip small { opacity: .7; margin-left: 5px; font-variant-numeric: tabular-nums; }

.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 75vh; }
.card .table-wrap { border: 0; box-shadow: none; margin: 0 -20px -20px; border-radius: 0 0 var(--radius) var(--radius); max-height: none; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; }
.data th { position: sticky; top: 0; z-index: 1; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr[data-id] { cursor: pointer; transition: background .08s; } .data tbody tr[data-id]:hover { background: var(--surface-2); }
.data tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }
.data a { text-decoration: none; } .data a:hover { text-decoration: underline; }
.r { text-align: right !important; white-space: nowrap; }
.strong { font-weight: 600; }
.neg { color: var(--red); } .pos { color: var(--green); }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty p { margin: 0 0 4px; }
.card .empty { border: 0; background: transparent; padding: 24px 8px; }
.empty .btn { margin-top: 10px; }
.loading { padding: 40px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.loading::before { content: ""; width: 16px; height: 16px; border: 2px solid var(--border-strong); border-right-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list a { text-decoration: none; } .list a:hover { color: var(--primary); }
.list li.clickable { cursor: pointer; margin: 0 -8px; padding: 10px 8px; border-radius: 8px; border-bottom-color: transparent; }
.list li.clickable:hover { background: var(--surface-2); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 280px; }

/* ---------- Formularios ---------- */
input, select, textarea { font: 14px var(--font); color: var(--text); width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow-xs); transition: border-color .12s, box-shadow .12s; }
select { appearance: none; padding-right: 30px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23667085' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right 10px center no-repeat; }
select.sm { width: auto; padding: 4px 28px 4px 10px; font-size: 12.5px; }
input[type=checkbox], input[type=radio] { width: auto; box-shadow: none; accent-color: var(--primary); }
input[type=color] { padding: 2px; height: 38px; }
input[type=file] { padding: 6px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .lbl { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.span2 { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; } .check input { width: auto; }
.sticky-save { position: sticky; bottom: 12px; justify-content: flex-end; padding: 10px; background: var(--topbar-bg); backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); }

.modal { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0; width: min(640px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.modal[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal.wide { width: min(900px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(16, 24, 40, .45); backdrop-filter: blur(3px); }
.modal header, .modal footer { display: flex; align-items: center; gap: 8px; padding: 16px 22px; flex-wrap: wrap; }
.modal header { justify-content: space-between; border-bottom: 1px solid var(--border); } .modal h2 { font-size: 17px; font-weight: 650; }
.modal footer { border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal-body { padding: 22px; max-height: 70vh; overflow-y: auto; }

.toast { position: fixed; bottom: 20px; right: 20px; z-index: 1000; display: flex; align-items: center; gap: 10px; max-width: min(440px, calc(100vw - 40px)); background: var(--text); color: var(--bg); padding: 12px 16px 12px 14px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 500; animation: up .2s ease-out; }
.toast::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: #47cd89; }
.toast-err::before { background: #f97066; }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Documento (editor) ---------- */
.doc-head { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 16px; }
.lines { width: 100%; border-collapse: collapse; margin-top: 8px; }
.lines th { font-size: 12px; color: var(--muted); text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.lines td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.lines td input, .lines td select, .lines td textarea { padding: 7px 8px; }
.lines .w-num { width: 90px; } .lines .w-tax { width: 90px; } .lines .w-tot { width: 120px; text-align: right; padding-top: 14px; font-weight: 600; }
.doc-foot { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; margin-top: 18px; }
.totals { width: 100%; } .totals td { padding: 6px 0; } .totals td:last-child { text-align: right; font-weight: 600; }
.totals .grand td { font-size: 20px; font-weight: 800; border-top: 2px solid var(--text); padding-top: 10px; }
.locked-note { display: flex; gap: 8px; align-items: flex-start; background: var(--amber-50); color: var(--amber); padding: 10px 14px; border-radius: 10px; font-weight: 500; margin: 0 0 14px; border: 1px solid color-mix(in srgb, var(--amber) 20%, transparent); }
.locked-note a { font-weight: 700; }
.fiscal { margin-bottom: 16px; padding: 0; }
.fiscal summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px 20px; cursor: pointer; list-style: none; }
.fiscal summary::-webkit-details-marker { display: none; }
.fiscal summary::before { content: '▸'; color: var(--muted); transition: transform .12s; }
.fiscal details[open] summary::before { transform: rotate(90deg); }
.fiscal summary h2 { font-size: 15px; font-weight: 650; margin: 0; }
.fiscal summary small { margin-left: auto; }
.fiscal-grid { padding: 0 20px 20px; }
.fiscal fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px 16px; margin: 0; min-width: 0; }
.fiscal legend { font-weight: 650; font-size: 13px; padding: 0 6px; }
.fiscal legend a { font-weight: 500; }
.fiscal input:invalid, .fiscal select:invalid { border-color: var(--amber); background: var(--amber-50); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: var(--surface-3); border-radius: var(--radius); padding: 10px; min-height: 140px; }
.col.drop { outline: 2px dashed var(--primary); outline-offset: -2px; }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 10px; font-weight: 650; font-size: 13px; }
.col-head small { color: var(--muted); font-weight: 600; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); transition: box-shadow .12s; }
.kcard:hover { box-shadow: var(--shadow-lg); }
.kcard:active { cursor: grabbing; } .kcard.dragging { opacity: .5; }
.kcard h4 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.kmeta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.add-card { width: 100%; border: 1px dashed var(--border-strong); background: transparent; border-radius: 10px; padding: 8px; color: var(--muted); cursor: pointer; font: 600 13px var(--font); }
.add-card:hover { background: var(--surface); color: var(--text); }

/* ---------- Gráficos ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font: 11px var(--font); fill: var(--muted); }
.chart .gl { stroke: var(--border); }
.chart .bar-in, .legend i.bar-in { fill: var(--chart-in); background: var(--chart-in); }
.chart .bar-out, .legend i.bar-out { fill: var(--chart-out); background: var(--chart-out); }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--primary-50); }
.chart .dot-pt { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.spark-wrap { display: flex; gap: 10px; align-items: stretch; }
.spark { height: 150px; flex: 1; }
.spark-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; padding: 2px 0; }
.spark-dates { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin: 6px 0 0 34px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.dist { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-3); margin-bottom: 10px; }
.dist i { display: block; height: 100%; transition: width .3s; }

/* ---------- Proyectos / informes ---------- */
.project-card { text-decoration: none; display: block; border-top: 3px solid var(--c, var(--primary)); transition: box-shadow .12s, transform .12s; }
.project-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.project-card h3 { font-size: 16px; margin-bottom: 4px; }
.pc-stats { display: flex; gap: 16px; margin-top: 12px; font-size: 13px; color: var(--muted); } .pc-stats b { color: var(--text); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 18px 14px; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline h4 { font-size: 14px; margin: 2px 0; }
.prose { line-height: 1.65; } .prose p, .prose ul { margin: 0 0 10px; } .prose h3, .prose h4, .prose h5 { margin: 16px 0 6px; }
.kpi-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.kpi-row .kpi { flex: 1 1 140px; box-shadow: none; background: var(--surface-2); }
.kpi-row .kpi strong { font-size: 20px; }
.delta { font-size: 12px; font-weight: 700; color: var(--green); } .delta.down { color: var(--red); }
.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; } .progress span { display: block; height: 100%; background: var(--green); }
.tax-box dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 0; } .tax-box dt { color: var(--muted); } .tax-box dd { margin: 0; text-align: right; font-weight: 600; }
.tax-box .result { border-top: 2px solid var(--text); padding-top: 8px; font-size: 18px; }

/* ---------- Documentos (archivos) ---------- */
.dropzone { display: flex; align-items: center; gap: 12px; padding: 16px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); color: var(--muted); cursor: pointer; transition: border-color .12s, background .12s; }
.dropzone:hover, .dropzone:focus-visible, .dropzone.over { border-color: var(--primary); background: var(--primary-50); color: var(--text); }
.files { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.file { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); transition: border-color .12s; }
.file:hover { border-color: var(--border-strong); }
.file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-main a { text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .file-main a:hover { color: var(--primary); }
.file-ic { flex: none; width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; font: 700 10px var(--font); letter-spacing: .04em; background: var(--surface-3); color: var(--muted); }
.file-pdf { background: var(--red-50); color: var(--red); }
.file-png, .file-jpg, .file-jpeg, .file-webp, .file-gif, .file-avif { background: var(--purple-50); color: var(--purple); }
.file-doc, .file-docx, .file-odt { background: var(--blue-50); color: var(--blue); }
.file-xls, .file-xlsx, .file-ods, .file-csv { background: var(--green-50); color: var(--green); }

/* ---------- SEO ---------- */
.seo-sources { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.pos-tag { display: inline-block; min-width: 38px; text-align: center; font-weight: 700; font-size: 12.5px; padding: 1px 7px; border-radius: 6px; }
.pos-top { background: var(--green-50); color: var(--green); } .pos-good { background: var(--blue-50); color: var(--blue); }
.pos-mid { background: var(--amber-50); color: var(--amber); } .pos-low { background: var(--surface-3); color: var(--muted); }

/* ---------- Rank & Rent / facturación ---------- */
.form-sec { grid-column: 1 / -1; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 12px 0 -2px; padding-top: 12px; border-top: 1px solid var(--border); }
.form-grid > .form-sec:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.warn-txt { color: var(--amber); font-weight: 600; }
.warn-note { background: var(--amber-50); border-color: transparent; color: var(--amber); }
.meter { display: inline-block; width: 46px; height: 6px; border-radius: 99px; background: var(--surface-3); vertical-align: middle; overflow: hidden; }
.meter i { display: block; height: 100%; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; } .dl dd { margin: 0; overflow-wrap: anywhere; }
.mb { margin-bottom: 12px; }
.serp-t { color: #1a0dab; font-size: 18px; margin: 0; } .serp-u { color: #006621; margin: 2px 0 4px; font-size: 13px; }
:root[data-theme="dark"] .serp-t { color: #8ab4f8; } :root[data-theme="dark"] .serp-u { color: #bdc1c6; }
.checklist { display: flex; flex-wrap: wrap; gap: 6px; }
.checklist span { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--surface-3); }
.checklist .ok { background: var(--green-50); color: var(--green); } .checklist .ko { background: var(--red-50); color: var(--red); }
.issues { list-style: none; margin: 0; padding: 0; }
.issues li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--border); }
.issues li > a { flex: 1; }
.issues li:last-child { border-bottom: 0; } .issues a { text-decoration: none; } .issues a:hover { color: var(--primary); }
.issue-actions { display: flex; gap: 2px; align-items: center; flex: none; opacity: .55; transition: opacity .12s; }
.issues li:hover .issue-actions, .issues li:focus-within .issue-actions { opacity: 1; }
.warn-list { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: var(--muted); }
.rr-band { margin-bottom: 18px; }
/* Leads y envíos */
.hidden { display: none !important; } .nowrap { white-space: nowrap; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); } label.inline input { width: auto; }
.daybars { display: flex; align-items: flex-end; gap: 2px; height: 140px; border-bottom: 1px solid var(--border); }
.daybars span { flex: 1; height: 100%; display: flex; align-items: flex-end; } .daybars i { display: block; width: 100%; background: var(--primary); border-radius: 3px 3px 0 0; opacity: .85; }
.daybars span:hover i { opacity: 1; }
tr.discarded td { opacity: .45; text-decoration: line-through; } tr.discarded td:last-child { opacity: 1; text-decoration: none; }
.checks { display: grid; gap: 6px; margin-top: 6px; } .checks .check { font-weight: 400; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .g3 { grid-template-columns: 1fr 1fr; } .g-main { grid-template-columns: 1fr; } .doc-head { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 50; left: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; z-index: 40; background: rgba(16, 24, 40, .4); }
  .topbar .only-mobile { display: inline-flex; }
  .topbar { padding: 10px 16px; } main { padding: 18px 16px; }
  .year-picker, .search kbd { display: none; }
  .g2, .g3, .doc-foot, .form-grid, .doc-head { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 22px; }
  .actions select { max-width: 100%; }
  .lines thead { display: none; } .lines tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .lines td { border: 0; padding: 0; } .lines td:first-child { grid-column: 1 / -1; } .lines .w-num, .lines .w-tax { width: auto; }
  .issue-actions { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { .sidebar, .topbar, .actions, .tabs { display: none !important; } main { padding: 0; } body { background: #fff; } }

/* ---------- Acceso ---------- */
body.login-page { display: grid; place-items: center; padding: 16px; }
.login-box { width: min(400px, 100%); padding: 0; }
.login-box h1 { font-size: 22px; font-weight: 700; }
.login-box .brand { padding: 0 0 4px; }
.login-box .btn { width: 100%; }
