/* -----------------------------------------------------------------------------
 * Edge — GT7 Telemetry — shared design system
 *
 * Tokens + page-shell rules + scrollbar styling shared across every page.
 * Visual language is "digit-edge": navy-dominant surfaces, signature blue
 * #409ed7 accents, sharp 6 px geometry, Inter throughout. Source of
 * truth for the brand tokens lives in
 *   C:/Users/mihae/Documents/NEW Stream Overalys/Banners/design-systems/
 *   digit-edge/colors_and_type.css
 * The design language was originally proven on the Banners > banner-creator
 * tool and is mirrored here so the app and the marketing surfaces feel
 * like the same product.
 *
 * Single-scroll-container rule:
 *   There is exactly ONE scrollbar per page and it lives on <body> — which
 *   puts it at the right edge of the viewport. .gt7-main is NOT a scroll
 *   container. Pages that previously set `overflow:auto` on inner panels
 *   should not — those create "scrollbars in the middle of the window"
 *   which is exactly what the user complained about.
 *
 *   The only sanctioned exception is a self-contained side panel (e.g.
 *   practice.html's drill sidebar) that's side-by-side with main content.
 *   Even those should be styled with .gt7-scroll so the scrollbar matches.
 * -------------------------------------------------------------------------- */

/* Pull Inter from Google so the whole app uses the celeritas-tools-php /
 * digit-edge brand face. Loaded via @import in this stylesheet so we don't
 * have to add a <link> to every HTML page. Display: swap so the page
 * renders in fallback sans-serif while the woff2 streams in.
 *
 * Mirrors the celeritas digit-edge token:
 *   --de-font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system,
 *                    'Helvetica Neue', Arial, sans-serif;
 * (see celeritas-tools-php/static/css/digit-edge.css). Most pages already
 * pulled in Inter via a per-page <link> so this is largely redundant —
 * keeping the @import here means a deleted/forgotten <link> won't FOUC. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* Paint the digit-edge navy before anything else renders. Without this, the
 * browser flashes its default white canvas between tab navigations (each
 * tab is a full page load) before Tailwind's `bg-background-dark` utility
 * kicks in. Setting it here — loaded in <head> before Tailwind — means the
 * very first paint is already the correct color. */
html, body {
  background-color: #09162d;
  color: #ffffff;
}

/* ── Date inputs — app-wide brand-match ──────────────────────────────
 *
 * The native browser date popup can only be styled with
 * `color-scheme: dark` (gives a dark theme but no brand colours, no
 * Inter font, no sharp digit-edge corners). For a fully-branded
 * picker we ship our own — gt7-datepicker.js suppresses the native
 * popup and renders the popup defined below.
 *
 * The native calendar-icon indicator is replaced with our own —
 * white via `filter: invert` so it actually shows on the navy input.
 * Hidden after JS enhancement (.gt7-dp-input) since our popup opens
 * on click of the whole input anyway. */
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="week"] {
  color-scheme: dark;
}
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="week"]::-webkit-calendar-picker-indicator {
  /* Replace the native black indicator glyph with our own white
   * calendar SVG. The `filter: invert(1) brightness(2)` approach
   * works in most Chromium versions, but Electron 28 has a quirk
   * where the indicator's default rendering uses a paint method
   * that's invisible to CSS filter. Setting background-image is
   * more reliable — it replaces the native icon outright. The
   * SVG is white-stroked at 2 px so it reads cleanly on the navy
   * input background. !important on the colour-affecting properties
   * to defeat any later Tailwind preflight that might land. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
  width: 18px;
  height: 18px;
  /* Override the default black glyph that would otherwise still show
   * underneath the background-image in some Chromium builds. */
  color: transparent;
  filter: none !important;
  opacity: 0.85;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover,
input[type="month"]::-webkit-calendar-picker-indicator:hover,
input[type="week"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}
/* Native calendar-picker indicator stays VISIBLE (so the user has a
 * visual cue that the field is a date) with the white-filter from above.
 * `pointer-events: none` makes it click-through — the click passes to
 * the input, whose mousedown handler fires our custom picker rather
 * than the native one. The cursor on the input is already set by the
 * page's input class (text/pointer), so the icon doesn't need its own. */
input.gt7-dp-input::-webkit-calendar-picker-indicator {
  pointer-events: none;
}

/* Inline edit fields (the "dd / mm / yyyy" placeholder text inside
 * the input). Slate-muted so empty state matches other inputs. */
input[type="date"]::-webkit-datetime-edit,
input[type="datetime-local"]::-webkit-datetime-edit {
  color: rgba(226, 232, 240, 0.95);
}
input[type="date"]::-webkit-datetime-edit-text,
input[type="datetime-local"]::-webkit-datetime-edit-text {
  color: rgba(148, 163, 184, 0.6);
  padding: 0 2px;
}

/* ── Custom date picker popup (driven by gt7-datepicker.js) ───────── */
.gt7-dp-popup {
  background: rgba(9, 22, 45, 0.98);
  border: 1px solid rgba(64, 158, 215, 0.4);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(64, 158, 215, 0.18), 0 0 30px rgba(64, 158, 215, 0.18);
  min-width: 268px;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: rgba(226, 232, 240, 0.92);
  user-select: none;
  -webkit-user-select: none;
}
.gt7-dp-header {
  display: flex; align-items: center; gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(64, 158, 215, 0.16);
  margin-bottom: 8px;
}
.gt7-dp-nav {
  background: transparent;
  border: 1px solid rgba(64, 158, 215, 0.28);
  border-radius: 6px;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  color: rgba(226, 232, 240, 0.85);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  padding: 0;
}
.gt7-dp-nav:hover {
  background: rgba(64, 158, 215, 0.18);
  border-color: rgba(64, 158, 215, 0.55);
  color: #ffffff;
}
.gt7-dp-nav .material-icons { font-size: 18px; line-height: 1; }
.gt7-dp-label {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ffffff;
}
.gt7-dp-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}
.gt7-dp-dow span {
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.7);
  padding: 4px 0;
}
.gt7-dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.gt7-dp-day {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: rgba(226, 232, 240, 0.88);
  cursor: pointer;
  padding: 0;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.gt7-dp-day:hover {
  background: rgba(64, 158, 215, 0.18);
  border-color: rgba(64, 158, 215, 0.5);
  color: #ffffff;
}
.gt7-dp-day.is-other {
  color: rgba(148, 163, 184, 0.32);
}
.gt7-dp-day.is-today {
  border-color: rgba(64, 158, 215, 0.55);
  font-weight: 700;
}
.gt7-dp-day.is-selected {
  background: #409ed7;
  border-color: #409ed7;
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 0 12px rgba(64, 158, 215, 0.4);
}
.gt7-dp-day.is-selected:hover {
  background: #4baddf;
  border-color: #4baddf;
}
.gt7-dp-footer {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid rgba(64, 158, 215, 0.16);
  margin-top: 8px;
}
.gt7-dp-action {
  background: transparent;
  border: 1px solid rgba(64, 158, 215, 0.28);
  border-radius: 6px;
  padding: 5px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.85);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.gt7-dp-action:hover {
  background: rgba(64, 158, 215, 0.18);
  border-color: rgba(64, 158, 215, 0.55);
  color: #ffffff;
}
.gt7-dp-action.gt7-dp-action--primary {
  background: #409ed7;
  border-color: #409ed7;
  color: #ffffff;
}
.gt7-dp-action.gt7-dp-action--primary:hover {
  background: #4baddf;
  border-color: #4baddf;
}

/* App-wide Inter — matches celeritas-tools-php's `--de-font-sans` token
 * exactly. Tailwind already has Inter configured per page via fontFamily,
 * but this body-level rule with !important guarantees it wins even when
 * a child has a stale Montserrat declaration that hasn't been migrated. */
body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Cross-document view transitions (Chromium 111+, which Electron uses).
 * The browser cross-fades between page navigations so the visible "tabs
 * jumping around" effect from each full page load disappears — even
 * though we're not a SPA, the user perceives smooth transitions. */
@view-transition {
  navigation: auto;
}

/* Reserve the sidebar nav's stacking position across the transition so it
 * doesn't briefly reflow / shift on each navigation. Same idea for the
 * sticky page header — both elements visually stay put while only the
 * main content cross-fades. */
nav.fixed { view-transition-name: gt7-sidebar; }
.gt7-titlebar { view-transition-name: gt7-titlebar; }

/* Bake in critical sidebar link styles so they don't pop in once Tailwind
 * loads (Tailwind CDN is async — there's a 50–100 ms gap on slow loads
 * where utility classes like `flex flex-col items-center` aren't applied
 * yet, which is the "moving" effect you see). These match the existing
 * Tailwind output so nothing changes once Tailwind takes over. */
nav.fixed { display: flex; flex-direction: column; align-items: center; }
nav.fixed > div.flex.flex-col { display: flex; flex-direction: column; align-items: center; }
/* Fixed width on every sidebar link so the ACTIVE pill (bg-primary/10 rounded-lg
   on the current page's link) is the SAME size on every tab — without this it
   sized to each label, so "FAQ" got a small pill and "RECORDING"/"TELEMETRY" a
   wide one. */
nav.fixed a { display: flex; flex-direction: column; align-items: center; gap: 0.125rem; padding: 0.5rem; width: 5rem; box-sizing: border-box; color: #64748b; text-decoration: none; }
nav.fixed a span:last-child { white-space: nowrap; }

:root {
  /* digit-edge brand colours (from colors_and_type.css). The Tailwind
   * config in each HTML page maps `primary` and `background-dark` to
   * these same hex values so utilities like `bg-primary/20` match. */
  --gt7-bg:               #09162d;   /* page background — digit-edge navy */
  --gt7-bg-elev-1:        #0d1c38;   /* card on page */
  --gt7-bg-elev-2:        #112344;   /* card on card */
  --gt7-bg-inset:         #06102a;   /* sunken — form inputs, terminal-like */
  --gt7-bg-raised:        rgba(13, 28, 56, 0.7);
  --gt7-primary:          #409ed7;   /* signature digit-edge blue */
  --gt7-primary-soft:     rgba(64, 158, 215, 0.12);
  --gt7-border:           rgba(255, 255, 255, 0.08);
  --gt7-border-strong:    rgba(64, 158, 215, 0.4);
  --gt7-text:             #ffffff;
  --gt7-text-dim:         #b9c6dc;
  --gt7-text-faint:       #7a8aa6;
  --gt7-radius:           6px;        /* digit-edge: sharp, geometric */
  --gt7-radius-card:      8px;
  --gt7-nav-w:            6rem;
  --gt7-header-h:         3.5rem;
  --gt7-page-pad:         1.25rem;
  --gt7-scrollbar:        rgba(64, 158, 215, 0.35);
  --gt7-scrollbar-hover:  rgba(64, 158, 215, 0.6);
}

/* -----------------------------------------------------------------------------
 * Themed scrollbars — matches the blue/dark palette instead of default OS grey.
 *
 * Applied globally so every scrollable element (body, aside, modals, tables)
 * gets the same treatment. Keeps the bar narrow and translucent so it doesn't
 * draw attention.
 * -------------------------------------------------------------------------- */

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--gt7-scrollbar);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--gt7-scrollbar-hover);
  background-clip: padding-box;
  border: 2px solid transparent;
}

/* Firefox */
* {
  scrollbar-color: var(--gt7-scrollbar) transparent;
  scrollbar-width: thin;
}

/* -----------------------------------------------------------------------------
 * Page shell — uses the natural document flow so body = scroll container.
 *
 * html/body: no overflow rules that would trap scroll inside a child. The
 * existing per-page `body { overflow-x: hidden }` stays (prevents accidental
 * horizontal scroll on narrow viewports) — we only touch overflow-y.
 * -------------------------------------------------------------------------- */

html, body {
  overflow-y: auto; /* body scrolls → scrollbar on window right edge */
}

/* -----------------------------------------------------------------------------
 * .gt7-shell — outer column (right of the fixed sidebar)
 *
 * All pages put their header + main inside a flex column that starts at the
 * left edge of the content area (past the 96px sidebar). This class
 * replicates the hand-written `ml-24 flex flex-col min-h-screen` combo so
 * pages that opt in get it in one token.
 * -------------------------------------------------------------------------- */

.gt7-shell {
  margin-left: var(--gt7-nav-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* -----------------------------------------------------------------------------
 * .gt7-main — standard page content area
 *
 * Before: had max-width:1400px + margin:auto → content centered with empty
 * gutters on wide screens AND the scrollbar appeared in the middle of the
 * window when overflow was set. Both fixed by letting main fill the width
 * and deferring scrolling to <body>.
 *
 * We still keep flex-column layout so `.gt7-fill` children expand to
 * remaining vertical space on pages like recording.
 * -------------------------------------------------------------------------- */

.gt7-main {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: var(--gt7-page-pad);
  gap: 0.75rem;
}

/* .gt7-main--scroll is now a NO-OP shell (body already scrolls) but kept so
 * existing class attrs don't fail any expectations. */
.gt7-main--scroll {
  /* intentionally empty — body is the scroll container */
}

/* .gt7-main--wide used to turn off the max-width cap; now main is always full
 * width so this is also a no-op. Left as a marker class. */
.gt7-main--wide {
  /* intentionally empty */
}

/* -----------------------------------------------------------------------------
 * .gt7-fill — child that takes the remaining vertical space
 *
 * For pages with a main content pane (recording's map, dashboard panels)
 * that should stretch to fit the viewport instead of pegging to a content
 * height. Uses flex:1 + min-height:0 so it plays nicely inside .gt7-main.
 * -------------------------------------------------------------------------- */

.gt7-fill {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* For pages that genuinely need a scrollable inner panel (practice's sticky
 * drill sidebar), attach this class so the scrollbar matches the theme. */
.gt7-scroll {
  overflow-y: auto;
  scrollbar-gutter: stable;
}

/* -----------------------------------------------------------------------------
 * Cards / sections — one look across pages.
 * -------------------------------------------------------------------------- */

.gt7-card {
  background: var(--gt7-bg-raised);
  border: 1px solid var(--gt7-border);
  border-radius: var(--gt7-radius);
  padding: 1rem 1.25rem;
}

.gt7-card--accent {
  border-left: 3px solid var(--gt7-primary);
}

.gt7-card-title {
  margin: 0 0 0.75rem 0;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--gt7-text-dim);
  border-bottom: 1px solid var(--gt7-border);
  padding-bottom: 0.5rem;
}

/* -----------------------------------------------------------------------------
 * digit-edge utility classes
 *
 * Mirrors the patterns used by the banner-creator marketing tool so the
 * app and the marketing surfaces feel like the same product. Use these
 * for new UI work; existing Tailwind utility-based markup keeps working
 * unchanged because we only changed the colour TOKENS, not the classes.
 * -------------------------------------------------------------------------- */

/* Card with the brand-blue accent rail on the left, mirroring the Tires +
 * Telemetry — digit-edge overlay. Padding 18 px / 20 px is the rhythm the
 * banner-creator uses on its `.gen-card`. */
.de-card {
  position: relative;
  background: var(--gt7-bg-elev-1);
  border: 1px solid var(--gt7-border);
  border-radius: var(--gt7-radius-card);
  padding: 18px 20px;
}
.de-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--gt7-primary);
  border-radius: var(--gt7-radius-card) 0 0 var(--gt7-radius-card);
}

/* Section heading — small, uppercase, wide-tracked. The visual signature
 * of the banner-creator side-panels and our admin section heads. */
.de-heading {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--gt7-text-dim);
  text-transform: uppercase;
  margin: 0 0 0.75rem 0;
}

/* Primary CTA — solid brand blue with navy text. This is the banner
 * creator's main "Generate" button styling. */
.de-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  background: var(--gt7-primary);
  color: var(--gt7-bg);
  border: 0;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter 120ms ease, box-shadow 120ms ease, transform 80ms ease;
  box-shadow: 0 4px 12px rgba(64, 158, 215, 0.25);
}
.de-btn-primary:hover { filter: brightness(1.1); box-shadow: 0 6px 18px rgba(64, 158, 215, 0.45); }
.de-btn-primary:active { transform: translateY(1px); }
.de-btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

/* Ghost button — for secondary actions next to a primary. */
.de-btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: transparent;
  border: 1px solid var(--gt7-border);
  border-radius: 4px;
  color: var(--gt7-text-dim);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}
.de-btn-ghost:hover { border-color: var(--gt7-primary); color: var(--gt7-primary); }

/* Form input — the banner-creator's deep-inset, blue-focus look. Apply
 * to <input>, <select>, <textarea> by adding the class, OR opt-in for
 * the whole form via a `.de-form` wrapper. */
.de-input,
.de-form input[type="text"],
.de-form input[type="email"],
.de-form input[type="password"],
.de-form input[type="number"],
.de-form input[type="search"],
.de-form input[type="date"],
.de-form select,
.de-form textarea {
  padding: 9px 12px;
  background: var(--gt7-bg-inset);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--gt7-text);
  border-radius: 4px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.de-input::placeholder, .de-form input::placeholder, .de-form textarea::placeholder {
  color: var(--gt7-text-faint);
}
.de-input:focus,
.de-form input:focus,
.de-form select:focus,
.de-form textarea:focus {
  outline: none;
  border-color: var(--gt7-primary);
  box-shadow: 0 0 0 1px var(--gt7-primary);
}

/* Highlight — glowing blue underline behind a span of text. Used in the
 * banner-creator on hero phrases like "GENERATE". */
.de-hl {
  color: var(--gt7-primary);
  position: relative;
  display: inline-block;
}
.de-hl::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 2px;
  background: var(--gt7-primary);
  box-shadow: 0 0 14px rgba(64, 158, 215, 0.7);
}

/* -----------------------------------------------------------------------------
 * Sticky tab strip (admin, telemetry).
 *
 * Now that body scrolls (not main), sticky works naturally: top: 0 sticks
 * the strip to the viewport. No z-index wars needed.
 * -------------------------------------------------------------------------- */

.gt7-tabs {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  gap: 0.25rem;
  padding: 0 1.5rem;
  background: rgba(16, 23, 41, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--gt7-border);
  flex-shrink: 0;
  overflow-x: auto;
}

.gt7-tab {
  padding: 0.625rem 1.25rem;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--gt7-text-dim);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: transparent;
  transition: color 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}

.gt7-tab:hover { color: var(--gt7-text); }

.gt7-tab.active {
  color: var(--gt7-primary);
  border-bottom-color: var(--gt7-primary);
}

/* -----------------------------------------------------------------------------
 * Toolbars + tables + pills (unchanged from before).
 * -------------------------------------------------------------------------- */

.gt7-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem 0;
  margin-bottom: 0.5rem;
}

.gt7-toolbar > .gt7-toolbar-spacer { flex: 1; }

.gt7-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.gt7-table th,
.gt7-table td {
  padding: 0.625rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.gt7-table th {
  color: var(--gt7-text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.6875rem;
}

.gt7-table td { color: var(--gt7-text); }

.gt7-table tbody tr:hover td {
  background: rgba(29, 133, 246, 0.06);
}

.gt7-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
  border: 1px solid currentColor;
  background-color: var(--gt7-primary-soft);
}

.gt7-main > :first-child { margin-top: 0; }

/* -----------------------------------------------------------------------------
 * Custom title bar (Electron only)
 *
 * Injected by static/js/gt7-titlebar.js when running inside the Electron main
 * window. Lives above every other chrome on the page (sidebar, header). The
 * empty middle area is draggable; everything else isn't, so clicks on the
 * logo + buttons register normally.
 * -------------------------------------------------------------------------- */

:root {
  /* 0 now: the window controls (min/max/close) live INSIDE the page header next
     to the connection badge (see gt7-titlebar.js), so there's no separate
     title-bar strip to reserve space for. Every offset rule below reads this var,
     so 0 collapses them all and the header sits flush at the very top. */
  --gt7-titlebar-h: 0px;
}

/* Do NOT use padding-top on <body> here — combined with the Tailwind
 * `min-h-screen` on the `.ml-24` wrapper that every page uses, you get
 * 100vh + 36px of total content height and an equal overflow of empty
 * black below the main area. Instead we push the wrapper itself down and
 * subtract the title bar height from its minimum, so the content sits
 * under the title bar and ends exactly at the window's bottom edge.
 */

html.gt7-in-electron .ml-24 {
  margin-top: var(--gt7-titlebar-h) !important;
  min-height: calc(100vh - var(--gt7-titlebar-h)) !important;
}

/* Special case: pages using h-screen (recording, telemetry) need the full
 * height overridden too. Tailwind's `h-screen { height: 100vh }` loads
 * after this file (injected at runtime by the CDN script) so we use
 * !important to win regardless of source order. */
html.gt7-in-electron .ml-24.h-screen {
  height: calc(100vh - var(--gt7-titlebar-h)) !important;
}

/* For pages where .ml-24 is itself the scroll container (h-screen +
 * overflow-hidden — recording.html), the wrapper is already shifted down
 * by margin-top, so sticky children inside should stick at top:0 of the
 * wrapper (= viewport y=36), NOT top:36 of the wrapper (= viewport y=72).
 * Override our general `.sticky.top-0` offset rule in that case. */
html.gt7-in-electron .ml-24.h-screen > header.sticky,
html.gt7-in-electron .ml-24.h-screen > .sticky.top-0 {
  top: 0 !important;
}

html.gt7-in-electron .gt7-shell {
  margin-top: var(--gt7-titlebar-h) !important;
  min-height: calc(100vh - var(--gt7-titlebar-h)) !important;
}

html.gt7-in-electron nav.fixed {
  top: var(--gt7-titlebar-h) !important;
  height: calc(100vh - var(--gt7-titlebar-h)) !important;
}

/* Sidebar shouldn't lose nav items (especially LOG OUT) on short windows.
 * Make it scrollable internally — its own scrollbar matches the global
 * theme via the shared scrollbar styling above. Combined with tighter
 * vertical spacing on the nav links (gap reduced from 1.25rem to 0.5rem,
 * padding p-2 → p-1.5 on each link via JS-injected button + CSS below),
 * the LOG OUT button stays in view at common viewport heights. */
nav.fixed.h-full,
nav.fixed[class*="w-24"] {
  overflow-y: auto;
  overflow-x: hidden;
  /* Hide the scrollbar visually — it's still functional, just doesn't
   * steal pixels from the already narrow 96 px column. */
  scrollbar-width: none;
}
nav.fixed.h-full::-webkit-scrollbar,
nav.fixed[class*="w-24"]::-webkit-scrollbar {
  display: none;
}

/* Tighten the nav link spacing so all 8 items + LOG OUT fit on a 720 p
 * Electron window without scrolling. Targets the inner flex column the
 * pages use (`<div class="flex flex-col gap-5">`) — overrides the gap. */
nav.fixed > div.flex.flex-col.gap-5 {
  gap: 0.5rem !important;
}
nav.fixed > div.flex.flex-col.gap-5 > a,
#gt7-logout-btn {
  padding: 0.375rem 0.5rem !important;
}

/* Every sticky chrome element (page header, internal tab strips on admin +
 * telemetry) needs to sit below the 36 px custom title bar. Tailwind's
 * `top-0` utility has the same specificity as `header.sticky` and can win
 * depending on stylesheet load order (Tailwind is injected at runtime by
 * its CDN script, AFTER this file), so the `!important` below is the
 * clean way to pin the shift regardless of ordering.
 *
 * The broad `.sticky.top-0` catches any ad-hoc sticky div a page author
 * adds later without us having to touch this file again. */
html.gt7-in-electron .gt7-header,
html.gt7-in-electron .gt7-tabs,
html.gt7-in-electron header.sticky,
html.gt7-in-electron .sticky.top-0,
html.gt7-in-electron [class*="sticky"][class*="top-0"] {
  top: var(--gt7-titlebar-h) !important;
}

.gt7-titlebar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--gt7-titlebar-h);
  z-index: 1000;
  display: flex;
  align-items: center;
  background: #0c1323;          /* slightly darker than the page so it reads
                                   as a distinct strip above the content */
  border-bottom: 1px solid var(--gt7-border);
  color: var(--gt7-text);
  font-family: Inter, system-ui, sans-serif;
  user-select: none;
  -webkit-app-region: drag;     /* whole bar draggable by default */
}

.gt7-titlebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem;
  -webkit-app-region: no-drag;  /* so right-click-context etc. still work */
}

.gt7-titlebar-logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.gt7-titlebar-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--gt7-text-dim);
  letter-spacing: 0.02em;
}

.gt7-titlebar-drag {
  flex: 1;
  height: 100%;
  -webkit-app-region: drag;
}

.gt7-titlebar-controls {
  display: flex;
  height: 100%;
  -webkit-app-region: no-drag;
}

.gt7-titlebar-btn {
  width: 46px;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--gt7-text-dim);
  cursor: pointer;
  padding: 0;
  /* Match the hover feel of the rest of the app — soft primary tint, no
   * hard border or shadow, instant transition. */
  transition: background-color 0.12s ease, color 0.12s ease;
}

.gt7-titlebar-btn:hover {
  background: var(--gt7-primary-soft);
  color: var(--gt7-text);
}

.gt7-titlebar-btn:active {
  background: rgba(29, 133, 246, 0.22);
}

/* Close button gets the app's chart-red hover tint — standard Windows
 * convention, adapted to our palette. */
.gt7-titlebar-close:hover {
  background: rgba(239, 67, 67, 0.85);
  color: #fff;
}

.gt7-titlebar-close:active {
  background: rgba(239, 67, 67, 1);
}

.gt7-titlebar-btn svg {
  pointer-events: none;         /* so the button, not the svg, gets the click */
}

/* ── In-header window controls (Electron) ────────────────────────────────────
   The min/max/close buttons now live INSIDE each page's sticky header, appended
   next to the connection badge by gt7-titlebar.js — so the window chrome reads as
   part of the frame, not a separate strip. The header itself becomes the drag
   region (so the user can still move the frameless window by grabbing an empty
   part of it); every interactive child opts out with no-drag. Only applied inside
   Electron (html.gt7-in-electron) so the plain-browser dev view is unaffected. */
html.gt7-in-electron header.sticky { -webkit-app-region: drag; }
html.gt7-in-electron header.sticky a,
html.gt7-in-electron header.sticky button,
html.gt7-in-electron header.sticky input,
html.gt7-in-electron header.sticky select,
html.gt7-in-electron header.sticky textarea,
html.gt7-in-electron header.sticky label,
html.gt7-in-electron header.sticky .badge,
html.gt7-in-electron header.sticky .cursor-pointer,
html.gt7-in-electron header.sticky [role="tab"],
html.gt7-in-electron header.sticky [role="tablist"],
html.gt7-in-electron header.sticky .gt7-win-controls {
  -webkit-app-region: no-drag;
}

/* Tight right-hand group: [connection badge][min][max][close], kept together so
   the badge never strands in the middle of a justify-between header. */
.gt7-win-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  -webkit-app-region: no-drag;
}
.gt7-win-controls {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  -webkit-app-region: no-drag;
}
.gt7-win-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(203, 213, 225, 0.85);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.gt7-win-btn:hover { background: rgba(255, 255, 255, 0.10); color: #fff; }
.gt7-win-btn:active { background: rgba(255, 255, 255, 0.16); }
.gt7-win-close:hover { background: #e11d2a; color: #fff; }
.gt7-win-close:active { background: #b91c24; color: #fff; }
.gt7-win-btn svg { pointer-events: none; display: block; }

/* Fallback when a page somehow has no header to anchor into — pin to the
   top-right corner so the controls are never lost. */
.gt7-win-controls-floating {
  position: fixed;
  top: 5px;
  right: 7px;
  z-index: 120;
  background: rgba(13, 28, 54, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 2px;
}

/* Admin tab-bar mount: the controls sit at the right end of the .gt7-tabs bar,
   inline with the tabs (so they read as the SAME frame controls as every other
   page — not a floating box). `position: sticky; right: 0` keeps them pinned to
   the visible right edge even if the tabs overflow-scroll on a narrow window. */
.gt7-win-controls-in-tabs {
  margin-left: auto;
  position: sticky;
  right: 0;
  align-self: center;
  background: rgba(16, 23, 41, 0.95);
  padding-left: 8px;
}
/* In Electron, the admin tab bar doubles as the window drag handle (its empty
   area moves the window) while the tabs + controls stay clickable. */
html.gt7-in-electron .gt7-tabs { -webkit-app-region: drag; }
html.gt7-in-electron .gt7-tabs button,
html.gt7-in-electron .gt7-tabs a,
html.gt7-in-electron .gt7-tabs input,
html.gt7-in-electron .gt7-tabs select,
html.gt7-in-electron .gt7-tabs .gt7-win-controls { -webkit-app-region: no-drag; }

/* -----------------------------------------------------------------------------
 * Mobile navigation — phones / narrow windows (≤ 768px)
 *
 * Every page shares the same fixed LEFT sidebar (nav.fixed.top-0.left-0,
 * 96px wide) with the content wrapper offset by .ml-24. On a phone that
 * sidebar eats a quarter of the screen, so below 768px it becomes a
 * BOTTOM tab bar (icons + tiny labels, horizontally scrollable if it
 * ever overflows) and the content wrapper drops its left margin and
 * gains bottom padding so nothing hides behind the bar.
 *
 * !important throughout: the Tailwind CDN injects its utilities at
 * runtime AFTER this stylesheet, so plain rules would lose the tie.
 * Added for the Traces Phone companion app; also improves any narrow
 * desktop window.
 * -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  body > nav.fixed.top-0.left-0 {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    height: 62px !important;
    width: 100% !important;
    flex-direction: row !important;
    align-items: center !important;
    padding: 0 2px !important;
    border-right: 0 !important;
    border-top: 1px solid rgba(64, 158, 215, 0.25) !important;
    background: #09162d !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  body > nav.fixed.top-0.left-0::-webkit-scrollbar { display: none; }
  body > nav.fixed.top-0.left-0 > div {
    flex-direction: row !important;
    justify-content: space-around !important;
    align-items: center !important;
    gap: 0 !important;
    width: 100%;
    min-width: max-content;
  }
  body > nav.fixed.top-0.left-0 a {
    padding: 6px 9px !important;
    flex-shrink: 0;
  }
  body > nav.fixed.top-0.left-0 a .material-icons { font-size: 22px; }
  /* The wrapper next to the nav loses the sidebar offset and reserves
     space for the bottom bar instead. */
  body > div.ml-24 {
    margin-left: 0 !important;
    padding-bottom: 62px;
  }
}
