/* ─────────────────────────────────────────────
   Tour Budget CMS — App Shell
   The one piece of chrome shared by every page. See client/js/shell.js.

   Typographic note: labels use DM Mono in the register of a spec sheet —
   uppercase, letter-spaced, small. Money and data elsewhere in the app should
   likewise carry tabular figures; `.tnum` below is the shared utility for that.
───────────────────────────────────────────── */

.shell-topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: var(--topbar-h);
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* ── Wordmark ── */
.shell-brand {
  display: flex;
  align-items: center;
  padding-right: 16px;
  margin-right: 6px;
  font-family: 'Bebas Neue', 'DM Sans', sans-serif;
  font-size: 20px;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  border-right: 1px solid var(--border);
}
.shell-brand span { color: var(--text); }
.shell-brand:hover { color: var(--accent2); }

/* ── Nav ── */
.shell-nav {
  display: flex;
  align-items: stretch;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.shell-nav::-webkit-scrollbar { display: none; }

.shell-group { position: relative; display: flex; }

.shell-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 0;
  background: none;
  cursor: pointer;
  white-space: nowrap;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.12s, border-color 0.12s;
}
.shell-link:hover { color: var(--text); background: var(--accent-subtle); }
.shell-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.shell-link[aria-current="page"],
.shell-trigger.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.shell-caret {
  width: 0; height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.7;
}

/* ── Dropdown ──
   position: FIXED, not absolute. .shell-nav needs overflow-x:auto so the nav can
   scroll on narrow screens, but CSS cannot have overflow visible on one axis and
   auto on the other — overflow-y computes to auto as well, which clipped an
   absolutely-positioned menu to the 52px nav box. The menu was rendered but
   invisible and unclickable. Fixed positioning escapes the ancestor's clipping;
   shell.js sets left/top from the trigger's rect each time it opens. */
.shell-menu {
  position: fixed;
  min-width: 190px;
  padding: 5px;
  display: none;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  z-index: 950;
}
.shell-group.open .shell-menu { display: flex; }

.shell-item {
  padding: 8px 11px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  border-left: 2px solid transparent;
}
.shell-item:hover { background: var(--accent-subtle); color: var(--accent); }
.shell-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.shell-item[aria-current="page"] {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-subtle);
}

/* ── Right cluster ── */
.shell-right {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
  margin-left: 6px;
  border-left: 1px solid var(--border);
}

.shell-user {
  font-family: 'DM Mono', monospace;
  text-decoration: none;
  font-size: 11px;
  color: var(--muted);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell-signout {
  padding: 5px 11px;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.shell-user:hover { color: var(--accent); }
.shell-user:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell-signout:hover { border-color: var(--accent); color: var(--accent); }
.shell-signout:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.shell-topbar .theme-toggle {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 4px 7px;
  line-height: 1;
  font-size: 13px;
}
.shell-topbar .theme-toggle:hover { border-color: var(--accent); }

/* ── Tour context: the stage bar replaces the global menu in the same slot ──
   Once you are inside a tour, day-to-day navigation IS the tour flow. The
   global menu returns on My Dashboard and other non-tour pages. */
.shell-tour-label {
  display: flex; align-items: center; gap: 6px; margin-right: 4px; padding: 0 10px 0 4px;
  font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--muted); text-decoration: none;
  white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis;
  background: none; border: 0; cursor: pointer;
}
.shell-tour-label:hover { color: var(--accent); background: var(--accent-subtle); }
.shell-tour-label:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.shell-tour-label b { color: var(--text); font-weight: 500; }

/* The switcher menu: every tour the user can see, current one marked. */
.shell-tour-menu { min-width: 260px; max-height: 60vh; overflow-y: auto; }
.shell-tour-item { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.sti-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sti-state {
  flex: none; font-family: 'DM Mono', monospace; font-size: 8.5px;
  letter-spacing: 0.09em; text-transform: uppercase; padding: 2px 6px;
}
.sti-final { background: color-mix(in srgb, var(--rag-green) 15%, transparent); color: var(--rag-green); }
.sti-draft { background: var(--surface2); color: var(--muted); }
.sti-band {
  font-family: 'DM Mono', monospace; font-size: 8.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}
.shell-tour-item:hover .sti-band { color: inherit; }
.sti-name { font-size: 13px; }

.shell-nav .stage {
  flex: 0 0 auto; display: flex; flex-direction: column; justify-content: center;
  gap: 2px; padding: 6px 11px 4px; border: 0; background: none; cursor: pointer;
  text-align: left; font: inherit; color: inherit; text-decoration: none;
  border-bottom: 2px solid transparent; min-width: 0;
}
.shell-nav .stage:hover { background: var(--accent-subtle); }
.shell-nav .stage:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.shell-nav .stage.active { border-bottom-color: var(--accent); background: var(--accent-subtle); }
.shell-nav .stage.disabled { cursor: not-allowed; opacity: 0.5; }
.shell-nav .stage.disabled:hover { background: none; }
.shell-nav .st-name { font-family: 'DM Mono', monospace; font-size: 8px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.shell-nav .st-val  { font-family: 'DM Mono', monospace; font-size: 10.5px; font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1; }
.shell-nav .st-meter { height: 2px; background: var(--surface2); min-width: 42px; }
.shell-nav .st-meter > i { display: block; height: 100%; }
.shell-nav .sm-ok > i   { background: var(--rag-green); }
.shell-nav .sm-warn > i { background: var(--rag-amber); }
.shell-nav .sm-crit > i { background: var(--rag-red); }
.shell-nav .sm-idle > i { background: var(--muted); opacity: 0.45; }

/* ── Page headers sit below the shell ──
   Pages keep their own header for page-specific actions; the shell removes the
   duplicated wordmark / back-link / theme toggle from them. A page header that
   was stuck to the top must now stick below the shell instead.

   Scoped to a DIRECT child so it cannot reach headers nested inside panels. */
body.has-shell > header { top: var(--topbar-h); }

/* Pages style the bare `nav` element as a sticky full-height sidebar. The shell
   uses a div, so it is unaffected — but those sidebars must now start below the
   shell rather than under a 56px page header. */
body.has-shell nav { top: calc(var(--topbar-h) + 56px); }

/* Tabular figures — money and any column of digits should line up.
   Applied here as a shared utility so pages can opt in without redefining it. */
.tnum,
td.num, th.num,
.money, .amount {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

@media (max-width: 860px) {
  .shell-brand { padding-right: 10px; margin-right: 2px; font-size: 17px; }
  .shell-user { display: none; }
  .shell-link { padding: 0 9px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .shell-link { transition: none; }
}

/* ── Shared new-tour modal (js/newTour.js) ──────────────────────────────────
   newTour.js injects its markup on ANY shell page; these styles must live
   with the shell, not copied per page — tours.html shipped without them and
   the dialog rendered unstyled in page flow (Cancel "did nothing" because
   .open had no meaning). Scoped under .modal-back so pages with their own
   modal systems (base.css .modal-overlay family) are untouched. */
.modal-back {
  display: none; position: fixed; inset: 0; z-index: 210;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(2px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-back.open { display: flex; }
.modal-back .modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; border-top: 3px solid var(--accent);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  padding: 0;
}
.modal-back .modal-head { padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-back .modal-head h3 { margin: 0; font-family: 'Inter', sans-serif; font-size: 15px; font-weight: 700; }
.modal-back .modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-back .modal-foot { padding: 13px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-back .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-back .note { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.modal-back .err { color: var(--danger); font-size: 12.5px; min-height: 16px; }
.modal-back .cand-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; }
.modal-back .cand { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border-subtle); cursor: pointer; }
.modal-back .cand:last-child { border-bottom: 0; }
.modal-back .cand:hover { background: var(--accent-subtle); }
.modal-back .cand input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; flex: none; }
.modal-back .cand-date { font-family: 'DM Mono', monospace; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.modal-back .cand-venue { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-back .quick { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-back .quick a { font-family: 'DM Mono', monospace; font-size: 10.5px; color: var(--muted); border: 1px solid var(--border); padding: 3px 9px; text-decoration: none; border-radius: 5px; }
.modal-back .quick a:hover { border-color: var(--accent); color: var(--accent); }
.modal-back .task-del { background: none; border: 0; color: var(--muted); cursor: pointer; line-height: 1; padding: 0 2px; }
.modal-back .task-del:hover { color: var(--danger); }
