/* Shell — structural chrome (header/nav/content frame) + a shared
   component library (buttons, cards, badges, tables, empty states,
   skeletons, toasts) used across every page instead of each page hand-
   rolling its own. Design tokens (color/spacing/type/shadow scale) live in
   tokens.css, loaded before this file on every page. No feature/business-
   logic related class names or content live in this file — pure
   presentation. */

* { box-sizing: border-box; }

/* Guarantees the `hidden` attribute always wins, even on elements whose
   own class sets `display: flex/grid/block` (author-origin CSS otherwise
   beats the browser's default `[hidden] { display: none }` UA-stylesheet
   rule regardless of selector specificity — this is the standard fix). */
[hidden] { display: none !important; }

/* Plan Restricted overlay (2026-08-24) — a full-page block for a project
   whose plan lapsed 7+ days ago, shown on every page except Inbox and
   Billing (see shell.js's showRestrictedOverlay). z-index above the header
   (30) and any modal (50) — this has to win over everything. */
.shell-restricted-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 17, 21, 0.6);
  padding: var(--space-4);
}
.shell-restricted-card {
  max-width: 420px;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8) var(--space-6);
}
.shell-restricted-card svg { color: var(--warning); margin-bottom: var(--space-3); }
.shell-restricted-card h2 { margin: 0 0 var(--space-2); }
.shell-restricted-card p { margin: 0 0 var(--space-5); color: var(--text-muted); font-size: var(--text-sm); }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Firefox's equivalent of the thin custom scrollbar below — no per-part
     selectors there, just a width keyword + thumb/track color pair. */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Thin, theme-matched scrollbar (2026-08-30) — replaces the OS's default
   wide gray scrollbar (jarring against the app's own dark/light surfaces)
   everywhere something scrolls: the main content area, modal bodies, long
   dropdowns, etc. Track is transparent (no separate box drawn behind it),
   thumb uses the same neutral `--border` color as the rest of the UI's
   hairlines and only tints toward the accent color on hover, so it reads
   as part of the app rather than a browser chrome element. */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
  background-clip: padding-box;
}
::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  background: var(--bg);
  color: var(--text);
}

/* Modern SaaS-scale headings (2026-09-01) — previously no font-size was set
   here at all, so any plain <h1>-<h4> without its own page-specific class
   override (e.g. Dashboard's title) fell back to the browser's oversized
   UA default (~32px h1) instead of this app's own type scale. Anything
   with a class-scoped override (`.automation-topbar-left h1`, etc.) keeps
   winning as before — higher specificity, unaffected by this. */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: var(--leading-tight);
  margin: 0 0 var(--space-2);
}

h1 { font-size: var(--text-2xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-base); }

a { color: inherit; }

/* Dark/light text-color fix (2026-08-23) — a bare <button> uses the
   browser's native ButtonText system color by default, NOT the page's own
   theme color, unlike every other element here. Any button whose own CSS
   class doesn't set a color (e.g. checkout.css's .addon-chip) silently fell
   back to black-on-dark-surface in dark mode. This is the systemic fix:
   inherit the theme text color everywhere, and let a more specific rule
   (.btn-primary, etc — those already work) override it as before. */
button { color: inherit; font-family: inherit; }

.icon { flex-shrink: 0; }

/* ── App shell frame ─────────────────────────────────────────────── */

#app-shell {
  display: flex;
  flex-direction: column;
  /* `height` (a definite size), not `min-height` (2026-08-30) — a flex
     child only gets properly bounded/clipped by its container when the
     container's own height is definite; `min-height` is just a floor, so
     once #content-placeholder's content (e.g. a long table) is taller
     than the viewport, #app-shell/.shell-body simply grew to match it
     instead of staying capped, which meant `overflow-y: auto` on
     #content-placeholder never actually had a smaller box than its
     content to clip against — the whole PAGE scrolled instead, dragging
     the sidebar (not sticky/fixed on desktop) off-screen with it.
     `100vh` is the LARGEST a mobile browser's viewport can ever be (as if
     its address bar were hidden) — while that bar is actually showing,
     plain `100vh` still stretches this shell past what's really on
     screen, and (now that this is a hard `height` rather than a floor)
     content would get clipped a bit early. `dvh` is that real,
     live-updating visible height; unsupported browsers ignore this
     second line and keep the `100vh` line above it. */
  height: 100vh;
  height: 100dvh;
}

#header-placeholder {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--chrome-border);
  background: var(--chrome-bg);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.header-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  /* Fixed black (not var(--chrome-text)) — this icon must always read
     against the header regardless of theme/accent, not just once a user
     has picked a preset (2026-09-27). */
  color: #12151c;
  cursor: pointer;
}

.header-menu-btn:hover { background: var(--chrome-hover); }

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--chrome-text);
  transition: opacity var(--duration) var(--ease);
}

.header-brand:hover { opacity: 0.85; }

.header-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.header-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.header-brand-text {
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--chrome-text);
  letter-spacing: -0.01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--chrome-text-muted);
  cursor: pointer;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}

.header-icon-btn:hover {
  background: var(--chrome-hover);
  color: var(--chrome-text);
}

.header-bell-btn { position: relative; text-decoration: none; }

.header-bell-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--accent);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 999px;
  min-width: 1em;
  text-align: center;
}

.header-profile { position: relative; }

.header-profile-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--chrome-active-bg);
  color: var(--chrome-active-text);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-sm);
  transition: box-shadow var(--duration) var(--ease);
}

.header-profile-btn:hover { box-shadow: 0 0 0 3px var(--accent-subtle); }

.header-profile-menu {
  position: absolute;
  right: 0;
  top: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 40;
  padding: var(--space-1);
}

.header-profile-menu.open { display: flex; }

.header-profile-menu a,
.header-profile-menu button {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: var(--text-sm);
  font-family: inherit;
  cursor: pointer;
}

.header-profile-menu a:hover,
.header-profile-menu button:hover { background: var(--surface-hover); }

/* ── Theme (color) picker (2026-09-15) ───────────────────────────────
   Same anchored-panel pattern as .header-profile-menu just above (own
   trigger button + `.open` class + the shared outside-click-close
   listener in shell.js) — a separate, independent control from the
   dark/light toggle: this only changes the accent + header/sidebar tint
   (`data-accent`, see tokens.css's 12 presets), dark/light stays its own
   button. Kept deliberately small/dependency-free — a plain swatch grid,
   no color-picker library. */
.header-theme { position: relative; }

.theme-picker-panel {
  position: absolute;
  right: 0;
  top: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 216px;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 40;
  padding: var(--space-3);
}

.theme-picker-panel.open { display: block; }

.theme-picker-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.theme-swatch-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

.theme-swatch {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--swatch-color);
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.theme-swatch:hover { border-color: var(--text-muted); }

.theme-swatch.selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--swatch-color); }

.theme-swatch .icon { opacity: 0; transition: opacity var(--duration) var(--ease); }
.theme-swatch.selected .icon { opacity: 1; }

/* White preset's swatch is white itself — give its check mark and
   selected ring a dark colour so they stay visible. */
.theme-swatch[data-accent-key="white"] { color: #1f2937; border-color: #d0d5dd; }
.theme-swatch[data-accent-key="white"].selected { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #1f2937; }

.shell-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── Sidebar nav (both the flat top-level menu and the project-workspace
   variant shell.js renders when a project is in context — same classes) ── */

#nav-placeholder {
  display: flex;
  flex-direction: column;
  width: 248px;
  flex-shrink: 0;
  border-right: 1px solid var(--chrome-border);
  background: var(--chrome-bg);
  overflow: hidden;
}

.nav-items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-4);
}

/* Sidebar-bottom brand strip — pinned below the (possibly scrolling)
   nav items, never scrolled away with them. */
.nav-footer {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--chrome-border);
}

.nav-footer-link { margin-bottom: var(--space-2); }

.nav-footer-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--chrome-text-muted);
  letter-spacing: 0.02em;
}

.nav-footer-brand img { flex-shrink: 0; opacity: 0.85; }

/* Current project's name (2026-08-30) — every project-scoped page has the
   sidebar, so this is the one spot that's guaranteed visible everywhere,
   unlike Dashboard's own stat cards which only render on project-view.html
   itself. Plain label, not a link — "Dashboard" right below it already
   covers navigating back to the project's own overview page. */
.nav-project-name {
  padding: 0 var(--space-3) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--chrome-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar "brand tile" — the workspace/dashboard entry at the top of a
   project's nav, styled like a proper nav item (icon + label) instead of
   bare text, so it doesn't read as a stray caption above the real menu. */
.nav-workspace-name {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--chrome-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}

.nav-workspace-name .icon { color: var(--chrome-text-muted); transition: color var(--duration) var(--ease); }

.nav-workspace-name:hover { background: var(--chrome-hover); color: var(--accent); }
.nav-workspace-name:hover .icon { color: var(--accent); }

.nav-workspace-name.active { background: var(--chrome-active-bg); color: var(--chrome-active-text); box-shadow: inset 3px 0 0 var(--accent); }
.nav-workspace-name.active .icon { color: var(--chrome-active-text); }

.nav-divider {
  height: 1px;
  background: var(--chrome-border);
  margin: var(--space-1) var(--space-2) var(--space-3);
}

.nav-section-label {
  padding: var(--space-4) var(--space-2) var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--chrome-text-muted);
}

.nav-section-label:first-child { padding-top: 0; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--chrome-text-muted);
  text-decoration: none;
  margin-bottom: 2px;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}

.nav-item .icon { color: var(--chrome-text-muted); transition: color var(--duration) var(--ease); }

.nav-item-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  min-width: 1.1em;
  text-align: center;
}

.nav-item:hover { background: var(--chrome-hover); color: var(--chrome-text); }
.nav-item:hover .icon { color: var(--chrome-text); }

.nav-item.active {
  background: var(--chrome-active-bg);
  color: var(--chrome-active-text);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-item.active .icon { color: var(--chrome-active-text); }

#content-placeholder {
  flex: 1;
  min-width: 0;
  /* Without these two, a flex item defaults to `min-height: auto` — it
     grows to fit tall content (e.g. a long table) instead of respecting
     `.shell-body`'s bounded height, which in turn forces the WHOLE page
     (header + sidebar included) to become the scroll container. The
     sidebar isn't sticky/fixed on desktop, so it just scrolled away with
     everything else. This makes #content-placeholder scroll internally
     instead — header stays sticky, sidebar stays put, only this scrolls. */
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-6);
}

/* ── "Back to X" link (2026-08-30) ────────────────────────────────────
   One shared pill-style back-link, in place of every secondary page
   (Reports, Billing, Media Gallery, Automation, editors, ...) styling its
   own plain "← Back to Project" text link — same place, same look,
   everywhere it appears. */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}

.back-link:hover { background: var(--surface-hover); color: var(--text); }

/* ── Responsive (2026-08-30) ──────────────────────────────────────────
   One breakpoint, kept deliberately simple: below it the persistent
   sidebar becomes an off-canvas drawer (toggled by the header's hamburger
   button, shell.js) instead of every page's layout being reworked
   individually — #content-placeholder already reflows on its own since
   the dashboard/quick-tiles grids use `auto-fit` and tables sit in their
   own `overflow-x: auto` wrapper. */

#nav-backdrop {
  display: none;
  position: fixed;
  top: 64px;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(15, 17, 21, 0.5);
  z-index: 45;
}

#nav-backdrop.show { display: block; }

@media (max-width: 768px) {
  .header-menu-btn { display: inline-flex; }

  /* Narrower gutters/gaps (2026-09-15) — the header now carries one more
     icon button (theme picker, alongside bell/dark-mode/profile) than it
     used to; without this, four 36px icon buttons plus their gaps could
     push right up against (or past) the brand logo on the smallest common
     phone widths (~360px). */
  #header-placeholder { padding: 0 var(--space-3); }
  .header-right { gap: var(--space-1); }

  #nav-placeholder {
    position: fixed;
    top: 64px;
    bottom: 0;
    left: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform var(--duration) var(--ease);
  }

  #nav-placeholder.nav-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  #content-placeholder { padding: var(--space-4); }

  /* Any table not already inside a page's own `overflow-x: auto` wrapper
     scrolls in place instead of forcing the whole page wider — `table`
     stays a block-level box under `display: block`, so its rows keep their
     normal table layout, they just scroll sideways as a unit. */
  .table { display: block; overflow-x: auto; }
}

.shell-loading {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* #nav-placeholder lost its own padding when it became a flex column (the
   padding moved onto .nav-items) — restore it just for this bare fallback
   span (Loading…/Menu unavailable), which never gets wrapped in .nav-items. */
#nav-placeholder > .shell-loading {
  display: block;
  padding: var(--space-4);
  color: var(--chrome-text-muted);
}

/* ── Buttons ──────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), opacity var(--duration) var(--ease);
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-active); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }

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

/* Generic loading-spinner treatment — pair with icons.js's `loader` glyph
   for any "in progress" button/inline state. */
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-subtle); }

.btn-sm { height: 28px; padding: 0 var(--space-3); font-size: var(--text-xs); }

/* Square icon-only button (2026-08-14) — was Inbox-only, promoted here since Contacts' row actions need it too. Same 36px as .btn/header icon buttons (2026-09-15) — one consistent control size across the app. */
.btn-icon { padding: 0; width: 36px; height: 36px; }

/* File upload drop-zone (2026-08-30, moved here from contacts.css so
   Single Send's media upload can reuse it too) — replaces the bare native
   `<input type="file">` (browser-default button + "No file chosen" text)
   with a clickable dashed card, the modern-upload-UI convention. The real
   `<input>` is either a sibling with `<label for=>` (Contacts' CSV import)
   or nested directly inside the `<label>` (Single Send's media upload) —
   both trigger the native picker with no JS needed for that part.
   `.dragover` is a JS-toggled class for an actual drag-and-drop target
   (Single Send) — same look as `:hover`, but `:hover` alone doesn't fire
   while a browser drag is in progress, so it needs its own rule. */
.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.file-drop:hover,
.file-drop.dragover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.file-drop-icon { color: var(--accent); }
.file-drop-text { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.file-drop-hint { font-size: var(--text-xs); color: var(--text-muted); }

/* "Show archived" toggle switch (2026-08-30, moved here from contacts.css
   so Campaigns' own "Show archived" checkbox can reuse it too) — replaces
   a plain checkbox with an on/off switch, the same soft-delete-visibility
   pattern in both places. `.archived-toggle .toggle-switch input` (not
   the bare `.toggle-switch input`) so this reliably beats generic
   `input:focus` etc rules regardless of file/load order. */
.archived-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
  cursor: pointer;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
  flex-shrink: 0;
}

.archived-toggle .toggle-switch input {
  position: absolute;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: var(--radius-full);
  transition: background var(--duration) var(--ease);
}

.toggle-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration) var(--ease);
}

.archived-toggle .toggle-switch input:checked ~ .toggle-slider { background: var(--accent); }
.archived-toggle .toggle-switch input:checked ~ .toggle-slider::before { transform: translateX(14px); }
.archived-toggle .toggle-switch input:focus-visible ~ .toggle-slider { box-shadow: 0 0 0 3px var(--accent-subtle); }

/* Backward-compat: plain <button> in these known containers still gets a
   sane default look on pages not yet migrated to explicit .btn classes
   (Phase B/C/D). Safe to remove once every page uses .btn explicitly. */
.auth-card button,
.projects-header button,
.project-view-page button,
.profile-section button {
  height: 36px;
  padding: 0 var(--space-4);
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: var(--text-sm);
}

/* ── Form controls ────────────────────────────────────────────────── */

/* Same 36px control height as .btn (2026-09-15) — buttons and single-line
   fields now line up in toolbars/forms instead of relying on padding +
   line-height to happen to match. Textarea is deliberately excluded below
   (a fixed height would defeat a multi-line field's purpose). */
.input, .select, .textarea,
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="tel"], input[type="date"],
select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: var(--text-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.input, .select,
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="tel"], input[type="date"],
select {
  height: 36px;
  padding: 0 var(--space-3);
}

.textarea, textarea {
  padding: var(--space-2) var(--space-3);
  min-height: 88px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* ── Cards ────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-padded { padding: var(--space-5); }

/* ── Badges ───────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
}

.badge-neutral { background: var(--surface-hover); color: var(--text-muted); }
.badge-success { background: var(--success-subtle); color: var(--success); }
.badge-warning { background: var(--warning-subtle); color: var(--warning); }
.badge-danger { background: var(--danger-subtle); color: var(--danger); }
.badge-info { background: var(--info-subtle); color: var(--info); }
.badge-accent { background: var(--accent-subtle); color: var(--accent); }

/* ── Tables ───────────────────────────────────────────────────────── */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: var(--text-sm);
}

.table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: var(--bg);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-hover); }

/* ── Empty states ─────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}

.empty-state .icon { color: var(--text-muted); opacity: 0.6; margin-bottom: var(--space-3); }
.empty-state h3 { color: var(--text); margin-bottom: var(--space-1); }
.empty-state p { margin: 0 0 var(--space-4); font-size: var(--text-sm); }

/* ── Skeleton loading ─────────────────────────────────────────────── */

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-hover) 25%, var(--border) 37%, var(--surface-hover) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
}

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

/* ── Toasts ───────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  z-index: 1100;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  max-width: 360px;
  animation: toast-in var(--duration) var(--ease);
}

.toast-success { border-color: var(--success); }
.toast-success .icon { color: var(--success); }
.toast-error { border-color: var(--danger); }
.toast-error .icon { color: var(--danger); }
.toast-warning { border-color: var(--warning); }
.toast-warning .icon { color: var(--warning); }

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

.toast-out {
  animation: toast-out var(--duration) var(--ease) forwards;
}

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

/* ── Global loading bar (2026-08-14) ─────────────────────────────────
   Same slim sweeping-highlight technique as the Inbox's own WebSocket
   reconnect indicator (inbox.css's .ws-loading-bar), generalized here so
   api-client.js can show it for any in-flight request on any page. */

.global-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-subtle);
  overflow: hidden;
  z-index: 200;
}

.global-loading-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: -40%;
  height: 100%;
  width: 40%;
  background: var(--accent);
  animation: global-loading-sweep 1.1s ease-in-out infinite;
}

@keyframes global-loading-sweep {
  0% { left: -40%; }
  100% { left: 100%; }
}

/* ── Auth pages ───────────────────────────────────────────────────── */

.auth-card {
  max-width: 400px;
  margin: 10vh auto;
  padding: var(--space-8);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.auth-card input,
.auth-card select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.auth-card button { width: 100%; }

.auth-secondary {
  width: 100%;
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: var(--text-sm);
}

.auth-error {
  color: var(--danger);
  font-size: var(--text-sm);
  min-height: 1.1em;
  margin: 0 0 var(--space-2);
}

/* `margin: 0` (2026-08-30) — this is a `<p>`, so without an explicit
   reset it still carried the browser's default ~1em top+bottom margin.
   Harmless where it happened to land next to unrelated block spacing, but
   inside a flex column with its own `gap` (Template/Campaign Editor's
   `.editor-form`) that default margin stacked on TOP of the gap, and on
   an empty note/error pair before any real content, that stray ~40-50px
   read as a big unexplained blank gap above the next field. Callers that
   want space around a note already have it via their own layout gap. */
.auth-note {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Collapses entirely while empty (2026-08-30) — unlike `.auth-error`
   (which keeps a reserved `min-height` on purpose, so the layout doesn't
   jump the moment an error appears), a note has no such "pops in
   unpredictably" case: it's either permanently informational (set once at
   load) or simply unused on a given page, so there's no reason for an
   unused one to hold open a line of empty space. */
.auth-note:empty {
  display: none;
}

/* ── Legacy page containers (kept working, restyled in their own Phase B/C/D pass) ── */

.profile-page,
.projects-page,
.project-view-page {
  max-width: 640px;
}

.projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.projects-list {
  list-style: none;
  padding: 0;
  margin: var(--space-4) 0;
}

.projects-list li {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: var(--space-2);
  box-shadow: var(--shadow-sm);
}

.projects-list a {
  display: flex;
  justify-content: space-between;
  padding: var(--space-4);
  color: var(--text);
  text-decoration: none;
}

.projects-list .project-status {
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-transform: capitalize;
}

.projects-list-deleted .project-deleted-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-4);
  color: var(--text-muted);
  opacity: 0.7;
}

.export-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
}

.project-view-page button:disabled { opacity: 0.5; cursor: not-allowed; }

.profile-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.profile-section h2 { margin-top: 0; font-size: var(--text-base); }

.profile-section label {
  display: block;
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}

.profile-section input,
.profile-section select {
  display: block;
  width: 100%;
  margin-top: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.profile-section button:disabled { opacity: 0.5; cursor: not-allowed; }

.profile-section h3 { margin: var(--space-4) 0 var(--space-1); font-size: var(--text-sm); }

/* Mobile No — country code + number. `.phone-code`/`.phone-number` carry a
   2nd class deliberately (specificity (0,2,0)) so this always wins over
   any generic `<container> input/select { width: 100% }` rule (e.g.
   `.auth-card input`, `.profile-section input`) regardless of which
   container this ends up nested in or CSS source order — no dependency on
   a particular ancestor tag like `<label>` (same fix as billing.css's own
   copy). */
.profile-phone-row {
  display: flex;
  gap: var(--space-2);
}
.profile-phone-row .phone-code {
  flex: 0 0 auto;
  width: 150px;
  min-width: 0;
}
.profile-phone-row .phone-number {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}

/* Live Chat "open in new tab" (2026-10-02) — small icon inside the Live
   Chat row's right edge; the link itself gets room for it so its unread
   bubble sits just left of the icon instead of under it. Shown on hover/
   focus with a mouse, always shown on touch screens (no hover there). */
.nav-item-row {
  position: relative;
}

.nav-item-row > .nav-item {
  padding-right: 34px;
}

.nav-newtab {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  color: var(--chrome-text-muted);
  opacity: 0;
  transition: opacity var(--duration) var(--ease), background var(--duration) var(--ease), color var(--duration) var(--ease);
}

.nav-item-row:hover .nav-newtab,
.nav-newtab:focus-visible {
  opacity: 1;
}

.nav-newtab:hover {
  background: var(--chrome-hover);
  color: var(--chrome-text);
}

@media (hover: none) {
  .nav-newtab {
    opacity: 1;
  }
}
