@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* FZ Inventario · panel. Colores como tokens; el modo oscuro tiene sus propios pasos (no es una inversión). */
:root {
  color-scheme: light;
  --bg: #f3f3f1;
  --surface-1: #fcfcfb;
  --surface-2: #f6f6f4;
  --border: #e2e1dc;
  --grid: #e9e8e4;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7b7a75;
  --series-1: #2a78d6;
  --series-1-soft: #dce9f9;
  --accent: #2a78d6;
  --on-accent: #ffffff;
  --warn-fg: #8a4b00;
  --warn-bg: #fdecd2;
  --ok-fg: #0a5c0a;
  --ok-bg: #dcf1dc;
  --danger-fg: #a12322;
  --danger-bg: #fbe0e0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .05);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #121211;
    --surface-1: #1a1a19;
    --surface-2: #222220;
    --border: #34332f;
    --grid: #2a2a27;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #96958c;
    --series-1: #3987e5;
    --series-1-soft: #1f3550;
    --accent: #3987e5;
    --on-accent: #0b0b0b;
    --warn-fg: #f2b45c;
    --warn-bg: #3a2a10;
    --ok-fg: #7fd37f;
    --ok-bg: #12301a;
    --danger-fg: #f09090;
    --danger-bg: #3d1a1a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface-1: #1a1a19;
  --surface-2: #222220;
  --border: #34332f;
  --grid: #2a2a27;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #96958c;
  --series-1: #3987e5;
  --series-1-soft: #1f3550;
  --accent: #3987e5;
  --on-accent: #0b0b0b;
  --warn-fg: #f2b45c;
  --warn-bg: #3a2a10;
  --ok-fg: #7fd37f;
  --ok-bg: #12301a;
  --danger-fg: #f09090;
  --danger-bg: #3d1a1a;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font: 14px/1.45 "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.hidden { display: none !important; }

/* ---------- barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 20px; min-height: 56px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; padding: 10px 0; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; flex: none; }
.logo svg { width: 16px; height: 16px; fill: var(--on-accent); }
.login .logo { width: 40px; height: 40px; border-radius: 10px; }
.login .logo svg { width: 24px; height: 24px; }
.brand small { font-weight: 500; color: var(--text-muted); }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.tab {
  background: none; border: 0; padding: 18px 12px 16px; cursor: pointer; color: var(--text-secondary);
  border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 550;
}
.tab:hover { color: var(--text-primary); }
.tab[aria-current="page"] { color: var(--text-primary); border-bottom-color: var(--accent); }
.tab .badge { margin-left: 6px; }
.top-actions { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12.5px; }

/* ---------- layout ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 20px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); margin-top: 14px; }
@media (max-width: 480px) { .two { grid-template-columns: 1fr; } main { padding: 14px; } }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 14px; color: var(--text-secondary); font-weight: 600; margin-bottom: 4px; }
.card .sub { color: var(--text-muted); font-size: 12.5px; margin-bottom: 12px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin-top: 6px; }
.kpi .value small { font-size: 14px; font-weight: 500; color: var(--text-muted); letter-spacing: 0; }
.kpi .foot { color: var(--text-muted); font-size: 12.5px; margin-top: 4px; }
.progress { height: 8px; border-radius: 4px; background: var(--series-1-soft); margin-top: 10px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--series-1); border-radius: 4px; }

/* ---------- controles ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
input[type="text"], input[type="search"], input[type="password"], input[type="number"], select, textarea {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 36px; width: 100%;
}
.toolbar input, .toolbar select { width: auto; }
.toolbar input[type="search"] { min-width: 240px; }
input:focus-visible, select:focus-visible, button:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 7px 14px; cursor: pointer;
  min-height: 36px; font-weight: 550; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger-fg); }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-1); }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; min-height: 34px; color: var(--text-secondary); font-weight: 550; }
.seg button[aria-pressed="true"] { background: var(--series-1-soft); color: var(--text-primary); }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
td.r, th.r { text-align: right; }
tr.anulada td { color: var(--text-muted); text-decoration: line-through; }
tr.anulada td.keep { text-decoration: none; }
.empty { padding: 32px 10px; text-align: center; color: var(--text-muted); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }
.badge.open { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: transparent; }
.badge.bad { background: var(--danger-bg); color: var(--danger-fg); border-color: transparent; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; font-size: 13px; font-weight: 500; }

/* ---------- gráficos ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--text-muted); font-size: 11px; font-family: inherit; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .bar { fill: var(--series-1); }
.chart .hit:hover + .bar, .chart .col:hover .bar { fill: var(--series-1); filter: brightness(1.15); }
.chart .hit { fill: transparent; }
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 10px; align-items: center; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 10px; background: var(--grid); border-radius: 5px; }
.hbar .fill { height: 100%; background: var(--series-1); border-radius: 0 5px 5px 0; min-width: 2px; }
.tooltip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; box-shadow: 0 6px 24px rgba(0,0,0,.18); font-size: 12.5px; min-width: 120px;
}
.tooltip b { display: block; margin-bottom: 2px; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 40; display: flex; justify-content: center; align-items: flex-start; padding: 5vh 12px; overflow-y: auto; }
.modal { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; width: min(920px, 100%); padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal.narrow { width: min(520px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.modal-head h2 { font-size: 18px; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-weight: 550; font-size: 13px; color: var(--text-secondary); }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; flex-wrap: wrap; }
.err { color: var(--danger-fg); background: var(--danger-bg); padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.stat-row { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 14px; }
.stat-row div b { display: block; font-size: 20px; }
.stat-row div span { color: var(--text-muted); font-size: 12.5px; }
.list { display: grid; gap: 0; }
.list .it { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--grid); align-items: baseline; }
.list .it time { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text-primary); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 60; font-weight: 550; max-width: 90vw; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); padding: 26px; }
.login h1 { font-size: 20px; margin: 12px 0 4px; }
.login p { color: var(--text-muted); margin: 0 0 18px; }
