/* The Panel's own layer over the shared web base (D-247): its shell (a dark sidebar of grouped pages, a slim top bar
   with the breadcrumb and the product shown) and the few looks only the Panel needs. Pages carry no style attribute
   and the Panel runs no script, so the narrow layout below is a breakpoint, not a toggle. */

/* ─── shell ──────────────────────────────────────────────────────────────── */
/* The sidebar is sticky and one window tall, so on a longer page the shell paints the rail's colour and its edge down
   the first column itself, and the dark column runs the page's full height under the sidebar. */
.shell {
  display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, var(--rail) 231px, var(--rail-line) 231px 232px, transparent 232px);
}
.work { display: flex; flex-direction: column; min-width: 0; }

.side {
  position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; padding: 14px 10px 12px;
  background: var(--rail); color: var(--rail-ink-2); border-right: 1px solid var(--rail-line);
}
.side .brand {
  display: flex; align-items: center; gap: 10px; padding: 2px 8px 14px; margin-bottom: 4px;
  border-bottom: 1px solid var(--rail-line); color: var(--rail-ink);
  font-size: 14px; font-weight: 700; font-stretch: 112%; letter-spacing: -.01em; text-decoration: none;
}
.side .brand:hover { color: var(--rail-ink); text-decoration: none; }
.mark { width: 27px; height: 27px; flex-shrink: 0; }
/* The Bunyad mark keeps its own blue in both themes, as the brand does. */
.mark-ground { fill: #2D46C8; }
.mark-brick { fill: #FFFFFF; }
.mark-brick.second { opacity: .88; }
.mark-brick.third { opacity: .6; }

/* rail-ink-2 on the rail, not rail-ink-3: the small labels still need AA contrast. */
.side .group {
  margin: 14px 8px 4px; font-size: 9.5px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--rail-ink-2);
}
.side nav { display: flex; flex-direction: column; gap: 1px; }
.side nav a {
  position: relative; display: flex; align-items: center; gap: 9px;
  min-height: 30px; padding: 0 10px; border-radius: var(--r-md);
  color: var(--rail-ink); opacity: .82; font-size: 12.5px; font-weight: 500; text-decoration: none;
}
.side nav a:hover { background: var(--rail-2); opacity: 1; color: var(--rail-ink); text-decoration: none; }
.side nav a[aria-current="page"] { background: var(--rail-2); opacity: 1; font-weight: 600; }
.side nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--rail-accent);
}
.side :focus-visible { outline-color: var(--rail-accent); }
.side .alert { margin: 8px 4px 0; font-size: 11.5px; }

.dot { width: 9px; height: 9px; flex-shrink: 0; border-radius: 50%; background: var(--rail-ink-2); }
.dot.all { background: transparent; border: 1.5px solid var(--rail-ink-2); }
/* The rail is dark in both themes, so a dot takes its product's dark-theme colour there (--product-cN-rail). */
.dot.product-c0 { background: var(--product-c0-rail); }
.dot.product-c1 { background: var(--product-c1-rail); }
.dot.product-c2 { background: var(--product-c2-rail); }
.dot.product-c3 { background: var(--product-c3-rail); }
.dot.product-c4 { background: var(--product-c4-rail); }
.dot.product-c5 { background: var(--product-c5-rail); }
.dot.product-c6 { background: var(--product-c6-rail); }
.dot.product-c7 { background: var(--product-c7-rail); }

.side .who {
  margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--rail-line);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 8px;
}
.side .who .name { color: var(--rail-ink); font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .who .role { grid-row: 2; font-size: 11px; color: var(--rail-ink-2); }
.side .who form { grid-row: 1 / span 2; grid-column: 2; }
.side .who .btn.quiet { height: 27px; padding: 0 9px; color: var(--rail-ink); }
.side .who .btn.quiet:hover { background: var(--rail-2); color: var(--rail-ink); }

.topbar {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.crumb { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 12.5px; color: var(--ink-3); }
.crumb b { color: var(--ink-1); font-weight: 600; }
.crumb .sep { color: var(--ink-4); }
.chip { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }

.content { width: 100%; max-width: 1280px; padding: 20px 24px 32px; }

/* ─── page header, filter bar ────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head .desc { margin: 4px 0 0; color: var(--ink-3); font-size: 12.5px; max-width: 46rem; }
.head-actions { display: flex; gap: 8px; }

.filter-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; margin-bottom: 12px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.filter-bar .field { margin: 0; width: 150px; }
.filter-bar .field.search { flex: 1 1 200px; width: auto; }
.filter-bar .check { min-height: 31px; }

.table-wrap + .hint, .card .table-wrap { margin-bottom: 8px; }
.card .table-wrap { box-shadow: none; }
.card .empty { padding: 20px 16px; }
td.json code { display: block; max-width: 22rem; white-space: pre-wrap; word-break: break-all; font-size: 11px; }
table.grid td .pill + .pill { margin-left: 4px; }
table.grid td.notes { min-width: 8rem; max-width: 18rem; }
table.grid td .sub.feed { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; }
table.grid td.row-actions a { display: block; line-height: 1.5; }
.table-wrap { margin-bottom: 12px; }

/* ─── the narrow window ──────────────────────────────────────────────────── */
/* Under 1000px the sidebar becomes a strip across the top: groups in a row, their labels dropped. */
@media (max-width: 1000px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; background: none; }
  .side {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 6px;
    padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--rail-line);
  }
  .side .brand { padding: 0 10px 0 0; margin: 0 6px 0 0; border-bottom: 0; border-right: 1px solid var(--rail-line); }
  .side .group { display: none; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side nav.products { padding-left: 8px; border-left: 1px solid var(--rail-line); }
  .side nav a[aria-current="page"]::before { left: 8px; right: 8px; top: auto; bottom: 0; width: auto; height: 2px; border-radius: 2px; }
  .side .who { margin: 0 0 0 auto; padding: 0; border-top: 0; }
  .side .alert { flex-basis: 100%; }
  .topbar { position: static; padding: 0 16px; }
  .content { padding: 16px; }
}

/* ─── detail pages ───────────────────────────────────────────────────────── */
.crumb a { color: var(--ink-3); }
.crumb a:hover { color: var(--accent); }
/* A long license key or business name in the trail gives way before the page's own name does. */
.crumb > a, .crumb > span:not(.sep) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }
.page-head h1.mono { font-family: var(--mono); font-size: 18px; font-weight: 600; letter-spacing: 0; }
.head-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.head-actions { flex-wrap: wrap; justify-content: flex-end; }

/* The page's body: the summary and its sections on the left, a narrow column of side cards on the right. */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 0 12px; align-items: start; }
.detail > .main, .detail > .aside { min-width: 0; }
.card > h2 { margin-bottom: 10px; }
.card > h2 .count { color: var(--ink-3); font-weight: 500; }
.card h3 { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; }
.card .section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card .section-head h2 { margin: 0; }
.card .table-wrap { margin: 0 0 4px; }
.card > p:last-child, .card > form:last-child > p:last-child { margin-bottom: 0; }
dl.facts dd .pill, dl.facts dd .badge { vertical-align: middle; }
.links { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 12.5px; }

/* A license inside a branch card on the business page: its own rule above it, not another card. */
.sub-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.sub-section > h3 { margin-top: 0; }
.sub-section > h4 { margin: 14px 0 6px; }

/* The danger zone: each destructive action on a row of its own, what it does on the left, its button on the right. */
.card.danger { background: color-mix(in srgb, var(--danger-bg) 35%, var(--surface)); }
.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 9px 0; border-top: 1px solid var(--danger-line); }
.danger-row:first-of-type { border-top: 0; padding-top: 2px; }
.danger-row p { margin: 0; font-size: 12px; color: var(--ink-2); }
.danger-row b { display: block; color: var(--ink-1); font-size: 12.5px; }
.danger-row .btn { flex-shrink: 0; }

table.grid td.row-buttons { text-align: right; }
table.grid td.row-buttons .btn { height: 26px; padding: 0 10px; font-size: 12px; }
table.grid td.row-buttons .btn + .btn { margin-left: 4px; }
.card > .muted:last-child { margin: 0; }

/* ─── forms ──────────────────────────────────────────────────────────────── */
form.card.form { max-width: 40rem; padding: 15px 17px; }
form.card.form > h2 { margin-bottom: 4px; }
form.card.form > .intro { margin: 0 0 12px; color: var(--ink-2); font-size: 12.5px; }
label.field > span:first-child { font-weight: 600; color: var(--ink-2); }
label.field .hint { font-weight: 400; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
fieldset.field { border: 0; padding: 0; margin: 0 0 10px; }
.form .check { margin: 2px 0 12px; align-items: flex-start; }
.form .check input { margin-top: 2px; flex-shrink: 0; }
.form .actions { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.form .alert { margin-bottom: 12px; }
.form.danger .actions { border-top-color: var(--danger-line); }

/* What a typed confirmation will do, said before the fields that ask for it. */
.consequence { display: block; margin-bottom: 12px; }
.consequence p { margin: 0; }
.consequence p + p { margin-top: 6px; }
.confirm-name { font-family: var(--mono); font-weight: 600; color: var(--ink-1); }

/* A small card of what the form acts on, above it, so the page says what will change before it is changed. */
.target { max-width: 40rem; }
.target .table-wrap { margin-top: 4px; }

/* ─── one-time secrets ───────────────────────────────────────────────────── */
/* A code or password the cloud keeps only a hash of: shown once, so it stands out and reads clearly over the phone. */
.secret {
  max-width: 40rem; margin-bottom: 12px; padding: 13px 15px; border-radius: var(--r-lg);
  background: var(--amber-bg); border: 1px solid var(--amber-line); color: var(--ink-1);
}
.secret .lbl { display: block; margin-bottom: 6px; color: var(--amber); }
.secret code.secret-value {
  display: inline-block; margin: 2px 0 8px; padding: 6px 12px; border-radius: var(--r-md);
  font-size: 20px; font-weight: 600; letter-spacing: .08em; user-select: all;
  background: var(--raised); border: 1px solid var(--amber-line); color: var(--ink-1);
}
.secret p { margin: 0; font-size: 12.5px; color: var(--ink-2); }
.secret p + p { margin-top: 4px; }

/* ─── sign-in and the pages outside the shell ────────────────────────────── */
.content.bare { max-width: 24rem; margin: 12vh auto 0; padding: 0 16px; }
.sign-in { padding: 24px 24px 20px; box-shadow: var(--shadow-md); }
.sign-in .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-size: 15px; font-weight: 700; font-stretch: 112%; letter-spacing: -.01em; }
.sign-in .brand .mark { width: 32px; height: 32px; }
.sign-in h1 { font-size: 18px; margin-bottom: 4px; }
.sign-in .intro { margin: 0 0 16px; color: var(--ink-3); font-size: 12.5px; }
.sign-in .btn.primary { width: 100%; height: 34px; margin-top: 6px; }
.sign-in .field { margin-bottom: 12px; }

.message { max-width: 34rem; }
.message .actions { margin-top: 8px; }

/* ─── the narrow window, for the detail pages ────────────────────────────── */
@media (max-width: 1000px) {
  .detail { grid-template-columns: minmax(0, 1fr); }
  .head-actions { justify-content: flex-start; }
}
@media (max-width: 640px) {
  .field-pair { grid-template-columns: 1fr; }
  .danger-row { flex-direction: column; align-items: flex-start; }
}

/* ─── product context and badges (D-247, panel.md §7) ─────────────────────── */
/* Each product's colour, picked by ProductPalette from a hash of its code. None is the red, amber or green of a
   status, so a badge never reads as one; the Panel's own, since which products exist is the Panel's business. */
:root {
  --product-c0: #1F6FB2; --product-c0-bg: #E8F1FA;
  --product-c1: #4B47B8; --product-c1-bg: #EDEDFA;
  --product-c2: #7440B5; --product-c2-bg: #F2ECFA;
  --product-c3: #93379A; --product-c3-bg: #F7ECF8;
  --product-c4: #AD2F6E; --product-c4-bg: #FBEAF2;
  --product-c5: #4F5B6E; --product-c5-bg: #EEF0F3;
  --product-c6: #0E7A84; --product-c6-bg: #E5F4F5;
  --product-c7: #865A7E; --product-c7-bg: #F4EEF3;
  --product-c0-rail: #74B0E8;
  --product-c1-rail: #9C98F0;
  --product-c2-rail: #B892EC;
  --product-c3-rail: #D88BDD;
  --product-c4-rail: #EC86B5;
  --product-c5-rail: #A3ADBD;
  --product-c6-rail: #5EC4CC;
  --product-c7-rail: #C79BBE;
}

@media (prefers-color-scheme: dark) {
  :root {
    --product-c0: #74B0E8; --product-c0-bg: #172433;
    --product-c1: #9C98F0; --product-c1-bg: #1F1F3A;
    --product-c2: #B892EC; --product-c2-bg: #261D36;
    --product-c3: #D88BDD; --product-c3-bg: #2C1C2E;
    --product-c4: #EC86B5; --product-c4-bg: #2E1A24;
    --product-c5: #A3ADBD; --product-c5-bg: #1F232A;
    --product-c6: #5EC4CC; --product-c6-bg: #142A2C;
    --product-c7: #C79BBE; --product-c7-bg: #2A2028;
  }
}

.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
  border-radius: 999px; font-size: 10.5px; font-weight: 600; white-space: nowrap;
  border: 1px solid currentColor;
}
.badge.product-c0 { color: var(--product-c0); background: var(--product-c0-bg); }
.badge.product-c1 { color: var(--product-c1); background: var(--product-c1-bg); }
.badge.product-c2 { color: var(--product-c2); background: var(--product-c2-bg); }
.badge.product-c3 { color: var(--product-c3); background: var(--product-c3-bg); }
.badge.product-c4 { color: var(--product-c4); background: var(--product-c4-bg); }
.badge.product-c5 { color: var(--product-c5); background: var(--product-c5-bg); }
.badge.product-c6 { color: var(--product-c6); background: var(--product-c6-bg); }
.badge.product-c7 { color: var(--product-c7); background: var(--product-c7-bg); }
.badge.all { color: var(--ink-2); background: var(--sunken); border-color: var(--line-strong); }
