/* Job Issues — one stylesheet, light and dark.
   Theme: follows the device unless someone picks Light or Dark (html[data-theme]). */

/* ================================================================ tokens */
:root {
  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-2: #f3f3f5;
  --border: #e6e6e9;
  --border-strong: #d4d4d9;
  --text: #18181b;
  --text-2: #4f4f57;
  --text-3: #75757e;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eaf0fe;
  --on-accent: #ffffff;
  --danger: #c2410c;
  --danger-soft: #fff1e8;
  --urgent: #dc2626;
  --s-open: #d97706;     --s-open-soft: #fdf3e2;
  --s-recheck: #7c3aed;  --s-recheck-soft: #f2edfd;
  --s-closed: #15803d;   --s-closed-soft: #e8f6ed;
  --tier-low-bg: #f0f0f2;  --tier-low-fg: #4f4f57;  --tier-low-bd: #dcdce0;
  --tier-mid-bg: #fdeeee;  --tier-mid-fg: #9f1d1d;  --tier-mid-bd: #f3c6c6;
  --tier-high-bg: #f9d0d0; --tier-high-fg: #7f1414; --tier-high-bd: #eda3a3;
  --tier-fail-bg: #b91c1c; --tier-fail-fg: #ffffff; --tier-fail-bd: #b91c1c;
  --toast-bg: #18181b; --toast-fg: #ffffff; --toast-link: #93b4ff;
  --scrim: rgba(12, 12, 16, .36);
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 16, 24, .05);
  --shadow-lg: 0 16px 40px rgba(16, 16, 24, .16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1012; --surface: #17181b; --surface-2: #1f2024; --border: #292a2f; --border-strong: #3a3b42;
    --text: #ececef; --text-2: #b6b6be; --text-3: #8b8b94;
    --accent: #6b9bff; --accent-hover: #86adff; --accent-soft: #1b2640; --on-accent: #0b0d12;
    --danger: #fb923c; --danger-soft: #3a2416; --urgent: #f87171;
    --s-open: #f5a524; --s-open-soft: #33270f; --s-recheck: #a78bfa; --s-recheck-soft: #271f40; --s-closed: #4ade80; --s-closed-soft: #13301f;
    --tier-low-bg: #24252a; --tier-low-fg: #c3c3ca; --tier-low-bd: #3a3b42;
    --tier-mid-bg: #3a1d1f; --tier-mid-fg: #fca5a5; --tier-mid-bd: #5c2a2d;
    --tier-high-bg: #5a2125; --tier-high-fg: #fecaca; --tier-high-bd: #7f2a30;
    --tier-fail-bg: #dc2626; --tier-fail-fg: #ffffff; --tier-fail-bd: #dc2626;
    --toast-bg: #ececef; --toast-fg: #0f1012; --toast-link: #1d4ed8;
    --scrim: rgba(0, 0, 0, .55); --shadow: none; --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1012; --surface: #17181b; --surface-2: #1f2024; --border: #292a2f; --border-strong: #3a3b42;
  --text: #ececef; --text-2: #b6b6be; --text-3: #8b8b94;
  --accent: #6b9bff; --accent-hover: #86adff; --accent-soft: #1b2640; --on-accent: #0b0d12;
  --danger: #fb923c; --danger-soft: #3a2416; --urgent: #f87171;
  --s-open: #f5a524; --s-open-soft: #33270f; --s-recheck: #a78bfa; --s-recheck-soft: #271f40; --s-closed: #4ade80; --s-closed-soft: #13301f;
  --tier-low-bg: #24252a; --tier-low-fg: #c3c3ca; --tier-low-bd: #3a3b42;
  --tier-mid-bg: #3a1d1f; --tier-mid-fg: #fca5a5; --tier-mid-bd: #5c2a2d;
  --tier-high-bg: #5a2125; --tier-high-fg: #fecaca; --tier-high-bd: #7f2a30;
  --tier-fail-bg: #dc2626; --tier-fail-fg: #ffffff; --tier-fail-bd: #dc2626;
  --toast-bg: #ececef; --toast-fg: #0f1012; --toast-link: #1d4ed8;
  --scrim: rgba(0, 0, 0, .55); --shadow: none; --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ================================================================ base */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14.5px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.loading { display: grid; place-items: center; height: 100vh; color: var(--text-3); }
.hidden { display: none !important; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.contents { display: contents; }
.clickable { cursor: pointer; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
svg.i { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.prose { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.block-label { font-size: 12.5px; font-weight: 600; color: var(--text-3); margin: 0 0 6px; }
.block-label.sm { font-size: 12px; margin-bottom: 2px; }
.empty { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 20px 14px; text-align: center; color: var(--text-3); font-size: 13.5px; }
.tbl { overflow-x: auto; max-width: 100%; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }

/* ================================================================ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 13px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.success { background: var(--s-closed); border-color: var(--s-closed); color: var(--on-accent); }
.btn.danger { background: var(--urgent); border-color: var(--urgent); color: #fff; }
.btn.warn, .btn.danger-text { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.icon { padding: 0; width: 38px; }
.btn.big { min-height: 44px; padding: 0 16px; }
.btn.block { width: 100%; }
.btn.flagged { background: var(--s-open-soft); border-color: var(--s-open); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field > span em { font-style: normal; color: var(--urgent); }
.input, select.input, textarea.input {
  width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea.input { resize: vertical; min-height: 80px; line-height: 1.45; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input:disabled { background: var(--surface-2); color: var(--text-3); }
.input.compact, select.input.compact { min-height: 34px; height: 34px; padding: 4px 10px; width: auto; }
.input.static { display: flex; align-items: center; background: var(--surface-2); color: var(--text-2); }
.input.saved { border-color: var(--s-closed); box-shadow: 0 0 0 3px var(--s-closed-soft); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.check input { width: 17px; height: 17px; accent-color: var(--urgent); }
.check.plain input { accent-color: var(--accent); }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.switch input { width: 17px; height: 17px; accent-color: var(--s-closed); }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: 8px; font-size: 13.5px; }
.hint { font-size: 13px; color: var(--danger); background: var(--danger-soft); padding: 8px 10px; border-radius: 8px; }
.kbd-hint { font-size: 12px; }

.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; background: var(--surface); width: fit-content; }
.seg button { border: 0; background: none; padding: 7px 12px; font-weight: 600; cursor: pointer; color: var(--text-2); min-height: 36px; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--accent); color: var(--on-accent); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--text-2);
}
.chip .n { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip.on .n { color: inherit; }

.tabs { display: inline-flex; gap: 2px; background: var(--surface-2); border-radius: 9px; padding: 3px; }
.tabs.wrap { flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 5px 13px; border-radius: 7px; font-weight: 600; cursor: pointer; color: var(--text-3); }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow), 0 0 0 1px var(--border); }

/* ================================================================ tags & chips */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 5px; background: var(--surface-2); color: var(--text-2); }
.tag.urgent { background: var(--urgent); color: #fff; }
.tag.region { background: transparent; border: 1px solid var(--border); color: var(--text-3); }
.tag svg.i { width: 12px; height: 12px; }
.tag.rv { font-weight: 600; }
.rv-pending { background: var(--s-open-soft); color: var(--s-open); }
.rv-done { background: var(--surface-2); color: var(--text-2); }
.rv-fail { background: var(--tier-fail-bg); color: var(--tier-fail-fg); }
.rv-invalid { background: var(--surface-2); color: var(--text-3); text-decoration: line-through; }
.code-chip { display: inline-flex; align-items: center; font: 600 12px/1 var(--mono); padding: 4px 6px; border-radius: 5px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.code-chip.big { font-size: 13.5px; padding: 6px 8px; color: var(--text); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; padding: 3px 9px; border-radius: 999px; background: var(--cs); color: var(--c); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.st-open    { --c: var(--s-open);    --cs: var(--s-open-soft); }
.st-recheck { --c: var(--s-recheck); --cs: var(--s-recheck-soft); }
.st-closed  { --c: var(--s-closed);  --cs: var(--s-closed-soft); }
.lock-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.lock-tag svg.i { width: 13px; height: 13px; }
.edit-hint { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--accent); font-weight: 600; }
.edit-hint svg.i { width: 13px; height: 13px; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--urgent); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }

.td-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; padding: 4px 6px 4px 10px; border-radius: 7px; border: 1px solid var(--bd); background: var(--bg-c); color: var(--fg); white-space: nowrap; }
.td-chip b { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: rgba(0, 0, 0, .08); }
.tier-low  { --bg-c: var(--tier-low-bg);  --fg: var(--tier-low-fg);  --bd: var(--tier-low-bd); }
.tier-mid  { --bg-c: var(--tier-mid-bg);  --fg: var(--tier-mid-fg);  --bd: var(--tier-mid-bd); }
.tier-high { --bg-c: var(--tier-high-bg); --fg: var(--tier-high-fg); --bd: var(--tier-high-bd); }
.tier-fail { --bg-c: var(--tier-fail-bg); --fg: var(--tier-fail-fg); --bd: var(--tier-fail-bd); }
.td-chip.toggle { cursor: pointer; background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.td-chip.toggle b { background: var(--surface-2); color: var(--text-3); }
.td-chip.toggle.sug:not(.on) { border-color: var(--fg); border-style: dashed; }
.td-chip.toggle.on { background: var(--bg-c); color: var(--fg); border-color: var(--bd); }
.td-chip.toggle.on b { background: rgba(0, 0, 0, .1); color: inherit; }
.td-grid, .chips-inline { display: flex; flex-wrap: wrap; gap: 6px; }

/* ================================================================ sign-in */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login-card h1 { margin: 0; font-size: 20px; display: flex; align-items: center; gap: 10px; }
.login-card h1 img { width: 28px; height: 28px; }

/* ================================================================ top bar & menu */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand img { width: 24px; height: 24px; }
.search { position: relative; flex: 1; max-width: 440px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search input { width: 100%; height: 38px; padding: 0 12px 0 34px; border-radius: 8px; border: 1px solid transparent; background: var(--surface-2); outline: none; }
.search input::placeholder { color: var(--text-3); }
.search input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.spacer { flex: 1; }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-size: 12px; font-weight: 700; color: #fff; background: #71717a; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 10.5px; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu .who b { display: block; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: left; color: var(--text); }
.menu button:hover { background: var(--surface-2); }
.menu button svg.i { color: var(--text-3); }
.update-bar { position: sticky; top: 0; z-index: 25; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 7px 12px; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 13.5px; }

/* ================================================================ board */
.toolbar { display: flex; align-items: center; gap: 8px; padding: 14px 20px 4px; flex-wrap: wrap; }
.board { display: grid; gap: 20px; padding: 10px 20px 40px; align-items: start; }
.board.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.col { min-width: 0; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 2px 10px; font-weight: 600; font-size: 13.5px; color: var(--text-2); }
.col-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.col-head small { display: none; }
.col-head .count { margin-left: auto; font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.col-body { display: flex; flex-direction: column; gap: 8px; }

.card {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer; text-align: left; width: 100%;
  display: flex; flex-direction: column; gap: 5px; transition: border-color .12s, box-shadow .12s;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.card.active { border-color: var(--accent); }
.card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; row-gap: 4px; min-width: 0; }
.job { font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.card .name { color: var(--text-2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.card .addr { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.card .tags:empty { display: none; }
.card .desc { font-size: 13.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .foot { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-3); }
.card .foot:empty { display: none; }
.card .foot span { display: inline-flex; align-items: center; gap: 4px; }
.card .foot svg.i { width: 13px; height: 13px; }
.card .quick { position: absolute; right: 8px; bottom: 8px; opacity: 0; transition: opacity .12s; }
.card:hover .quick, .card:focus-within .quick { opacity: 1; }
@media (hover: none) { .card .quick { opacity: 1; } }
.quick .btn { min-height: 28px; height: 28px; padding: 0 9px; font-size: 12.5px; }
.quick .btn svg.i { width: 14px; height: 14px; }
.list { padding: 10px 20px 40px; display: flex; flex-direction: column; gap: 8px; max-width: 1100px; }
.list .card { flex-direction: row; align-items: center; gap: 14px; }
.list .card .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mobile-cols { display: none; }

/* timer: neutral → full red by 48 hours */
.timer {
  --heat: 0; margin-left: auto; font: 600 11.5px/1 var(--mono); padding: 4px 6px; border-radius: 5px; white-space: nowrap; color: var(--text-3);
  background: color-mix(in srgb, #dc2626 calc(var(--heat) * 100%), var(--surface-2));
}
.timer.hot { color: #fff; }
.timer.stopped { opacity: .7; }

/* ================================================================ card drawer */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 30; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(600px, 100vw); z-index: 31; background: var(--bg); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slide .18s ease-out; border-left: 1px solid var(--border); }
@keyframes slide { from { transform: translateX(24px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }
.d-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.d-head .title { flex: 1; min-width: 0; }
.d-head .title .job { font-size: 18px; }
.d-head .title .sub { font-size: 12.5px; color: var(--text-3); }
.d-body { flex: 1; overflow-y: auto; padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.info-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.info-box.editable { cursor: pointer; }
.info-box.editable:hover, .info-box.editable:focus-visible { border-color: var(--accent); outline: none; }
.info-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 5px 12px; margin: 0; font-size: 14px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.calc-report { display: flex; flex-direction: column; gap: 8px; }
.code-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crew-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crew-actions .btn { flex: 1; }
.flag-row, .history-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flag-row .muted svg.i { width: 14px; height: 14px; vertical-align: -2px; }

.thread { display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 10px; }
.msg .bubble { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; }
.msg.mine .bubble { background: var(--accent-soft); border-color: transparent; }
.msg .meta { font-size: 12.5px; color: var(--text-3); margin-bottom: 3px; }
.msg .meta b { color: var(--text); font-weight: 600; margin-right: 6px; }
.role { font-size: 11px; font-weight: 600; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); color: var(--text-3); margin-right: 6px; }

.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.att.img img { display: block; width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.att.file { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); text-decoration: none; color: var(--text); max-width: 100%; }
.att.file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.att.file small { color: var(--text-3); }

.composer { background: var(--surface); border-top: 1px solid var(--border); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.composer textarea.input { min-height: 60px; max-height: 40vh; }
.composer .row { gap: 8px; }
.composer .note { font-size: 12.5px; color: var(--text-3); }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; }
.pending-files:empty { display: none; }
.pfile { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; padding: 3px 4px 3px 8px; border-radius: 6px; background: var(--accent-soft); max-width: 100%; }
.pfile.uploading { opacity: .7; }
.pfile svg.i { width: 13px; height: 13px; }
.pfile .x { border: 0; background: none; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; color: var(--text-2); }

/* field metrics panel */
.metrics-panel { display: grid; gap: 12px; }
.rv-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.rv-head .block-label { margin: 0; }
.only-field { display: flex; align-items: center; gap: 4px; margin: 0; }
.only-field svg.i { width: 13px; height: 13px; }
.rv-row { display: grid; grid-template-columns: 86px 1fr; gap: 10px; align-items: center; }
.rv-row.top { align-items: start; }
.rv-lab { font-size: 13px; color: var(--text-3); padding-top: 2px; }
.rv-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--border); }
.rv-sum { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rv-sum code { font: 600 13.5px var(--mono); background: var(--surface-2); padding: 3px 8px; border-radius: 6px; overflow-wrap: anywhere; }

/* history */
ol.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
ol.history li { border-left: 2px solid var(--border-strong); padding: 2px 0 2px 12px; }
ol.history li.h-created { border-left-color: var(--accent); }
ol.history li.field-only { border-left-style: dashed; }
.h-head { margin-bottom: 6px; }
ol.history table { border-collapse: collapse; font-size: 13px; width: 100%; }
ol.history th, ol.history td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
ol.history td.before { color: var(--text-3); text-decoration: line-through; }
.snap-wrap summary { cursor: pointer; font-size: 13px; color: var(--accent); margin: 4px 0; }
table.snap th { width: 120px; color: var(--text-3); font-weight: 500; }

/* ================================================================ modals & forms */
.modal-wrap { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: var(--scrim); animation: fade .12s; }
.modal { width: 100%; max-width: 620px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 1040px; }
.modal-head { display: flex; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; }
.modal-body { padding: 18px 20px; display: grid; gap: 14px; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3c { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: end; }
.prefixed { display: flex; align-items: stretch; }
.prefixed .prefix { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--border-strong); border-right: 0; border-radius: 8px 0 0 8px; background: var(--surface-2); font-weight: 600; color: var(--text-2); }
.prefixed .input { border-radius: 0 8px 8px 0; min-width: 0; flex: 1; }
.sub-picker { position: relative; display: flex; flex-direction: column; gap: 6px; }
.sub-list { position: absolute; top: 44px; left: 0; right: 0; z-index: 5; max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow-lg); }
.sub-item { display: block; width: 100%; text-align: left; padding: 8px 12px; border: 0; background: none; cursor: pointer; border-bottom: 1px solid var(--border); }
.sub-item:hover, .sub-item:focus { background: var(--accent-soft); outline: none; }
.sub-item.not-listed { color: var(--accent); font-weight: 600; }
.sub-sections { display: flex; gap: 8px; }
.sub-sections .input { flex: 1; }
.code-builder { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px 14px; margin: 0; display: grid; grid-template-columns: auto 1fr 1fr; gap: 10px 14px; align-items: end; }
.code-builder legend { font-weight: 600; padding: 0 6px; font-size: 13.5px; }
.code-preview { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; min-height: 28px; }

/* tables (team, setup, reports) */
.users-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.users-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.users-table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.users-table tr.off td { opacity: .5; }
.users-table tr.on td, .users-table tr.clickable:hover td { background: var(--surface-2); }
.users-table input.input, .users-table select.input { min-height: 34px; padding: 5px 9px; }
.users-table input.input:disabled { background: transparent; border-color: transparent; color: var(--text); }
.users-table .w-code { width: 120px; }
.w-sec { width: 140px; }
.warn-text { color: var(--danger); font-size: 12.5px; }
.add-user, .add-row { background: var(--surface-2); border-radius: 10px; padding: 12px; }
.add-user { display: grid; gap: 12px; }
.add-user .grid { display: grid; grid-template-columns: repeat(5, 1fr) auto; gap: 8px; align-items: end; }
.add-row { display: grid; grid-template-columns: 1.2fr 1.6fr 1fr auto; gap: 8px; }
.region-picks { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.region-pick { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
.region-pick.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.region-pick input { display: none; }
.setup-pane { display: grid; gap: 14px; margin-top: 4px; }
.bulk { border: 1px dashed var(--border-strong); border-radius: 10px; padding: 10px 14px; }
.bulk summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.bulk[open] { display: grid; gap: 10px; }
.setting { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.setting input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--accent); }
.imp-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.imp-stat { padding: 8px 12px; border-radius: 8px; background: var(--surface-2); }
.imp-stat.good { background: var(--s-closed-soft); }
.imp-stat.warn { background: var(--s-open-soft); }
.import-out { display: grid; gap: 10px; }
.changelog h4 { display: flex; justify-content: space-between; margin: 14px 0 4px; }
.changelog h4 span { font-weight: 400; color: var(--text-3); font-size: 13px; }
.changelog ul { margin: 0; padding-left: 20px; color: var(--text-2); }

/* ================================================================ reports (Metrics, Calc report) */
.reports { padding: 6px 20px 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.reports > *, .report-grid > * { min-width: 0; }
.report-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.report-filters .range { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile.warn { border-color: var(--s-open); }
.tile.heat-tile { --heat: 0; background: color-mix(in srgb, #dc2626 calc(var(--heat) * 45%), var(--surface)); }
.tile-label { font-size: 12.5px; color: var(--text-3); }
.tile-value { font-size: 26px; font-weight: 700; line-height: 1.2; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--text-3); }
.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.report-card.wide { grid-column: 1 / -1; }
.report-card h3 { margin: 0 0 4px; font-size: 14.5px; font-weight: 600; }
.bars { display: grid; gap: 2px; margin-top: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr 90px; gap: 12px; align-items: center; padding: 5px 6px; border: 0; background: none; border-radius: 6px; text-align: left; width: 100%; color: var(--text); }
button.bar-row { cursor: pointer; }
button.bar-row:hover { background: var(--surface-2); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.bar-label b { font-weight: 600; }
.bar-track { height: 10px; display: block; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.bar-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; line-height: 1.2; }
.bar-value small { font-weight: 400; font-size: 11.5px; }
.cols-chart { display: flex; align-items: stretch; gap: 4px; height: 170px; margin-top: 12px; overflow-x: auto; }
.col-item { flex: 1; min-width: 26px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.col-val { font-size: 11.5px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.col-track { flex: 1; width: 100%; display: flex; align-items: flex-end; border-bottom: 1px solid var(--border); }
.col-fill { display: block; width: 100%; max-width: 26px; margin: 0 auto; background: var(--accent); border-radius: 4px 4px 0 0; }
.col-lab { font-size: 10.5px; color: var(--text-3); white-space: nowrap; }
.heat-pts { --heat: 0; font-weight: 600; background: color-mix(in srgb, #dc2626 calc(var(--heat) * 100%), transparent); }
.heat-pts.hot { color: #fff; }
.calc-cards { display: flex; flex-direction: column; gap: 8px; }
.calc-card { text-align: left; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.calc-card:hover { border-color: var(--border-strong); }
.calc-card .desc { overflow-wrap: anywhere; }

/* ================================================================ toasts */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: var(--toast-bg); color: var(--toast-fg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; font-size: 14px; animation: fade .15s; }
.toast.err { background: #9a3412; color: #fff; }
.toast button { background: none; border: 0; color: var(--toast-link); font-weight: 700; cursor: pointer; padding: 2px 4px; }

/* ================================================================ smaller screens */
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .topbar { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .brand span, .topbar .new-label { display: none; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
  .toolbar { padding: 10px 12px 4px; }
  .toolbar .chips { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .toolbar .chip { flex: none; }
  .toolbar .spacer { display: none; }
  .toolbar select.input.compact { width: 100%; }
  .board, .board.two { grid-template-columns: 1fr; padding: 6px 12px 40px; }
  .board .col { display: none; }
  .board .col.show { display: block; }
  .board .col-head { display: none; }
  .mobile-cols { display: flex; gap: 4px; margin: 6px 12px 0; padding: 3px; background: var(--surface-2); border-radius: 9px; }
  .mobile-cols button { flex: 1; border: 0; background: none; border-radius: 7px; padding: 7px 10px; font-weight: 600; font-size: 13px; color: var(--text-3); cursor: pointer; }
  .mobile-cols button.on { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
  .list { padding: 6px 12px 40px; }
  .grid-2, .grid-3c, .code-builder, .add-row { grid-template-columns: 1fr; }
  .add-user .grid { grid-template-columns: 1fr 1fr; }
  .users-table .hide-sm { display: none; }
  .d-body { padding: 14px 14px 20px; }
  .kv { grid-template-columns: 86px 1fr; }
  .reports { padding: 6px 12px 40px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: minmax(90px, 40%) 1fr 56px; gap: 8px; }
}
