/* =========================================================================
   App design system
   -------------------------------------------------------------------------
   Single source of truth for visual style. Everything is built from CSS
   custom properties so a future dark mode is one block of overrides.
   ========================================================================= */

:root {
  /* Color — neutral surface palette + one indigo accent */
  --bg:             #f7f8fa;
  --surface:        #ffffff;
  --surface-2:      #f3f4f6;
  --surface-hover:  #f9fafb;

  --border:         #e5e7eb;
  --border-strong:  #d1d5db;

  --text:           #0f172a;
  --text-muted:     #64748b;
  --text-subtle:    #94a3b8;
  --text-inverse:   #ffffff;

  --accent:         #4f46e5;
  --accent-hover:   #4338ca;
  --accent-soft:    #eef2ff;
  --accent-text:    #3730a3;

  --danger:         #dc2626;
  --danger-hover:   #b91c1c;
  --danger-soft:    #fee2e2;
  --danger-text:    #991b1b;

  --success:        #059669;
  --success-soft:   #d1fae5;
  --success-text:   #065f46;

  --warning:        #d97706;
  --warning-soft:   #fef3c7;
  --warning-text:   #92400e;

  /* Effects */
  --shadow-sm:  0 1px 2px rgb(15 23 42 / 0.04);
  --shadow:     0 1px 3px rgb(15 23 42 / 0.06), 0 1px 2px rgb(15 23 42 / 0.04);
  --shadow-md:  0 4px 12px rgb(15 23 42 / 0.06), 0 2px 4px rgb(15 23 42 / 0.04);
  --shadow-lg:  0 10px 24px rgb(15 23 42 / 0.08), 0 4px 8px rgb(15 23 42 / 0.04);

  --radius-sm:  6px;
  --radius:     8px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-full: 9999px;

  /* Spacing scale */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
               Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  --text-xs:   12px;
  --text-sm:   13px;
  --text-base: 14px;
  --text-md:   15px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;
  --text-4xl:  36px;

  --leading-tight:  1.25;
  --leading-snug:   1.4;
  --leading-normal: 1.55;

  /* Transitions */
  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-med:  200ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --nav-h:        60px;
  --container-w:  1200px;
  --container-px: var(--space-6);
}

/* =========================================================================
   Reset / base
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: -0.015em;
  color: var(--text);
}

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

p  { margin: 0; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--accent-hover); }

button { font-family: inherit; }

::selection {
  background: var(--accent-soft);
  color: var(--accent-text);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* =========================================================================
   App shell — top navbar + main container
   ========================================================================= */

.app-nav {
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: saturate(180%) blur(8px);
}

.app-nav__inner {
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 0 var(--container-px);
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.app-nav__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--text);
  letter-spacing: -0.01em;
}

.app-nav__brand-logo {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-sm);
}

/* Image-based brand mark. Workspaces upload their own; the top-level
   nav uses static/images/goose.png. Height is the nav-line constraint;
   width is auto so wide wordmarks (like Goose) keep their proportions. */
.app-nav__brand-logo-img {
  height: 30px;
  width: auto;
  max-width: 180px;
  display: block;
}

/* Variant for when the brand is purely the wordmark image — no text
   sibling, so the gap collapses. */
.app-nav__brand--logo-only {
  gap: 0;
}

.app-nav__links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
}

.app-nav__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--text-base);
  transition: background var(--t-fast), color var(--t-fast);
}

.app-nav__link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.app-nav__link.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* =========================================================================
   App sub-nav — strip rendered under the main nav on admin pages.
   Mirrors .app-nav__inner's container so it lines up under the page
   content rather than flush-left against the viewport edge.
   ========================================================================= */

.app-subnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-subnav__inner {
  max-width: var(--container-w);
  margin: 0 auto;
  padding: var(--space-2) var(--container-px);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.app-subnav__link {
  display: inline-flex;
  align-items: center;
  padding: 6px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--text-sm);
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
}

.app-subnav__link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.app-subnav__link.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.app-nav__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}

/* Active-tenant chip in the navbar */
.nav-tenant-form { margin: 0; }
.nav-tenant {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px 4px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  max-width: 220px;
}
.nav-tenant:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}
.nav-tenant__logo {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.nav-tenant__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-tenant__chev {
  width: 14px;
  height: 14px;
  color: var(--text-subtle);
  flex-shrink: 0;
}

.app-nav__user {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px var(--space-2) 4px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.app-nav__user:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

/* avatar circle */
.avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: white;
  font-weight: 600;
  font-size: var(--text-xs);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}
.avatar--lg { width: 40px; height: 40px; font-size: var(--text-base); }

/* =========================================================================
   Container + page header
   ========================================================================= */

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--container-w);
  margin: 0 auto;
  padding: var(--space-10) var(--container-px) var(--space-16);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-6);
  flex-wrap: wrap;
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
}

.page-header__titles { min-width: 0; }

.page-title {
  font-size: var(--text-3xl);
  letter-spacing: -0.025em;
  margin-bottom: var(--space-2);
}

.page-subtitle {
  color: var(--text-muted);
  font-size: var(--text-md);
  max-width: 64ch;
}

.page-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* =========================================================================
   Card / panel
   ========================================================================= */

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

.card__header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.card__title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.card__body { padding: var(--space-6); }

.card__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* tight card variant for auth screens */
.card--auth {
  width: 100%;
  max-width: 420px;
  margin: var(--space-12) auto;
  border-radius: var(--radius-lg);
}
.card--auth .card__body { padding: var(--space-8); }

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  height: 36px;
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-weight: 500;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  transition: background var(--t-fast), border-color var(--t-fast),
              color var(--t-fast), box-shadow var(--t-fast),
              transform var(--t-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--text-inverse);
}

.btn--secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.btn--secondary:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

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

.btn--danger {
  background: var(--danger);
  color: var(--text-inverse);
  border-color: var(--danger);
}
.btn--danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  color: var(--text-inverse);
}

.btn--danger-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--danger);
}
.btn--danger-outline:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger-text);
}

.btn--sm   { height: 30px; padding: 0 var(--space-3); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn--lg   { height: 44px; padding: 0 var(--space-5); font-size: var(--text-md); }
.btn--icon { padding: 0; width: 36px; }
.btn--full { width: 100%; }

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* =========================================================================
   Forms
   ========================================================================= */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field + .field { margin-top: var(--space-4); }

.label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 0 var(--space-3);
  height: 38px;
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color var(--t-fast), box-shadow var(--t-fast),
              background var(--t-fast);
  appearance: none;
}

.textarea {
  height: auto;
  padding: var(--space-3);
  line-height: var(--leading-normal);
  resize: vertical;
  min-height: 96px;
}

.input::placeholder { color: var(--text-subtle); }

.input:hover,
.select:hover,
.textarea:hover { border-color: var(--text-subtle); }

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

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.field-help {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.field-error { color: var(--danger-text); }

/* horizontal form row (label left, input right) — for detail/edit pages */
.form-grid {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  column-gap: var(--space-6);
  row-gap: var(--space-5);
  align-items: center;
}

.form-grid > .label { justify-self: end; text-align: right; }

@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: 1fr;
    row-gap: var(--space-2);
  }
  .form-grid > .label { justify-self: start; text-align: left; }
}

/* search-style input with leading icon */
.input-search {
  position: relative;
  display: flex;
  align-items: center;
}
.input-search svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-subtle);
  pointer-events: none;
}
.input-search .input {
  padding-left: 36px;
}

/* =========================================================================
   Tables
   ========================================================================= */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.table thead th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr {
  transition: background var(--t-fast);
}

.table tbody tr:hover { background: var(--surface-hover); }

.table a {
  color: var(--text);
  font-weight: 500;
}
.table a:hover { color: var(--accent); }

.table .col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

/* =========================================================================
   Badges / status pills
   ========================================================================= */

.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: 500;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  line-height: 1.4;
}

.badge--accent  { background: var(--accent-soft);  color: var(--accent-text);  border-color: transparent; }
.badge--success { background: var(--success-soft); color: var(--success-text); border-color: transparent; }
.badge--warning { background: var(--warning-soft); color: var(--warning-text); border-color: transparent; }
.badge--danger  { background: var(--danger-soft);  color: var(--danger-text);  border-color: transparent; }

.badge::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  opacity: 0.65;
}

/* =========================================================================
   Alerts (flash messages)
   ========================================================================= */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-base);
  border: 1px solid transparent;
}

.alert + .alert { margin-top: var(--space-2); }

.alert--info    { background: var(--accent-soft);  color: var(--accent-text);  }
.alert--success { background: var(--success-soft); color: var(--success-text); }
.alert--warning { background: var(--warning-soft); color: var(--warning-text); }
.alert--danger  { background: var(--danger-soft);  color: var(--danger-text);  }

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.flash-stack {
  margin-bottom: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* =========================================================================
   Stat cards (admin dashboards)
   ========================================================================= */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.stat-card__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.stat-card__value {
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-card__sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* =========================================================================
   Empty states + utility
   ========================================================================= */

.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}

.empty-state h3 { margin-bottom: var(--space-2); color: var(--text); }

.divider {
  height: 1px;
  background: var(--border);
  border: none;
  margin: var(--space-6) 0;
}

.muted   { color: var(--text-muted); }
.subtle  { color: var(--text-subtle); }
.mono    { font-family: var(--font-mono); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }

.stack > * + *      { margin-top: var(--space-4); }
.stack-sm > * + *   { margin-top: var(--space-2); }
.stack-lg > * + *   { margin-top: var(--space-6); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.cluster--end { justify-content: flex-end; }

/* =========================================================================
   Hero / landing
   ========================================================================= */

.hero-landing {
  padding: var(--space-16) 0 var(--space-12);
  text-align: center;
}

.hero-landing__eyebrow {
  display: inline-block;
  padding: 4px var(--space-3);
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: var(--space-6);
}

.hero-landing__title {
  font-size: var(--text-4xl);
  letter-spacing: -0.03em;
  margin-bottom: var(--space-4);
  background: linear-gradient(180deg, var(--text) 0%, #475569 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-landing__lede {
  font-size: var(--text-lg);
  color: var(--text-muted);
  max-width: 56ch;
  margin: 0 auto var(--space-8);
}

/* =========================================================================
   Confirm-destruction screen
   ========================================================================= */

.confirm-card {
  border-color: var(--danger-soft);
  background: linear-gradient(180deg, #fff 0%, var(--danger-soft) 240%);
}

.confirm-card .card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* =========================================================================
   Responsive tweaks
   ========================================================================= */

@media (max-width: 720px) {
  :root { --container-px: var(--space-4); }
  .app-nav__links { gap: 0; }
  .app-nav__link { padding: 6px var(--space-2); }
  .page-title { font-size: var(--text-2xl); }
  .hero-landing__title { font-size: var(--text-3xl); }
}

/* Voice briefing — mic button pulses while listening */
.voice-toolbar { margin: var(--space-2) 0 var(--space-3); }
#voice-toggle.is-listening {
  background: #fee2e2;
  border-color: #f87171;
  color: #991b1b;
  animation: voice-pulse 1.6s ease-in-out infinite;
}
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.45); }
  50%      { box-shadow: 0 0 0 6px rgba(248, 113, 113, 0); }
}

#voice-toggle.is-disabled,
#voice-toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  animation: none;
}
.voice-status--blocked {
  color: #991b1b;
}

.text-right { text-align: right; }

.nav-search { margin: 0; }
.nav-search input { width: 200px; }
.input--sm {
  padding: 4px 10px;
  font-size: var(--text-sm);
  height: 32px;
}
mark { background: #fef08a; padding: 0 2px; border-radius: 3px; }

/* =========================================================================
   Mobile-first responsive: salesperson in the car / on the marina dock.
   The desktop layout was designed for ≥1024px; below that everything
   should collapse to one column with bigger tap targets and a mic
   button that's easy to hit one-handed.
   ========================================================================= */

@media (max-width: 900px) {
  /* Cards-in-grid layouts → stack vertically. */
  .stat-grid                 { grid-template-columns: 1fr 1fr !important; }
  .card-grid,
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns: 3fr 2fr"] {
    display: block !important;
  }
  .card-grid > * + *,
  [style*="grid-template-columns"] > * + * {
    margin-top: var(--space-4);
  }

  /* Page header — stack title and action buttons. */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }
  .page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .page-actions .btn { flex: 1 1 auto; }

  /* Tables: allow horizontal scroll instead of squashing columns. */
  .table-wrap, .card > .table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table {
    min-width: 560px;
  }

  /* Search box in nav hides on small screens (it's still on /search). */
  .nav-search { display: none; }

  /* Hero / welcome title scales down further on phones. */
  .hero-landing__title { font-size: var(--text-2xl); }
}

@media (max-width: 600px) {
  /* Phones */
  .stat-grid { grid-template-columns: 1fr !important; }

  /* Top nav: brand only + collapsed links. */
  .app-nav__inner { gap: var(--space-3); }
  .app-nav__brand span:not(.app-nav__brand-logo) { display: none; }
  .app-nav__link { padding: 6px var(--space-2); font-size: var(--text-sm); }

  /* Conversation textarea + voice button: bigger tap target. */
  #voice-toggle {
    font-size: var(--text-md);
    padding: 12px 16px;
    min-height: 44px;            /* iOS HIG tap target */
  }
  .voice-toolbar { flex-wrap: wrap; }

  /* Page title shrinks; subtitle wraps. */
  .page-title { font-size: var(--text-xl); }
  .page-subtitle { font-size: var(--text-sm); }

  /* Clusters become full-width stacks where they were horizontal. */
  .cluster--end { justify-content: flex-start; }
  .cluster .btn { min-height: 40px; }

  /* Sub-nav: scroll horizontally instead of wrapping awkwardly. */
  .app-subnav__inner {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .app-subnav__link { white-space: nowrap; }
}

/* =========================================================================
   Marketing landing page (/). Self-contained styles — designed for an
   anonymous visitor, no app chrome. The existing .app-nav still renders
   at the top, but the page below it overrides default container widths
   so sections breathe to the viewport edges.
   ========================================================================= */

.landing-hero,
.landing-section,
.landing-cta,
.landing-footer {
  width: 100%;
}

.landing-hero {
  padding: 96px 24px 80px;
  background:
    radial-gradient(ellipse at top, rgba(220, 38, 38, 0.06), transparent 60%),
    var(--bg);
  text-align: center;
}

.landing-hero__inner,
.landing-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.landing-hero__eyebrow {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-5);
}

.landing-hero__title {
  font-size: clamp(2rem, 5vw, 3.75rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-4);
  font-weight: 700;
}
.landing-hero__title-accent {
  color: #dc2626;
  display: inline-block;
}

.landing-hero__lede {
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto var(--space-8);
}

.landing-hero__ctas {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}

.landing-hero__footnote {
  margin-top: var(--space-6);
}

.btn--lg {
  padding: 12px 24px;
  font-size: var(--text-md);
  font-weight: 600;
}

/* ----- Section blocks ----- */

.landing-section {
  padding: 80px 24px;
}
.landing-section--alt {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.landing-eyebrow {
  display: inline-block;
  color: var(--text-subtle);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}

.landing-h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-5);
  font-weight: 700;
}

.landing-lede {
  font-size: var(--text-md);
  line-height: 1.6;
  color: var(--text);
  margin: 0 0 var(--space-4);
  max-width: 680px;
}

/* ----- The loop (4-step) ----- */

.landing-loop {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  margin-top: var(--space-8);
}
.landing-loop__step {
  position: relative;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.landing-loop__num {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #dc2626;
  color: white;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: var(--space-3);
}
.landing-loop__title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.landing-loop__step p {
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--text-muted);
}

/* ----- Feature grid (6 blocks) ----- */

.landing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  margin-top: var(--space-8);
}
.landing-feature h3 {
  font-size: var(--text-md);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--text);
}
.landing-feature p {
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--text-muted);
}

/* ----- Verticals chips ----- */

.landing-verticals {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-6);
}
.landing-vertical {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-full);
}

/* ----- Pricing cards ----- */

.landing-pricing {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  margin-top: var(--space-8);
  align-items: stretch;
}
.landing-price-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  position: relative;
  display: flex;
  flex-direction: column;
}
.landing-price-card--featured {
  border-color: #dc2626;
  border-width: 2px;
  box-shadow: var(--shadow-lg);
  transform: scale(1.03);
}
.landing-price-card__badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: #dc2626;
  color: white;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-full);
}
.landing-price-card__tier {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  display: block;
}
.landing-price-card__price {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin-bottom: var(--space-2);
}
.landing-price-card__currency {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text);
}
.landing-price-card__amount {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
}
.landing-price-card__period {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-left: var(--space-1);
}
.landing-price-card__list {
  list-style: none;
  padding: 0;
  margin: var(--space-4) 0 0;
  flex: 1;
}
.landing-price-card__list li {
  padding: 6px 0;
  font-size: var(--text-sm);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.landing-price-card__list li:last-child {
  border-bottom: none;
}
.landing-price-card__list li::before {
  content: "✓";
  color: var(--success);
  font-weight: 700;
  margin-right: 8px;
}
.landing-pricing__note {
  margin-top: var(--space-6);
  text-align: center;
}

/* ----- Final CTA ----- */

.landing-cta {
  padding: 96px 24px;
  background: linear-gradient(135deg, #1f1d3a 0%, #2b1d3a 100%);
  color: white;
  text-align: center;
}
.landing-cta__title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-4);
  color: white;
}
.landing-cta__lede {
  font-size: var(--text-md);
  line-height: 1.55;
  max-width: 600px;
  margin: 0 auto var(--space-6);
  opacity: 0.85;
}
.landing-cta__buttons {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}
.landing-cta .btn--primary {
  background: #dc2626;
  border-color: #dc2626;
}
.landing-cta .btn--primary:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}
.landing-cta .btn--ghost {
  color: white;
  border-color: rgba(255,255,255,0.3);
}
.landing-cta .btn--ghost:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

/* ----- Footer ----- */

.landing-footer {
  padding: var(--space-6) var(--space-4);
  background: var(--surface);
  border-top: 1px solid var(--border);
  text-align: center;
}

/* ----- Mobile collapses ----- */

@media (max-width: 900px) {
  .landing-loop      { grid-template-columns: 1fr 1fr; }
  .landing-grid      { grid-template-columns: 1fr 1fr; }
  .landing-pricing   { grid-template-columns: 1fr; }
  .landing-price-card--featured { transform: none; }
}

@media (max-width: 600px) {
  .landing-hero { padding: 64px 16px 56px; }
  .landing-section { padding: 56px 16px; }
  .landing-cta { padding: 64px 16px; }
  .landing-loop      { grid-template-columns: 1fr; }
  .landing-grid      { grid-template-columns: 1fr; }
}

/* Workspace picker — shown after login when a user belongs to more
   than one active workspace. Same surface as auth cards but stacked
   rows that scan like a list of accounts. */
.workspace-picker__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.workspace-picker__item:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
  transform: translateY(-1px);
}
.workspace-picker__logo {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  overflow: hidden;
}
.workspace-picker__logo img { width: 100%; height: 100%; object-fit: cover; }
.workspace-picker__body { flex: 1; min-width: 0; }
.workspace-picker__chev {
  color: var(--text-subtle);
  font-size: var(--text-xl);
}
