:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #dfe2e7;
  --border-strong: #c5cad3;
  --text: #1d2330;
  --text-2: #5b6474;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --danger: #c92a2a;
  --shadow: 0 6px 24px rgba(20, 25, 40, .12);

  --st-blocked: #e03131;      --st-blocked-bg: #ffe3e3;      --st-blocked-fg: #a51d1d;
  --st-completable: #f08c00;  --st-completable-bg: #fff1d6;  --st-completable-fg: #8a5100;
  --st-shippable: #2f9e44;    --st-shippable-bg: #dcf5e1;    --st-shippable-fg: #1d6b2e;
  --st-progress: #1c7ed6;     --st-progress-bg: #dbeafe;     --st-progress-fg: #12579a;
  --empty-bg: transparent;

  --col-w: 128px;
  --col-collapsed: 22px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161b; --surface: #1c1f26; --surface-2: #22262e; --border: #2e333d; --border-strong: #3d4350;
    --text: #e6e8ec; --text-2: #9aa2b1; --accent: #5c7cfa; --shadow: 0 6px 24px rgba(0,0,0,.5);
    --st-blocked-bg: #4a1f22;     --st-blocked-fg: #ffb3b3;
    --st-completable-bg: #4a3512; --st-completable-fg: #ffd28a;
    --st-shippable-bg: #183d24;   --st-shippable-fg: #9be3ad;
    --st-progress-bg: #15324f;    --st-progress-fg: #9dccff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161b; --surface: #1c1f26; --surface-2: #22262e; --border: #2e333d; --border-strong: #3d4350;
  --text: #e6e8ec; --text-2: #9aa2b1; --accent: #5c7cfa; --shadow: 0 6px 24px rgba(0,0,0,.5);
  --st-blocked-bg: #4a1f22;     --st-blocked-fg: #ffb3b3;
  --st-completable-bg: #4a3512; --st-completable-fg: #ffd28a;
  --st-shippable-bg: #183d24;   --st-shippable-fg: #9be3ad;
  --st-progress-bg: #15324f;    --st-progress-fg: #9dccff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-wrap { display: inline-flex; }
.btn-wrap > .btn:disabled { pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.icon-btn { border: 0; background: transparent; color: var(--text-2); cursor: pointer; font-size: 15px; padding: 4px 6px; border-radius: 4px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 6px 8px; min-height: 32px;
}
textarea { resize: vertical; min-height: 60px; }
input[type=checkbox] { min-height: auto; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); min-width: 0; }
.field > input, .field > select, .field > textarea { font-size: 14px; color: var(--text); width: 100%; min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* minmax(0, 1fr): long content (e.g. a select with long options) shrinks instead of widening the dialog */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }

/* ---------- shell ---------- */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 48px; flex: none;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 22px; height: 22px; flex: none; display: inline-block; vertical-align: middle; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; align-self: stretch; }
.tab {
  display: flex; align-items: center; padding: 0 14px; border: 0; background: transparent; color: var(--text-2);
  font: inherit; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.user-menu { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); min-width: 200px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 4px; z-index: 50;
}
.menu button, .menu a {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: transparent; color: var(--text);
  font: inherit; cursor: pointer; border-radius: 4px; text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

.subbar {
  display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 44px; flex: none;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.toolbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px; flex: none; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.toolbar select, .toolbar input { height: 30px; min-height: 30px; padding: 2px 8px; }
.toolbar .sep { width: 1px; align-self: stretch; background: var(--border); }

.workspace { flex: 1; display: flex; min-height: 0; overflow: hidden; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.empty-state { margin: 60px auto; text-align: center; max-width: 420px; color: var(--text-2); }
.empty-state h2 { color: var(--text); margin-bottom: 8px; }

/* ---------- matrix ---------- */
.matrix-wrap { flex: 1; overflow: auto; position: relative; }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.matrix th, .matrix td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 0; }
.matrix thead th { position: sticky; background: var(--surface); z-index: 2; font-weight: 600; text-align: left; }
.matrix thead tr.groups th { top: 0; height: 28px; }
.matrix thead tr.builds th { top: var(--hdr-top, 0px); }
.matrix .qcol { position: sticky; background: var(--surface); z-index: 1; }
.matrix thead .qcol { z-index: 3; }
.matrix td.qcol { padding: 6px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.matrix .q-code { left: 0; width: 90px; min-width: 90px; max-width: 90px; font-family: Consolas, monospace; text-align: center; }
/* Name column width is adjustable (--qname-w, set by dragging its header edge); the columns after it shift with it */
.matrix .q-name { left: 90px; width: var(--qname-w, 220px); min-width: var(--qname-w, 220px); max-width: var(--qname-w, 220px); }
.matrix .q-ld { left: calc(90px + var(--qname-w, 220px)); width: 120px; min-width: 120px; max-width: 120px; text-align: center; }
.matrix .q-nd { left: calc(210px + var(--qname-w, 220px)); width: 120px; min-width: 120px; max-width: 120px; text-align: center; }
.matrix .q-qa { left: calc(330px + var(--qname-w, 220px)); width: 120px; min-width: 120px; max-width: 120px; text-align: center; }
.matrix .q-vid { left: calc(450px + var(--qname-w, 220px)); width: 104px; min-width: 104px; max-width: 104px; text-align: center; box-shadow: 2px 0 0 var(--border-strong); }
.matrix.compact .q-name { box-shadow: 2px 0 0 var(--border-strong); }
.matrix .col-resize { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; touch-action: none; }
.matrix .col-resize:hover, body.col-resizing .matrix .col-resize { background: linear-gradient(to right, transparent 4px, var(--accent) 4px); }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none; }
.matrix.compact .q-ld, .matrix.compact .q-nd, .matrix.compact .q-qa, .matrix.compact .q-vid { display: none; }
.matrix thead th.qcol { padding: 6px 8px; vertical-align: bottom; text-align: center; color: var(--text-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .02em; }
.matrix tbody tr:hover td.qcol { background: var(--surface-2); }

.group-hdr { padding: 4px 8px !important; cursor: pointer; user-select: none; white-space: nowrap; color: var(--text-2); font-size: 11.5px; background: var(--surface-2) !important; }
.group-hdr:hover { color: var(--text); }
.build-hdr { width: var(--col-w); min-width: var(--col-w); max-width: var(--col-w); padding: 6px 8px !important; vertical-align: top; cursor: pointer; }
.build-hdr:hover { background: var(--surface-2) !important; }
.build-hdr .bnum { font-family: Consolas, monospace; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.build-hdr .bdate { color: var(--text-2); font-weight: 400; font-size: 11px; }
.build-hdr .bbranch { color: var(--text-2); font-weight: 400; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.build-hdr.collapsed, td.cell.collapsed { width: var(--col-collapsed); min-width: var(--col-collapsed); max-width: var(--col-collapsed); }
/* Collapsed build: short name + date written horizontally; the column is as wide as that text (width: 1px = shrink to content) */
.build-hdr.collapsed, td.cell.collapsed { width: 1px; max-width: none; }
.build-hdr.collapsed { padding: 6px 5px !important; text-align: center; }
.build-hdr.collapsed .cname { font-family: Consolas, monospace; font-size: 11px; white-space: nowrap; }
.build-hdr.collapsed .cdate { color: var(--text-2); font-weight: 400; font-size: 10.5px; white-space: nowrap; }
.build-hdr.group-summary { background: var(--surface-2) !important; }
/* Build IDs */
.build-hdr.needs-fix { background: repeating-linear-gradient(135deg, var(--st-blocked-bg) 0 6px, transparent 6px 12px) !important; }
.build-hdr.needs-fix .bnum { color: var(--st-blocked-fg); font-family: inherit; font-weight: 700; }
.build-hdr.needs-fix .bbranch { font-family: Consolas, monospace; }
.danger-text { color: var(--danger); }
.ok-text { color: var(--st-shippable-fg); }
.unlinked { font-size: 11px; color: var(--st-completable-fg); white-space: nowrap; margin-left: 4px; cursor: help; }
.build-menu-head { padding: 6px 10px; max-width: 320px; overflow-wrap: anywhere; }
.build-raw { font-size: 11px; overflow-wrap: anywhere; }
.menu button.danger-text { color: var(--danger); }
/* Build header menu: the two main actions stand out (same colours as the Start test run button / global bug icon) */
.menu button.menu-run, .menu button.menu-gbug { margin: 3px 0; border-radius: 6px; font-weight: 600; color: #fff; }
.menu button.menu-run { background: var(--accent); color: var(--accent-text); }
.menu button.menu-gbug { background: var(--danger); }
.menu button.menu-run:hover, .menu button.menu-gbug:hover { filter: brightness(1.1); }
.menu button.menu-run:hover { background: var(--accent); }
.menu button.menu-gbug:hover { background: var(--danger); }
.new-build { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: 8px; background: var(--surface-2); }
.new-build input { font-family: Consolas, monospace; }
.build-preview { min-height: 18px; overflow-wrap: anywhere; }

/* Global bugs: warning on the build header + hover list */
.build-hdr .bnum-row { display: flex; align-items: center; gap: 4px; }
.build-hdr .bnum-row .bnum { flex: 1; min-width: 0; }
.build-hdr.has-gb { box-shadow: inset 0 3px 0 var(--st-blocked); }
.gb-icon { flex: none; display: inline-flex; align-items: center; gap: 1px; padding: 0 4px; border-radius: 4px; cursor: help;
  font-size: 12px; line-height: 18px; color: var(--st-blocked-fg); background: var(--st-blocked-bg); }
.gb-dialog-list { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.gb-icon .gb-count { font-size: 10.5px; font-weight: 700; }
.build-hdr.collapsed .gb-icon { padding: 0; margin: 0 0 4px; justify-content: center; width: 100%; }
.gb-tip { width: 340px; max-width: calc(100vw - 32px); display: flex; flex-direction: column; gap: 8px; }
.gb-tip h4 { margin: 0; }
.gb-item { display: flex; flex-direction: column; gap: 2px; }
.gb-comment { overflow-wrap: anywhere; }
.gb-tip > .btn { align-self: flex-start; }

td.cell { width: var(--col-w); min-width: var(--col-w); max-width: var(--col-w); height: 46px; vertical-align: middle; cursor: default; }
td.cell.has { cursor: pointer; }
td.cell .c {
  position: relative; height: 100%; min-height: 45px; padding: 4px 6px 4px 8px; display: flex; flex-direction: column; justify-content: center; gap: 1px;
  border-left: 3px solid transparent;
}
td.cell.collapsed .c { padding: 0; border-left: 0; }
.c .c-status { display: flex; align-items: center; gap: 5px; font-weight: 600; font-size: 12px; }
.c .c-who { font-size: 11px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c .c-tags { display: flex; gap: 3px; flex-wrap: nowrap; overflow: hidden; }
.c .c-more { position: absolute; top: 3px; right: 4px; font-size: 10px; font-weight: 700; opacity: .8; }
.c .c-bugs { position: absolute; bottom: 3px; right: 4px; font-size: 10px; opacity: .85; }
.st-icon { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; cursor: help; border: 2px solid currentColor; }
.st-blocked .st-icon { background: var(--st-blocked); border-color: var(--st-blocked); }
.st-completable .st-icon { background: var(--st-completable); border-color: var(--st-completable); }
.st-shippable .st-icon { background: var(--st-shippable); border-color: var(--st-shippable); }
.st-progress .st-icon { background: transparent; border-color: var(--st-progress); border-style: dashed; animation: spin 4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.c.st-blocked { background: var(--st-blocked-bg); color: var(--st-blocked-fg); border-left-color: var(--st-blocked); }
.c.st-completable { background: var(--st-completable-bg); color: var(--st-completable-fg); border-left-color: var(--st-completable); }
.c.st-shippable { background: var(--st-shippable-bg); color: var(--st-shippable-fg); border-left-color: var(--st-shippable); }
.c.st-progress { background: var(--st-progress-bg); color: var(--st-progress-fg); border-left-color: var(--st-progress); }
td.cell.collapsed .c.st-blocked { background: var(--st-blocked); }
td.cell.collapsed .c.st-completable { background: var(--st-completable); }
td.cell.collapsed .c.st-shippable { background: var(--st-shippable); }
td.cell.collapsed .c.st-progress { background: var(--st-progress); }
td.cell.selected .c { outline: 2px solid var(--accent); outline-offset: -2px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; height: 18px; border-radius: 9px;
  font-size: 10.5px; font-weight: 600; background: rgba(127,127,127,.18); white-space: nowrap;
}
.chip-x { cursor: pointer; opacity: .7; }
.chip-x:hover { opacity: 1; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.pill.st-blocked { background: var(--st-blocked-bg); color: var(--st-blocked-fg); }
.pill.st-completable { background: var(--st-completable-bg); color: var(--st-completable-fg); }
.pill.st-shippable { background: var(--st-shippable-bg); color: var(--st-shippable-fg); }
.pill.st-progress { background: var(--st-progress-bg); color: var(--st-progress-fg); }

.legend { display: flex; gap: 12px; align-items: center; font-size: 12px; color: var(--text-2); }
.legend span.pill { cursor: help; }

/* ---------- tooltip ---------- */
.tip {
  position: fixed; z-index: 100; max-width: 360px; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow); padding: 10px 12px; font-size: 12.5px; line-height: 1.45;
}
.tip h4 { margin: 0 0 6px; font-size: 13px; }
.tip .tip-item { padding: 6px 0; border-top: 1px solid var(--border); }
.tip .tip-item:first-of-type { border-top: 0; padding-top: 0; }
.tip ul { margin: 4px 0 0; padding-left: 16px; }
.tip .help { max-width: 300px; }

/* ---------- side panel ---------- */
.panel {
  width: 420px; flex: none; border-left: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; min-height: 0;
}
.panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 14px; }
.panel-body > * { flex: none; }
.run-card { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.run-card.focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.run-card > header { padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.run-card .run-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.run-card .run-meta { font-size: 12px; color: var(--text-2); }
.run-card .run-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.qrow { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.qrow:last-child { border-bottom: 0; }
.qrow.focus { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.qrow .qtitle { display: flex; gap: 8px; align-items: baseline; }
.qrow .qtitle code { font-size: 12px; color: var(--text-2); }
.qrow .qtitle span { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-select { font-weight: 600; border-left-width: 4px; }
.status-select.st-blocked { border-left-color: var(--st-blocked); background: var(--st-blocked-bg); color: var(--st-blocked-fg); }
.status-select.st-completable { border-left-color: var(--st-completable); background: var(--st-completable-bg); color: var(--st-completable-fg); }
.status-select.st-shippable { border-left-color: var(--st-shippable); background: var(--st-shippable-bg); color: var(--st-shippable-fg); }
.status-select.st-progress { border-left-color: var(--st-progress); background: var(--st-progress-bg); color: var(--st-progress-fg); }
.jira-list { display: flex; flex-wrap: wrap; gap: 4px; }
.jira-list .chip { background: var(--surface-2); border: 1px solid var(--border); height: 22px; font-size: 11.5px; }
.jira-list .chip a { text-decoration: none; }
.jira-add { display: flex; gap: 6px; }
.jira-add input { flex: 1; height: 28px; min-height: 28px; font-size: 12.5px; }
.qrow .who { font-size: 11.5px; color: var(--text-2); }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 18, .45); display: flex; align-items: flex-start; justify-content: center; z-index: 80; padding: 6vh 16px; overflow: auto; }
.modal { width: 100%; max-width: 480px; background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: 88vh; }
.modal-wide { max-width: 760px; }
.modal > header { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal > header h2 { flex: 1; }
.modal-body { padding: 16px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.modal-error { margin: 0 16px 12px; padding: 8px 10px; background: var(--st-blocked-bg); color: var(--st-blocked-fg); border-radius: 6px; font-size: 13px; }
.quest-pick { border: 1px solid var(--border); border-radius: 6px; max-height: 300px; overflow: auto; }
.quest-pick label { display: grid; grid-template-columns: 20px 90px 1fr auto; gap: 8px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--border); cursor: pointer; }
.quest-pick label:last-child { border-bottom: 0; }
.quest-pick label:hover { background: var(--surface-2); }
.quest-pick code { font-size: 12px; }
.tag-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pick label { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: 16px; cursor: pointer; }
.tag-pick label:has(input:checked) { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tag-pick input { display: none; }
.section-title { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
pre.code, textarea.code { font-family: Consolas, monospace; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px; white-space: pre-wrap; word-break: break-all; margin: 0; }

/* ---------- admin / settings pages ---------- */
.page { flex: 1; overflow: auto; padding: 20px 24px; }
.page-inner { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; align-items: center; gap: 12px; }
.page-head h1 { font-size: 20px; flex: 1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.card > header { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card > header h2 { flex: 1; }
.card-body { padding: 16px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; color: var(--text-2); font-weight: 600; font-size: 12px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
table.data td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.archived td { opacity: .5; }
table.data td.actions { text-align: right; white-space: nowrap; }
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.subtabs .tab { padding: 10px 14px; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--st-progress-bg); color: var(--st-progress-fg); font-size: 13px; }
.notice.warn { background: var(--st-completable-bg); color: var(--st-completable-fg); }

/* ---------- login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-box { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login-box h1 { font-size: 20px; display: flex; align-items: center; gap: 10px; }
.idp-btn { justify-content: center; height: 38px; width: 100%; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { padding: 10px 16px; border-radius: 8px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-size: 13px; transition: opacity .4s; }
.toast-error { background: var(--danger); color: #fff; }
.toast.hide { opacity: 0; }

@media (max-width: 900px) {
  .panel { position: fixed; right: 0; top: 0; bottom: 0; width: min(420px, 100vw); z-index: 60; box-shadow: var(--shadow); }
  .matrix .q-ld, .matrix .q-nd, .matrix .q-qa, .matrix .q-vid { display: none; }
  .matrix .q-name { width: 150px; min-width: 150px; max-width: 150px; box-shadow: 2px 0 0 var(--border-strong); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Jira bug summaries ---------- */
.jira-sum { color: var(--text-2); }

/* ---------- quest links & video column ---------- */
/* Quest tags (Base, DLC, …) */
.matrix .q-name-in { display: flex; align-items: center; gap: 4px; min-width: 0; }
.matrix .q-name-text { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qtag { flex: none; display: inline-block; padding: 0 5px; border-radius: 4px; font-size: 10.5px; font-weight: 700; line-height: 16px;
  letter-spacing: .02em; white-space: nowrap; border: 1px solid transparent; }
.qtag-blue   { color: #1c5fb8; background: #dbeafe; border-color: #bcd6fb; }
.qtag-green  { color: #1d6b2e; background: #dcf5e1; border-color: #b8e6c3; }
.qtag-amber  { color: #8a5100; background: #fff1d6; border-color: #fbdca0; }
.qtag-red    { color: #a51d1d; background: #ffe3e3; border-color: #fbc2c2; }
.qtag-violet { color: #6b2fb3; background: #efe4ff; border-color: #dcc7fb; }
.qtag-teal   { color: #0b6b66; background: #d6f5f2; border-color: #aee6e0; }
.qtag-gray   { color: #4a5160; background: #eceef2; border-color: #d6d9df; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .qtag { filter: none; }
  :root:not([data-theme="light"]) .qtag-blue   { color: #a9cbff; background: #18304f; border-color: #24456f; }
  :root:not([data-theme="light"]) .qtag-green  { color: #9be3ad; background: #183d24; border-color: #235634; }
  :root:not([data-theme="light"]) .qtag-amber  { color: #ffd28a; background: #4a3512; border-color: #65491a; }
  :root:not([data-theme="light"]) .qtag-red    { color: #ffb3b3; background: #4a1f22; border-color: #662a2e; }
  :root:not([data-theme="light"]) .qtag-violet { color: #d4b8ff; background: #33204f; border-color: #472d6e; }
  :root:not([data-theme="light"]) .qtag-teal   { color: #8ee6dd; background: #133b39; border-color: #1c5552; }
  :root:not([data-theme="light"]) .qtag-gray   { color: #c3c8d1; background: #2a2e36; border-color: #3a3f4a; } }
:root[data-theme="dark"] .qtag-blue   { color: #a9cbff; background: #18304f; border-color: #24456f; }
:root[data-theme="dark"] .qtag-green  { color: #9be3ad; background: #183d24; border-color: #235634; }
:root[data-theme="dark"] .qtag-amber  { color: #ffd28a; background: #4a3512; border-color: #65491a; }
:root[data-theme="dark"] .qtag-red    { color: #ffb3b3; background: #4a1f22; border-color: #662a2e; }
:root[data-theme="dark"] .qtag-violet { color: #d4b8ff; background: #33204f; border-color: #472d6e; }
:root[data-theme="dark"] .qtag-teal   { color: #8ee6dd; background: #133b39; border-color: #1c5552; }
:root[data-theme="dark"] .qtag-gray   { color: #c3c8d1; background: #2a2e36; border-color: #3a3f4a; }
.qtag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.qtag-pick { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.qtag-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.qtag-row:first-child { border-top: 0; }
.qtag-row .qtag-name { flex: 1; }
.matrix a.q-link { color: inherit; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.matrix a.q-link:hover { color: var(--accent); text-decoration-color: currentColor; }
.matrix .vid { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 4px; }
.matrix .vid-link { font-size: 14px; text-decoration: none; }
.matrix .vid-date { font-size: 11px; color: var(--text-2); white-space: nowrap; }
.matrix .vid-edit { opacity: .45; font-size: 13px; padding: 0 3px; }
.matrix tr:hover .vid-edit, .matrix .vid-edit:focus { opacity: 1; }

/* ---------- cell pop-up (opens on click) ---------- */
.cell-pop { max-width: 420px; max-height: calc(100vh - 16px); overflow: auto; z-index: 90; }
.cell-pop .pop-head { display: flex; align-items: flex-start; gap: 8px; }
.cell-pop .pop-head h4 { flex: 1; }
.matrix td.cell.pop-open { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- bug IDs with summaries ---------- */
.bug-list { margin: 4px 0 0; padding-left: 16px; }
.bug-list li { margin: 2px 0; }
.bug-link { text-decoration: none; }
.bug-link b { font-weight: 600; }
.bug-link:hover b { text-decoration: underline; }
.jira-sum { color: var(--text); font-weight: 400; }
.jira-list { display: flex; flex-direction: column; gap: 4px; }
.bug-row { display: flex; align-items: flex-start; gap: 6px; font-size: 12.5px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
.bug-row .bug-link { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.jira-dialog-list { max-height: 260px; overflow: auto; }
