/* Console shell. Colours, type and geometry come only from tokens.css
   (DESIGN.md §2, §8.2): no literal colours in this file — tests enforce it. */

.cx { margin: 0; min-height: 100vh; background: var(--bg); color: var(--fg-1);
      font-family: var(--font-sans); font-size: var(--text-base); }

.cx-skip { position: absolute; left: -9999px; top: 8px; z-index: 10; padding: 8px 12px;
           background: var(--surface-2); color: var(--fg); border-radius: var(--r-sm); }
.cx-skip:focus { left: 8px; outline: 2px solid var(--focus); }

/* Rail: 64 px column, fixed (DESIGN.md §2 geometry, §6 shell). */
.cx-rail { position: fixed; inset: 0 auto 0 0; width: 64px; display: flex; flex-direction: column;
           align-items: center; gap: 4px; padding: 12px 0; background: var(--surface);
           border-right: 1px solid var(--line); overflow-y: auto; z-index: 3; }
.cx-rail-brand { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 12px;
                 color: var(--lockup-ink); border-radius: var(--r); }
.cx-rail-item { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 52px;
                padding: 8px 0 6px; border-radius: var(--r); color: var(--fg-2); text-decoration: none;
                font-size: var(--text-xs); }
.cx-rail-item svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.cx-rail-item:hover { background: var(--surface-2); color: var(--fg); }
.cx-rail-item.is-current { color: var(--accent-text); background: var(--surface-2); }
.cx-rail-item:focus-visible, .cx-rail-brand:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Topbar: --topbar-h tall, sits right of the rail. */
.cx-topbar { position: sticky; top: 0; margin-left: 64px; height: var(--topbar-h); display: flex;
             align-items: center; gap: 16px; padding: 0 24px; background: var(--bg);
             border-bottom: 1px solid var(--line); z-index: 2; }
.cx-title { margin: 0; font-size: var(--text-xl); font-weight: 600; color: var(--fg); }
.cx-topbar-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.cx-theme svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.cx-theme .cx-fill { fill: currentColor; stroke: none; }

.cx-main { margin-left: 64px; padding: 24px; max-width: 1440px; }

.cx-empty { max-width: 520px; margin: 64px auto; padding: 24px; text-align: center;
            background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.cx-empty h2 { margin: 0 0 8px; font-size: var(--text-lg); color: var(--fg); }
.cx-empty p { margin: 0; color: var(--fg-2); line-height: 1.5; }

/* Phone width: the rail becomes a bottom bar so nothing scrolls sideways. */
@media (max-width: 640px) {
  .cx-rail { inset: auto 0 0 0; width: auto; height: 56px; flex-direction: row; justify-content: center;
             padding: 0 8px; border-right: 0; border-top: 1px solid var(--line); }
  .cx-rail-brand { display: none; }
  .cx-topbar, .cx-main { margin-left: 0; }
  .cx-topbar { padding: 0 16px; }
  .cx-main { padding: 16px 16px 80px; }
}

/* Sign-in and account pages (C1): no rail, one centred card. Tokens only. */
.cx-bare .cx-topbar, .cx-bare .cx-main { margin-left: 0; }
.cx-signout { margin: 0; }
.cx-auth { max-width: 420px; margin: 48px auto; padding: 28px 24px; display: flex; flex-direction: column;
           gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.cx-auth [hidden] { display: none !important; }
.cx-auth-brand { color: var(--lockup-ink); }
.cx-auth h2 { margin: 0; font-size: var(--text-lg); color: var(--fg); }
.cx-auth-lead { margin: 0; color: var(--fg-2); line-height: 1.5; }
.cx-auth-error { margin: 0; padding: 8px 10px; border-radius: var(--r); color: var(--bad-text);
                 background: var(--bad-soft); border: 1px solid var(--bad-line); }
.cx-auth-status { margin: 0; color: var(--fg-2); }
.cx-form { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.cx-field { display: flex; flex-direction: column; gap: 6px; color: var(--fg-1); font-size: var(--text-md); }
.cx-form .btn { align-self: flex-start; }
.cx-auth-alt { display: flex; flex-direction: column; gap: 8px; }
.cx-auth-or { margin: 0; color: var(--fg-3); font-size: var(--text-sm); }
.cx-auth-more summary { cursor: pointer; color: var(--fg-2); }
.cx-auth-more .cx-form { margin-top: 10px; }
.cx-auth-cancel { margin: 0; }
.cx-code, .cx-secret, .cx-codes code { font-family: var(--font-mono); letter-spacing: .04em; }
.cx-secret { display: block; margin-top: 6px; padding: 8px 10px; background: var(--surface-3);
             border-radius: var(--r); color: var(--fg); overflow-wrap: anywhere; }
.cx-uri { margin-top: 6px; font-family: var(--font-mono); font-size: var(--text-sm); }
.cx-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px;
            color: var(--fg-1); line-height: 1.5; }
.cx-codes { margin: 0; padding-left: 28px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 6px 16px; color: var(--fg); }
@media (max-width: 640px) {
  .cx-auth { margin: 16px auto; padding: 20px 16px; }
  .cx-codes { grid-template-columns: minmax(0, 1fr); }
}

/* Fleet home (C4): status strip, tools, saved views, the site table, the
   one-site card. Tokens only. */
.cx-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
                      clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.cx-sub { color: var(--fg-3); font-size: var(--text-sm); }
.cx-lead { margin: 0 0 12px; color: var(--fg-2); font-size: var(--text-md); }

.cx-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin: 0 0 6px; }
.cx-stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; min-width: 0;
           background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
           color: var(--fg-1); text-decoration: none; transition: border-color var(--t-fast) var(--ease); }
.cx-stat:hover { border-color: var(--line-2); background: var(--surface-2); }
.cx-stat:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.cx-stat.is-current { border-color: var(--select); background: var(--select-soft); }
.cx-stat-n { font-family: var(--font-mono); font-size: var(--text-2xl); font-weight: 600; color: var(--fg); }
.cx-stat-label { font-size: var(--text-sm); color: var(--fg-2); }
.cx-stat.is-bad .cx-stat-n { color: var(--bad-text); }
.cx-stat.is-warn .cx-stat-n { color: var(--warn-text); }
.cx-stat.is-attn .cx-stat-n { color: var(--attn); }
.cx-asof { margin: 0 0 16px; }

.cx-tools { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 12px; }
.cx-search, .cx-save { display: flex; gap: 8px; align-items: center; margin: 0; }
.cx-search .input { width: 280px; }
.cx-save { margin-left: auto; }
.cx-save .input { width: 200px; }

.cx-views { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.cx-view { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 11px;
           border: 1px solid var(--line); border-radius: var(--r-pill); font-size: var(--text-sm); }
.cx-view.is-current { border-color: var(--select); background: var(--select-soft); }
.cx-view a { color: var(--fg-1); text-decoration: none; }
.cx-view a:hover { color: var(--fg); text-decoration: underline; }
.cx-view form { margin: 0; }
.cx-view-del { width: 22px; height: 22px; padding: 0; border: 0; border-radius: var(--r-pill); cursor: pointer;
               background: transparent; color: var(--fg-3); font: inherit; line-height: 1; }
.cx-view-del:hover { background: var(--surface-2); color: var(--fg); }
.cx-view-del:focus-visible { outline: 2px solid var(--focus); }

.cx-showing { margin: 0 0 8px; }
.cx-table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line);
                 border-radius: var(--r-lg); }
.cx-table { width: 100%; border-collapse: collapse; font-size: var(--text-md); }
.cx-table th, .cx-table td { padding: 10px 12px; text-align: left; vertical-align: middle;
                             border-bottom: 1px solid var(--line); white-space: nowrap; }
.cx-table tbody tr:last-child th, .cx-table tbody tr:last-child td { border-bottom: 0; }
.cx-table thead th { background: var(--surface-2); color: var(--fg-2); font-size: var(--text-sm); font-weight: 500; }
.cx-table thead th a { color: inherit; text-decoration: none; }
.cx-table thead th a:hover { color: var(--fg); text-decoration: underline; }
.cx-table thead th[aria-sort="ascending"] a::after { content: " ↑"; }
.cx-table thead th[aria-sort="descending"] a::after { content: " ↓"; }
.cx-table tbody th { font-weight: 500; }
.cx-table tbody th a, .cx-site-card h2 a { color: var(--fg); text-decoration: none; }
.cx-table tbody th a:hover, .cx-site-card h2 a:hover { text-decoration: underline; }
.cx-table tbody tr:hover { background: var(--surface-2); }
.cx-table code, .cx-facts code { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--fg-2); }
.cx-num { text-align: right; font-variant-numeric: tabular-nums; }
.cx-table th.cx-num { text-align: right; }
.cx-none { padding: 24px 12px; text-align: center; color: var(--fg-2); }
.cx-low { color: var(--warn-text); font-weight: 500; }
.cx-lic.is-warn { color: var(--warn-text); }
.cx-lic.is-bad { color: var(--bad-text); }
.cx-alerts { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: var(--r-pill);
             background: var(--attn-soft); border: 1px solid var(--attn-line); color: var(--attn);
             font-family: var(--font-mono); font-size: var(--text-xs); text-align: center; }
.cx-pager { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

.cx-site-card { max-width: 720px; padding: 20px 24px; background: var(--surface); border: 1px solid var(--line);
                border-radius: var(--r-lg); }
.cx-site-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
                     margin-bottom: 16px; }
.cx-site-card h2 { margin: 0 0 4px; font-size: var(--text-xl); }
.cx-site-card .cx-sub { margin: 0; }
.cx-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0; }
.cx-facts dt { color: var(--fg-3); font-size: var(--text-sm); margin-bottom: 4px; }
.cx-facts dd { margin: 0; color: var(--fg); }

@media (max-width: 1100px) {
  .cx-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .cx-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cx-search, .cx-save { width: 100%; }
  .cx-search .input, .cx-save .input { width: auto; flex: 1; min-width: 0; }
  .cx-save { margin-left: 0; }
  .cx-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Site overview (C5): header with Open site, health / license / alerts /
   access panels beside the camera grid. A still that fails to load leaves
   its placeholder showing (the <img> sits over it and draws nothing when
   broken). Tokens only. */
.cx-crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; color: var(--fg-3); font-size: var(--text-sm); }
.cx-crumbs a { color: var(--fg-2); text-decoration: none; }
.cx-crumbs a:hover { color: var(--fg); text-decoration: underline; }
.cx-site-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin: 0 0 16px; }
.cx-site-head .cx-sub { margin: 0; }
.cx-site-head code { font-family: var(--font-mono); }
.cx-site-open { margin-left: auto; }
.cx-site-open form { margin: 0; }
.cx-open { min-height: 40px; padding-left: 20px; padding-right: 20px; font-size: var(--text-md); }
.cx-banner { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--line);
             background: var(--surface); color: var(--fg-1); line-height: 1.5; }
.cx-banner.is-bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--fg); }
.cx-banner.is-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--fg); }
.cx-site-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.cx-site-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.cx-panel { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
            min-width: 0; }
.cx-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 0 12px; }
.cx-panel-head h3 { margin: 0; font-size: var(--text-md); font-weight: 600; color: var(--fg); }
.cx-panel .cx-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cx-panel p { margin: 0 0 8px; color: var(--fg-2); line-height: 1.5; }
.cx-flag { color: var(--warn-text); }
.cx-flag.is-bad { color: var(--bad-text); }
.cx-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.cx-list li { display: flex; justify-content: space-between; gap: 8px; color: var(--fg-1); font-size: var(--text-sm); }
.cx-list li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.cx-list time, .cx-list .cx-sub { white-space: nowrap; }

.cx-cam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px;
               margin: 0; padding: 0; list-style: none; }
.cx-cam { min-width: 0; }
.cx-cam-open { display: flex; flex-direction: column; gap: 4px; width: 100%; margin: 0; padding: 0; border: 0;
               background: transparent; color: inherit; font: inherit; text-align: left; }
button.cx-cam-open { cursor: pointer; }
button.cx-cam-open:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r); }
button.cx-cam-open:hover .cx-still { border-color: var(--line-2); }
.cx-still { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--r);
            background: var(--surface-3); border: 1px solid var(--line); }
.cx-still-ph { position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; text-align: center;
               color: var(--fg-3); font-size: var(--text-xs); }
.cx-still img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; color: transparent;
                font-size: 0; }
.cx-cam-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); font-size: var(--text-sm); }
.cx-cam .cx-sub { font-size: var(--text-xs); }
.cx-enter { max-width: 520px; }
.cx-enter form { margin: 16px 0 12px; }

@media (max-width: 1100px) {
  .cx-site-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .cx-site-open { margin-left: 0; width: 100%; }
  .cx-cam-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Fleet home, camera grants only (C5): the person's sites by name. */
.cx-cam-sites { max-width: 720px; padding: 20px 24px; background: var(--surface); border: 1px solid var(--line);
                border-radius: var(--r-lg); }
.cx-cam-sites h2 { margin: 0 0 4px; font-size: var(--text-lg); color: var(--fg); }
.cx-cam-sites > .cx-sub { margin: 0 0 12px; }
.cx-cam-site-list { list-style: none; margin: 0; padding: 0; }
.cx-cam-site-list li { display: flex; align-items: baseline; gap: 8px; padding: 10px 0;
                       border-top: 1px solid var(--line); }
.cx-cam-site-list a { color: var(--fg); font-weight: 500; text-decoration: none; overflow-wrap: anywhere; }
.cx-cam-site-list a:hover { text-decoration: underline; }
/* Under the table or the site card: the same list, set apart. */
.cx-cam-sites[data-camera-access] { margin-top: 24px; }
.cx-cam-sites .cx-pager { margin-top: 8px; }
