/* Bug tracker UI.
   Colour is data here, not decoration: the chrome stays desaturated graphite so
   that priority, platform state and regression flags are the only things that
   carry hue. Monospace is used wherever the content is an identifier a person
   will read digit by digit - issue keys, build labels, changelists, stacks. */

:root {
  --bg: #14161a;
  --surface: #1b1e24;
  --raised: #22262e;
  --raised-2: #2a2f38;
  --line: #2e333d;
  --line-soft: #262a32;
  --text: #dfe3ea;
  --text-dim: #a4acbb;
  --muted: #7f889a;
  --accent: #4d9fff;
  --accent-dim: #2b5f9e;

  --blocker: #ff4d5e;
  --high: #ff8c3b;
  --medium: #ffc93b;
  --low: #6fd08c;
  --trivial: #6f7787;
  --regression: #c46bff;
  --verified: #3ddc97;
  --cert: #ff4d5e;

  --radius: 4px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f3f6;
    --surface: #ffffff;
    --raised: #f7f8fa;
    --raised-2: #eceef2;
    --line: #d6dae2;
    --line-soft: #e4e7ed;
    --text: #1a1d23;
    --text-dim: #454b57;
    --muted: #6b7280;
    --accent: #1f6feb;
    --accent-dim: #a9c7f5;
    --trivial: #8b93a3;
  }
}

/* Every size below is in rem, so the root font size is the single dial that
   scales the whole interface. People read this all day; some want it denser,
   some want it bigger, and screens vary. */
html { font-size: 16px; }
html[data-text="compact"] { font-size: 15px; }
html[data-text="large"]   { font-size: 17.5px; }
html[data-text="xlarge"]  { font-size: 19px; }

* { box-sizing: border-box; }

/* The user-agent [hidden] rule loses to any author display declaration, so an
   element like the bulk action bar (display:flex) would never actually hide.
   State this once, with force, rather than per component. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 0.95rem/1.6 var(--sans);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }

code, kbd, pre, .mono { font-family: var(--mono); }

pre.code, pre {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .7rem .8rem;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.5;
}
code { background: var(--raised); padding: .1em .35em; border-radius: 3px; font-size: .92em; }
pre code { background: none; padding: 0; }

blockquote {
  margin: .5rem 0;
  padding-left: .8rem;
  border-left: 2px solid var(--line);
  color: var(--text-dim);
}

/* ---------- layout ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  height: 46px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .45rem;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .dot {
  width: 9px; height: 9px; border-radius: 2px;
  background: var(--blocker);
  box-shadow: 0 0 0 3px rgba(255,77,94,.15);
}

.topnav { display: flex; gap: .15rem; align-items: center; flex: 1; min-width: 0; overflow-x: auto; }
.topnav a {
  color: var(--text-dim);
  padding: .3rem .6rem;
  border-radius: var(--radius);
  white-space: nowrap;
}
.topnav a:hover { background: var(--raised); color: var(--text); text-decoration: none; }
.topnav a.on { background: var(--raised-2); color: var(--text); }

.topright { display: flex; align-items: center; gap: .5rem; margin-left: auto; }

.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--raised-2);
  color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center;
  font: 600 0.76rem var(--sans);
  border: 1px solid var(--line);
}

.bell { position: relative; color: var(--text-dim); padding: .3rem .5rem; }
.bell .count {
  position: absolute; top: -1px; right: -2px;
  background: var(--blocker); color: #fff;
  font: 700 0.7rem var(--mono);
  border-radius: 8px; padding: 1px 4px;
}

.wrap { max-width: 1440px; margin: 0 auto; padding: 1rem; }
.wrap.narrow { max-width: 720px; }

.page-head {
  display: flex; align-items: flex-start; gap: 1rem;
  flex-wrap: wrap; margin-bottom: .9rem;
}
.page-head .spacer { flex: 1; }

.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.side { grid-template-columns: minmax(0,1fr) 19rem; }
.grid.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) {
  .grid.two, .grid.side, .grid.four { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .85rem;
}
.card > h2, .card > h3 { margin-top: 0; }
.card-head {
  display: flex; align-items: center; gap: .5rem;
  margin: -.85rem -.85rem .7rem;
  padding: .55rem .85rem;
  border-bottom: 1px solid var(--line-soft);
  background: var(--raised);
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 600;
}
.card-head .spacer { flex: 1; }

.muted { color: var(--muted); }
.dim { color: var(--text-dim); }
.small { font-size: 0.86rem; }
.tiny { font-size: 0.8rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.mt { margin-top: .8rem; }
.mb { margin-bottom: .8rem; }

/* ---------- controls ---------- */

input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=url], input[type=search], select, textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .45rem .55rem;
  font: inherit;
  width: 100%;
  min-width: 0;
}
textarea { resize: vertical; min-height: 90px; font-family: var(--mono); font-size: 0.89rem; }
select { appearance: none; padding-right: 1.6rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right .7rem center, right .45rem center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }

label { display: block; font-size: 0.83rem; color: var(--muted); margin-bottom: .18rem;
  text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.field { margin-bottom: .7rem; }
.check { display: flex; align-items: center; gap: .4rem; }
.check label { margin: 0; text-transform: none; letter-spacing: 0; font-size: 0.92rem;
  color: var(--text-dim); font-weight: 400; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); margin: 0; }

.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--raised-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .45rem .8rem;
  font: 500 0.92rem var(--sans);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--line); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--blocker); border-color: #4a2a30; }
.btn.danger:hover { background: var(--blocker); color: #fff; border-color: var(--blocker); }
.btn.sm { padding: .2rem .45rem; font-size: 0.86rem; }
.btn.ghost { background: none; }

.inline-form { display: inline; }

/* ---------- badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font: 600 0.76rem/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .25rem .4rem;
  border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  background: var(--raised);
  white-space: nowrap;
}
.badge .swatch { width: 6px; height: 6px; border-radius: 1px; background: currentColor; }

.p-blocker { color: var(--blocker); border-color: color-mix(in srgb, var(--blocker) 40%, transparent); }
.p-high    { color: var(--high);    border-color: color-mix(in srgb, var(--high) 40%, transparent); }
.p-medium  { color: var(--medium);  border-color: color-mix(in srgb, var(--medium) 40%, transparent); }
.p-low     { color: var(--low);     border-color: color-mix(in srgb, var(--low) 40%, transparent); }
.p-trivial { color: var(--trivial); }

.b-regression { color: var(--regression); border-color: color-mix(in srgb, var(--regression) 45%, transparent); }
.b-cert       { color: var(--cert); border-color: color-mix(in srgb, var(--cert) 45%, transparent);
                background: color-mix(in srgb, var(--cert) 12%, transparent); }
.b-verified   { color: var(--verified); border-color: color-mix(in srgb, var(--verified) 40%, transparent); }

.label-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: 0.8rem; padding: .1rem .4rem;
  border-radius: 10px; border: 1px solid var(--line);
  color: var(--text-dim);
}
.label-chip .swatch { width: 7px; height: 7px; border-radius: 50%; }

.ikey {
  font: 600 0.86rem var(--mono);
  color: var(--text-dim);
  letter-spacing: -.01em;
}
a.ikey:hover { color: var(--accent); }

.mention { color: var(--accent); font-weight: 600; }

/* ---------- the platform matrix: the one loud element ----------
   A per-issue strip showing repro state on every target platform, so a
   console bug and a PC bug are one row instead of five duplicates. */

.pmatrix { display: inline-flex; gap: 2px; flex-wrap: wrap; max-width: 100%; }
.pm {
  font: 600 0.72rem/1 var(--mono);
  letter-spacing: .06em;
  padding: .28rem .3rem;
  border-radius: 2px;
  border: 1px solid var(--line-soft);
  color: var(--muted);
  background: var(--raised);
  min-width: 1.9rem;
  text-align: center;
}
.pm.repro     { color: #fff; background: var(--blocker); border-color: var(--blocker); }
.pm.not_repro { color: var(--low); border-color: color-mix(in srgb, var(--low) 40%, transparent); }
.pm.fixed     { color: var(--verified); border-color: color-mix(in srgb, var(--verified) 45%, transparent); }
.pm.untested  { color: var(--muted); border-style: dashed; }
.pm.more      { color: var(--text-dim); background: var(--raised-2); }

.pmatrix-edit { display: flex; flex-wrap: wrap; gap: .35rem; }
.pmatrix-edit .pm-cell { display: flex; flex-direction: column; gap: .2rem; align-items: stretch; }
.pmatrix-edit select { font-size: 0.8rem; padding: .15rem .3rem; }

/* ---------- issue list ---------- */

/* No overflow:hidden here. It would make this box a scroll container, and the
   sticky header below would then position itself against this box instead of
   the page, dropping 46px straight onto the first row. Corners are rounded on
   the first and last child instead. */
.ilist { border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); }
.ilist-head > *, .irow > * { min-width: 0; }
.irow > .pcell { overflow: hidden; }

.ilist-head, .irow {
  display: grid;
  grid-template-columns: 1.7rem 6.2rem minmax(0,1fr) 11.5rem 7.5rem 6.5rem 4.6rem;
  gap: .6rem;
  align-items: center;
  padding: .45rem .6rem;
}
.ilist-head {
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  font: 600 0.76rem var(--sans);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  position: sticky; top: 46px; z-index: 5;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}
.irow {
  border-bottom: 1px solid var(--line-soft);
  border-left: 3px solid transparent;
}
.irow:last-child { border-bottom: none;
  border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px); }
.irow:hover { background: var(--raised); }
.irow.pr-blocker { border-left-color: var(--blocker); }
.irow.pr-high    { border-left-color: var(--high); }
.irow.pr-medium  { border-left-color: var(--medium); }
.irow.pr-low     { border-left-color: var(--low); }
.irow.pr-trivial { border-left-color: transparent; }
.irow .title { min-width: 0; }
.irow .title a { color: var(--text); font-weight: 500; }
.irow .title a:hover { color: var(--accent); }
.irow .sub { color: var(--muted); font-size: 0.83rem; display: flex; gap: .5rem; flex-wrap: wrap;
  align-items: center; margin-top: .12rem; }
.irow .closed a { color: var(--muted); text-decoration: line-through; }

@media (max-width: 900px) {
  .ilist-head { display: none; }
  .irow { grid-template-columns: 1.6rem minmax(0,1fr); grid-auto-rows: min-content; }
  .irow > .col-hide { display: none; }
}

/* ---------- filter bar ---------- */

.filterbar {
  display: flex; gap: .4rem; flex-wrap: wrap; align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .5rem;
  margin-bottom: .8rem;
}
.filterbar select, .filterbar input { width: auto; min-width: 110px; }
.filterbar input[type=search] { min-width: 220px; flex: 1; }

.chips { display: flex; gap: .3rem; flex-wrap: wrap; }
.chip {
  font-size: 0.83rem; padding: .2rem .5rem;
  border: 1px solid var(--line); border-radius: 11px;
  color: var(--text-dim); background: var(--surface);
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip.on { background: var(--accent-dim); border-color: var(--accent); color: #fff; }

/* ---------- board ---------- */

.board { display: flex; gap: .7rem; overflow-x: auto; padding-bottom: .5rem; align-items: flex-start; }
.bcol { flex: 0 0 17rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); }
.bcol h3 { font-size: 0.83rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: .5rem .6rem; margin: 0; border-bottom: 1px solid var(--line-soft);
  display: flex; justify-content: space-between; }
.bcol .items { padding: .45rem; display: flex; flex-direction: column; gap: .45rem;
  max-height: calc(100vh - 220px); overflow-y: auto; }
.bcard { background: var(--raised); border: 1px solid var(--line-soft);
  border-left: 3px solid var(--trivial); border-radius: 3px; padding: .5rem; }
.bcard.pr-blocker { border-left-color: var(--blocker); }
.bcard.pr-high { border-left-color: var(--high); }
.bcard.pr-medium { border-left-color: var(--medium); }
.bcard.pr-low { border-left-color: var(--low); }
.bcard .t { color: var(--text); display: block; margin: .2rem 0 .35rem; }

/* ---------- issue detail ---------- */

.issue-title { font-size: 1.45rem; line-height: 1.35; margin: 0; }
.meta-table { width: 100%; border-collapse: collapse; font-size: 0.89rem; }
.meta-table th {
  text-align: left; font: 600 0.8rem var(--sans); text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); padding: .3rem .5rem .3rem 0;
  width: 7rem; vertical-align: top; font-weight: 600;
}
.meta-table td { padding: .3rem 0; vertical-align: top; }

.buildlane {
  display: flex; align-items: stretch; gap: 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; font-size: 0.83rem;
}
.buildlane div { flex: 1; padding: .45rem .55rem; background: var(--raised); }
.buildlane div + div { border-left: 1px solid var(--line); }
.buildlane .k { display: block; font: 600 0.72rem var(--sans); text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); margin-bottom: .15rem; }
.buildlane .v { font-family: var(--mono); color: var(--text); }
.buildlane .found .v { color: var(--high); }
.buildlane .fixed .v { color: var(--accent); }
.buildlane .verified .v { color: var(--verified); }

.comment { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.comment + .comment { margin-top: .6rem; }
.comment .chead {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .6rem; background: var(--raised);
  border-bottom: 1px solid var(--line-soft); font-size: 0.86rem;
}
.comment .cbody { padding: .6rem; }
.comment .cbody > :first-child { margin-top: 0; }
.comment .cbody > :last-child { margin-bottom: 0; }
.comment p { margin: .4rem 0; }

.timeline { border-left: 2px solid var(--line); padding-left: .8rem; margin-left: .35rem; }
.tl-item { position: relative; padding: .25rem 0; font-size: 0.86rem; color: var(--text-dim); }
.tl-item::before {
  content: ""; position: absolute; left: -1.19rem; top: .65rem;
  width: 6px; height: 6px; border-radius: 50%; background: var(--line);
  border: 2px solid var(--bg);
}
.tl-item .was { color: var(--muted); text-decoration: line-through; }
.tl-item .now { color: var(--text); }

.attachments { display: flex; flex-wrap: wrap; gap: .5rem; }
.att {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--raised); overflow: hidden; width: 10rem;
}
.att img, .att video { display: block; width: 100%; height: 96px; object-fit: cover; background: #000; }
.att .name { padding: .3rem .4rem; font-size: 0.8rem; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .kindtag { font: 600 0.7rem var(--mono); text-transform: uppercase; color: var(--muted); }

.dropzone {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: .6rem; text-align: center; color: var(--muted); font-size: 0.86rem;
}
.dropzone.hot { border-color: var(--accent); color: var(--accent); }

/* ---------- stats & charts ---------- */

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem .8rem; }
.stat .n { font: 700 1.8rem/1 var(--mono); letter-spacing: -.02em; }
.stat .k { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  margin-top: .25rem; }
.stat.alert .n { color: var(--blocker); }
.stat.warn .n { color: var(--high); }
.stat.good .n { color: var(--verified); }

.bar { height: 6px; background: var(--raised-2); border-radius: 3px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.barlist { display: flex; flex-direction: column; gap: .4rem; }
.barlist .r { display: grid; grid-template-columns: 7.5rem 1fr 2.6rem; gap: .5rem; align-items: center;
  font-size: 0.86rem; }
.barlist .r .v { text-align: right; font-family: var(--mono); color: var(--text-dim); }

.chart { width: 100%; height: auto; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .gridline { stroke: var(--line-soft); stroke-width: 1; }
.chart .open { fill: none; stroke: var(--high); stroke-width: 2; }
.chart .opened-bar { fill: var(--blocker); opacity: .75; }
.chart .closed-bar { fill: var(--verified); opacity: .75; }
.chart text { fill: var(--muted); font: 0.75rem var(--mono); }

/* ---------- tables ---------- */

table.data { width: 100%; border-collapse: collapse; font-size: 0.89rem; }
table.data th {
  text-align: left; padding: .4rem .5rem; background: var(--raised);
  border-bottom: 1px solid var(--line);
  font: 600 0.76rem var(--sans); text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
table.data td { padding: .4rem .5rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--raised); }

/* ---------- misc ---------- */

.flash { padding: .55rem .7rem; border-radius: var(--radius); margin-bottom: .8rem;
  border: 1px solid var(--line); font-size: 0.92rem; }
.flash.error { border-color: color-mix(in srgb, var(--blocker) 45%, transparent);
  background: color-mix(in srgb, var(--blocker) 12%, transparent); color: var(--text); }
.flash.ok { border-color: color-mix(in srgb, var(--verified) 45%, transparent);
  background: color-mix(in srgb, var(--verified) 10%, transparent); }
.flash.warn { border-color: color-mix(in srgb, var(--medium) 45%, transparent);
  background: color-mix(in srgb, var(--medium) 10%, transparent); }

.empty { text-align: center; color: var(--muted); padding: 1.6rem .8rem; }
.empty h3 { color: var(--text-dim); }

.auth-page { max-width: 380px; margin: 8vh auto; padding: 0 1rem; }
.auth-page .card { padding: 1.2rem; }
.auth-page h1 { margin-bottom: 1rem; }

.token-box { font-family: var(--mono); font-size: 0.86rem; word-break: break-all;
  background: var(--raised); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: .6rem; }

.pager { display: flex; gap: .4rem; align-items: center; justify-content: center; margin-top: .9rem; }

.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: .9rem;
  overflow-x: auto; }
.tabs a { padding: .4rem .7rem; color: var(--text-dim); border-bottom: 2px solid transparent;
  white-space: nowrap; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

details.sect > summary { cursor: pointer; padding: .35rem 0; color: var(--text-dim);
  font-weight: 600; font-size: 0.89rem; }
details.sect > summary:hover { color: var(--text); }

.sticky-actions { position: sticky; bottom: 0; background: var(--surface);
  border-top: 1px solid var(--line); padding: .5rem; display: flex; gap: .5rem;
  align-items: center; border-radius: 0 0 var(--radius) var(--radius); }

.kbd { font: 600 0.8rem var(--mono); background: var(--raised-2); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 3px; padding: .05rem .3rem; color: var(--text-dim); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media print {
  .topbar, .filterbar, .btn, .sticky-actions { display: none; }
  body { background: #fff; color: #000; }
}
