/* ============================================================
   Project LEAP dashboard
   ------------------------------------------------------------
   An internal ops board, not a product surface. It is read on a
   laptop in a review and on a phone in a corridor, so density and
   legibility beat decoration.
   ============================================================ */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16191d;
  --ink-2: #4a5158;
  --ink-3: #7c848d;
  --line: #e3e6ea;
  --line-2: #eef0f3;
  --accent: #2f5bd7;
  --accent-soft: #eaefff;

  --red: #c0392f;
  --red-soft: #fdecea;
  --amber: #9a6410;
  --amber-soft: #fdf3e2;
  --green: #1e7a4c;
  --green-soft: #e8f6ee;
  --blue: #2a5fb8;
  --blue-soft: #e9f0fd;
  --grey-soft: #f0f2f5;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 20, 26, .05), 0 4px 16px rgba(16, 20, 26, .06);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* The UA's `[hidden] { display: none }` is a plain element-level
   rule, so any class that sets `display` beats it. Several things
   here are flex or grid and hidden by attribute — .savebar was
   visible to readers because of exactly this. Make the attribute
   win everywhere rather than remembering it per component. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

/* ---------------------------------------------------------- shell */

.wrap { max-width: 1320px; margin: 0 auto; padding: 0 20px 80px; }

header.top {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--line);
}

.top-in {
  max-width: 1320px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 { margin: 0; font-size: 17px; font-weight: 640; letter-spacing: -.01em; white-space: nowrap; }

.spacer { flex: 1 1 auto; }

.tabs { display: flex; gap: 2px; background: var(--grey-soft); padding: 3px; border-radius: 9px; }
.tabs button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 13.5px; font-weight: 520; color: var(--ink-2);
  padding: 6px 13px; border-radius: 7px; white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] {
  background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(16,20,26,.08);
}

/* ---------------------------------------------------------- buttons */

.btn {
  appearance: none; cursor: pointer; font: inherit; font-size: 13.5px; font-weight: 520;
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--grey-soft); color: var(--ink); }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }

/* ---------------------------------------------------------- panels */

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

.panel-head {
  display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid var(--line-2);
}
.panel-head .controls { margin-left: auto; }
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 620; letter-spacing: -.005em; }
.panel-head .hint { color: var(--ink-3); font-size: 12.5px; }

section[hidden] { display: none !important; }

/* ---------------------------------------------------------- stats */

.stats { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 14px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 13px; min-width: 96px;
}
.stat .n { font-size: 20px; font-weight: 620; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; margin-top: 3px; }
.stat.alert .n { color: var(--red); }
.stat.warn .n { color: var(--amber); }

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

.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

input[type="search"], input[type="text"], input[type="date"], input[type="password"], select, textarea {
  font: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft); outline-offset: 0; border-color: var(--accent);
}
textarea { resize: vertical; line-height: 1.55; width: 100%; }
label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block; font-size: 12.5px; font-weight: 560; color: var(--ink-2); margin-bottom: 5px;
}
label.field > span em { font-style: normal; font-weight: 400; color: var(--ink-3); }

/* ---------------------------------------------------------- table */

.tablewrap { overflow-x: auto; }

table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th {
  text-align: left; font-weight: 560; font-size: 11.5px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0; background: var(--panel); z-index: 2;
}
table.grid th.sortable { cursor: pointer; user-select: none; }
table.grid th.sortable:hover { color: var(--ink); }
table.grid th .arrow { opacity: .45; font-size: 9px; margin-left: 3px; }
table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }

/* Titles carry the meaning, so they get the room. Everything else
   is short and fixed-width, which stops the browser from giving
   the date columns space they never need. */
table.bugs { table-layout: fixed; min-width: 1000px; }
table.bugs col.c-id     { width: 72px; }
table.bugs col.c-title  { width: auto; }
table.bugs col.c-sev    { width: 96px; }
table.bugs col.c-state  { width: 118px; }
table.bugs col.c-owner  { width: 150px; }
table.bugs col.c-filer  { width: 130px; }
table.bugs col.c-filed  { width: 86px; }
table.bugs col.c-due    { width: 104px; }
table.grid tbody tr:hover { background: color-mix(in srgb, var(--grey-soft) 55%, transparent); }
table.grid tbody tr:last-child td { border-bottom: 0; }

.num { font-variant-numeric: tabular-nums; }
.id a { font-family: var(--mono); font-size: 12.5px; }
.title { font-weight: 520; }
.title .tags { margin-top: 4px; display: flex; gap: 5px; flex-wrap: wrap; }
.nowrap { white-space: nowrap; }
.muted { color: var(--ink-3); }
.sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ---------------------------------------------------------- pills */

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 560; white-space: nowrap; line-height: 1.5;
  background: var(--grey-soft); color: var(--ink-2);
}
.pill.red    { background: var(--red-soft);   color: var(--red); }
.pill.amber  { background: var(--amber-soft); color: var(--amber); }
.pill.green  { background: var(--green-soft); color: var(--green); }
.pill.blue   { background: var(--blue-soft);  color: var(--blue); }
.pill.tag    { font-weight: 450; font-size: 11px; color: var(--ink-3); }
.pill.tiny   { font-size: 10.5px; padding: 1px 6px; }

/* ---------------------------------------------------------- states */

.empty, .loading, .failed {
  padding: 40px 20px; text-align: center; color: var(--ink-3); font-size: 14px;
}
.failed { color: var(--red); }
.failed .detail {
  margin-top: 8px; font-size: 12.5px; color: var(--ink-3);
  font-family: var(--mono); word-break: break-word;
  max-width: 640px; margin-left: auto; margin-right: auto;
}

.freshness { font-size: 12.5px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.dot.stale { background: var(--amber); }
.dot.dead { background: var(--red); }

/* ---------------------------------------------------------- drawer */

.scrim {
  position: fixed; inset: 0; background: rgba(12, 15, 20, .38);
  z-index: 40; opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw);
  background: var(--panel); border-left: 1px solid var(--line);
  z-index: 50; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .22s cubic-bezier(.32, .72, 0, 1);
  box-shadow: -8px 0 32px rgba(12, 15, 20, .14);
}
.drawer.open { transform: none; }
.drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--line-2);
}
.drawer-head h2 { margin: 0; font-size: 15px; font-weight: 620; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
.drawer-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-top: 1px solid var(--line-2);
}

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* AI assist block */
.ai {
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 9px; padding: 13px; margin-bottom: 18px;
}
.ai h3 { margin: 0 0 4px; font-size: 13px; font-weight: 620; }
.ai p { margin: 0 0 9px; font-size: 12.5px; color: var(--ink-2); }
.ai textarea { background: var(--panel); }

/* attachments */
.drop {
  border: 1.5px dashed var(--line); border-radius: 9px; padding: 14px;
  text-align: center; color: var(--ink-3); font-size: 13px; cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.files { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.files li {
  display: flex; align-items: center; gap: 9px; font-size: 12.5px;
  background: var(--grey-soft); border-radius: 7px; padding: 6px 8px;
}
.files img { width: 34px; height: 34px; object-fit: cover; border-radius: 5px; flex: none; }
.files .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.note { font-size: 12.5px; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }
.note.err { background: var(--red-soft); color: var(--red); }
.note.ok { background: var(--green-soft); color: var(--green); }
.note.info { background: var(--grey-soft); color: var(--ink-2); }

/* ---------------------------------------------------------- editable */

[contenteditable="true"] {
  outline: none; border-radius: 5px;
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 3px 6px; margin: -3px -6px; min-width: 40px; display: inline-block;
}
[contenteditable="true"]:focus { box-shadow: inset 0 0 0 2px var(--accent); background: var(--panel); }
[contenteditable="true"]:empty::before {
  content: attr(data-placeholder); color: var(--ink-3); font-style: italic;
}

.editing tbody tr:hover { background: transparent; }

.cat-band td {
  background: var(--grey-soft); font-weight: 620; font-size: 12px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2);
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.cat-band .acts { float: right; display: flex; gap: 6px; text-transform: none; letter-spacing: 0; }

.rowacts { width: 1%; white-space: nowrap; }
.rowacts .btn { visibility: hidden; }
tr:hover .rowacts .btn, .rowacts .btn:focus { visibility: visible; }

/* ---------------------------------------------------------- queries */

/* Grouped by what the query is FOR — leadership demo vs capability
   check — because that is the question being asked of this list.
   The thematic A–M grouping from the script is kept underneath as a
   band, so a section still reads in the script's own order. */

.qsection + .qsection { border-top: 8px solid var(--bg); }

.qsection-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 15px 16px 11px;
}
.qsection-head h3 { margin: 0; font-size: 14px; font-weight: 640; letter-spacing: -.005em; }
.qsection-head .blurb { font-size: 12.5px; color: var(--ink-3); }

/* A section band, so the eye lands on "which set am I looking at"
   before it starts reading rows. */
.qsection + .qsection .qsection-head { padding-top: 18px; }

table.queries { table-layout: fixed; min-width: 1080px; }
table.queries col.c-n      { width: 44px; }
table.queries col.c-name   { width: 148px; }
table.queries col.c-query  { width: auto; }
table.queries col.c-follow { width: 234px; }
table.queries col.c-tests  { width: 262px; }
table.queries col.c-acts   { width: 84px; }

table.queries td { font-size: 13px; }
table.queries .n { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
table.queries .qname { font-weight: 600; color: var(--ink-2); }

/* The opening query is the thing a presenter reads off the screen,
   so it is the only text here set larger than the table default. */
.qq-native { font-size: 15px; line-height: 1.45; }
.qq-roman  { font-size: 12.5px; color: var(--ink-2); font-style: italic; margin-top: 3px; }
.qq-gloss  { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.qq-follow { color: var(--ink-2); line-height: 1.55; }
.qq-tests  { color: var(--ink-3); font-size: 12.5px; line-height: 1.55; }

/* ---------------------------------------------------------- dialog */

dialog {
  border: 1px solid var(--line); border-radius: 12px; padding: 0;
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow);
  width: min(400px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(12, 15, 20, .4); }
dialog .dlg-body { padding: 20px; }
dialog h2 { margin: 0 0 6px; font-size: 16px; font-weight: 620; }
dialog p.lede { margin: 0 0 16px; font-size: 13px; color: var(--ink-2); }
dialog .dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 0 20px 20px; }

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

.savebar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 35; display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 10px 8px 16px; box-shadow: var(--shadow); font-size: 13px;
}
.savebar .who { color: var(--ink-3); }

footer.foot {
  margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-3); display: flex; gap: 14px; flex-wrap: wrap;
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Below roughly a laptop, the single header row runs out of space
   and wraps into [brand][tabs] / [actions], which puts the buttons
   under the tab strip where they read as belonging to it. Give the
   tabs their own full-width row instead and keep the actions up
   beside the title, which is where people reach for them. */
@media (max-width: 920px) {
  .top-in { row-gap: 10px; }
  .top-in .spacer { display: none; }
  .brand     { order: 1; }
  .freshness { order: 2; margin-left: auto; }
  #btn-edit  { order: 3; }
  #btn-file  { order: 4; }
  .top-in .tabs { order: 5; flex: 1 0 100%; justify-content: space-between; }
  .top-in .tabs button { flex: 1; justify-content: center; }
}

@media (max-width: 860px) {
  .q { grid-template-columns: 26px 1fr; }
  .q .side, .q .acts { grid-column: 2; }
  .brand .sub { display: none; }
  .row2 { grid-template-columns: 1fr; }
}
