/* Tokens, reset, typography, focus and the legacy --red/--ink aliases live in
   foundation.css (loaded first). This file holds layout and components. */

/* ---- layout ---- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: 58px; z-index: 20;
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: var(--color-frame-900); color: var(--color-frame-text);
  border-bottom: 6px solid var(--color-brand-600);   /* the brand accent, not a red slab */
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; white-space: nowrap; }
.brand img { height: 38px; width: 38px; object-fit: contain; background: #fff; border-radius: 50%; padding: 2px; }
/* direct child only: .brand span would also hit .brand-full/.brand-short and
   its higher specificity would defeat their display toggles */
.brand > span { display: flex; flex-direction: column; line-height: 1.15; }
.brand-short { display: none; }
.brand small { color: var(--color-frame-muted); font-size: .72rem; }
.topbar-search { flex: 1; max-width: 420px; }
.topbar-search input {
  width: 100%; border: 1px solid transparent; border-radius: var(--radius-control); padding: 8px 12px;
  background: var(--color-frame-800); color: var(--color-frame-text); font-size: .9rem;
}
.topbar-search input::placeholder { color: #b9c0cc; }  /* brighter than frame-muted for readability on graphite */
.topbar-search input:focus { background: #fff; color: var(--color-text); }
.nav-toggle, .search-toggle {
  display: none; background: none; border: none; color: #fff; font-size: 1.3rem; cursor: pointer;
  min-width: var(--target-min); min-height: var(--target-min);
  align-items: center; justify-content: center;
}

/* Phone search disclosure: full-width bar directly under the header. Desktop
   never shows it (the inline .topbar-search is always visible there). */
.global-search {
  position: fixed; top: 58px; left: 0; right: 0; z-index: 18;
  display: flex; gap: 8px; padding: 10px 14px;
  background: var(--color-frame-800); border-bottom: 1px solid var(--color-frame-900);
  box-shadow: var(--shadow-2);
}
.global-search input { flex: 1; }
@media (min-width: 861px) { .global-search { display: none !important; } }

/* Graphite sidebar: grouped navigation on desktop, drawer on phones.
   Never uses [hidden] — the global [hidden]{display:none!important} rule
   would defeat the media queries (see plan/01a Task 3). */
.sidenav {
  position: fixed; top: 58px; bottom: 0; left: 0; width: 232px; z-index: 15;
  background: var(--color-frame-900); color: var(--color-frame-text);
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 12px 12px; overflow-y: auto;
}
.nav-org { display: none; }  /* drawer-only product identity (phones) */
.nav-group { display: flex; flex-direction: column; gap: 1px; margin-bottom: 10px; }
/* titles lead, links soften: bright bold group titles over quieter links
   (chosen from three rendered variants, 2026-08-17) */
.nav-group-label {
  margin: 0 0 3px; padding: 0 12px; font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: #fff;
}
.sidenav a {
  padding: 8px 12px; border-radius: var(--radius-control); color: #aab2c0;
  text-decoration: none; font-weight: 400; font-size: .92rem;
  border-left: 3px solid transparent;
}
.sidenav a:hover { background: var(--color-frame-800); color: #fff; }
.sidenav a.active { background: var(--color-frame-800); color: #fff; font-weight: 600; border-left-color: var(--color-brand-600); }

/* account menu: pinned to the bottom of the sidebar/drawer */
.account-menu { margin-top: auto; border-top: 1px solid var(--color-frame-800); padding-top: 8px; }
.account-menu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius-control); min-height: var(--target-min);
}
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary::after { content: "▾"; margin-left: auto; color: var(--color-frame-muted); font-size: .8rem; }
.account-menu[open] summary::after { content: "▴"; }
.account-menu summary:hover { background: var(--color-frame-800); }
.account-name { font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-role {
  flex: none; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  background: rgba(255,255,255,.12); color: var(--color-frame-text);
  padding: 2px 8px; border-radius: 999px;
}
.account-menu-panel { padding: 4px 0 2px; display: flex; flex-direction: column; }
.account-menu-panel a {
  padding: 8px 12px; border-radius: var(--radius-control);
  color: var(--color-frame-text); text-decoration: none; font-size: .88rem;
}
.account-menu-panel a:hover { background: var(--color-frame-800); }

main.with-nav { padding: 78px 24px 40px 256px; }
main.centered { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 20px; }

@media (max-width: 860px) {
  .nav-toggle, .search-toggle { display: flex; }
  .topbar-search { display: none; }
  .brand small { display: none; }
  /* compact header: short brand */
  .brand-full { display: none; }
  .brand-short { display: inline; }
  /* the sidebar becomes an off-canvas drawer driven by data-open */
  .sidenav { transform: translateX(-100%); transition: transform .18s ease; width: 264px; box-shadow: none; }
  .sidenav[data-open="true"] { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  .nav-org {
    display: block; margin: 0 0 12px; padding: 0 12px;
    font-weight: 700; line-height: 1.3;
  }
  .nav-org small { display: block; color: var(--color-frame-muted); font-weight: 400; }
  main.with-nav { padding: 74px 14px 40px; }
}

/* ---- grids ---- */
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
/* wide table + narrow side panel (e.g. Users page) */
.grid.cols-main-side { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; }
@media (max-width: 860px) { .grid.cols-main-side { grid-template-columns: 1fr; } }

/* ---- dashboard task actions ---- */
.task-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

/* ---- stat tiles ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); text-decoration: none; display: block;
}
.stat .n { font-size: 1.7rem; font-weight: 700; line-height: 1.1; color: var(--ink); }
.stat .l { font-size: .8rem; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.stat .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--neutral); flex: none; }
.stat.s-ok .dot { background: var(--ok); }
.stat.s-warn .dot { background: var(--warn); }
.stat.s-serious .dot { background: var(--serious); }
.stat.s-serious .n { color: var(--serious); }
.stat:hover { border-color: var(--ink-3); }

/* ---- bar list (single-hue magnitude) ---- */
.barlist { display: flex; flex-direction: column; gap: 7px; }
.barlist .row { display: grid; grid-template-columns: 170px 1fr 42px; gap: 10px; align-items: center; font-size: .85rem; }
.barlist .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.barlist .track { background: var(--surface); border-radius: 4px; height: 14px; }
.barlist .fill { background: #a63d45; height: 100%; border-radius: 4px 4px 4px 4px; min-width: 2px; }
.barlist .val { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---- filter bar (inside a phone-collapsible disclosure) ---- */
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filterbar .field { min-width: 140px; flex: 0 1 auto; }
.filterbar .field.grow { flex: 1 1 220px; }
.filters > summary { display: none; }  /* desktop: always-open filter bar, no toggle */
@media (max-width: 560px) {
  .filters > summary { display: inline-block; margin-bottom: 10px; }
  .filters .filterbar { flex-direction: column; align-items: stretch; }
  .filters .filterbar .field { min-width: 0; }
}
.chips { margin-bottom: 14px; }

/* ---- equipment list: desktop table vs phone cards ---- */
.equipment-table .col-secondary { color: var(--color-muted); }
/* sticky sortable headings need the page (not the wrapper) to be the scroll
   container, so only disable horizontal clipping where the table fits */
@media (min-width: 1100px) {
  .equipment-wrap { overflow-x: visible; }
  .equipment-table thead th { position: sticky; top: 58px; background: var(--card); z-index: 5; box-shadow: 0 1px 0 var(--line); }
}
.item-cards { display: none; list-style: none; margin: 0; padding: 0; }
@media (max-width: 560px) {
  .equipment-wrap { display: none; }
  .item-cards { display: flex; flex-direction: column; gap: 10px; }
  .item-card {
    display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 12px 14px; min-height: var(--target-min);
  }
  .item-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .item-card-head strong { font-size: 1.05rem; }
  .item-card-type { font-weight: 600; color: var(--ink); }
  .item-card-meta { font-size: .84rem; color: var(--ink-2); }
}

/* ---- login ---- */
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand-big { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 16px; text-align: center; }
.auth-card .brand-big img { width: 84px; height: 84px; object-fit: contain; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.page-subtitle { margin: -8px 0 12px; color: var(--color-muted); font-size: .9rem; max-width: 64ch; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; font-size: .9rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
@media (max-width: 560px) { .kv { grid-template-columns: 130px 1fr; } }

/* ---- team directory: A-Z jump bar ---- */
.alpha-index { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 14px; }
.alpha-index a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; min-height: 32px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: var(--radius-control);
  background: var(--card); text-decoration: none; font-size: .9rem;
}
.alpha-index a[aria-current="true"] { background: var(--red); border-color: var(--red); color: #fff; }
@media (max-width: 560px) {
  .alpha-index a { min-width: var(--target-min); min-height: var(--target-min); }
}
