/* ============ Tokens ============ */
:root {
  color-scheme: light;
  --page: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eef0f6;
  --ink: #0f1222;
  --ink-2: #4a4f63;
  --ink-3: #868b9e;
  --line: #e4e6ee;
  --line-2: #d3d6e2;
  --accent: #1b1fb0;
  --accent-ink: #ffffff;
  --accent-soft: #e6e7fb;
  --accent-soft-ink: #1b1fb0;
  --grid: #eceef3;
  --axis: #c9ccd8;
  --shadow: 0 1px 2px rgba(15, 18, 34, .04), 0 4px 16px rgba(15, 18, 34, .05);
  --shadow-lg: 0 10px 40px rgba(15, 18, 34, .18);

  --s1: #2a78d6;  /* blue   */
  --s2: #eb6834;  /* orange */
  --s3: #1baf7a;  /* aqua   */
  --s4: #eda100;  /* yellow */
  --s5: #e87ba4;  /* magenta*/
  --s6: #008300;  /* green  */
  --s7: #4a3aa7;  /* violet */
  --s8: #e34948;  /* red    */

  --good: #0ca30c;  --good-ink: #006300;  --good-bg: #e5f5e5;
  --warn: #fab219;  --warn-ink: #8a5a00;  --warn-bg: #fdf3dc;
  --serious: #ec835a;
  --bad: #d03b3b;   --bad-ink: #b02a2a;   --bad-bg: #fbe7e7;

  --radius: 14px;
  --radius-sm: 9px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0e13; --surface: #17181f; --surface-2: #1d1f28; --surface-3: #262834;
    --ink: #f3f4f8; --ink-2: #c3c6d3; --ink-3: #8a8ea0;
    --line: #2a2c38; --line-2: #383b4a;
    --accent: #7b7ff5; --accent-ink: #0d0e13; --accent-soft: #262a5a; --accent-soft-ink: #c5c7ff;
    --grid: #252733; --axis: #3a3d4c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --good-ink: #2fc02f; --good-bg: #13301a; --warn-ink: #f5c04a; --warn-bg: #352a10; --bad-ink: #f07a7a; --bad-bg: #3a1717;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0e13; --surface: #17181f; --surface-2: #1d1f28; --surface-3: #262834;
  --ink: #f3f4f8; --ink-2: #c3c6d3; --ink-3: #8a8ea0;
  --line: #2a2c38; --line-2: #383b4a;
  --accent: #7b7ff5; --accent-ink: #0d0e13; --accent-soft: #262a5a; --accent-soft-ink: #c5c7ff;
  --grid: #252733; --axis: #3a3d4c;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --good-ink: #2fc02f; --good-bg: #13301a; --warn-ink: #f5c04a; --warn-bg: #352a10; --bad-ink: #f07a7a; --bad-bg: #3a1717;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page); color: var(--ink); font-family: var(--font);
  font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.ink2 { color: var(--ink-2); }
.small { font-size: 12px; }
.pos { color: var(--good-ink); }
.neg { color: var(--bad-ink); }
.hidden { display: none !important; }

/* ============ Layout ============ */
.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.app > div { min-width: 0; }  /* sin esto, una tabla ancha estira la columna y desborda en móvil */
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--line);
  background: var(--surface); display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 16px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 15px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2);
  text-decoration: none; font-weight: 500; border: 1px solid transparent; cursor: pointer; background: none; text-align: left; width: 100%;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-soft-ink); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.nav-sep { height: 1px; background: var(--line); margin: 10px 6px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 6px 12px 4px; }
.nav-co { display: flex; justify-content: space-between; padding: 6px 12px; font-size: 13px; }
.nav-co .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.sidebar-foot { margin-top: auto; font-size: 11px; color: var(--ink-3); padding: 10px 12px; }
.main { padding: 22px 28px 60px; min-width: 0; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; font-weight: 750; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.mobile-bar { display: none; }

/* ============ Cards & surfaces ============ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); margin: 26px 0 10px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ============ Company header ============ */
.co-head { display: flex; align-items: center; gap: 16px; padding: 16px 20px; flex-wrap: wrap; }
.co-logo { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; flex: none; }
.co-name { font-size: 20px; font-weight: 700; }
.co-sub { color: var(--ink-3); font-size: 13px; }
.co-price { font-size: 26px; font-weight: 750; margin-left: 6px; }
.co-pricesub { font-size: 12px; color: var(--ink-3); }
.search { position: relative; min-width: 260px; flex: 1; max-width: 420px; margin-left: auto; }
.search input { width: 100%; padding: 11px 16px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface-2); outline: none; }
.search input:focus { border-color: var(--accent); background: var(--surface); }
.search-res { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; }
.search-res button { display: flex; width: 100%; gap: 10px; padding: 10px 14px; background: none; border: 0; cursor: pointer; text-align: left; }
.search-res button:hover, .search-res button.hl { background: var(--surface-2); }

.chips { display: flex; gap: 10px; padding: 14px 20px; flex-wrap: wrap; align-items: center; }
.chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; min-width: 104px; }
.chip .k { font-size: 11.5px; color: var(--ink-2); }
.chip .v { font-size: 15px; font-weight: 700; margin-top: 1px; }
.linkbtn { background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.linkbtn:hover { background: var(--accent-soft); }

/* ============ Segmented / pills ============ */
.toolbar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; flex-wrap: wrap; margin: 14px 0; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; cursor: pointer; color: var(--ink-2); font-weight: 500; font-size: 13px; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

.btn { border: 1px solid var(--line-2); background: var(--surface); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad-ink); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.iconbtn { width: 30px; height: 30px; border-radius: 8px; border: 0; background: none; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.iconbtn:hover { background: var(--surface-3); color: var(--ink); }
.iconbtn svg { width: 16px; height: 16px; }

/* ============ Badges ============ */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.b-good { background: var(--good-bg); color: var(--good-ink); }
.b-warn { background: var(--warn-bg); color: var(--warn-ink); }
.b-bad { background: var(--bad-bg); color: var(--bad-ink); }
.b-neutral { background: var(--surface-3); color: var(--ink-2); }
.b-accent { background: var(--accent-soft); color: var(--accent-soft-ink); }

/* ============ Chart cards ============ */
.charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.chart-card { padding: 16px 18px 12px; display: flex; flex-direction: column; min-width: 0; transition: box-shadow .15s; }
.chart-card:hover { box-shadow: var(--shadow-lg); }
.chart-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.chart-card h3 { font-size: 16px; font-weight: 700; }
.chart-card .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.chart-card .cagr { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chart-card .cagr span { font-size: 11px; background: var(--surface-2); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; color: var(--ink-2); }
.chart-box { position: relative; height: 220px; }
.chart-box.tall { height: 360px; }
.chart-box.xl { height: 420px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.empty { display: grid; place-items: center; height: 100%; min-height: 160px; color: var(--ink-3); font-size: 13px; text-align: center; padding: 10px; border: 1px dashed var(--line-2); border-radius: 10px; }

/* ============ Tables ============ */
.table-wrap { overflow: auto; border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
.fin th, .fin td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.fin th:first-child, .fin td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 230px; border-right: 1px solid var(--line); }
.fin thead th { background: var(--surface-2); font-weight: 600; font-size: 13px; position: sticky; top: 0; z-index: 2; }
.fin thead th:first-child { z-index: 3; background: var(--surface-2); }
.fin tr.group td { background: var(--accent-soft); color: var(--accent-soft-ink); font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.fin tr.group td:first-child { background: var(--accent-soft); }
.fin tr.bold td { font-weight: 700; }
.fin tr.pct td { color: var(--ink-2); font-size: 13px; }
.fin tr.pct td:first-child { padding-left: 28px; }
.fin tbody tr:hover td { background: var(--surface-2); }
.fin td .chg { display: block; font-size: 11px; font-weight: 500; }
.fin td.clickable { cursor: pointer; }

.list th, .list td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.list th { font-size: 12px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
.list td.n, .list th.n { text-align: right; }
.list tbody tr { cursor: default; }
.list tbody tr.click { cursor: pointer; }
.list tbody tr.click:hover td { background: var(--surface-2); }
.list input.cell { width: 90px; padding: 5px 8px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface-2); text-align: right; }

/* ============ Stat tiles ============ */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { padding: 14px 16px; }
.tile .k { font-size: 12px; color: var(--ink-2); }
.tile .v { font-size: 24px; font-weight: 750; margin-top: 4px; }
.tile .d { font-size: 12px; margin-top: 2px; }

/* ============ Forms ============ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink); display: flex; justify-content: space-between; gap: 8px; }
.field label .hint { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.input, select.input, textarea.input { padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); outline: none; width: 100%; }
.input:focus { border-color: var(--accent); }
.input.api { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.slider-row { display: flex; gap: 12px; align-items: center; }
.slider-row .input { width: 90px; text-align: right; }
input[type=range] { flex: 1; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }

/* ============ Calculator ============ */
.calc-top { padding: 18px 20px; }
.calc-co { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-top: 14px; background: var(--surface); }
.calc-co .stats { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 10px; margin-top: 12px; }
.calc-co .stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.calc-co .stat .k { font-size: 12px; color: var(--ink-2); }
.calc-co .stat .v { font-weight: 700; font-size: 15px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--ink-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 7px; align-items: center; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.calc-body { display: grid; grid-template-columns: 380px 1fr; gap: 16px; }
.scen-btns { display: flex; gap: 8px; margin: 12px 0 18px; flex-wrap: wrap; }
.scen-btns button { padding: 7px 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 500; }
.scen-btns button.on { border-color: var(--s4); background: var(--warn-bg); color: var(--warn-ink); font-weight: 600; }
.outs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0; }
.out { background: var(--surface-2); border-radius: 12px; padding: 14px; text-align: center; }
.out .k { font-weight: 600; font-size: 13px; }
.out .s { font-size: 11.5px; color: var(--ink-3); }
.out .v { font-size: 26px; font-weight: 750; margin-top: 6px; }
.out .v.blue { color: var(--s1); }

/* ============ Kanban ============ */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.kcol { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 220px; }
.kcol.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.kcol h4 { font-size: 13px; display: flex; justify-content: space-between; padding: 4px 6px 10px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); }
.kcard:hover { border-color: var(--accent); }
.kcard .t { font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.kcard .m { font-size: 12px; color: var(--ink-2); margin-top: 4px; display: flex; justify-content: space-between; gap: 6px; }
.bar { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ============ Report ============ */
.idea-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.verdict { border-left: 4px solid var(--accent); padding: 14px 18px; background: var(--surface-2); border-radius: 0 12px 12px 0; }
.verdict.VERDE { border-left-color: var(--good); }
.verdict.AMARILLO { border-left-color: var(--warn); }
.verdict.ROJO { border-left-color: var(--bad); }
details.sec { border-bottom: 1px solid var(--line); padding: 12px 4px; }
details.sec summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; gap: 10px; }
details.sec summary::before { content: "›"; transition: transform .15s; display: inline-block; color: var(--ink-3); }
details.sec[open] summary::before { transform: rotate(90deg); }
details.sec p { margin: 8px 0 0 18px; color: var(--ink-2); }
.report-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.report-card h3 { font-size: 16px; line-height: 1.3; }

/* ============ Drawer & modal ============ */
.overlay { position: fixed; inset: 0; background: rgba(10, 12, 25, .45); z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding: 40px 16px; overflow: auto; }
.modal { width: min(1100px, 100%); padding: 22px 24px; }
.modal.narrow { width: min(640px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); z-index: 60; padding: 20px 22px; overflow: auto; transform: translateX(105%); transition: transform .2s ease; }
.drawer.open { transform: none; }
.kv { display: grid; grid-template-columns: 1fr auto auto; gap: 0; }
.kv > div { padding: 8px 2px; border-bottom: 1px solid var(--line); }
.kv > div.v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.kv > div.c { text-align: right; font-size: 12px; padding-left: 12px; min-width: 64px; }
.kv > div.h { font-weight: 700; color: var(--accent); grid-column: 1 / -1; padding-top: 14px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--page); padding: 10px 16px; border-radius: 10px; z-index: 90; font-weight: 600; box-shadow: var(--shadow-lg); }
.tip { position: relative; }
.tip[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: 260px; background: #151826; color: #fff; padding: 9px 11px; border-radius: 9px; font-size: 12px; font-weight: 500; line-height: 1.4; z-index: 40; white-space: normal; text-align: left; }

/* ============ Responsive ============ */
@media (max-width: 1200px) {
  .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calc-co .stats { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 70; left: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .mobile-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .main { padding: 16px 16px 60px; }
  .charts, .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .calc-body { grid-template-columns: 1fr; }
  .outs { grid-template-columns: 1fr; }
  .calc-co .stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .search { max-width: none; min-width: 0; width: 100%; }
}

/* nota de cuánto aplica cada gráfico al tipo de empresa */
.chart-card h3 .fit { font-size: 10.5px; font-weight: 600; vertical-align: middle; margin-left: 6px; letter-spacing: 0; white-space: nowrap; }
.chart-card .fit-note { margin-top: 8px; font-size: 12px; color: var(--ink-2); line-height: 1.35; }
.chart-card.low-fit .chart-box { opacity: .55; }
.fit-head { margin-bottom: 16px; }

/* ============ Servidor local: agregar empresa, tareas y fichas automáticas ============ */
.nav-add { display: block; width: 100%; margin: 2px 0 6px; padding: 8px 12px; border: 1px dashed var(--line-2); border-radius: 10px; background: none; color: var(--accent); font-weight: 600; font-size: 13px; text-align: left; cursor: pointer; }
.nav-add:hover { background: var(--accent-soft); border-color: var(--accent); }
.auto-badge { letter-spacing: .04em; }
.auto-badge.xs { font-size: 10px; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; }
.auto-note { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-top: 12px; padding: 12px 16px; background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.auto-note b { color: var(--ink); }
.auto-note .small { margin-top: 3px; }
.task-box .task-top { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; font-size: 13px; }
.task-box .bar { height: 8px; }
.task-box .bar > i { transition: width .4s ease; }
.task-box.done .bar > i { background: var(--good); }
.task-box.err .bar > i { background: var(--bad); }
.task-log { margin: 12px 0 0; min-height: 60px; max-height: 240px; overflow: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-word; color: var(--ink-2); }
.task-log:empty::before { content: "Esperando al servidor…"; color: var(--ink-3); }
.ac-search { position: relative; }
.add-co .search-res { position: static; margin-top: 6px; max-height: 260px; overflow: auto; box-shadow: none; }
.add-co .search-res button span.muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-sel { margin-top: 8px; min-height: 18px; }
.ac-limits { margin: 14px 0 0; padding-left: 18px; }
.ac-limits li { margin: 2px 0; }
.btn:disabled, .iconbtn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .iconbtn:focus-visible, .nav-add:focus-visible, .nav-item:focus-visible, .seg button:focus-visible, .search-res button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 900px) {
  .overlay { padding: 16px 12px; }
  .modal { padding: 18px 16px; }
}

/* Gráficos divididos en dos bloques: datos de la SEC / requieren informe */
.chart-group-head { margin: 22px 0 10px; }
.chart-group-head:first-of-type { margin-top: 0; }
.chart-group-head p { margin: 4px 0 0; }
.chart-card.needs-report { border-top: 3px solid var(--accent-soft-ink); }

/* Cuentas: usuario en la barra lateral y casillas en línea */
.sidebar-foot .user-row { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink); }
.sidebar-foot .linkbtn { padding: 2px 6px; font-size: 13px; }
.chk-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); padding: 0 6px; }
.badge.xs { font-size: 10px; padding: 1px 6px; }
/* la lista de empresas se desplaza sola: el pie (usuario y "Salir") siempre queda visible */
#navCompanies { flex: 1 1 auto; min-height: 80px; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.sidebar-foot { flex: none; border-top: 1px solid var(--line); }

/* ============ Precio interactivo (como Google Finance) ============ */
#card-price { grid-column: 1 / -1; }
#card-price .chart-box, .px-box { height: 320px; }
.modal .px-box { height: 440px; }
.px-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin: 2px 0 10px; }
.px-now { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.px-price { font-size: 28px; font-weight: 750; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.px-chg { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.px-chg .muted { font-weight: 500; margin-left: 4px; }
.px-seg button { padding: 6px 11px; font-size: 12.5px; }
.px-box.loading canvas { opacity: .35; transition: opacity .15s; }
.px-box.loading::after { content: "Cargando…"; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); font-size: 12px; color: var(--ink-3); }
.px-box .px-msg { position: absolute; inset: 0; }

/* recuadro de la selección por arrastre */
.sel-box { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); z-index: 5; max-width: min(96%, 520px); background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 8px 30px 8px 12px; font-size: 12.5px; line-height: 1.4; pointer-events: auto; }
.sel-title { font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.sel-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.sel-row i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.sel-row.big b { font-size: 14px; }
.sel-x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: 0; border-radius: 6px; background: none; color: var(--ink-3); cursor: pointer; font-size: 13px; }
.sel-x:hover { background: var(--surface-3); color: var(--ink); }
.chart-box canvas { touch-action: pan-y; }

/* ============ Categoría de Peter Lynch ============ */
.lynch { margin-bottom: 16px; }
.lynch-top { gap: 8px; flex-wrap: wrap; }
.lynch-main { font-size: 13px; padding: 4px 11px; }
.lynch-link { text-decoration: none; vertical-align: 3px; }
.lynch-b { font-size: 11px; padding: 2px 8px; }
.lynch-rule { position: relative; display: grid; grid-template-columns: 32fr 28fr 40fr; height: 26px; margin: 14px 0 4px; border-radius: 8px; overflow: visible; font-size: 11px; color: var(--ink-2); }
.lynch-rule .z { display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); }
.lynch-rule .z1 { background: var(--surface-3); border-radius: 8px 0 0 8px; }
.lynch-rule .z2 { background: var(--accent-soft); color: var(--accent-soft-ink); }
.lynch-rule .z3 { background: var(--good-bg); color: var(--good-ink); border-radius: 0 8px 8px 0; }
.lynch-rule i { position: absolute; top: -5px; bottom: -5px; width: 4px; margin-left: -2px; border-radius: 3px; background: var(--ink); box-shadow: 0 0 0 2px var(--surface); }
.lynch-mets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.lynch-mets > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; }
.lynch-mets .k { font-size: 11px; color: var(--ink-2); }
.lynch-mets .v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.lynch-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 12px; }
.lynch-cols ul { margin: 6px 0 0; padding-left: 18px; }
.lynch-cols li { margin: 3px 0; }
.lynch-tl { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.lynch-tl > span { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.lynch-tl > span.chg { border-color: var(--ink-2); box-shadow: 0 0 0 1px var(--ink-2); }
.lynch-tl em { font-style: normal; font-size: 10.5px; color: var(--ink-3); }
.lynch-how { margin-top: 10px; line-height: 1.45; }
.lynch-how summary { cursor: pointer; color: var(--ink-2); }
@media (max-width: 900px) {
  #card-price .chart-box, .px-box { height: 260px; }
  .px-price { font-size: 24px; }
  .px-head { align-items: flex-start; }
  .px-seg { width: 100%; justify-content: space-between; }
  .px-seg button { padding: 6px 8px; flex: 1; }
  .lynch-mets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lynch-cols { grid-template-columns: minmax(0, 1fr); }
  .lynch-rule { font-size: 9.5px; }
}
