/* =====================================================================
   Cadence — admin dashboard
   BASE — reset, element defaults, generic utilities, and the app shell
   layout (sidebar + nav + page header + content column). Structural only;
   anything with a shape/colour of its own lives in components.css.
   ===================================================================== */

/* ---------- Reset / base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Satoshi', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: var(--type-body-lg);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
h1, h2, h3 { line-height: 1.2; letter-spacing: -.02em; margin: 0; font-weight: 700; }
p { margin: 0; }
button { font: inherit; color: inherit; }
input, select { font: inherit; color: inherit; }
svg { display: block; }
.ic { width: var(--ic); height: var(--ic); fill: currentColor; stroke: none; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
[role="tab"]:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Utilities ---------- */
/* `!important` for the same reason as `[hidden]` below, and it is load-bearing:
   `.hidden` is a single class, so it loses to any equally-specific `display:`
   rule declared later in the cascade — and three of the elements the JS hides
   with it have exactly that:
     .shell  { display: grid  }  base.css:59   (later in THIS file)
      .panel  { display: block }  base.css:122  (later in THIS file)
      .login  { display: flex  }  components.css, which loads after base.css
   Without this, showApp()/showLogin()/switchTab() add the class and nothing
   happens: the login card and all five panels render stacked on one page,
   for signed-out visitors too. Regression from the split of the admin
   monolith into per-concern stylesheets, where the old ordering hid it. */
.hidden { display: none !important; }
/* The `hidden` ATTRIBUTE only hides via the UA stylesheet, which any author
   `display:` rule outranks — so `.notice[hidden]`, `.bank[hidden]` and friends
   would stay on screen. The JS hides several elements this way (tryShow, the
   nav badges, the login code row); make the attribute actually mean hidden. */
[hidden] { display: none !important; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.is-busy { cursor: progress; }
button.is-busy { opacity: .7; pointer-events: none; }

/* ---------- App shell — sidebar + main ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: var(--space-xs);
  background: var(--surface); border-right: 1px solid var(--border-2);
  padding: var(--space-sm) 0;
}
.sidebar__brand {
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-xs) 0 var(--space-md);
}
.sidebar__word { display: none; }

/* Nav — M3 Navigation Rail: icon-only, centered, 56dp touch targets. */
.nav { display: flex; flex-direction: column; gap: var(--space-xs); flex: 1; align-items: center; }
.nav__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 56px; height: 56px; gap: 2px;
  border: none; background: transparent; color: var(--muted);
  font-weight: 600; font-size: var(--type-label-sm); border-radius: var(--radius-lg);
  cursor: pointer; text-align: center; position: relative;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav__item .ic { width: var(--ic); height: var(--ic); flex: none; }
.nav__label { display: none; }
/* M3 state layer: 8% on-surface wash. */
.nav__item:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
.nav__item[aria-selected="true"] {
  background: var(--accent-tint); color: var(--accent-ink);
}
.nav__badge { display: none; }

.sidebar__foot {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--space-xs); padding-top: var(--space-sm);
  border-top: 1px solid var(--border-2);
}
.sidebar__actions { display: flex; flex-direction: column; align-items: center; gap: var(--space-xs); }
.who {
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-xs);
}
.who__avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: #fff;
  background: var(--accent);
}
.who__meta { display: none; }

/* Theme toggle — M3 icon button in rail. */
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none;
  border: none; border-radius: 50%;
  background: transparent; color: var(--muted);
  cursor: pointer; position: relative;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.theme-toggle:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
.theme-toggle__moon,
.theme-toggle__sun { display: flex; align-items: center; justify-content: center; }
/* Show sun in dark mode, moon in light mode (the thing you click to switch TO). */
:root:not([data-theme]) .theme-toggle__moon { display: flex; }
:root:not([data-theme]) .theme-toggle__sun { display: none; }
:root[data-theme="dark"] .theme-toggle__sun { display: flex; }
:root[data-theme="dark"] .theme-toggle__moon { display: none; }
:root[data-theme="light"] .theme-toggle__moon { display: flex; }
:root[data-theme="light"] .theme-toggle__sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle__sun { display: flex; }
  :root:not([data-theme]) .theme-toggle__moon { display: none; }
}

/* Sign-out icon-only in rail — the .nav__label inside #sign-out hides like nav labels. */
#sign-out { width: 40px; height: 40px; padding: 0; border-radius: 50%; }

/* Mobile drawer scrim — a grid child would steal the second shell column on
   desktop, so it is display:none here and only appears as a fixed overlay
   inside the under-900px drawer block (responsive.css). */
.nav-backdrop { display: none; }

/* Main column */
.main { min-width: 0; display: flex; flex-direction: column; }
.pagehead {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px clamp(16px, 3vw, 30px);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.pagehead__title { font-size: var(--type-title-lg); }
.pagehead__sub { color: var(--muted); font-size: var(--type-body-md); margin-top: 2px; }
.content {
  flex: 1; width: 100%;
  padding: clamp(18px, 3vw, 28px) clamp(16px, 3vw, 30px) 64px;
}
.panel { display: block; }
.panel__toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.field--search { flex: 1 1 260px; max-width: 460px; }
.panel__count { color: var(--muted); font-size: .85rem; font-weight: 500; }