/*
 * QHEY app layout — the structure the design mockups expressed as inline
 * styles (docs/design/screens/*.html), as reusable classes.
 *
 * Rules (docs/design/HANDOFF.md):
 *  - colours come ONLY from tokens.css variables; no hard-coded colours here
 *  - logical properties only (inline-start/end), never left/right
 *  - radius 8px for bars and tracks
 */

/* ---------- base ---------- */
html.q, html.q body { height: 100%; }
html.q body {
  margin: 0;
  font-family: "Heebo", system-ui, sans-serif;
  font-size: 14px;
  line-height: 20px;
  color: var(--ink);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.q :focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.q button { font-family: inherit; }
.icon-svg { flex-shrink: 0; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 240px; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
  padding: 16px 12px;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; color: var(--ink); }
/* beats components.css `.q a` (link blue): the wordmark is ink, like the design */
.q a.brand, .q a.brand:hover { text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  /* the mark is a raster logo on white; keep its tile white in dark mode too */
  background: #FFFFFF;
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
}
.brand-mark img { width: 24px; height: 22px; object-fit: contain; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: .02em; }
.side-section { display: flex; flex-direction: column; gap: 2px; }
.side-section > .lbl { padding: 4px 10px; }
.nav .cnt.bad { color: var(--danger); }
.side-user {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 8px 6px; border-top: 1px solid var(--border);
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-3);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.side-user-text { display: flex; flex-direction: column; line-height: 16px; }
.side-user-text .name { font-size: 13px; font-weight: 500; }
.side-user-text .role { font-size: 11px; }

/* ---------- project picker ---------- */
.picker { position: relative; }
.picker-btn { width: 100%; height: 44px; justify-content: space-between; padding: 0 10px; }
.picker-current { display: flex; align-items: center; gap: 8px; min-width: 0; }
.picker-badge {
  width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;
  background: var(--blue-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.picker-badge.none { background: var(--surface-3); color: var(--ink-muted); }
.picker-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 16px; min-width: 0; }
.picker-text .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.picker-text .s { font-size: 11px; }
.picker-menu {
  position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 20;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .12);
  padding: 6px; display: flex; flex-direction: column; gap: 4px;
  max-height: 360px;
}
.picker-menu[hidden] { display: none; }
.picker-search {
  height: 32px; padding: 0 10px; width: 100%;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 13px;
}
.picker-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.picker-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  height: 36px; padding: 0 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); font-size: 13px; cursor: pointer; text-align: start;
}
.picker-item:hover, .picker-item[aria-selected="true"] { background: var(--surface-2); }
.picker-item .grow { flex-grow: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-empty { padding: 8px; font-size: 12px; color: var(--ink-muted); }

/* ---------- top bar ---------- */
.content { flex-grow: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; flex-shrink: 0; position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.crumbs .here { font-weight: 600; }
.topbar-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.search {
  display: flex; align-items: center; gap: 8px;
  height: 32px; width: 260px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: 8px; color: var(--ink-muted);
}
.search input {
  border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 13px; color: var(--ink); width: 100%;
}
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.bell { position: relative; }
.bell-dot {
  position: absolute; top: 5px; inset-inline-end: 6px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--danger);
}

/* ---------- page ---------- */
.page { flex-grow: 1; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head .btn.pri { margin-inline-start: auto; }

/* watchdog banner */
.banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 10px;
  background: var(--danger-soft); color: var(--ink); border: 1px solid transparent;
}
.banner-icon { color: var(--danger); display: inline-flex; }
.banner-text { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; }
.banner-text strong { font-weight: 600; }
.banner-text .muted { font-size: 13px; }
.q a.btn { text-decoration: none; color: var(--ink); }
.q a.btn.pri { color: var(--on-primary); }

/* KPI row */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi-line { display: flex; align-items: baseline; gap: 10px; }
.kpi .note { font-size: 12px; }
.kpi .sev-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.kpi .sev-row .num { font-size: 12px; }
.kpi .chip { align-self: flex-start; }

/* table card */
.table-card { overflow: hidden; }
.table-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.table-head .sub { font-size: 13px; }
.table-tools { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.seg button {
  padding: 0 12px; height: 30px; display: inline-flex; align-items: center;
  font-size: 13px; color: var(--ink-muted); background: transparent; border: 0;
  border-inline-start: 1px solid var(--border); cursor: pointer;
}
.seg button:first-child { border-inline-start: none; }
.seg button[aria-pressed="true"] { background: var(--blue-soft); color: var(--primary); font-weight: 500; }
/* position: relative keeps the visually-hidden caption inside the scroll box;
   without it, it escapes to the page and adds a horizontal scrollbar */
.table-scroll { overflow-x: auto; position: relative; }
.tbl th:last-child, .tbl td:last-child { text-align: end; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl td.strong { font-weight: 600; }

.proj { display: flex; align-items: center; gap: 10px; }
.proj-letter {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  background: var(--surface-3);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}
.proj-text { display: flex; flex-direction: column; }
.q a.proj-name { color: var(--ink); font-weight: 600; }
.proj-channels { font-size: 12px; }

.status { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.status-note { font-size: 12px; }
.status-note.warn { color: var(--warning); }
.status-note.bad { color: var(--danger); }
.status-note.muted { color: var(--ink-muted); }

/* stacked severity bar: widths are proportional, colours from --sev-1..5 */
.sevcell { display: flex; flex-direction: column; gap: 4px; }
.sevstack { display: flex; gap: 2px; width: 132px; }
.sevstack span { height: 10px; border-radius: 8px; }
.sevstack .s1 { background: var(--sev-1); }
.sevstack .s2 { background: var(--sev-2); }
.sevstack .s3 { background: var(--sev-3); }
.sevstack .s4 { background: var(--sev-4); }
.sevstack .s5 { background: var(--sev-5); }
.sevmeta { font-size: 12px; display: flex; gap: 8px; }
.hatch-bar { display: inline-block; width: 132px; height: 10px; border-radius: 8px; }

.rate { display: flex; align-items: center; gap: 10px; }
.rate .dot { width: 10px; height: 10px; }
.rate .pct { font-weight: 600; width: 44px; }
.dot.good { background: var(--good); }
.dot.mid { background: var(--mid); }
.dot.bad { background: var(--bad); }

.empty-row td { text-align: center; padding: 32px; color: var(--ink-muted); }

/* toast — for links to screens that are not built yet */
.toast {
  position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(50%);
  background: var(--ink); color: var(--surface);
  padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 50;
  box-shadow: 0 8px 24px rgb(0 0 0 / .18);
}
.toast[hidden] { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .side { display: none; }  /* mobile gets its own design (m1/m2) in a later step */
  .search { width: 180px; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .page { padding: 16px; }
  .topbar { padding: 0 16px; }
  .search { display: none; }
}
.picker-item .unknown { font-size: 11px; color: var(--ink-muted); }
.picker-list { min-height: 0; }
.nodata { font-size: 12px; color: var(--ink-muted); }
.side-user .btn { margin-inline-start: auto; }

/* the menu may extend past the sidebar, so long client names fit on one line */
.picker-menu { inset-inline-end: auto; width: max(100%, 340px); }
.picker-item .picker-state { display: inline-flex; color: var(--ink-faint); flex-shrink: 0; }

/* ---------- project settings (screen 11) ---------- */
.set-card { padding: 20px 24px; display: flex; flex-direction: column; max-width: 900px; }
.set-card-head { display: flex; align-items: baseline; gap: 10px; padding-block-end: 8px; }
.set-row {
  display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: 24px;
  padding-block: 16px; border-top: 1px solid var(--border);
}
.set-title { font-weight: 600; font-size: 14px; }
.set-help { font-size: 13px; line-height: 18px; margin-top: 2px; }
.set-hint { font-size: 12px; margin-top: 6px; }
.set-control { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.set-input {
  height: 38px; padding-inline: 12px; border-radius: 8px; width: 100%; max-width: 480px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 14px;
}
.set-input:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.set-input:disabled { opacity: .6; }
.ltr-input { direction: ltr; text-align: left; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; }
.readonly { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-height: 38px; }
.key-box {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; max-width: 560px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
}
.key-box .grow { flex-grow: 1; font-size: 13px; }
.key-box .lock { display: inline-flex; color: var(--ink-muted); }
.key-box.warn { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.key-edit { display: flex; flex-direction: column; gap: 8px; max-width: 560px; }
.key-actions { display: flex; gap: 8px; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.banner.info { background: var(--blue-soft); border-color: var(--blue-line); }
.seg button[disabled] { cursor: not-allowed; opacity: .6; }
@media (max-width: 720px) {
  .set-row { grid-template-columns: 1fr; gap: 8px; }
  .set-card { padding: 16px; }
}
.set-control > .seg, .set-control > .readonly { align-self: flex-start; }
