/* ==========================================================================
   HOBBY VAULT — APPLICATION STYLES
   --------------------------------------------------------------------------
   Design tokens first, then layout, then components. Tailwind utilities handle
   spacing/interaction ergonomics; this sheet owns the theme tokens, the iOS-
   style slider switches, and the pieces Tailwind cannot express cleanly.

   Performance note: everything here is static CSS. There are no runtime
   style recalculations, no layout thrash and no web fonts, which keeps the
   first paint fast on low-end mobile devices.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS
   -------------------------------------------------------------------------- */
:root {
  /* Surfaces — a single dark ramp keeps contrast predictable */
  --surface-base: #0f172a;
  --surface-raised: #1a2438;
  --surface-overlay: #223049;
  --surface-sunken: #0a1020;

  /* Borders */
  --border-subtle: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Brand + semantic accents */
  --accent: #22d3ee;
  --accent-strong: #06b6d4;
  --accent-contrast: #062a33;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --premium: #a78bfa;

  /* Radii + elevation */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 2px rgba(2, 6, 23, 0.4), 0 8px 24px -12px rgba(2, 6, 23, 0.7);

  /* Motion — respects prefers-reduced-motion further down */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 120ms;
  --dur-base: 200ms;

  /* iOS safe-area insets for standalone (chrome-less) display mode */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Tailwind utility bridge: lets markup use bg-surface-base etc. */
.bg-surface-base { background-color: var(--surface-base); }
.bg-surface-raised { background-color: var(--surface-raised); }

/* --------------------------------------------------------------------------
   2. BASE RESET & TYPOGRAPHY
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--surface-base);
  color: var(--text-primary);
  /* System font stack: zero network cost, native feel on every OS. */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* Prevents iOS rubber-band overscroll revealing a white gutter. */
  overscroll-behavior-y: none;
}

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; }

input, button, textarea, select { font: inherit; color: inherit; }

/* Visible, high-contrast focus ring for keyboard users only. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Screen-reader-only helper (used for live regions and icon labels). */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Skip link: hidden until focused, then pinned to the top-left. */
.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 650;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top var(--dur-base) var(--ease-out);
}
.skip-link:focus { top: calc(var(--safe-top) + 12px); }

[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   3. BOOT / SPLASH SCREEN
   -------------------------------------------------------------------------- */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: radial-gradient(120% 90% at 50% 0%, #16203a 0%, var(--surface-base) 60%);
  transition: opacity var(--dur-base) var(--ease-out);
}
.boot-screen.is-hiding { opacity: 0; pointer-events: none; }

.boot-mark {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  color: var(--accent);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  animation: boot-pulse 1.8s ease-in-out infinite;
}
.boot-mark svg { width: 32px; height: 32px; }

.boot-label { color: var(--text-secondary); font-size: 14px; margin: 0; }

.boot-bar {
  width: 168px; height: 3px;
  border-radius: var(--radius-pill);
  background: var(--surface-overlay);
  overflow: hidden;
}
.boot-bar span {
  display: block;
  width: 40%; height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  animation: boot-slide 1.2s var(--ease-out) infinite;
}

@keyframes boot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.06); opacity: 0.82; }
}
@keyframes boot-slide {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(260%); }
}

/* --------------------------------------------------------------------------
   4. AUTH VIEW (signed out)
   -------------------------------------------------------------------------- */
.auth-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 24px) 16px calc(var(--safe-bottom) + 24px);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 28px 24px;
}

.auth-header { text-align: center; margin-bottom: 22px; }

.auth-logo {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  color: var(--accent);
  background: var(--surface-overlay);
  border-radius: var(--radius-md);
}
.auth-logo svg { width: 26px; height: 26px; }

.auth-title { font-size: 24px; letter-spacing: -0.01em; }
.auth-subtitle {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-form { display: flex; flex-direction: column; gap: 8px; }

.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 22px 0 16px;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.oauth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* --------------------------------------------------------------------------
   5. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* 44px min target: WCAG 2.5.5 / iOS HIG touch-target guidance. */
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--surface-overlay);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }

/* Disabled state must remain legible, not invisible. */
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: var(--accent-contrast);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 18px -8px rgba(34, 211, 238, 0.7);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-overlay); }

.btn-danger {
  background: var(--danger);
  color: #450a0a;
  border-color: rgba(255, 255, 255, 0.16);
}

.btn-oauth {
  background: #ffffff;
  color: #0f172a;
  border-color: #e2e8f0;
  font-weight: 600;
}
.btn-oauth:hover:not(:disabled) { background: #f1f5f9; }
.oauth-icon { width: 18px; height: 18px; flex: 0 0 auto; }

.btn-block { width: 100%; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--surface-overlay); color: var(--text-primary); }

/* --------------------------------------------------------------------------
   6. FORM CONTROLS
   -------------------------------------------------------------------------- */
.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 16px; /* 16px prevents iOS Safari from auto-zooming on focus. */
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.field-input::placeholder { color: var(--text-muted); }
.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}
.field-input[readonly] {
  color: var(--text-muted);
  cursor: default;
  background: rgba(10, 16, 32, 0.6);
}

textarea.field-input { resize: vertical; min-height: 84px; }

/* Normalises the native date/number controls to the dark palette. */
.field-input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

.field-hint {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-with-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.req { color: var(--danger); }

/* --------------------------------------------------------------------------
   7. iOS-STYLE SLIDER SWITCHES
   --------------------------------------------------------------------------
   Technique: the real <input type="checkbox" role="switch"> is visually hidden
   but left in the DOM and focusable. The visible track/knob is rendered by
   .switch-track, and the :checked / :focus-visible states of the input drive it
   through sibling combinators. This preserves native semantics (Space toggles,
   screen readers announce "switch, on/off") while looking like iOS UISwitch.
   -------------------------------------------------------------------------- */
.switch-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.switch-row:last-of-type { border-bottom: none; }

/* Visually hidden, still interactive: keyboard and AT both reach it. */
.switch-input {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.switch-copy { display: flex; flex-direction: column; gap: 3px; }

.switch-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.switch-desc {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 42ch;
}

/* The visible control. Sits directly after the input in source order. */
.switch-track {
  position: relative;
  display: block;
  width: 52px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: var(--radius-pill);
  background: var(--surface-overlay);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: background-color var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}

.switch-knob {
  position: absolute;
  top: 50%;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f8fafc;
  box-shadow: 0 2px 6px rgba(2, 6, 23, 0.55);
  transform: translateY(-50%);
  transition: transform var(--dur-base) var(--ease-out);
  will-change: transform; /* kept to a composited property only */
}

/* ON state: the input precedes the track, so `~` reaches it. */
.switch-input:checked ~ .switch-track {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  border-color: transparent;
}
.switch-input:checked ~ .switch-track .switch-knob {
  transform: translateY(-50%) translateX(20px);
}

/* Keyboard focus is mirrored onto the visible track. */
.switch-input:focus-visible ~ .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Locked (premium-gated) switches: dimmed and non-interactive. */
.switch-row.is-locked .switch-track {
  opacity: 0.42;
  cursor: not-allowed;
}

/* Tap target: the whole row forwards clicks to the input. */
.switch-row { cursor: pointer; }
.switch-row.is-locked { cursor: not-allowed; }

/* --------------------------------------------------------------------------
   8. BADGES & PILLS
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--surface-overlay);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.badge-premium {
  background: rgba(167, 139, 250, 0.16);
  color: var(--premium);
  border-color: rgba(167, 139, 250, 0.4);
}

.badge-success {
  background: rgba(52, 211, 153, 0.14);
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.36);
}

.badge-warning {
  background: rgba(251, 191, 36, 0.14);
  color: var(--warning);
  border-color: rgba(251, 191, 36, 0.36);
}

.badge-danger {
  background: rgba(248, 113, 113, 0.14);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.36);
}

/* --------------------------------------------------------------------------
   9. APP SHELL & HEADER
   -------------------------------------------------------------------------- */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  /* Frosted-glass header; backdrop-filter is GPU-composited and cheap. */
  background: rgba(15, 23, 42, 0.86);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  padding-top: var(--safe-top);
}

.app-header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  flex: 0 0 auto;
  color: var(--accent);
  background: var(--surface-overlay);
  border-radius: var(--radius-sm);
}
.brand-mark svg { width: 19px; height: 19px; }

.brand-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.avatar {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: var(--accent-contrast);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Tab bar: horizontally scrollable so long labels never break the layout. */
.tab-bar {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  padding: 11px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.tab:hover { color: var(--text-primary); }
.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

.tab-panel { display: flex; flex-direction: column; gap: 16px; }

.app-footer {
  padding: 20px 16px calc(var(--safe-bottom) + 24px);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
}
.app-footer p { margin: 0; }

/* --------------------------------------------------------------------------
   10. PANEL HEADS, CARDS & STATS
   -------------------------------------------------------------------------- */
.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title { font-size: 20px; letter-spacing: -0.01em; }
.panel-sub { margin: 4px 0 0; font-size: 13px; color: var(--text-secondary); }

.card {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-title { font-size: 15px; font-weight: 650; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.stat-label {
  margin: 0 0 6px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.stat-value {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   11. ASSET LIST & CARDS
   -------------------------------------------------------------------------- */
.asset-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
}

.asset-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  /* Only opacity/transform animate, so no layout invalidation on hover. */
  transition: border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.asset-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }

/* Highlight cards that need action so urgency reads at a glance. */
.asset-card.is-due-now {
  border-color: rgba(248, 113, 113, 0.5);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.18), var(--shadow-card);
}
.asset-card.is-due-soon { border-color: rgba(251, 191, 36, 0.42); }

.asset-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.asset-name {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  /* Long equipment names truncate instead of reflowing the grid. */
  overflow-wrap: anywhere;
}

.asset-category {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.asset-badges { display: flex; flex-wrap: wrap; gap: 6px; }

.asset-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
  font-size: 13px;
}
.asset-meta dt { color: var(--text-muted); }
.asset-meta dd {
  margin: 0;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.asset-notes {
  margin: 0;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  /* Bounded height keeps every card visually uniform. */
  max-height: 88px;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.asset-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}
.asset-actions .btn { flex: 1; min-height: 40px; font-size: 14px; }

/* --------------------------------------------------------------------------
   12. EMPTY / LOADING / ERROR STATES
   -------------------------------------------------------------------------- */
.state-block {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 44px 20px;
  text-align: center;
  background: var(--surface-raised);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.state-icon { font-size: 30px; line-height: 1; }
.state-title { margin: 0; font-size: 16px; font-weight: 650; }
.state-copy {
  margin: 0;
  max-width: 46ch;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* Skeleton placeholder shown during the first network-first fetch. */
.skeleton-card {
  padding: 16px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.skeleton-line {
  height: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-overlay) 25%, #2b3a55 37%, var(--surface-overlay) 63%);
  background-size: 400% 100%;
  animation: skeleton-sweep 1.4s ease infinite;
}
.skeleton-line.is-title { height: 18px; width: 60%; }
.skeleton-line.is-short { width: 40%; }

@keyframes skeleton-sweep {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* --------------------------------------------------------------------------
   13. STATUS LINES, METERS & KEY-VALUE LISTS
   -------------------------------------------------------------------------- */
.status-line {
  margin: 0;
  min-height: 18px;
  font-size: 13px;
  color: var(--text-secondary);
}
.status-line.is-error { color: var(--danger); }
.status-line.is-success { color: var(--success); }
.status-line.is-pending { color: var(--warning); }

.billing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kv-list { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
}
.kv dt { color: var(--text-muted); }
.kv dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

/* Usage meter for the free-tier 5-asset cap. */
.meter {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-overlay);
  overflow: hidden;
}
.meter-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  transition: width var(--dur-base) var(--ease-out),
              background-color var(--dur-base) var(--ease-out);
}
.meter-fill.is-warning { background: linear-gradient(90deg, #f59e0b, var(--warning)); }
.meter-fill.is-full { background: linear-gradient(90deg, #dc2626, var(--danger)); }

.feature-list {
  margin: 0;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--text-secondary);
}
.feature-list li::marker { color: var(--accent); }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

/* --------------------------------------------------------------------------
   14. DIALOGS (native <dialog>)
   -------------------------------------------------------------------------- */
.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  color: var(--text-primary);
  box-shadow: 0 24px 60px -20px rgba(2, 6, 23, 0.9);
  /* Native <dialog> handles focus trapping and Esc dismissal. */
  overflow: hidden;
}
.dialog-sm { width: min(420px, calc(100vw - 32px)); }

.dialog::backdrop {
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.dialog form {
  display: flex;
  flex-direction: column;
  max-height: inherit;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.dialog-title { font-size: 17px; }

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  /* Scrolls independently so the footer actions stay reachable. */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-sunken);
}
.dialog-foot .btn { min-width: 108px; }

.confirm-copy {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   15. TOASTS
   -------------------------------------------------------------------------- */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 16px);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  transform: translateX(-50%);
  /* Container ignores pointer events so it never blocks the UI beneath. */
  pointer-events: none;
}

.toast {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-overlay);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: var(--shadow-card);
  animation: toast-in var(--dur-base) var(--ease-out);
}
.toast.is-success { border-color: rgba(52, 211, 153, 0.5); }
.toast.is-error { border-color: rgba(248, 113, 113, 0.55); }
.toast.is-info { border-color: var(--accent); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.noscript-warning {
  margin: 40px auto;
  max-width: 480px;
  padding: 16px;
  text-align: center;
  background: var(--surface-raised);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  color: var(--danger);
}

/* --------------------------------------------------------------------------
   16. RESPONSIVE
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .auth-card { padding: 22px 18px; }
  .app-header-inner { padding: 10px 14px; }
  .app-main { padding: 16px 14px 28px; }

  /* Brand text yields space to the essential header actions. */
  .brand-text { font-size: 15px; }

  /* Single-column stacks beat cramped two-up grids on narrow phones. */
  .field-grid { grid-template-columns: 1fr; }
  .asset-list { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }

  /* Full-width, bottom-anchored dialog actions are easier to thumb-reach. */
  .dialog-foot { flex-direction: column-reverse; }
  .dialog-foot .btn { width: 100%; }
}

@media (max-width: 420px) {
  .oauth-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  /* Edge-to-edge sheet on very small viewports. */
  .dialog { width: 100vw; max-height: 100dvh; border-radius: 0; }
}

/* Landscape phones: the standalone window is short, so trim vertical padding. */
@media (max-height: 500px) and (orientation: landscape) {
  .app-header { position: static; }
  .boot-mark { width: 48px; height: 48px; }
}

/* --------------------------------------------------------------------------
   17. ACCESSIBILITY
   -------------------------------------------------------------------------- */

/* Honour the OS "reduce motion" setting: keep state changes, drop animation. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .btn:hover:not(:disabled),
  .asset-card:hover { transform: none; }
}

/* Forced-colors / Windows High Contrast keeps the switches legible. */
@media (forced-colors: active) {
  .switch-track { border: 2px solid ButtonText; }
  .switch-input:checked ~ .switch-track { background: Highlight; }
  .switch-knob { background: ButtonText; }
  .btn { border: 1px solid ButtonText; }
}

/* --------------------------------------------------------------------------
   18. PRINT — used by the Premium "Save as PDF" export path
   --------------------------------------------------------------------------
   exporter.js calls window.print() as a zero-dependency PDF fallback and relies
   on these rules to strip interactive furniture from the printed page.
   -------------------------------------------------------------------------- */
@media print {
  .app-header,
  .app-footer,
  .asset-actions,
  .btn,
  .toast-region,
  .dialog,
  .boot-screen,
  .tab-bar,
  .no-print { display: none !important; }

  body,
  .app-shell { background: #ffffff !important; color: #000000 !important; }

  .app-main { max-width: none; padding: 0; }

  .asset-list { display: block; }
  .asset-card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    margin-bottom: 12px;
    background: #ffffff !important;
    color: #000000 !important;
  }
  .asset-name,
  .asset-meta dd,
  .asset-meta dt,
  .asset-category,
  .asset-notes,
  .stat-value,
  .stat-label { color: #000000 !important; }

  /* Expand truncated notes so the printed report is complete. */
  .asset-notes { max-height: none !important; overflow: visible !important; }

  .stat-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .stat-card { border: 1px solid #cbd5e1 !important; background: #ffffff !important; }

  /* Repeat table headers across page breaks in the printable summary. */
  thead { display: table-header-group; }
}






