/* BC Dashboard – the "Rapport" style. Every rule follows DESIGN.md in the repo root:
   tokens, one 12-column grid per page, cards (title · figure tiles · footer), status pills,
   centred list dialog, pick ✓ + "Klarmarkera N" with confirmation, copy feedback.
   Light is the default theme; dark is chosen with the Ljust | Mörkt switch (data-theme). */

/* ---------- Tokens ---------- */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f8fa; --surface: #ffffff; --surface2: #f3f6f9; --line: #e3e8ee; --line2: #d3dae3;
  --ink: #1a2433; --muted: #5a6577; --faint: #8b95a5;
  --accent: #2b57e8; --accent-ink: #ffffff; --accent-soft: #eaeffe;
  --ok: #1d7f48; --warn: #a35f00; --bad: #c0392f; --run: #2563c9; --brand: #8b2a2c;
  --shadow: 0 1px 2px rgba(26,36,51,.05);
  --shadow-lg: 0 30px 70px -20px rgba(26,36,51,.38), 0 0 0 1px rgba(26,36,51,.06);
  --scrim: rgba(17,24,39,.42);
  --f: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fm: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2,.7,.2,1);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220; --surface: #111a2b; --surface2: #162036; --line: #22304a; --line2: #2d3d5c;
  --ink: #e3e9f3; --muted: #93a0b5; --faint: #6c7a91;
  --accent: #7d9cff; --accent-ink: #0b1220; --accent-soft: #1a2750;
  --ok: #4cc283; --warn: #e9ad4f; --bad: #ef7369; --run: #7aa7ff; --brand: #b8474a;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  --shadow-lg: 0 30px 70px -20px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.06);
  --scrim: rgba(0,0,0,.6);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--bg); }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; color: var(--ink); font: 14px/1.5 var(--f); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
code, .mono { font-family: var(--fm); font-size: .93em; }
.num { font-variant-numeric: tabular-nums; }
svg.i { flex: none; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { text-wrap: balance; }

/* ---------- Top nav ---------- */
.nav { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.nav-in { max-width: 1720px; margin: 0 auto; height: 56px; display: flex; align-items: center; gap: 28px; padding: 0 24px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; white-space: nowrap; }
.brand img { width: 26px; height: 26px; border-radius: 6px; display: block; }
.tabs { display: flex; align-self: stretch; gap: 22px; overflow: hidden; min-width: 0; flex: 1; }
.tab { display: flex; align-items: center; gap: 7px; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color .15s; }
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--accent); border-color: var(--accent); }
.nav-r { margin-left: auto; flex: none; display: flex; align-items: center; gap: 18px; }
.clock { text-align: right; line-height: 1.2; }
.clock b { display: block; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 15px; }
.clock span { color: var(--muted); font-size: 12px; }
/* Top bar menu: replaces the tabs when they do not fit (JS adds .compact to .nav) */
.navdd { position: relative; display: none; min-width: 0; }
.nav.compact .tabs { display: none; }
.nav.compact .navdd { display: block; }
.navdd-btn .i:last-child { color: var(--faint); transition: transform .14s var(--ease); }
.navdd-btn[aria-expanded="true"] .i:last-child { transform: rotate(180deg); }
.navdd-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 230px; background: var(--surface);
              border: 1px solid var(--line2); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px;
              display: flex; flex-direction: column; gap: 2px; animation: pop .14s var(--ease); }
.navdd-menu[hidden] { display: none; }
.navdd-menu.out { animation: navout .14s var(--ease) forwards; pointer-events: none; }
.navdd-menu a { display: flex; align-items: center; padding: 8px 10px; border-radius: 6px; font-size: 14px; font-weight: 500;
                color: var(--ink); text-decoration: none; }
.navdd-menu a:hover { background: var(--surface2); }
.navdd-menu a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.navdd-head { display: none; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface2); border: 1px solid var(--line); }
.seg button { border: 0; background: none; color: var(--muted); height: 28px; padding: 0 9px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--line); }

/* ---------- Page grid ---------- */
.wrap { width: 100%; max-width: 1720px; margin: 0 auto; flex: 1; padding: 26px 24px 40px;
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-content: start; }
.wrap > * { grid-column: 1 / -1; min-width: 0; }
.wrap > .s3 { grid-column: span 3; } .wrap > .s4 { grid-column: span 4; } .wrap > .s6 { grid-column: span 6; }
.sub2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 16px; min-width: 0; }
.sub2 > .wide { grid-column: 1 / -1; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.phead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-bottom: 4px; }
.phead h1 { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; }
.phead p { margin: 3px 0 0; color: var(--muted); }
.phead .right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumb { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 4px; flex-wrap: wrap; }
.crumb a { color: var(--accent); text-decoration: none; font-weight: 500; }
.crumb a:hover { text-decoration: underline; }
.upd { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; box-shadow: var(--shadow); white-space: nowrap; }
.upd b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: live 2.4s infinite; flex: none; }
.upd.problem .live { background: var(--bad); animation: none; }
.upd.problem [data-upd] { color: var(--bad); }
.upd.flash [data-upd] { animation: flash 1.2s var(--ease); }
@keyframes live { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 45%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }
@keyframes flash { 0%, 30% { color: var(--accent); } }
.sech { display: flex; align-items: center; gap: 10px; padding-top: 8px; }
.sech h2 { margin: 0; font-size: 16px; font-weight: 600; }
.sech .link { margin-left: auto; }
.alertbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; background: color-mix(in srgb, var(--bad) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--bad) 30%, var(--line)); }
.alertbar .i { color: var(--bad); }
.alertbar.warn { background: color-mix(in srgb, var(--warn) 9%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.alertbar.warn .i { color: var(--warn); }
.foot { text-align: center; color: var(--faint); font-size: 12px; padding: 0 16px 24px; }

/* ---------- Panels and cards ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); min-width: 0; position: relative; }
.ph { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); min-height: 52px; flex-wrap: wrap; }
.ph h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.ph .meta { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.help { border: 0; background: none; color: var(--faint); padding: 2px; border-radius: 50%; cursor: help; display: inline-grid; place-items: center; flex: none; }
.help:hover, .help:focus-visible { color: var(--ink); }
.card { display: flex; flex-direction: column; padding: 16px 18px 0; }
.card-h { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-h .ic { color: var(--faint); }
.card-h h3 { margin: 0; font-size: 14px; font-weight: 600; min-width: 0; }
.card-h .help { margin-left: auto; }
.card-b { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 14px 0 16px; gap: 10px; min-width: 0; }
.card-f { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 -18px; padding: 10px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; min-height: 49px; }
.card-f .acts { display: flex; align-items: center; gap: 14px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.card.list-card .card-b { justify-content: flex-start; }
.fig { font-size: 34px; line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.fig-sub { color: var(--muted); font-size: 13px; }
.cnt-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cnt-line .fig { font-size: 30px; }

/* Figure tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat { background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 11px; min-width: 0; min-height: 92px; display: flex; flex-direction: column; justify-content: center; }
.stat.has-spark { flex-direction: row; align-items: flex-end; justify-content: space-between; gap: 12px; }
.stat .l { color: var(--muted); font-size: 12.5px; font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v { font-size: 30px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; display: block; }
.stat.t-bad .v { color: var(--bad); } .stat.t-warn .v { color: var(--warn); }
.d { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.d.up { color: var(--bad); } .d.down { color: var(--ok); }
.stat > div { min-width: 0; }
a.stat { text-decoration: none; transition: border-color .15s, background .15s; }
a.stat:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

/* Key figure cards */
.kpi { padding: 16px 20px; display: flex; flex-direction: column; gap: 6px; min-width: 0; text-decoration: none; }
a.kpi { transition: border-color .15s, box-shadow .2s, transform .2s var(--ease); }
a.kpi:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-1px); }
.kpi .l { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.kpi .row > div { min-width: 0; }
.kpi .v { font-size: 30px; line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi.t-bad .v { color: var(--bad); }
.kpi .error-box { margin: 0; }

/* Sparkline */
.spark { width: 120px; height: 36px; flex: none; overflow: visible; }
.spark .ln { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark .ar { fill: color-mix(in srgb, var(--accent) 12%, transparent); }
.spark .pt { fill: var(--accent); }

/* Notes, empty states, errors */
.hint { color: var(--muted); font-size: 12.5px; white-space: pre-line; }
.hint.bad { color: var(--bad); }
.panel > .hint, .notes .hint { padding: 10px 18px 0; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty b, .empty .stor { display: block; color: var(--ink); font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.empty .desc { font-size: 13px; }
.error-box { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 8px; background: color-mix(in srgb, var(--bad) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--bad) 30%, var(--line)); font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.error-box .stor { color: var(--bad); font-weight: 600; font-size: 13.5px; }
.panel > .error-box { margin: 14px 18px; }

/* ---------- Status ---------- */
.t-ok { --tone: var(--ok); } .t-warn { --tone: var(--warn); } .t-bad { --tone: var(--bad); } .t-run { --tone: var(--run); } .t-info { --tone: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--tone, var(--muted)); background: color-mix(in srgb, var(--tone, var(--muted)) 12%, transparent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tone, var(--muted)); flex: none; display: inline-block; }
.sbadge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tone) 45%, transparent); }
.sbadge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.sbadge.t-bad { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.sbadge.t-run::before, .tile.t-run .dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Buttons and links ---------- */
.btn, .button-link { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 13px; border-radius: 7px; border: 1px solid var(--line2); background: var(--surface); color: var(--ink); font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; box-shadow: 0 1px 1px rgba(26,36,51,.05); text-decoration: none; transition: border-color .12s, background .12s, color .12s; }
.btn:hover:not([disabled]), .button-link:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line2)); background: var(--surface2); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.pri:hover:not([disabled]) { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); border-color: transparent; }
.btn.sm, .button-link.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 34px; padding: 0; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link, .group-link { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; padding: 4px 0; color: var(--accent); font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.link .i { transition: transform .15s var(--ease); }
.link:hover:not([disabled]) .i { transform: translateX(3px); }
.link[disabled] { color: var(--faint); cursor: default; font-weight: 500; }
.group-link { font-size: 12.5px; margin-left: 10px; }
.ibtn, .icon-btn { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); display: inline-grid; place-items: center; cursor: pointer; padding: 0; flex: none; transition: background .12s, color .12s, border-color .12s; }
.icon-btn svg { width: 15px; height: 15px; }
.ibtn:hover, .icon-btn:hover { color: var(--ink); background: var(--surface2); }
.ibtn.pick { color: var(--faint); }
.ibtn.pick:hover { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); }
.ibtn.pick[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.ibtn.pick.partial { color: var(--ok); border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.ibtn.pick[aria-pressed="true"] .i { animation: popin .22s var(--ease); }
.copied { background: color-mix(in srgb, var(--ok) 14%, var(--surface)) !important; border-color: var(--ok) !important; color: var(--ok) !important; }
.copy-fail { border-color: var(--bad) !important; color: var(--bad) !important; }
.copied .i, .copy-fail .i { animation: popin .28s var(--ease); }
@keyframes popin { from { transform: scale(.3); opacity: 0; } }
.yn { border: 1px solid transparent; border-radius: 999px; padding: 1px 10px; font-size: 12px; font-weight: 600; cursor: pointer; background: none; }
.yn.yes { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.yn.no { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.yn:hover { border-color: currentColor; }

/* ---------- Toolbars and fields ---------- */
.toolbar, .filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.toolbar .sp { flex: 1; }
.filters > button { margin-left: auto; }
.field, .filters > label { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 11px; border: 1px solid var(--line2); border-radius: 7px; background: var(--surface); color: var(--muted); font-size: 12.5px; min-width: 0; white-space: nowrap; }
.field:focus-within, .filters > label:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.field input, .field select, .filters > label input, .filters > label select { border: 0; outline: 0; background: none; color: var(--ink); min-width: 0; height: 100%; font-size: 14px; }
.field input[type="search"], .filters input[type="search"] { width: 220px; }
.field input[type="date"], .filters input[type="date"] { width: 132px; }
.field .i { color: var(--faint); }
.count-note { color: var(--muted); font-size: 13px; white-space: nowrap; }
.segtabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--surface2); border: 1px solid var(--line); }
.segtabs button { border: 0; background: none; padding: 5px 12px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.segtabs button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--line); }
.segtabs .n { color: var(--faint); font-variant-numeric: tabular-nums; font-weight: 500; }
.dd { position: relative; }
.dd-btn .i:last-child { color: var(--faint); }
.dd-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 5; min-width: 230px; max-height: 320px; overflow: auto; background: var(--surface); border: 1px solid var(--line2); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; animation: pop .14s var(--ease); }
.dd-menu label { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13.5px; font-weight: 500; }
.dd-menu label:hover { background: var(--surface2); }
.dd-menu label small { margin-left: auto; color: var(--faint); font-variant-numeric: tabular-nums; }
.dd-menu input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.dd-f { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); margin-top: 6px; padding: 6px 6px 0; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow: auto; min-height: 0; }
table.tbl, table.warranty-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .warranty-table th { position: sticky; top: 0; z-index: 1; background: var(--surface2); text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td, .warranty-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr, .warranty-table tbody tr { transition: background .12s; }
.tbl tbody tr:hover, .warranty-table tbody tr:hover { background: var(--surface2); }
.tbl .r, .tbl th.num, .tbl td.num, .warranty-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th button[data-sort] { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.tbl th button[data-sort]:hover, th.sortable:hover { color: var(--ink); }
.tbl th button[data-sort]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
th.sortable { cursor: pointer; }
.tbl .sort { color: var(--accent); font-size: 10px; }
.tbl td.w { max-width: 460px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.tbl td.dim { color: var(--muted); }
.tbl td.act { width: 1%; white-space: nowrap; }
.tbl td.act > div { display: flex; gap: 6px; }
.tbl th.pickcol { width: 1%; padding-top: 5px; padding-bottom: 5px; }
.tbl tr.picked td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.tbl tr.leaving td { transition: opacity .2s, padding .25s var(--ease); opacity: 0; padding-top: 0; padding-bottom: 0; }
.tbl.nowrap td { white-space: nowrap; }
.ilist { border: 1px solid var(--line); border-radius: 8px; overflow: auto; flex: 1 1 auto; min-height: 140px; max-height: 520px; }
.ilist .tbl { font-size: 13px; }
.ilist .tbl td, .ilist .tbl th { padding: 7px 10px; }
.ilist .empty { padding: 28px 16px; }
.more { display: flex; justify-content: center; padding: 12px; }

/* ---------- Dialogs, confirm, toast, tooltip ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: var(--scrim); animation: fade .16s ease-out; }
.modal-box { width: min(1080px, 100%); max-height: min(86vh, 900px); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: pop .22s var(--ease); }
.modal-box.narrow { width: min(640px, 100%); }
.mh, .modal-head { display: flex; align-items: flex-start; gap: 14px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.mh h2, .modal-head h3 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.mh p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.mh .x { margin-left: auto; }
.mb { overflow: auto; min-height: 0; flex: 1; }
.mb > .error-box, .mb > .hint { margin: 12px 20px; }
.mf { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.mf .sp { flex: 1; }
.confirm { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: var(--scrim); animation: fade .14s ease-out; }
.confirm-box { width: min(460px, 100%); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 22px; display: flex; flex-direction: column; gap: 12px; animation: pop .2s var(--ease); }
.confirm-box h2 { margin: 0; font-size: 18px; font-weight: 600; }
.confirm-box p { margin: 0; color: var(--muted); }
.confirm-ids { display: flex; flex-wrap: wrap; gap: 6px; max-height: 140px; overflow: auto; }
.confirm-ids code { background: var(--surface2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; font-size: 12.5px; }
.confirm-f { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg); animation: toast .22s var(--ease); max-width: calc(100vw - 32px); }
.toast button { border: 0; background: color-mix(in srgb, var(--bg) 18%, transparent); color: var(--bg); padding: 5px 11px; border-radius: 6px; font-weight: 600; cursor: pointer; }
#tip { position: fixed; z-index: 90; max-width: 340px; padding: 9px 11px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 12.5px; line-height: 1.5; white-space: pre-line; pointer-events: none; visibility: hidden; box-shadow: var(--shadow-lg); }
#tip.wide { max-width: 460px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes navout { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- Job queues ---------- */
.qpanel { container-type: inline-size; display: flex; flex-direction: column; }
.qsec + .qsec, .qsec + .tiles, .tiles + .qsec { border-top: 1px solid var(--line); }
.qsec-h { display: flex; align-items: center; gap: 8px; padding: 14px 18px 8px; }
.qsec-h h3 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.qsec-h .qsec-b { margin-left: auto; }
.qgrid { display: grid; grid-template-columns: minmax(0, 1fr) 104px 84px 84px 60px 14px; gap: 12px; align-items: center; padding: 0 18px; }
.qhead { font-size: 11.5px; font-weight: 500; color: var(--faint); padding-bottom: 6px; }
.qhead span:nth-child(n+3) { text-align: right; }
a.qrow { text-decoration: none; padding-top: 9px; padding-bottom: 9px; border-top: 1px solid var(--line); transition: background .12s; box-shadow: inset 4px 0 0 var(--tone, transparent); }
a.qrow:hover { background: var(--surface2); }
a.qrow:hover .chev { color: var(--accent); transform: translateX(2px); }
.qgrid > .sbadge { justify-self: start; }
.qname { display: flex; flex-direction: column; min-width: 0; }
.qname b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qname small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qname small.err { color: var(--bad); }
.qname small.late { color: var(--warn); }
.qt { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; white-space: nowrap; line-height: 1.3; }
.qt small { display: block; color: var(--faint); font-size: 11.5px; }
.chev { color: var(--faint); transition: transform .15s var(--ease), color .15s; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; padding: 12px 18px 16px; }
.tile { display: flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 7px; border: 1px solid color-mix(in srgb, var(--tone) 45%, var(--line)); background: color-mix(in srgb, var(--tone) 11%, var(--surface)); color: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: .02em; cursor: default; min-width: 0; }
.tile span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .dot { width: 9px; height: 9px; }
.tile.t-bad { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.tile.t-bad .dot { background: var(--surface); }
.qlegend { display: flex; gap: 10px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--line); margin-top: auto; }
.qtrend { display: inline-flex; align-items: center; gap: 10px; }
.qtrend .spark { width: 96px; height: 28px; }
@container (max-width: 520px) {
  .qgrid { grid-template-columns: minmax(0, 1fr) 96px 52px 14px; }
  .qgrid > :nth-child(4), .qgrid > :nth-child(5) { display: none; }
}

/* ---------- Start page ---------- */
/* Start page: every dashboard side by side */
.home5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; min-width: 0; }
a.home { text-decoration: none; display: flex; flex-direction: column; gap: 14px; padding: 20px; transition: border-color .15s, box-shadow .2s, transform .2s var(--ease); }
a.home:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 10px 28px -14px rgba(26,36,51,.35); transform: translateY(-2px); }
.home-top { display: flex; align-items: center; gap: 12px; }
.tile-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.home h2 { margin: 0; font-size: 17px; font-weight: 600; }
.home p { margin: 0; color: var(--muted); flex: 1; }
.home-f { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.home-f .link { pointer-events: none; }

/* ---------- WMS queue and job queue ---------- */
.bars { display: flex; flex-direction: column; gap: 4px; padding: 12px 10px; }
a.bar-row { display: grid; grid-template-columns: minmax(0, 190px) minmax(0, 1fr) 48px; gap: 12px; align-items: center; font-size: 13.5px; text-decoration: none; padding: 7px 8px; border-radius: 7px; }
a.bar-row:hover { background: var(--surface2); }
.bar-row .track { height: 10px; border-radius: 5px; background: var(--surface2); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 5px; background: var(--accent); transform-origin: left; animation: grow .7s var(--ease) backwards; }
.bar-row b { text-align: right; font-variant-numeric: tabular-nums; }
.bar-row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes grow { from { transform: scaleX(0); } }
.chart { padding: 10px 18px 14px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--faint); font: 11px var(--f); }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .ar { fill: color-mix(in srgb, var(--accent) 10%, transparent); }
.chart .pt { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .bar { fill: color-mix(in srgb, var(--accent) 75%, transparent); }
.chart .bar.hi { fill: var(--warn); }
.chart .val { fill: var(--ink); font: 600 11px var(--f); }
.chart .limit { stroke: var(--warn); stroke-dasharray: 4 4; }
.kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kv > div { padding: 14px 18px; border-left: 1px solid var(--line); border-top: 1px solid var(--line); min-width: 0; }
.kv > div:nth-child(4n+1) { border-left: 0; }
.kv > div:nth-child(-n+4) { border-top: 0; }
.kv span { display: block; color: var(--muted); font-size: 12.5px; }
.kv b { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.jobs .job { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 12px 18px; border-top: 1px solid var(--line); }
.jobs .job:first-child { border-top: 0; }
.jobs .job .sub { color: var(--muted); font-size: 12.5px; }
.jobs .job .error { color: var(--bad); font-size: 12.5px; }

/* ---------- Garantiservice (classes drawn by warranty.ts) ---------- */
.vendor-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
a.vendor-tile { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .2s, transform .2s var(--ease); min-width: 0; }
a.vendor-tile:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 10px 28px -14px rgba(26,36,51,.35); transform: translateY(-2px); }
a.vendor-tile.has-outside { border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); }
a.vendor-tile.no-vendor { border-style: dashed; }
.vendor-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vendor-no { color: var(--muted); font-family: var(--fm); font-size: 12px; }
.vendor-ir { align-self: flex-start; margin: 6px 0 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.vendor-ir:empty, .vendor-ir:not(.bad):not(.muted):is(:only-child) { background: none; }
.vendor-ir.muted { color: var(--muted); background: color-mix(in srgb, var(--muted) 12%, transparent); }
.vendor-ir.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.vendor-tile .figure { font-size: 30px; font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.vendor-meta { color: var(--muted); font-size: 12.5px; }
.vendor-open { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--bad); font-size: 12.5px; font-weight: 600; }
.vendor-open.done { color: var(--ok); }
.outside-banner { margin-bottom: 16px; padding: 12px 16px; border-radius: 10px; background: color-mix(in srgb, var(--bad) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--bad) 30%, var(--line)); color: var(--bad); font-weight: 500; }
.outside-banner a { color: var(--bad); font-weight: 600; }
.unassigned { background: var(--surface); border: 1px solid color-mix(in srgb, var(--bad) 40%, var(--line)); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.unassigned-head { padding: 14px 18px; border-bottom: 1px solid var(--line); color: var(--bad); font-weight: 600; }
.unassigned-scroll { overflow: auto; }
.ir-status { display: inline-flex; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.ir-status:empty { display: none; }
.ir-status.open, .ir-status.onir-yes { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.ir-status.released { color: var(--run); background: color-mix(in srgb, var(--run) 12%, transparent); }
.ir-status.closed, .ir-status.pending, .ir-status.onir-pending { color: var(--muted); background: color-mix(in srgb, var(--muted) 12%, transparent); }
.ir-status.onir-no { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.warranty-table tr.group-row td { background: var(--surface2); font-weight: 600; font-size: 13px; padding-top: 10px; padding-bottom: 10px; }
.warranty-table tr.group-row.active td { box-shadow: inset 4px 0 0 var(--ok); }
.warranty-table tr.group-row.bad td { color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.warranty-table tr.outside-row td { background: color-mix(in srgb, var(--bad) 5%, transparent); }
.warranty-table td.text { min-width: 140px; }
.warranty-table td.fault { max-width: 360px; color: var(--muted); }
.warranty-table td.row-actions { width: 1%; white-space: nowrap; }
.warranty-table td.row-actions .icon-btn + .icon-btn { margin-left: 6px; }
.view-back { justify-self: start; }
.warranty-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px 20px; overflow: auto; }
.warranty-form .wide { grid-column: 1 / -1; }
.warranty-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.warranty-form input, .warranty-form select, .warranty-form textarea { height: 36px; border: 1px solid var(--line2); border-radius: 7px; background: var(--surface); padding: 0 10px; font-weight: 400; font-size: 14px; color: var(--ink); }
.warranty-form textarea { height: 90px; padding: 8px 10px; resize: vertical; }
.warranty-form input:focus, .warranty-form select:focus, .warranty-form textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.form-error { color: var(--bad); font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Motion ---------- */
.enter > *, .enter .sub2 > *, .enter .grid4 > *, .enter .vendor-grid > *, .enter .home5 > * { animation: rise .36s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 40ms); }
.enter > .sub2, .enter > .home5 { animation: none; }
.enter .spark .ln { stroke-dasharray: 300; animation: draw .9s .2s ease-out backwards; }
.enter .chart .ln { stroke-dasharray: 2000; animation: draw2 1.1s .15s ease-out backwards; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes draw { from { stroke-dashoffset: 300; } }
@keyframes draw2 { from { stroke-dashoffset: 2000; } }

/* ---------- TV mode (it.html?tv=1, same as the Ongoing dashboard): one screen, sizes from the viewport ---------- */
.tvhead { display: flex; align-items: center; justify-content: space-between; gap: 2vw; flex-wrap: wrap; }
.tvhead .tvl, .tvhead .tvr { display: flex; align-items: center; gap: 1.2vw; flex-wrap: wrap; }
.tvhead h1 { margin: 0; font-size: clamp(22px, 2.1vw, 52px); font-weight: 600; letter-spacing: -0.015em; }
.tvhead .logo { width: clamp(26px, 2.2vw, 48px); height: clamp(26px, 2.2vw, 48px); border-radius: 8px; display: block; }
.tvclock { text-align: right; line-height: 1.15; }
.tvclock b { display: block; font-size: clamp(20px, 2.1vw, 52px); font-weight: 600; font-variant-numeric: tabular-nums; }
.tvclock span { color: var(--muted); font-size: clamp(12px, .9vw, 22px); }
.tvhead .upd { font-size: clamp(13px, .95vw, 22px); }
body.tv .tvhead .seg button { height: clamp(28px, 2.1vw, 48px); padding: 0 clamp(9px, .8vw, 18px); font-size: clamp(12.5px, .9vw, 20px); }
body.tv .nav, body.tv .foot { display: none; }
body.tv .wrap { max-width: none; height: 100vh; padding: 1.2vh 2vw; gap: 1.2vh 1.2vw; grid-template-rows: auto minmax(0, 1fr); }
body.tv .wrap:has(> .alertbar:not([hidden])) { grid-template-rows: auto auto minmax(0, 1fr); }
body.tv .wrap > .qpanel, body.tv .wrap > .sub2 { min-height: 0; overflow: hidden; }
body.tv .sub2 { gap: 1vh 1.2vw; }
body.tv .sub2 > * { min-height: 0; overflow: hidden; }
/* Job queues */
body.tv .ph { padding: 1.1vh 1vw; min-height: 0; }
body.tv .ph h2 { font-size: clamp(15px, 1.25vw, 30px); }
body.tv .ph .meta { font-size: clamp(13px, .95vw, 22px); }
body.tv .qsec-h { padding: 1vh 1vw .5vh; }
body.tv .qsec-h h3 { font-size: clamp(12px, .8vw, 19px); }
/* No Intervall column on the TV (it is the 5th cell of every queue row and the header). */
body.tv .qgrid { padding: 0 1vw; gap: .8vw; grid-template-columns: minmax(0, 1fr) clamp(104px, 7vw, 170px) clamp(84px, 5vw, 130px) clamp(84px, 5vw, 130px) 14px; }
body.tv .qgrid > :nth-child(5) { display: none; }
body.tv .qhead { font-size: clamp(11.5px, .75vw, 18px); padding-bottom: .5vh; }
body.tv a.qrow { padding-top: .55vh; padding-bottom: .55vh; }
body.tv .qname b { font-size: clamp(14px, 1vw, 24px); }
body.tv .qname small { font-size: clamp(12px, .8vw, 19px); }
body.tv .qt { font-size: clamp(13px, .9vw, 22px); }
body.tv .qt small { font-size: clamp(11.5px, .72vw, 18px); }
body.tv .sbadge { font-size: clamp(12px, .8vw, 19px); }
body.tv .tiles { grid-template-columns: repeat(auto-fill, minmax(clamp(96px, 6vw, 150px), 1fr)); gap: .6vh .4vw; padding: 1vh 1vw 1.1vh; }
body.tv .tile { font-size: clamp(12px, .8vw, 19px); padding: .6vh .5vw; }
body.tv .qlegend { padding: .9vh 1vw; }
/* Cards: one size for every big figure */
body.tv { --tv-fig: clamp(24px, 2.1vw, 60px); }
body.tv .card { padding: 1.2vh 1vw 0; }
body.tv .card-h h3 { font-size: clamp(14px, 1vw, 24px); }
body.tv .card-b { padding: .6vh 0 .8vh; gap: .6vh; }
body.tv .card-f { margin: 0 -1vw; padding: .4vh 1vw; min-height: 0; }
body.tv .stat { min-height: 0; padding: .8vh .8vw; }
body.tv .stat .l { font-size: clamp(12.5px, .85vw, 20px); }
body.tv .stat .v { font-size: var(--tv-fig); }
body.tv .stat.has-spark .spark { width: clamp(96px, 7vw, 200px); height: clamp(28px, 3.4vh, 60px); }
@media (max-width: 1280px) { body.tv .wrap { height: auto; } }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .wrap > .s3 { grid-column: span 6; }
  .wrap > .s6 { grid-column: 1 / -1; }
  .vendor-grid, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .wrap > .s4 { grid-column: 1 / -1; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv > div { border-left: 1px solid var(--line) !important; border-top: 1px solid var(--line) !important; }
  .kv > div:nth-child(odd) { border-left: 0 !important; }
  .kv > div:nth-child(-n+2) { border-top: 0 !important; }
  .clock { display: none; }
  .seg .lbl { display: none; }
  .home5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .nav-in { gap: 16px; padding: 0 16px; }
  .brand span { display: none; }
  .wrap { padding: 18px 16px 32px; gap: 12px; }
  .wrap > .kpi.s3 { grid-column: 1 / -1; }
  .sub2, .vendor-grid, .grid4, .home5 { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; gap: 12px; }
  .navdd-btn { height: 34px; }
  /* Phone: the menu is a full-screen sheet, like the dialogs */
  .navdd-menu { position: fixed; inset: 0; z-index: 60; min-width: 0; border: 0; border-radius: 0; box-shadow: none; gap: 4px;
                padding: env(safe-area-inset-top, 0px) 16px calc(16px + env(safe-area-inset-bottom, 0px)); overflow-y: auto;
                animation: pop .22s var(--ease); }
  .navdd-menu.out { animation: navout .14s var(--ease) forwards; }
  .navdd-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; flex: none;
                margin: 0 -16px 8px; padding: 0 16px; border-bottom: 1px solid var(--line); }
  .navdd-head b { font-size: 16px; font-weight: 600; }
  .navdd-menu a { min-height: 52px; padding: 0 14px; font-size: 16px; border-radius: 8px; }
  html.navdd-open, html.navdd-open body { overflow: hidden; }
  .stat.has-spark .spark { width: 90px; }
  .phead .upd { width: 100%; justify-content: center; }
  .card-f .acts { width: 100%; }
  .toolbar, .filters { padding: 10px 14px; }
  .field input[type="search"], .filters input[type="search"] { width: 150px; }
  .field input[type="date"], .filters input[type="date"] { width: 118px; }
  .ibtn, .icon-btn { width: 34px; height: 34px; }
  .tbl td.w { max-width: 200px; }
  .ilist { max-height: 420px; }
  .modal { padding: 0; place-items: stretch; }
  .modal-box, .modal-box.narrow { width: 100%; height: 100%; max-height: none; border-radius: 0; }
  .mh, .modal-head { padding: 14px 16px 12px; }
  .mf { padding: 10px 16px; }
  .dd-menu { position: fixed; left: 16px; right: 16px; top: auto; bottom: 16px; }
  .warranty-form { grid-template-columns: 1fr; }
  a.bar-row { grid-template-columns: minmax(0, 120px) minmax(0, 1fr) 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Vertical stack of full-width blocks inside the grid (Garantiservice views). */
.stackv { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel.toolbar { border-bottom: 1px solid var(--line); }
