/* BRIBOX Ticketing, UI v2.
   Design read: operator work tool for a small IT team, in the layout language of current
   issue trackers (Linear, Plain): an inverted-L shell (fixed sidebar + content), list rows
   instead of a spreadsheet grid, a composer card for intake. Palette, type, radius and
   elevation from C:\Users\Administrator\DESIGN.md (dark default, teal accent, system font).
   Dials: ENERGY 2 / RHYTHM 2 / MOTION 1 (hover, focus, one 160ms reveal). */

:root {
  --canvas: #0b1416;
  --sidebar: #0e181b;
  --surface: #121d20;
  --surface-2: #172529;
  --raised: #1b2b30;
  --text: #e6f1f0;
  --muted: #9db3b1;
  --faint: #7f9795;
  --accent: #2dd4bf;
  --accent-deep: #134e4a;
  --accent-ink: #0b1416;
  --accent-soft: rgba(45, 212, 191, .12);
  --border: #23343a;
  --border-strong: #2f454c;
  --ok: #4ade80;
  --warn: #fbbf24;
  --down: #f87171;
  --ok-soft: rgba(74, 222, 128, .12);
  --warn-soft: rgba(251, 191, 36, .12);
  --down-soft: rgba(248, 113, 113, .12);
  --tint: rgba(255, 255, 255, .03);
  --hover: rgba(255, 255, 255, .045);
  --focus: rgba(45, 212, 191, .45);
  --font-ui: ui-sans-serif, system-ui, "Segoe UI Variable Text", "Segoe UI", sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-num: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r-card: 18px;
  --r-ctl: 10px;
  --r-chip: 6px;
  --elev-1: 0 1px 0 rgba(0, 0, 0, .35);
  --elev-2: 0 12px 24px -18px rgba(0, 0, 0, .55);
  --sidebar-w: 248px;
}
[data-theme="light"] {
  --canvas: #f7faf9;
  --sidebar: #eef4f2;
  --surface: #ffffff;
  --surface-2: #f3f7f6;
  --raised: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --faint: #5b6b7d;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: rgba(15, 118, 110, .09);
  --border: #dbe5e2;
  --border-strong: #c5d3cf;
  --ok: #15803d;
  --warn: #b45309;
  --down: #b91c1c;
  --ok-soft: rgba(21, 128, 61, .09);
  --warn-soft: rgba(180, 83, 9, .09);
  --down-soft: rgba(185, 28, 28, .08);
  --tint: rgba(15, 23, 42, .025);
  --hover: rgba(15, 23, 42, .04);
  --focus: rgba(15, 118, 110, .35);
  --elev-1: 0 1px 0 rgba(15, 23, 42, .05);
  --elev-2: 0 16px 32px -20px rgba(15, 23, 42, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--canvas);
  color: var(--text);
  font: 14px/22px var(--font-ui);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 16px; }
.num, .mono { font-family: var(--font-num); font-size: 13px; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
kbd {
  font: 500 11px/16px var(--font-num); padding: 0 5px; border-radius: 4px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
}

/* ------------------------------------------------------------ controls */
input, select, textarea {
  width: 100%;
  background: var(--canvas);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-ctl);
  padding: 8px 11px;
  font: inherit;
  min-height: 40px;
  transition: border-color .12s, background .12s;
}
[data-theme="light"] input, [data-theme="light"] select, [data-theme="light"] textarea { background: #fff; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
textarea { resize: vertical; line-height: 20px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible, .ticket-row:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; accent-color: var(--accent); }
input[type="file"] { padding: 7px; }
label { display: block; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
[data-theme="dark"] input[type="date"] { color-scheme: dark; }
.input-strong { font-size: 15px; font-weight: 600; font-family: var(--font-num); letter-spacing: .01em; }
.input-strong::placeholder { font: 400 14px var(--font-ui); letter-spacing: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; min-height: 40px; padding: 0 16px;
  border-radius: var(--r-ctl); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font: 500 14px/1 var(--font-ui); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { border-color: var(--border-strong); background: var(--raised); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: #5eead4; border-color: #5eead4; }
[data-theme="light"] .btn-primary:hover { background: #115e59; border-color: #115e59; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--hover); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 44px; padding: 0 22px; font-size: 15px; }
.btn-icon { width: 40px; padding: 0; }
.btn[disabled] { opacity: .55; cursor: progress; }

.chip {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border-radius: var(--r-chip); background: var(--accent-soft); color: var(--accent);
  font: 600 12px/1 var(--font-ui);
}
.chip:empty { display: none; }

/* ------------------------------------------------------------ login */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    linear-gradient(180deg, var(--canvas) 0%, var(--canvas) 55%, var(--sidebar) 100%);
}
.login-panel {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: 36px; box-shadow: var(--elev-2);
}
.login-panel h1 { font: 600 24px/32px var(--font-display); margin: 28px 0 6px; }
.login-panel > p { margin-bottom: 24px; }
.login-form { display: grid; gap: 14px; }
.login-form .btn { width: 100%; margin-top: 4px; }
.form-error { color: var(--down); margin: 0; font-size: 13px; line-height: 18px; }
.form-error:empty { display: none; }
.form-error.ok { color: var(--ok); }

/* ------------------------------------------------------------ brand */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); flex: none;
}
.brand-lg .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
.brand-text { display: grid; line-height: 16px; }
.brand-text b { font-size: 14px; letter-spacing: .06em; }
.brand-text span { font-size: 12px; color: var(--muted); }
.brand-lg .brand-text b { font-size: 16px; line-height: 20px; }

/* ------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 20px;
  padding: 18px 14px 14px; background: var(--sidebar); border-right: 1px solid var(--border);
}
.sidebar > .brand { padding: 0 6px; }
.side-nav { display: grid; gap: 2px; }
.side-label {
  font-size: 11px; line-height: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--faint); padding: 14px 10px 6px;
}
.side-label:first-child { padding-top: 0; }
.zone-list, .mainnav { display: grid; gap: 2px; }

.nav-item, .zone-tab {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px;
  border-radius: var(--r-ctl); color: var(--muted); text-decoration: none; font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-item:hover, .zone-tab:hover { background: var(--hover); color: var(--text); }
.nav-item.active, .zone-tab[aria-selected="true"] { background: var(--accent-soft); color: var(--text); }
.nav-item svg { flex: none; color: var(--faint); }
.nav-item.active svg { color: var(--accent); }

.zone-tab .zt-no {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; flex: none;
  border: 1px solid var(--border-strong); font: 600 12px/1 var(--font-num); color: var(--muted);
}
.zone-tab[aria-selected="true"] .zt-no { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.zone-tab .zt-name { flex: 1; }
.zone-tab .zt-count {
  font: 600 12px/20px var(--font-num); min-width: 22px; padding: 0 6px; border-radius: 6px; text-align: center;
  color: var(--muted); background: var(--tint);
}
.zone-tab .zt-count.has-open { color: var(--warn); background: var(--warn-soft); }

.side-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 14px; display: grid; gap: 10px; }
.who { display: flex; align-items: center; gap: 10px; padding: 0 6px; min-width: 0; }
.avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--accent-deep); color: #fff; font: 600 13px/1 var(--font-ui);
}
.who-text { display: grid; min-width: 0; line-height: 18px; }
.who-text b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text span { font-size: 12px; color: var(--muted); }
.side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.mobile-bar, .scrim { display: none; }

main { padding: 28px 32px 48px; min-width: 0; max-width: 1680px; width: 100%; }
.view { animation: reveal .16s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font: 600 28px/36px var(--font-display); letter-spacing: -.01em; }
.page-head p { margin-top: 2px; }

.stat-strip { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; }
.stat { padding: 10px 18px; min-width: 120px; border-left: 1px solid var(--border); }
.stat:first-child { border-left: 0; }
.stat .v { font: 600 22px/28px var(--font-num); }
.stat .l { font-size: 12px; line-height: 16px; color: var(--muted); }
.stat.warn .v { color: var(--warn); }
.stat.focus .v { color: var(--accent); }

/* ------------------------------------------------------------ cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--elev-1); padding: 20px; min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 47px;
  padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 16px; line-height: 24px; display: flex; align-items: center; gap: 8px; }
.card-title { font-size: 16px; line-height: 24px; padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--border); display: flex; align-items: baseline; gap: 8px; }
.sub-title { font-size: 14px; margin: 24px 0 4px; }

.zone-grid { display: grid; grid-template-columns: minmax(360px, 460px) minmax(0, 1fr); gap: 20px; align-items: start; }

/* Zona view = two independent panes (composer, ticket list). Each pane: fixed head, its own
   scroll area, fixed foot. Only on screens tall and wide enough; smaller screens use one
   natural page scroll with the panes stacked. */
.pane-foot { border-top: 1px solid var(--border); margin: 16px -20px -20px; padding: 14px 20px 16px; background: var(--surface); border-radius: 0 0 var(--r-card) var(--r-card); }
.pane-foot:empty { display: none; }
.pane-foot .form-error { margin-bottom: 10px; }
@media (min-width: 1101px) and (min-height: 620px) {
  main:has(> #view-zona:not([hidden])) { padding-bottom: 20px; }
  #view-zona:not([hidden]) { display: flex; flex-direction: column; height: calc(100vh - 48px); min-height: 560px; }
  #view-zona > .page-head { flex: none; margin-bottom: 18px; }
  #view-zona .zone-grid { flex: 1 1 auto; min-height: 0; align-items: stretch; }
  .pane { display: flex; flex-direction: column; min-height: 0; overflow: hidden; padding-bottom: 0; }
  .pane > .card-head, .pane > .list-filters { flex: none; }
  .pane > .card-head { margin-bottom: 14px; }
  .pane-body {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    margin: 0 -20px; padding: 2px 20px 18px; scrollbar-width: thin; scrollbar-gutter: stable;
  }
  .pane-foot { flex: none; margin: 0 -20px; padding: 12px 20px 14px; border-radius: 0; }
  .pane-body.can-scroll {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent);
  }
  .pane-body.can-scroll.at-end { -webkit-mask-image: none; mask-image: none; }
  .pane > .card-head { padding-bottom: 12px; }
  .list > .card-head { margin-bottom: 12px; }
  .list .ticket-list { margin-top: 0; border-top: 0; }
  .list > .list-filters { padding-bottom: 12px; border-bottom: 1px solid var(--border); }
}

/* ------------------------------------------------------------ composer */
.composer { position: relative; }
.paste-box { border: 1px dashed var(--border-strong); border-radius: 14px; padding: 12px; background: var(--tint); }
.paste-box:focus-within { border-style: solid; border-color: var(--accent); }
.paste-box textarea { border: 0; background: transparent; padding: 2px 0; min-height: 0; font-size: 13px; box-shadow: none; resize: none; }
.paste-box textarea:focus { box-shadow: none; }
.paste-foot { font-size: 12px; line-height: 16px; color: var(--muted); padding-top: 8px; border-top: 1px solid var(--border); margin-top: 6px; }
.paste-foot.ok { color: var(--ok); }

.warnings { display: grid; gap: 6px; margin-top: 12px; }
.warnings:empty { display: none; }
.warn-item {
  font-size: 13px; line-height: 18px; padding: 9px 12px; border-radius: var(--r-ctl);
  border: 1px solid var(--border); background: var(--tint);
}
.warn-item.warn { background: var(--warn-soft); border-color: transparent; }
.warn-item.down { background: var(--down-soft); border-color: transparent; }
.warn-item.info { background: var(--accent-soft); border-color: transparent; }
.warn-item b { font-size: 11px; font-weight: 700; letter-spacing: .04em; margin-right: 8px; }
.warn-item.warn b { color: var(--warn); }
.warn-item.down b { color: var(--down); }
.warn-item.info b { color: var(--accent); }
.warn-item a { cursor: pointer; font-weight: 500; }

.ticket-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; margin-top: 18px; }
.f { min-width: 0; }
.f-wide, .f-submit, .group-title { grid-column: 1 / -1; }
.group-title {
  font-size: 11px; line-height: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--faint); padding-top: 8px; margin-top: 2px; border-top: 1px solid var(--border);
}
.hint { display: block; font-size: 12px; line-height: 16px; color: var(--muted); margin-top: 5px; }
.hint:empty { display: none; }
.filled { border-color: rgba(45, 212, 191, .7); background: rgba(45, 212, 191, .10); box-shadow: inset 3px 0 0 var(--accent); }
[data-theme="light"] .filled { border-color: rgba(15, 118, 110, .55); background: #ecf8f5; }
.f-submit { display: grid; gap: 10px; margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--border); }
.submit-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.submit-row .btn { min-width: 160px; }

.devices { display: grid; gap: 6px; }
.devices:empty::before { content: "Belum ada IP. Tempel pesan atau tambah manual."; color: var(--faint); font-size: 13px; }
.device {
  display: grid; grid-template-columns: 116px minmax(0, 1fr) auto auto; gap: 4px 10px; align-items: center;
  padding: 7px 8px 7px 12px; border: 1px solid var(--border); border-radius: var(--r-ctl); font-size: 13px; background: var(--canvas);
}
[data-theme="light"] .device { background: #fff; }
.device .ip { font-family: var(--font-num); font-weight: 600; }
.device .loc { color: var(--muted); overflow-wrap: anywhere; font-size: 12px; line-height: 16px; }
.add-ip { display: flex; gap: 8px; margin-top: 8px; }
.add-ip input { flex: 0 1 220px; min-height: 32px; padding: 4px 10px; font-size: 13px; }

/* ------------------------------------------------------------ status + source words */
.tag, .status-pill {
  display: inline-flex; align-items: center; height: 22px; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 0 9px; border-radius: 999px; white-space: nowrap; background: var(--tint);
}
.tone-muted { color: var(--muted); }
.tone-accent { color: var(--accent); }
.tone-ok { color: var(--ok); }
.tone-warn { color: var(--warn); }
.tone-down { color: var(--down); }
.tag.tone-ok, .status-pill.tone-ok { background: var(--ok-soft); }
.tag.tone-warn, .status-pill.tone-warn { background: var(--warn-soft); }
.tag.tone-down, .status-pill.tone-down { background: var(--down-soft); }
.tag.tone-accent, .status-pill.tone-accent { background: var(--accent-soft); }
.src { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 0 6px; border-radius: 6px; line-height: 20px; }
.src-exact { color: var(--ok); background: var(--ok-soft); }
.src-subnet { color: var(--warn); background: var(--warn-soft); }
.src-none { color: var(--down); background: var(--down-soft); }
.src-manual { color: var(--muted); background: var(--tint); }

/* ------------------------------------------------------------ ticket list */
.list-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.list-filters .search { grid-column: 1 / -1; }
.flt-toggle .btn { min-height: 36px; padding: 0 14px; font-size: 13px; border-color: var(--border); }
.flt-toggle .btn[aria-expanded="true"], .flt-toggle .btn.has-value { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.flt-dates { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.flt-dates .btn { min-height: 36px; }
.flt { margin: 0; min-width: 0; }
.flt span { display: block; font-size: 11px; line-height: 14px; color: var(--faint); margin-bottom: 4px; font-weight: 500; }
.flt select, .flt input { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.search { position: relative; margin: 0; }
.search svg { position: absolute; left: 11px; top: 12px; color: var(--faint); pointer-events: none; }
.search input { padding-left: 34px; }

.list { container: tlist / inline-size; }
.ticket-list { margin-top: 14px; border-top: 1px solid var(--border); }
.ticket-row {
  display: grid; align-items: center; gap: 14px;
  grid-template-columns: 64px minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) 150px;
  padding: 12px 10px; border-bottom: 1px solid var(--border); cursor: pointer;
  border-radius: 0; transition: background .12s;
}
.ticket-row:hover { background: var(--hover); }
.ticket-row .t-id { font: 600 13px/18px var(--font-num); color: var(--muted); }
.ticket-row .t-id span { display: block; font: 400 12px/16px var(--font-ui); color: var(--faint); }
.ticket-row .t-main { min-width: 0; }
.ticket-row .t-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.ticket-row .t-title b { font: 600 14px/20px var(--font-num); white-space: nowrap; }
.ticket-row .t-title span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-row .t-desc { color: var(--muted); font-size: 13px; line-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.ticket-row .t-meta { min-width: 0; font-size: 13px; line-height: 18px; }
.ticket-row .t-meta .l { display: block; font-size: 11px; color: var(--faint); line-height: 14px; }
.ticket-row .t-meta .v { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-row .t-meta .v.num { font-size: 12px; }
.ticket-row .t-status select {
  min-height: 32px; height: 32px; padding: 0 28px 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .03em;
  border-radius: 999px; border-color: transparent; background-color: var(--tint);
}
.ticket-row .t-status select.tone-ok { background-color: var(--ok-soft); }
.ticket-row .t-status select.tone-warn { background-color: var(--warn-soft); }
.ticket-row .t-status select.tone-down { background-color: var(--down-soft); }
.ticket-row .t-status select.tone-accent { background-color: var(--accent-soft); }
.ticket-row .t-status select option { color: var(--text); background: var(--surface); font-weight: 500; }

.list-empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.list-empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.skeleton { height: 62px; border-bottom: 1px solid var(--border); background: linear-gradient(90deg, transparent, var(--tint), transparent); }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 14px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.pager .btns { display: flex; gap: 6px; }

/* ------------------------------------------------------------ tables (report, settings) */
.table-wrap { overflow-x: auto; margin-top: 10px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11px; line-height: 16px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--faint); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl th.r { text-align: right; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; height: 44px; }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl td .sub { display: block; color: var(--muted); font-size: 12px; line-height: 16px; }
.tbl .empty td { color: var(--muted); text-align: center; padding: 28px 10px; height: auto; }
.tbl input, .tbl select { min-height: 32px; padding: 4px 8px; font-size: 13px; }

/* ------------------------------------------------------------ dashboard, analytics, report */
.stack-lg { display: grid; gap: 20px; }
#report-body, #analytics-body, #dashboard-body { margin-top: 20px; }
.head-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg-label { font-size: 13px; color: var(--muted); }
.select-compact { width: auto; min-width: 150px; }

.filter-bar { display: flex; align-items: center; gap: 16px 24px; flex-wrap: wrap; padding: 14px 16px; }
.fb-fields { display: flex; gap: 12px; flex-wrap: wrap; margin-left: auto; }
.fb-f { display: grid; gap: 4px; margin: 0; }
.fb-f span { font-size: 11px; line-height: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); }
.fb-f input, .fb-f select { width: 168px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.seg button {
  font: 500 13px/20px var(--font-ui); color: var(--muted); background: transparent; border: 0; border-radius: 9px;
  padding: 7px 14px; min-height: 36px; cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--text); background: var(--hover); }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong), var(--elev-1); }
.seg button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.period-nav { display: flex; align-items: center; gap: 6px; }
.period-label { display: grid; min-width: 220px; text-align: center; line-height: 20px; }
.period-label b { font-size: 15px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.rp-export { display: flex; gap: 8px; }

/* KPI row: one focal tile, three supporting tiles */
.kpi-row { display: grid; grid-template-columns: 1.25fr repeat(3, minmax(0, 1fr)); padding: 0; overflow: hidden; }
.kpi-c { display: grid; align-content: start; gap: 4px; padding: 20px 22px; border-left: 1px solid var(--border); min-width: 0; }
.kpi-c:first-child { border-left: 0; }
.kpi-c .l { font-size: 13px; color: var(--muted); }
.kpi-c .v { font: 600 32px/40px var(--font-num); letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-c .s { font-size: 12px; line-height: 18px; color: var(--muted); }
.kpi-c.focal { background: linear-gradient(135deg, var(--accent-soft), transparent 75%); }
.kpi-c.focal .v { font-size: 42px; line-height: 50px; color: var(--accent); }
.kpi-c.focal.calm .v { color: var(--ok); }
.kpi-c .v-badge {
  display: inline-block; margin-left: 8px; padding: 1px 8px; vertical-align: middle; position: relative; top: -2px;
  font-size: 12px; line-height: 18px; font-weight: 600; border-radius: 999px;
  color: var(--accent); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.kpi-c .s.tone-ok { color: var(--ok); }
.kpi-c .s.tone-warn { color: var(--warn); }
.kpi-c .v.tone-ok { color: var(--ok); }
.kpi-c .v.tone-warn { color: var(--warn); }
.progress { height: 6px; border-radius: 3px; background: var(--tint); border: 1px solid var(--border); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ok); }

/* grids */
.grid-db { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: stretch; }
.grid-an { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: stretch; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-2.even { align-items: stretch; }
.span-2 { grid-column: span 2; }
/* A column holding two cards that together match the height of the wide card beside it. */
.col-stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.col-stack > .card:not(.fill-card) { flex: none; }
/* fill-card: takes the height the row gives it; its list scrolls inside instead of stretching the row. */
.fill-card { display: flex; flex-direction: column; min-height: 0; }
.col-stack > .fill-card { flex: 1 1 0; }
.fill-card .scroll-body { flex: none; max-height: 440px; overflow-y: auto; margin-right: -12px; padding-right: 12px; scrollbar-width: thin; }
/* Only while cards sit side by side: the list card takes the row height set by its neighbours. */
@media (min-width: 1101px) {
  .grid-db > .fill-card { contain: size layout; }
  .grid-db .fill-card .scroll-body { flex: 1 1 0; min-height: 120px; max-height: none; }
  /* In a column stack the list card keeps a real minimum height (header + about 4 rows) and its list
     scrolls inside. contain:size would let it collapse to 0 and its rows spill under the next card. */
  .col-stack > .fill-card { flex: 1 1 auto; min-height: 260px; max-height: 420px; overflow: hidden; }
  .col-stack .fill-card .scroll-body { flex: 1 1 0; min-height: 0; max-height: none; }
}
@media (min-width: 1361px) {
  .grid-an > .fill-card { contain: size layout; }
  .grid-an .fill-card .scroll-body { flex: 1 1 0; min-height: 120px; max-height: none; }
}
.fill-card .scroll-body .table-wrap { margin-top: 0; }
.fill-card .scroll-body {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  padding-bottom: 20px;
}
.heat-wrap { overflow-x: auto; }
.heat-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px 24px; flex-wrap: wrap; margin-top: 14px; }
.heat-scale { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.heat-scale i { display: block; width: 18px; height: 12px; border-radius: 3px; background: color-mix(in srgb, var(--accent) calc(var(--a) * 85% + 10%), transparent); }
.heat-scale i.z { background: var(--tint); box-shadow: inset 0 0 0 1px var(--border); }
.heat-scale span:last-child { margin-left: 4px; }
.card-head .small { text-align: right; }
.note { margin: 10px 0 0; }

/* empty state */
.empty-state { display: grid; gap: 4px; padding: 28px 8px; text-align: center; color: var(--muted); }
.empty-state b { color: var(--text); font-size: 15px; }
.empty-state span { max-width: 560px; justify-self: center; }

/* bar chart (SVG geometry, HTML labels) */
.chart { display: grid; grid-template-columns: 34px minmax(0, 1fr); grid-template-rows: var(--h) 22px; column-gap: 8px; }
.chart-y { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; font: 11px/1 var(--font-num); color: var(--faint); }
.chart-y span { transform: translateY(-50%); }
.chart-y span:last-child { transform: translateY(50%); }
.chart-plot { position: relative; min-width: 0; }
.chart-grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.chart-grid i { display: block; border-top: 1px dashed var(--border); }
.chart-grid i:last-child { border-top: 1px solid var(--border-strong); }
.chart-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.s-a { fill: var(--accent); background: var(--accent); }
.s-b { fill: #60a5fa; background: #60a5fa; }
[data-theme="light"] .s-b { fill: #2563eb; background: #2563eb; }
.chart-hit { position: absolute; top: 0; bottom: 0; display: none; background: var(--hover); border-radius: 6px; pointer-events: none; }
.chart-tip {
  position: absolute; top: 4px; transform: translateX(10px); z-index: 2; display: grid; gap: 2px; min-width: 150px;
  padding: 8px 12px; font-size: 12px; line-height: 18px; background: var(--raised); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--elev-2); pointer-events: none;
}
.chart-tip.flip { transform: translateX(calc(-100% - 10px)); }
.chart-tip span { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); }
.chart-tip span b { color: var(--text); }
.chart-x { position: relative; font: 11px/22px var(--font-num); color: var(--faint); }
.chart-x span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.legend { display: flex; gap: 18px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend.wrap { flex-wrap: wrap; gap: 8px 16px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ranked list */
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: rk; }
.rank li { counter-increment: rk; display: grid; gap: 5px; }
.rank-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.rank-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-label::before { content: counter(rk); display: inline-block; width: 22px; color: var(--faint); font: 12px var(--font-num); }
.rank-v { font-weight: 600; white-space: nowrap; }
.rank-sub { font-size: 12px; line-height: 16px; color: var(--muted); padding-left: 22px; }
.rank .bar { margin-left: 22px; }
.bar { height: 6px; background: var(--tint); border: 1px solid var(--border); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-row .bar { flex: 1; }
.bar-row span { width: 36px; text-align: right; color: var(--muted); }
.tbl td.barcol, .tbl th.barcol { width: 32%; }
.tbl-click tbody tr { cursor: pointer; }
.tbl-click tbody tr:focus-visible td { background: var(--hover); outline: none; }
.tbl td a { color: var(--accent); text-decoration: none; }
.tbl td a:hover { text-decoration: underline; }

/* aging + status split */
.aging { display: grid; gap: 10px; }
.ag { display: grid; grid-template-columns: 48px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 12px; align-items: center; }
.ag .v { grid-row: span 2; font: 600 24px/1 var(--font-num); text-align: right; }
.ag .l { font-size: 13px; color: var(--muted); }
.ag.stale .v, .ag.stale .l { color: var(--warn); }
.ag.stale .bar i { background: var(--warn); }
.status-split { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.stack-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--tint); margin-bottom: 12px; }
.stack-bar i { display: block; height: 100%; }
.tone-bg-muted { background: var(--faint); }
.tone-bg-accent { background: var(--accent); }
.tone-bg-ok { background: var(--ok); }
.tone-bg-warn { background: var(--warn); }
.tone-bg-down { background: var(--down); }

/* activity feed */
.feed { list-style: none; margin: 0; padding: 0; display: grid; }
.feed li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.feed li:last-child { border-bottom: 0; }
.feed-at { color: var(--faint); font-size: 12px; }
.feed-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.feed-txt { min-width: 0; overflow-wrap: anywhere; }
.feed-txt .muted { display: block; font-size: 12px; line-height: 16px; }
.feed-link:hover { text-decoration: underline; }

/* heatmap */
.heat { display: grid; grid-template-columns: 40px repeat(var(--cols), minmax(22px, 1fr)) 110px; gap: 3px; min-width: 620px; }
.heat .hx { font: 10px/16px var(--font-num); color: var(--faint); text-align: center; }
.heat .hx.tot { text-align: left; padding-left: 12px; font-family: var(--font-ui); font-size: 11px; }
.heat .hy { font-size: 12px; line-height: 26px; color: var(--muted); }
.heat i { display: block; height: 26px; border-radius: 4px; background: color-mix(in srgb, var(--accent) calc(var(--a) * 85% + 10%), transparent); }
.heat i.z { background: var(--tint); box-shadow: inset 0 0 0 1px var(--border); }
.heat .htot { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: center; gap: 8px; padding-left: 12px; font-size: 13px; }
.heat .htot .bar { min-width: 0; }

/* data quality */
.quality { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.quality > div { display: grid; gap: 2px; padding: 4px 20px; border-left: 1px solid var(--border); }
.quality > div:first-child { border-left: 0; padding-left: 0; }
.quality .v { font: 600 26px/34px var(--font-num); }
.quality .l { font-size: 13px; }
.quality .s { font-size: 12px; color: var(--muted); }

@media (max-width: 1360px) {
  .grid-an { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-an > .span-2, .grid-an > .fill-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-width: 1100px) {
  .grid-db, .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-c:nth-child(3) { border-left: 0; }
  .kpi-c:nth-child(n+3) { border-top: 1px solid var(--border); }
  .fb-fields { margin-left: 0; }
  .quality { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 16px; }
  .quality > div:nth-child(3) { border-left: 0; padding-left: 0; }
}
@media (max-width: 760px) {
  .grid-an { grid-template-columns: 1fr; }
  .heat { grid-template-columns: 34px repeat(var(--cols), 22px) 96px; min-width: 0; width: max-content; }
  .heat .htot { padding-left: 8px; grid-template-columns: 26px minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .kpi-c.focal { grid-column: 1 / -1; }
  .kpi-c:nth-child(2) { border-left: 0; }
  .kpi-c:nth-child(3) { border-left: 1px solid var(--border); }
  .kpi-c { padding: 14px 16px; }
  .kpi-c .v { font-size: 24px; line-height: 30px; }
  .kpi-c.focal .v { font-size: 34px; line-height: 40px; }
  .filter-bar { padding: 12px; gap: 12px; }
  .filter-bar .seg { width: 100%; }
  .filter-bar .seg button { flex: 1; padding: 7px 6px; }
  .fb-fields { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .fb-f input, .fb-f select { width: 100%; }
  .fb-fields .fb-f:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .period-nav { width: 100%; }
  .period-label { flex: 1; min-width: 0; }
  .rp-export { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .head-tools { width: 100%; }
  .select-compact { flex: 1; }
  .feed li { grid-template-columns: 1fr; gap: 0; }
  .quality { grid-template-columns: 1fr 1fr; }
  .chart { grid-template-columns: 26px minmax(0, 1fr); }
}

/* ------------------------------------------------------------ settings */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }

/* settings: one tab = one task. Panels use explicit column templates so cards line up. */
.settings-tabs {
  display: flex; gap: 4px; margin-bottom: 20px; padding: 4px; width: fit-content; max-width: 100%;
  overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.settings-tabs a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 16px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; transition: background .12s, color .12s;
}
.settings-tabs a:hover { color: var(--text); background: var(--hover); }
.settings-tabs a.active { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px rgba(45, 212, 191, .35); }
.set-panel { display: grid; gap: 24px; align-items: start; }
.set-akun { grid-template-columns: minmax(0, 1fr) 360px; }
.set-akun #set-password { position: sticky; top: 20px; }
.set-ref { grid-template-columns: 1fr; max-width: 1180px; }
.set-kanwil { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.set-master { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; max-width: 1180px; }
input[type="file"] { color: var(--muted); font-size: 13px; padding: 6px; }
input[type="file"]::file-selector-button {
  font: 500 13px var(--font-ui); color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 12px; margin-right: 12px; cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--raised); }
#master-meta dd { overflow-wrap: anywhere; }
.set-panel[hidden] { display: none; }
.card-note { color: var(--muted); font-size: 13px; line-height: 20px; margin: -4px 0 12px; max-width: 72ch; }
.tbl th.c, .tbl td.c { text-align: center; width: 72px; }
.tbl td.r { text-align: right; white-space: nowrap; width: 1%; }
.tbl td > input[type="checkbox"] { vertical-align: middle; }
.row-actions { display: inline-flex; gap: 4px; }
.tone-pick { display: flex; align-items: center; gap: 8px; }
.tone-pick select { min-width: 96px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: currentColor; }
.add-row {
  display: grid; gap: 8px; align-items: center; margin: 16px -20px -20px; padding: 16px 20px 20px;
  border-top: 1px solid var(--border); background: var(--tint); border-radius: 0 0 var(--r-card) var(--r-card);
}
.add-row .add-title { grid-column: 1 / -1; font-size: 12px; font-weight: 600; color: var(--muted); margin: 0; }
.add-row input, .add-row select { min-height: 38px; }
.add-row .btn { min-height: 38px; }
.add-user { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1.3fr) 100px auto; }
.add-cat { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; }
.add-status { grid-template-columns: minmax(0, 1fr) 110px auto auto; }
.add-kanwil { grid-template-columns: 90px minmax(0, 1fr) 90px auto; }
#set-master .kv { margin: 0; }
.job:empty { display: none; }
.job { margin-top: 12px; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--accent-soft); }
.stack label { margin-bottom: 6px; }
@media (max-width: 1360px) {
  .set-akun, .set-ref, .set-kanwil { grid-template-columns: 1fr; }
  .set-akun #set-password { max-width: 480px; position: static; }
}
@media (max-width: 900px) {
  .set-master { grid-template-columns: 1fr; }
  .add-user { grid-template-columns: 1fr 1fr; }
  .add-user .btn { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  /* settings tables become stacked rows: label above each value, no sideways scroll */
  .set-panel .tbl thead { display: none; }
  .set-panel .tbl, .set-panel .tbl tbody { display: block; }
  .set-panel .tbl tr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
  .set-panel .tbl td { display: block; border: 0; padding: 0; height: auto; width: auto; text-align: left; }
  .set-panel .tbl td.c { text-align: left; width: auto; }
  .set-panel .tbl td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; line-height: 14px; color: var(--faint); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
  .set-panel .tbl td.wide, .set-panel .tbl td.r { grid-column: 1 / -1; }
  /* first cell acts as the row heading; checkbox cells put their label inline to save height */
  .set-panel .tbl td:first-child.num { grid-column: 1 / -1; font-size: 14px; font-weight: 600; color: var(--text); }
  .set-panel .tbl td:first-child.num::before { display: none; }
  .set-panel .tbl td.c { display: flex; align-items: center; gap: 8px; min-height: 40px; }
  .set-panel .tbl td.c::before { order: 2; margin: 0 !important; font-size: 12px !important; }
  .set-panel .tbl td.c input { order: 1; }
  .set-panel .tbl tr { gap: 8px 12px; padding: 12px 0; }
  #set-users .tbl tr { grid-template-columns: minmax(0, 1.2fr) auto auto; align-items: end; }
  #set-users .tbl td:nth-child(2) { grid-column: 1 / -1; }
  .set-panel .tbl td.r .btn { width: 100%; }
  .set-panel .tbl tbody tr:hover td { background: none; }
  .set-panel .tbl input:not([type="checkbox"]), .set-panel .tbl select { min-height: 40px; }
  .row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .settings-tabs { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  body:not(.is-admin) .settings-tabs { grid-template-columns: 1fr 1fr; }
  .settings-tabs a { padding: 0 10px; justify-content: center; text-align: center; white-space: normal; line-height: 16px; font-size: 13px; }
  .add-row, .add-cat, .add-status, .add-kanwil, .add-user { grid-template-columns: 1fr 1fr; }
  .add-row input[name="keywords"], .add-row input[name="name"], .add-user input[name="password"], .add-row .btn { grid-column: 1 / -1; }
  .add-row { margin: 16px -16px -16px; padding: 14px 16px 16px; }
  .set-akun #set-password { max-width: none; }
}
.inline-add { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.inline-add input, .inline-add select { flex: 1 1 140px; width: auto; }
.chk { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--text); font-size: 13px; }
.stack { display: grid; gap: 10px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0 0 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--font-num); overflow-wrap: anywhere; }
body:not(.is-admin) .admin-only { display: none !important; }

/* ------------------------------------------------------------ dialog */
.dialog {
  width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: 0; box-shadow: var(--elev-2);
}
.dialog::backdrop { background: rgba(5, 10, 12, .65); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dialog-head h2 { font: 600 18px/26px var(--font-num); }
#dlg-body { padding: 20px; }
#dlg-body .ticket-form { margin-top: 0; }
.history { margin-top: 20px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 14px; }
.history ul { padding-left: 18px; margin: 6px 0 10px; }
.history li { margin-bottom: 2px; }
.raw { white-space: pre-wrap; font-family: var(--font-num); font-size: 12px; background: var(--canvas); border: 1px solid var(--border); border-radius: var(--r-ctl); padding: 12px; margin: 8px 0 0; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 16px; }

.toast {
  position: fixed; right: 24px; bottom: 24px; max-width: 420px; z-index: 50;
  background: var(--raised); border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 12px 16px; box-shadow: var(--elev-2); font-size: 13px;
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .16s, transform .16s;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { border-color: var(--down); }

/* ------------------------------------------------------------ responsive */
/* Ticket rows: layout by list pane width. */
@container tlist (max-width: 900px) {
  /* two lines: title + description, then IP and category; status on the right */
  .ticket-row {
    grid-template-columns: 58px minmax(0, 1fr) 136px; grid-template-areas: "id main status" "id where status";
    gap: 2px 12px; padding: 10px 8px;
  }
  .ticket-row .t-id { grid-area: id; align-self: start; }
  .ticket-row .t-main { grid-area: main; }
  .ticket-row .t-where { grid-area: where; display: flex; gap: 10px; align-items: baseline; min-width: 0; }
  .ticket-row .t-where .l { display: none; }
  .ticket-row .t-where .v { font-size: 12px; line-height: 16px; }
  .ticket-row .t-where .v.num { flex: none; }
  .ticket-row .t-who { display: none; }
  .ticket-row .t-status { grid-area: status; align-self: center; }
  .ticket-row .t-status select { width: 100%; }
}
@container tlist (max-width: 420px) {
  .ticket-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: none; gap: 6px 12px; padding: 12px 6px; }
  .ticket-row .t-id, .ticket-row .t-main, .ticket-row .t-where, .ticket-row .t-status { grid-area: auto; }
  .ticket-row .t-id { grid-column: 1; grid-row: 1; display: flex; gap: 8px; align-items: baseline; }
  .ticket-row .t-id span { display: inline; }
  .ticket-row .t-status { grid-column: 2; grid-row: 1; justify-self: end; }
  .ticket-row .t-main { grid-column: 1 / -1; }
  .ticket-row .t-where { grid-column: 1 / -1; display: flex; gap: 10px; align-items: baseline; }
  .ticket-row .t-where .l { display: none; }
  .ticket-row .t-who { display: none; }
}
@container tlist (max-width: 380px) {
  .list-filters, .flt-dates { grid-template-columns: 1fr 1fr; }
  .flt-toggle, .flt-dates .btn { grid-column: 1 / -1; }
  .flt-toggle > span { display: none; }
  .flt-toggle .btn { width: 100%; }
}
@media (max-width: 1100px) {
  .zone-grid { grid-template-columns: 1fr; }
  .col-stack > .fill-card { flex: none; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .mobile-bar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    padding: 8px 12px; background: var(--sidebar); border-bottom: 1px solid var(--border);
  }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 40; width: min(300px, 86vw);
    transform: translateX(-100%); transition: transform .2s ease-out; box-shadow: var(--elev-2);
  }
  .shell.nav-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(5, 10, 12, .6); }
  main { padding: 20px 16px 40px; }
  .page-head h1 { font-size: 24px; line-height: 32px; }
  .stat-strip { width: 100%; }
  .stat { flex: 1; min-width: 0; padding: 10px 12px; }
}
@media (max-width: 640px) {
  .card { padding: 16px; }
  .pane-foot { margin: 14px -16px -16px; padding: 12px 16px 14px; }
  .ticket-form { grid-template-columns: 1fr; }
  .ticket-row .t-desc { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .submit-row { flex-direction: column; align-items: stretch; }
  .kbd-hint { display: none; }
  .btn-sm { min-height: 40px; }
  .device { grid-template-columns: minmax(0, 1fr) auto auto; }
  .device .loc { grid-column: 1 / -1; grid-row: 2; }
  .toast { left: 16px; right: 16px; bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, .view { transition: none !important; animation: none !important; }
}

/* export buttons: busy state while the file is generated */
.export-btn[aria-busy="true"] { opacity: .7; pointer-events: none; }
.export-btn[aria-busy="true"]::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.login-notice { margin: 0 0 14px; padding: 10px 12px; border-radius: var(--r-ctl); font-size: 13px; line-height: 18px; background: var(--warn-soft); color: var(--text); border: 1px solid transparent; }
.login-notice:empty { display: none; }
