/* Vallejo Systems · Soporte e Inventario — tema oscuro, tipografía del sistema */
:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222220;
  --border: rgba(255, 255, 255, .10);
  --border-strong: rgba(255, 255, 255, .22);
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --focus: #6da7ec;

  /* categóricos (dataviz, pasos para superficie oscura) */
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  /* estado (fijos) */
  --good: #0ca30c; --warning: #fab219; --critical: #d03b3b;

  --radius: 10px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--page); color: var(--ink); font: 15px/1.5 var(--sans); min-height: 100vh; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: inherit; }

/* ── Header ── */
.top { position: sticky; top: 0; z-index: 20; background: rgba(13,13,13,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 0 20px; min-height: 72px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { height: 52px; width: auto; display: block; }
.brand span { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.spacer { flex: 1; }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tab { background: none; border: 0; color: var(--muted); font: 600 14px var(--sans); padding: 10px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); background: var(--surface); }
.tab[aria-selected="true"] { color: var(--ink); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--s1); }

main { max-width: 1240px; margin: 0 auto; padding: 28px 20px 64px; }
.narrow { max-width: 760px; }
h1 { font-size: 28px; letter-spacing: -.02em; line-height: 1.2; }
h2 { font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lead { color: var(--ink-2); margin-top: 6px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }

/* ── Tarjetas y formularios ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.form { display: grid; gap: 18px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: grid; gap: 6px; align-content: start; }
label, .label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
label .opt { text-transform: none; letter-spacing: 0; font-weight: 400; }
input, select, textarea {
  width: 100%; background: var(--page); color: var(--ink); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 11px 12px; font: 16px var(--sans); /* 16px evita zoom en iOS */
}
textarea { resize: vertical; min-height: 92px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input::placeholder, textarea::placeholder { color: #5f5e59; }
.hint { font-size: 13px; color: var(--muted); }
.err { color: #ff8a80; font-size: 14px; min-height: 1.3em; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; position: relative; }
.seg input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.seg label { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink-2); text-align: center; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px 6px; display: flex; gap: 6px; align-items: center; justify-content: center; }
.seg input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }
.seg input:checked + label { color: var(--ink); background: var(--surface-2); border-color: var(--ink-2); font-weight: 600; }

.btn { font: 600 15px var(--sans); border-radius: 8px; padding: 11px 18px; border: 1px solid var(--border-strong); background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--ink); color: #0b0b0b; border-color: var(--ink); }
.btn.primary:hover { background: #fff; }
.btn.danger { color: #ff8a80; border-color: rgba(255,138,128,.35); }
.btn.danger:hover { background: rgba(208,59,59,.14); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── Chips de estado (siempre con texto/ícono, nunca solo color) ── */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px 2px 7px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--ink-2); white-space: nowrap; }
.chip i { font-style: normal; font-size: 10px; }
.chip.p-alta i { color: var(--critical); } .chip.p-media i { color: var(--warning); } .chip.p-baja i { color: var(--good); }
.chip.e-abierto i { color: var(--s1); } .chip.e-proceso i { color: var(--s2); } .chip.e-cerrado i { color: var(--muted); }
.chip.low { color: #ffb4ab; border-color: rgba(208,59,59,.5); background: rgba(208,59,59,.1); }

/* ── Éxito ── */
.ok-box { text-align: center; padding: 40px 22px; }
.ok-box .folio { font: 700 34px var(--mono); letter-spacing: .04em; margin: 10px 0 6px; }
.ok-mark { width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--good); color: var(--good); display: inline-grid; place-items: center; font-size: 26px; }
.lookup { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--border); }
.lookup form { display: flex; gap: 10px; margin-top: 10px; }
.lookup input { max-width: 220px; }
.lookup-out { margin-top: 12px; color: var(--ink-2); min-height: 1.4em; }

/* ── Login ── */
.login { max-width: 380px; margin: 9vh auto 0; text-align: center; }
.login img { height: 56px; margin-bottom: 18px; }
.login .form { text-align: left; margin-top: 18px; }

/* ── Resumen / métricas ── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.tile .k { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin-top: 4px; }
.tile .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tile .v .u { font-size: 16px; font-weight: 500; color: var(--ink-2); margin-left: 3px; }
.tile.alert .v { color: #ffb4ab; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.chart { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.chart h2 { margin-bottom: 14px; }
.chart.wide { margin-top: 12px; }
.empty { color: var(--muted); padding: 22px 0; font-size: 14px; }
details.as-table { margin-top: 12px; font-size: 13px; color: var(--muted); }
details.as-table summary { cursor: pointer; }
details.as-table table { margin-top: 8px; }

.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 34%) 1fr 36px; gap: 10px; align-items: center; font-size: 13px; }
.hbar .name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .name i { font-style: normal; margin-right: 6px; font-size: 10px; }
.hbar .track { height: 10px; }
.hbar .fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.hbar:hover .name, .hbar:focus-visible .name { color: var(--ink); }

.segbar { display: flex; gap: 2px; height: 14px; }
.segbar > div { min-width: 3px; }
.segbar > div:first-child { border-radius: 4px 0 0 4px; } .segbar > div:last-child { border-radius: 0 4px 4px 0; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--ink-2); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

svg.bars text { fill: var(--muted); font: 11px var(--sans); }
svg.bars .grid { stroke: var(--grid); stroke-width: 1; }
svg.bars .axis { stroke: var(--axis); stroke-width: 1; }
svg.bars .hit { fill: transparent; }
svg.bars .hit:hover + path, svg.bars g:hover path { filter: brightness(1.25); }

.tip { position: fixed; z-index: 100; pointer-events: none; background: #2a2a28; color: var(--ink); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.5); max-width: 260px; }
.tip b { font-variant-numeric: tabular-nums; }

/* ── Tablas ── */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search], .toolbar select { width: auto; min-width: 150px; padding: 8px 10px; font-size: 14px; }
.toolbar input[type=search] { min-width: 240px; }
.check { display: inline-flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink-2); font-weight: 400; }
.check input { width: 16px; height: 16px; }
.tablewrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 11px 14px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; } tbody tr.click:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono, .mono { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
td.dim { color: var(--ink-2); font-size: 13px; }
td.date { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.count { color: var(--muted); font-size: 13px; margin-left: auto; }

/* ── Diálogos ── */
dialog { margin: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
dialog::backdrop { background: rgba(0,0,0,.65); }
.dlg { padding: 22px; display: grid; gap: 16px; }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dlg-head h3 { font-size: 20px; letter-spacing: -.01em; }
.x { background: none; border: 0; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; padding: 2px 8px; border-radius: 6px; }
.x:hover { color: var(--ink); background: var(--surface-2); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.mats { font-size: 13px; color: var(--ink-2); display: grid; gap: 4px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: .25s; background: var(--ink); color: #0b0b0b; padding: 10px 18px; border-radius: 8px; font-weight: 600; font-size: 14px; z-index: 200; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: #ff8a80; }

@media (max-width: 760px) {
  .row, .grid2 { grid-template-columns: 1fr; }
  .top-in { flex-wrap: wrap; padding: 10px 14px; gap: 8px 14px; }
  .brand span { display: none; }
  main { padding: 20px 14px 56px; }
  h1 { font-size: 24px; }
  .hbar { grid-template-columns: minmax(80px, 40%) 1fr 30px; }
  .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .top, .no-print { display: none !important; } }
