/* Tablero GHM — estilos */
:root {
  --ground: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --ink: #142238;
  --ink-2: #3f4d63;
  --muted: #74819a;
  --line: #e1e6ef;
  --line-2: #eef1f6;
  --navy: #0f2740;
  --navy-2: #163a60;
  --navy-3: #1d4b7c;
  --amber: #f2a900;
  --amber-2: #d99300;
  --amber-soft: #fff4d6;
  --teal: #0e9f8a;
  --teal-soft: #dcf5f0;
  --red: #d64545;
  --red-soft: #fde4e4;
  --yellow: #e8a317;
  --yellow-soft: #fff1cf;
  --blue: #2f6fd6;
  --blue-soft: #e4edfb;
  --shadow: 0 8px 24px rgba(20, 34, 56, .06);
  --radius: 14px;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0d1520; --surface: #152033; --surface-2: #1a273d; --ink: #e8edf5; --ink-2: #c3cddc; --muted: #8d9bb3;
    --line: #253650; --line-2: #1f2d45; --amber-soft: #3a2f10; --teal-soft: #103b34; --red-soft: #3f1d1d; --yellow-soft: #3b2f12; --blue-soft: #16294a;
    --shadow: 0 8px 24px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-body); font-size: 14px; color: var(--ink); background: var(--ground); line-height: 1.45; }
a { color: var(--blue); }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
small { font-size: 12px; }
.muted { color: var(--muted); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.hidden { display: none !important; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 250px; flex: none; background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%); color: #e8eef7; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px; text-decoration: none; color: #fff; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-logo { width: 42px; height: 42px; border-radius: 12px; background: var(--amber); color: var(--navy); font-family: var(--font-display); font-weight: 700; font-size: 17px; display: grid; place-items: center; letter-spacing: .02em; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--font-display); font-size: 16px; }
.brand-text small { opacity: .75; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; }
.menu { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.menu-link { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: #d6e0ee; text-decoration: none; font-weight: 500; font-size: 13.5px; transition: background .15s, color .15s; }
.menu-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.menu-link.active { background: rgba(242,169,0,.16); color: #fff; box-shadow: inset 3px 0 0 var(--amber); }
.menu-link.active .ic { color: var(--amber); }
.sidebar-footer { padding: 14px 14px 18px; border-top: 1px solid rgba(255,255,255,.1); display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.user-chip span:last-child { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip small { opacity: .7; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy-3); display: grid; place-items: center; font-weight: 600; flex: none; }
.btn-ghost { display: inline-flex; align-items: center; gap: 8px; color: #d6e0ee; text-decoration: none; border: 1px solid rgba(255,255,255,.2); padding: 8px 12px; border-radius: 10px; font-size: 13px; justify-content: center; }
.btn-ghost:hover { background: rgba(255,255,255,.08); color: #fff; }
.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }
.app-wide .main { padding-left: 20px; padding-right: 20px; }
.topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.topbar-title p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.menu-toggle { display: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 40px; font-size: 18px; cursor: pointer; color: var(--ink); }

/* Panels & cards */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head p { color: var(--muted); font-size: 12.5px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpis-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--navy-3); }
.kpi-amber::before { background: var(--amber); }
.kpi-teal::before { background: var(--teal); }
.kpi-red::before { background: var(--red); }
.kpi-yellow::before { background: var(--yellow); }
.kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.kpi-value { font-family: var(--font-display); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.delta-up { color: var(--teal); font-weight: 600; }
.delta-down { color: var(--red); font-weight: 600; }

/* Filters */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px 12px; margin-bottom: 18px; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.filter-box label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
.filter-box input, .filter-box select, .ms-btn, .input { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13.5px; }
.filter-box input:focus, .filter-box select:focus, .ms-btn:focus, .input:focus { outline: 2px solid rgba(47,111,214,.35); border-color: var(--blue); }
.filter-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn-primary { background: var(--navy-2); color: #fff; }
.btn-primary:hover { background: var(--navy-3); }
.btn-amber { background: var(--amber); color: var(--navy); }
.btn-amber:hover { background: var(--amber-2); }
.btn-light { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.btn-light:hover { background: var(--line-2); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.quick { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.quick-row { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-btn { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; }
.quick-btn.sm { padding: 4px 10px; font-size: 12px; }
.quick-btn:hover { border-color: var(--navy-3); color: var(--ink); }
.quick-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.quick-year { font-weight: 600; }

/* Multiselect */
.ms { position: relative; }
.ms-btn { text-align: left; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.ms-btn::after { content: "▾"; color: var(--muted); font-size: 12px; }
.ms-panel { display: none; position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; right: 0; min-width: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(20,34,56,.16); padding: 8px; }
.ms.open .ms-panel { display: block; }
.ms-search { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; margin-bottom: 6px; background: var(--surface); color: var(--ink); }
.ms-list { max-height: 240px; overflow-y: auto; }
.ms-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 400; margin: 0; }
.ms-opt:hover { background: var(--surface-2); }
.ms-opt input { accent-color: var(--navy-3); width: 15px; height: 15px; margin: 0; }
.ms-all { border-bottom: 1px solid var(--line-2); margin-bottom: 4px; font-weight: 600; }

/* Tables */
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 0; }
.table-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.table-head p { color: var(--muted); font-size: 12.5px; width: 100%; }
.table-wrap { overflow: auto; max-height: 420px; }
.table-wrap.tall { max-height: 640px; }
.table-wrap.auto { max-height: none; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tfoot td { font-weight: 600; background: var(--surface-2); position: sticky; bottom: 0; border-top: 1px solid var(--line); }
.tbl .empty { text-align: center; color: var(--muted); padding: 26px; }
.tbl .sub td { background: var(--amber-soft); font-weight: 600; }
.tbl .grp td { background: var(--surface-2); font-weight: 600; font-family: var(--font-display); font-size: 12.5px; }
.clickable { cursor: pointer; }
.clickable:hover td:first-child { color: var(--blue); }
.bar-cell { position: relative; display: block; padding-bottom: 4px; }
.bar-cell i { display: block; height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--navy-3), var(--amber)); margin-top: 3px; opacity: .8; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill-green { background: var(--teal-soft); color: var(--teal); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-yellow { background: var(--yellow-soft); color: #9a6a00; }
.pill-blue { background: var(--blue-soft); color: var(--blue); }
.pill-gray { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.dot-green { background: var(--teal); } .dot-red { background: var(--red); } .dot-yellow { background: var(--yellow); }
.progress { height: 8px; background: var(--line-2); border-radius: 999px; overflow: hidden; min-width: 90px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--navy-3), var(--teal)); border-radius: 999px; }
.progress.warn i { background: var(--yellow); }
.progress.bad i { background: var(--red); }

/* Charts */
.chart-wrap { position: relative; height: 300px; }
.chart-wrap.short { height: 220px; }
.chart-wrap.tall { height: 380px; }

/* Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: none; }
.tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Search box */
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; background: var(--surface); min-width: 260px; }
.search input { border: 0; outline: 0; padding: 9px 4px; font: inherit; width: 100%; background: transparent; color: var(--ink); }
.search .ic { color: var(--muted); }

/* Tree (activación) */
.crumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.crumb { background: var(--blue-soft); color: var(--blue); padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer; }
.tree-node { display: grid; grid-template-columns: minmax(0, 1fr) 160px auto auto; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px dashed var(--line); font-size: 13px; }
.tree-node .val { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.tree-bar { height: 10px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.tree-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--navy-3), var(--amber)); }
.tree-expand { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-weight: 700; color: var(--ink); }
.tree-expand:hover { background: var(--amber-soft); border-color: var(--amber); }

/* Landing */
.landing { min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, #1d4b7c 0%, var(--navy) 55%, #0a1a2c 100%); color: #e8eef7; padding: 36px 28px 60px; }
.landing-wrap { max-width: 1240px; margin: 0 auto; }
.landing-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 30px; flex-wrap: wrap; }
.landing-header .brand { padding: 0; border: 0; }
.landing-header .brand-logo { width: 54px; height: 54px; font-size: 22px; border-radius: 14px; }
.landing-header .brand-text strong { font-size: 24px; }
.landing-clock { font-family: var(--font-display); font-size: 14px; opacity: .85; text-align: right; }
.hero { display: grid; grid-template-columns: 1.4fr .9fr; gap: 20px; margin-bottom: 26px; }
.hero-card { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 22px; padding: 30px 32px; backdrop-filter: blur(6px); }
.hero-tag { display: inline-block; background: var(--amber); color: var(--navy); font-weight: 700; font-size: 11.5px; letter-spacing: .08em; padding: 5px 11px; border-radius: 999px; margin-bottom: 14px; }
.hero-card h2 { font-size: 32px; font-weight: 700; color: #fff; margin-bottom: 10px; }
.hero-card p { color: #c8d5e6; font-size: 15px; max-width: 60ch; }
.hero-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.hero-kpi { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); border-radius: 16px; padding: 16px 18px; }
.hero-kpi span { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: #b6c5da; margin-bottom: 6px; }
.hero-kpi strong { font-family: var(--font-display); font-size: 22px; color: #fff; font-variant-numeric: tabular-nums; }
.hero-kpi small { display: block; color: #9fb2cb; margin-top: 4px; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.module-card { display: flex; gap: 14px; align-items: flex-start; background: #fff; color: var(--navy); text-decoration: none; border-radius: 18px; padding: 20px; box-shadow: 0 12px 30px rgba(0,0,0,.18); transition: transform .15s, box-shadow .15s; }
.module-card:hover { transform: translateY(-3px); box-shadow: 0 18px 36px rgba(0,0,0,.24); }
.module-card .ic { width: 22px; height: 22px; color: var(--amber-2); margin-top: 2px; }
.module-card h3 { font-size: 16px; margin-bottom: 4px; color: #0f2740; }
.module-card p { color: #5b6b83; font-size: 13px; }
.module-card .ico { width: 42px; height: 42px; border-radius: 12px; background: var(--amber-soft); display: grid; place-items: center; flex: none; }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(900px 500px at 80% -10%, #1d4b7c 0%, var(--navy) 50%, #0a1a2c 100%); padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: #fff; color: var(--navy); border-radius: 20px; padding: 32px 30px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.login-card .brand { padding: 0 0 18px; border: 0; color: var(--navy); }
.login-card .brand-text small { color: #5b6b83; opacity: 1; }
.login-card h2 { font-size: 18px; margin-bottom: 4px; }
.login-card .sub { color: #5b6b83; font-size: 13px; margin-bottom: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; color: #3f4d63; }
.field input { width: 100%; padding: 11px 13px; border: 1px solid #d5dbe6; border-radius: 10px; font: inherit; font-size: 14px; }
.field input:focus { outline: 2px solid rgba(47,111,214,.35); border-color: var(--blue); }
.alert { padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-ok { background: var(--teal-soft); color: var(--teal); }
.alert-info { background: var(--blue-soft); color: var(--blue); }

/* Misc */
.note { font-size: 12.5px; color: var(--muted); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.inline-form { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.inline-form .filter-box { min-width: 160px; flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
.print-only { display: none; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }

@media (max-width: 1280px) {
  .kpis, .kpis-5, .kpis-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3 { grid-column: span 2; }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { position: fixed; left: -260px; top: 0; z-index: 100; transition: left .2s; width: 250px; }
  .sidebar.open { left: 0; box-shadow: 0 0 0 100vw rgba(0,0,0,.4); }
  .menu-toggle { display: block; }
  .main { padding: 14px; }
  .kpis, .kpis-5, .kpis-6, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: span 1; }
  .tree-node { grid-template-columns: 1fr auto; }
  .tree-node .tree-bar { display: none; }
}
@media print {
  .sidebar, .filters, .topbar-actions, .quick, .btn, .menu-toggle { display: none !important; }
  .main { padding: 0; }
  .panel, .table-card, .kpi { box-shadow: none; break-inside: avoid; }
  .table-wrap { max-height: none; overflow: visible; }
  body { background: #fff; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
