/* Tablero de ventas SUIMPORT · tema oscuro (como el tablero anterior) y claro, por tokens */
:root {
  color-scheme: dark;
  --page: #09121e; --surface: #111e2e; --surface-2: #172739; --line: #25364a; --grid: #1d2d40; --axis: #33465c;
  --ink: #eef4fa; --ink-2: #b9c7d6; --muted: #8597ab;
  --accent: #64b6f7; --series: #3987e5; --series-soft: rgba(57,135,229,.16);
  --good: #0ca30c; --good-ink: #72d6b2; --bad: #e66767; --bad-ink: #ff9a99; --warn: #fab219;
  --t-adelante: #72d6b2; --t-adelante-bg: #163b33; --t-meta: #a4d5ff; --t-meta-bg: #173f67; --t-extra: #ffdd79; --t-extra-bg: #56411a;
  --radius: 12px; --shadow: 0 1px 0 rgba(255,255,255,.03) inset;
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f4f6f9; --surface: #ffffff; --surface-2: #f1f4f8; --line: #e1e5eb; --grid: #e9ecf0; --axis: #c3c9d1;
  --ink: #0b1320; --ink-2: #445263; --muted: #6b7a8c;
  --accent: #1d6fc9; --series: #2a78d6; --series-soft: rgba(42,120,214,.12);
  --good: #0ca30c; --good-ink: #006300; --bad: #d03b3b; --bad-ink: #b42323; --warn: #b87800;
  --t-adelante: #0a7a52; --t-adelante-bg: #e3f6ee; --t-meta: #1d5fae; --t-meta-bg: #e4effc; --t-extra: #8a5a00; --t-extra-bg: #fdf1d3;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.good { color: var(--good-ink); } .bad { color: var(--bad-ink); } .muted { color: var(--muted); } .ink2 { color: var(--ink-2); }

/* ---------- estructura */
.app { max-width: 1400px; margin: 0 auto; padding: 16px 16px 96px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.brand { display: flex; flex-direction: column; }
.eyebrow { font-size: 11px; letter-spacing: .16em; color: var(--accent); text-transform: uppercase; font-weight: 600; }
.brand h1 { font-size: clamp(22px, 3.4vw, 34px); letter-spacing: -.03em; margin: 2px 0 0; line-height: 1.1; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.pill.stale .dot { background: var(--warn); } .pill.err .dot { background: var(--bad); }
.btn { background: var(--surface); border: 1px solid var(--line); color: var(--ink); padding: 9px 14px; border-radius: 9px; cursor: pointer; min-height: 40px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--series); border-color: var(--series); color: #fff; }
.btn.small { padding: 6px 10px; min-height: 32px; font-size: 13px; }
.btn.danger { color: var(--bad-ink); }
.btn:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tabs { display: flex; gap: 4px; margin: 4px 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 10px 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
@media (max-width: 760px) {
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0; background: var(--surface); border-top: 1px solid var(--line); border-bottom: 0;
          padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .tabs button { flex: 1 1 0; min-width: 0; padding: 11px 1px; font-size: 12px; border-bottom: 0; border-top: 2px solid transparent; overflow: hidden; text-overflow: ellipsis; }
  .tabs button[aria-selected="true"] { border-top-color: var(--accent); }
}

.banner { padding: 12px 14px; border-radius: 10px; background: var(--surface); border-left: 3px solid var(--accent); color: var(--ink-2); margin: 0 0 14px; font-size: 14px; }
.banner.warn { border-left-color: var(--warn); } .banner.err { border-left-color: var(--bad); }
.banner b { color: var(--ink); }

/* ---------- tarjetas y números */
.grid { display: grid; gap: 12px; }
.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)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .g6, .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g2.stack { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; box-shadow: var(--shadow); }
.card h2 { font-size: 16px; margin: 0 0 4px; letter-spacing: -.01em; }
.card .sub { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.section { margin-top: 18px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 22px 0 10px; }
.section-head h2 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
.tile .label { font-size: 12.5px; color: var(--ink-2); }
.tile .value { font-size: clamp(20px, 2.4vw, 28px); font-weight: 650; letter-spacing: -.02em; margin: 4px 0 2px; white-space: nowrap; }
.tile .foot { font-size: 12.5px; color: var(--muted); }
.hero { display: flex; flex-direction: column; gap: 6px; }
.hero .value { font-size: clamp(40px, 8vw, 64px); font-weight: 700; letter-spacing: -.04em; line-height: 1; }
.delta { display: inline-flex; flex-wrap: wrap; column-gap: 6px; align-items: baseline; font-size: 13.5px; }
.delta .arrow { font-weight: 700; white-space: nowrap; }

/* medidor */
.meter { position: relative; height: 12px; border-radius: 999px; background: var(--series-soft); overflow: visible; margin: 10px 0 6px; }
.meter > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--series); max-width: 100%; }
.meter.ok > span { background: var(--good); }
.meter .tick { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); opacity: .7; border-radius: 1px; }
.meter .tick.extra { background: var(--t-extra); opacity: 1; }
.meter-legend { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2px 12px; font-size: 12px; color: var(--muted); }
.meter-legend span { white-space: nowrap; }
.meter-legend span:first-child { white-space: normal; }

.verdict { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 4px 8px; border-radius: 6px; white-space: nowrap; line-height: 1.2; }
.badge.adelante { background: var(--t-adelante-bg); color: var(--t-adelante); }
.badge.meta { background: var(--t-meta-bg); color: var(--t-meta); }
.badge.extra { background: var(--t-extra-bg); color: var(--t-extra); }
.badge.bajo { background: rgba(230,103,103,.14); color: var(--bad-ink); }
.badge.neutro { background: var(--surface-2); color: var(--ink-2); }

/* reconocimientos */
.recog { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 12px; }
.recog .card { border-width: 2px; }
.recog .card.adelante { border-color: var(--t-adelante); background: linear-gradient(135deg, var(--t-adelante-bg), var(--surface)); }
.recog .card.meta { border-color: var(--t-meta); background: linear-gradient(135deg, var(--t-meta-bg), var(--surface)); }
.recog .card.extra { border-color: var(--t-extra); background: linear-gradient(135deg, var(--t-extra-bg), var(--surface)); box-shadow: 0 0 24px rgba(255,213,104,.12); }
.recog h3 { margin: 10px 0 2px; font-size: 20px; }
.recog strong { font-size: 26px; font-variant-numeric: tabular-nums; }

/* barras por vendedor (vendido frente a esperado) */
.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 210px) 1fr minmax(110px, 170px); gap: 14px; align-items: center; }
.bar-name { font-weight: 600; min-width: 0; }
.bar-name small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.track { position: relative; height: 18px; }
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--series); border-radius: 0 4px 4px 0; min-width: 2px; }
.track .fill.adelante, .track .fill.meta { background: var(--good); }
.track .fill.extra { background: var(--t-extra); }
.track .goal { position: absolute; top: 0; bottom: 0; right: 0; border-radius: 0 4px 4px 0; background: var(--series-soft); }
.track .exp { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--ink); border-radius: 1px; }
.bar-nums { text-align: right; font-variant-numeric: tabular-nums; }
.bar-nums small { display: block; color: var(--muted); font-size: 12px; }
@media (max-width: 600px) {
  .bar-row { grid-template-columns: 1fr auto; gap: 6px 10px; }
  .bar-row .track { grid-column: 1 / -1; grid-row: 2; }
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 12px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend i.line { width: 2px; height: 14px; background: var(--ink); border-radius: 1px; vertical-align: -3px; }

/* gráficos SVG */
.chart { max-width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .col { fill: var(--series); }
.chart .col.off { fill: var(--axis); }
.chart .col.future { fill: none; }
.chart .ref { stroke: var(--ink); stroke-width: 2; opacity: .75; }
.chart .target { stroke: var(--ink); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: default; }
.chart .lbl { fill: var(--ink-2); font-size: 11px; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); padding: 8px 10px; border-radius: 8px; font-size: 12.5px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 260px; }
.tooltip b { display: block; margin-bottom: 2px; }

/* tablas */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
th:first-child, td:first-child { text-align: left; }
td.left, th.left { text-align: left; }
tr.tier-adelante td:first-child { box-shadow: inset 4px 0 var(--t-adelante); }
tr.tier-meta td:first-child { box-shadow: inset 4px 0 var(--t-meta); }
tr.tier-extra td:first-child { box-shadow: inset 4px 0 var(--t-extra); }
td .share { display: inline-block; height: 6px; border-radius: 3px; background: var(--series); vertical-align: middle; margin-right: 6px; }
.list { display: flex; flex-direction: column; }
.list .item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.list .item small { color: var(--muted); display: block; font-size: 12px; }
.empty { color: var(--muted); font-size: 14px; padding: 10px 0; }

/* formularios y ajustes */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; min-height: 40px; width: 100%; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--series); }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.msg { font-size: 13px; color: var(--ink-2); }
.msg.err { color: var(--bad-ink); } .msg.ok { color: var(--good-ink); }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.subtabs button { border-radius: 999px; padding: 7px 12px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; font-size: 13px; color: var(--ink-2); }
.subtabs button[aria-pressed="true"] { background: var(--series); border-color: var(--series); color: #fff; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; max-width: 640px; }
.cal .wd { text-align: center; font-size: 12px; color: var(--muted); }
.cal label { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; font-size: 14px; min-height: 52px; }
.cal label.off { background: rgba(230,103,103,.12); border-color: rgba(230,103,103,.45); }
.cal label small { font-size: 10px; color: var(--muted); text-align: center; line-height: 1.1; }
.cal input { width: 16px; height: 16px; accent-color: var(--bad); }

/* acceso */
.login { max-width: 380px; margin: 12vh auto 0; }
.login h1 { font-size: 28px; letter-spacing: -.03em; margin: 6px 0 18px; }
.login form { display: flex; flex-direction: column; gap: 12px; }

/* modo TV */
body.tv .app { max-width: none; padding: 24px 32px; }
body.tv .tabs, body.tv .no-tv { display: none !important; }
body.tv .hero .value { font-size: clamp(64px, 9vw, 120px); }
body.tv .tile .value { font-size: clamp(26px, 2.8vw, 44px); }
body.tv .bar-row { grid-template-columns: minmax(160px, 260px) 1fr minmax(160px, 220px); }
body.tv .bar-name { font-size: 20px; }
body.tv .bar-nums { font-size: 20px; }
body.tv .track { height: 26px; }
.tv-progress { height: 3px; background: var(--accent); position: fixed; left: 0; top: 0; z-index: 30; transition: width linear; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .tabs, .top-actions, .no-print { display: none !important; } body { background: #fff; } }
