/*
 * Lead Router — app styles on top of the FPS Design System.
 *
 * The design system (public/vendor/fps-design-system, loaded first) provides the tokens, reset and
 * component classes: .btn, .card, .badge, .input, .table, .callout, .stat-card, .empty-state,
 * .filter-chip, .app-page-header, .avatar. This file only adds the app shell, the login page
 * (spec §12) and a few app-specific pieces.
 *
 * Token contract: semantic tokens only (--color-*, --space-*, --font-*, --border-radius-*). Never
 * --fps-* or --gray-*. Unlayered, so these rules sit above the design system's cascade layers.
 */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/static/fonts/inter/inter-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/static/fonts/inter/inter-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Registered so the sidebar width can animate (grid column and brand background together). */
@property --sidebar-current {
  syntax: '<length>';
  inherits: true;
  initial-value: 260px;
}

:root {
  --sidebar-width: 260px;
  /* Collapsed rail: icons sit centered at this width given the link padding below. */
  --sidebar-width-collapsed: 70px;
  --sidebar-speed: 260ms;
  --content-max: 1240px;
  /* Brand-surface text shades, derived from the semantic on-brand color. */
  --sidebar-text: color-mix(in oklch, var(--color-text-on-surface-brand) 72%, transparent);
  --sidebar-text-faint: color-mix(in oklch, var(--color-text-on-surface-brand) 45%, transparent);
  --sidebar-hover: color-mix(in oklch, var(--color-text-on-surface-brand) 6%, transparent);
  --sidebar-active: color-mix(in oklch, var(--color-text-on-surface-brand) 10%, transparent);
  --sidebar-rule: color-mix(in oklch, var(--color-text-on-surface-brand) 10%, transparent);
}

body {
  background: var(--color-surface-sunken);
}

.icon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

.muted { color: var(--color-text-muted); }
.small { font-size: var(--font-size-sm); }
.strong { font-weight: 600; color: var(--color-text-heading); }
.mono { font-family: var(--font-family-mono); font-size: var(--font-size-sm); }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.error-text { color: var(--color-error-text); }
.center { text-align: center; }

code {
  padding: 1px var(--space-1);
  border-radius: var(--border-radius-sm);
  background: var(--color-surface-sunken);
  border: 1px solid var(--color-border-subtle);
  font-size: var(--font-size-sm);
  color: var(--color-text-heading);
}

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

.shell {
  --sidebar-current: var(--sidebar-width);
  display: grid;
  grid-template-columns: var(--sidebar-current) minmax(0, 1fr);
  min-height: 100vh;
  /* Paints the brand column to the bottom of long pages, under the sticky sidebar. */
  background: linear-gradient(to right, var(--color-surface-brand) var(--sidebar-current), transparent var(--sidebar-current));
  transition: --sidebar-current var(--sidebar-speed) var(--ease-standard);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20; /* above the main column, so the account menu can overlap it */
  height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-5) var(--space-3) var(--space-4);
  background: var(--color-surface-brand);
  color: var(--color-text-on-surface-brand);
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  padding-left: var(--space-3);
  flex-shrink: 0;
  overflow: hidden; /* clips the logo while the width animates */
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  min-width: 0;
  padding-top: var(--space-1);
  color: inherit;
  &:hover { text-decoration: none; }
}

/* The FPS logo starts with the bracket mark, so narrowing this box leaves just the mark. */
.sidebar-logo {
  display: block;
  width: 126px;
  height: 32px;
  overflow: hidden;
  transition: width var(--sidebar-speed) var(--ease-standard);
  img { height: 32px; width: auto; max-width: none; }
}

.sidebar-app-name {
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--sidebar-text);
}

.sidebar-collapse {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius-sm);
  color: var(--sidebar-text);
  transition: background 120ms var(--ease-standard), color 120ms var(--ease-standard);
  &:hover { background: var(--sidebar-hover); color: var(--color-text-on-surface-brand); }
  &:focus-visible { outline: 2px solid var(--color-focus-ring); outline-offset: -2px; }
}
.sidebar-collapse .when-expanded { display: inline-flex; }
.sidebar-collapse .when-collapsed { display: none; }

.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  /* One column exactly as wide as the rail, so long labels clip instead of widening the list
     (a wider list would scroll sideways when a link is focused, hiding the icons). */
  ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
}

.nav-group-label {
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--sidebar-text-faint);
  transition: opacity 160ms var(--ease-standard);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid transparent;
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  white-space: nowrap;
  color: var(--sidebar-text);
  font-weight: 500;
  transition: background 120ms var(--ease-standard), color 120ms var(--ease-standard);

  > span { transition: opacity 160ms var(--ease-standard); }
  &:hover {
    background: var(--sidebar-hover);
    color: var(--color-text-on-surface-brand);
    text-decoration: none;
  }
  &.is-active {
    background: var(--sidebar-active);
    border-left-color: var(--color-accent-brand);
    color: var(--color-text-on-surface-brand);
  }
  &:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: -2px;
  }
}

.sidebar-footer {
  padding-top: var(--space-3);
  border-top: 1px solid var(--sidebar-rule);
}

/* ─── Account menu (under the signed-in person's name) ───────────────────── */

.user-menu { position: relative; }
.user-menu form { margin: 0; }

.user-menu-button {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  white-space: nowrap;
  text-align: left;
  color: var(--color-text-on-surface-brand);
  transition: background 120ms var(--ease-standard);

  &:hover, &[aria-expanded='true'] { background: var(--sidebar-hover); }
  &.is-active { background: var(--sidebar-active); }
  &:focus-visible { outline: 2px solid var(--color-focus-ring); outline-offset: -2px; }
  > .icon { margin-left: auto; color: var(--sidebar-text); transition: opacity 160ms var(--ease-standard); }
}

.user-menu-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
  transition: opacity 160ms var(--ease-standard);
}

.user-menu-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu-email {
  font-size: var(--font-size-xs);
  color: var(--sidebar-text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + var(--space-2));
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-1);
  background: var(--color-surface-raised);
  color: var(--color-text-body);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  transform-origin: bottom center;
  /* Closed: fades and drops slightly; visibility flips after the fade so items can't be tabbed to. */
  opacity: 0;
  visibility: hidden;
  transform: translateY(var(--space-2)) scale(0.97);
  transition:
    opacity 140ms var(--ease-in),
    transform 140ms var(--ease-in),
    visibility 0s linear 140ms;
}

.user-menu.is-open .user-menu-panel {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity 180ms var(--ease-out),
    transform 260ms var(--ease-spring-gentle),
    visibility 0s;
}

.user-menu-header {
  display: none;
  padding: var(--space-2) var(--space-3) var(--space-3);
  margin-bottom: var(--space-1);
  border-bottom: 1px solid var(--color-border-subtle);
  .user-menu-name { color: var(--color-text-heading); }
  .user-menu-email { color: var(--color-text-muted); }
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--border-radius-sm);
  text-align: left;
  color: var(--color-text-body);
  font-size: var(--font-size-sm);
  font-weight: 500;

  .icon { color: var(--color-text-muted); }
  &:hover, &:focus-visible {
    background: var(--color-surface-sunken);
    color: var(--color-text-heading);
    text-decoration: none;
    outline: none;
  }
  &.is-active, &.is-active .icon { color: var(--color-interactive); }
}

.user-menu-divider { height: 1px; margin: var(--space-1) 0; background: var(--color-border-subtle); }

/* ─── Collapsed sidebar (desktop) ────────────────────────────────────────── */

@media (min-width: 901px) {
  .shell.is-collapsed {
    --sidebar-current: var(--sidebar-width-collapsed);

    .sidebar-header { flex-direction: column; align-items: center; gap: var(--space-3); padding-left: 0; }
    .sidebar-brand { align-items: center; }
    .sidebar-logo { width: 26px; }
    .sidebar-app-name { display: none; }
    .sidebar-collapse .when-expanded { display: none; }
    .sidebar-collapse .when-collapsed { display: inline-flex; }
    .nav-group-label, .nav-link > span, .user-menu-text, .user-menu-button > .icon { opacity: 0; }

    /* The menu opens beside the rail instead of above it. */
    .user-menu-panel {
      left: calc(100% + var(--space-3));
      right: auto;
      bottom: 0;
      width: 240px;
      transform-origin: bottom left;
      transform: translateX(calc(var(--space-2) * -1)) scale(0.97);
    }
    .user-menu.is-open .user-menu-panel { transform: none; }
    .user-menu-header { display: block; }
  }
}

.nav-toggle { display: none; }

.main {
  min-width: 0;
  width: 100%;
  max-width: var(--content-max);
  padding: 0 var(--space-8) var(--space-8);
}

/* Page header: the design system's .app-page-header plus a back link and actions. */
.app-page-header {
  align-items: flex-end;
  flex-wrap: wrap;
  .back-link { margin-bottom: var(--space-1); }
}

.page-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

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

.main > * + * { margin-top: var(--space-5); }
.main > .app-page-header + * { margin-top: 0; }

/* ─── Layout helpers ─────────────────────────────────────────────────────── */

.stack { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: var(--space-3); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); align-items: start; }
.grid-wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.inline-form { display: flex; gap: var(--space-2); align-items: center; }
.inline-form > .input, .inline-form > .select { flex: 1; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: var(--space-2); }

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

.card { min-width: 0; }
.card-title { font-size: var(--font-size-md); }
.card-header .count { margin-left: var(--space-2); }
.card-header a { font-size: var(--font-size-sm); white-space: nowrap; }

/* A card whose body is a full-bleed table. */
.card-table {
  padding: 0;
  gap: 0;
  overflow: hidden;
  > .card-header { padding: var(--space-5) var(--space-5) var(--space-4); }
  > .card-note { padding: 0 var(--space-5) var(--space-4); margin: 0; }
  > .table-wrap { border: 0; border-top: 1px solid var(--color-border); border-radius: 0; }
  > .empty-state { border-top: 1px solid var(--color-border); }
}

.card-danger { border-color: color-mix(in oklch, var(--color-danger) 40%, var(--color-border)); }

.count {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--border-radius-pill);
  background: var(--color-neutral-bg);
  color: var(--color-neutral-text);
  font-size: var(--font-size-xs);
  font-weight: 600;
  vertical-align: middle;
}

/* ─── Stats ──────────────────────────────────────────────────────────────── */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
a.stat-card {
  color: inherit;
  transition: border-color 150ms var(--ease-standard), box-shadow 150ms var(--ease-standard);
  &:hover { text-decoration: none; border-color: var(--color-interactive); box-shadow: var(--shadow-sm); }
}
/* Icon shades: the status text shades are too dark to read on dark-mode surfaces. */
.stat-card.is-warning .stat-value { color: var(--color-warning-icon); }
.stat-card.is-error .stat-value { color: var(--color-error-icon); }

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

.table td.num, .table th.num { text-align: right; }
.table td .muted.small { margin-top: 2px; }
.table .badges { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.leads-table td:nth-child(2), .leads-table td:nth-child(3) { min-width: 150px; }

.table-kv {
  th { width: 34%; color: var(--color-text-muted); font-weight: 500; background: none; position: static; }
  th, td { padding: var(--space-2) 0; border-bottom: 1px solid var(--color-border-subtle); word-break: break-word; vertical-align: top; text-align: left; }
  tr:last-child th, tr:last-child td { border-bottom: 0; }
}

/* ─── Forms ──────────────────────────────────────────────────────────────── */

.check {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  cursor: pointer;
  input { margin-top: 3px; accent-color: var(--color-interactive); }
}
.check.small input { margin-top: 2px; }
.radio-list { display: grid; gap: var(--space-3); }

/* Sits on a .card, whose design-system default is a column; the filters run in a wrapping row. */
.filters {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-4);
  .input { flex: 2 1 200px; width: auto; min-width: 0; }
  /* min-width: 0 lets a select shrink below its longest option. */
  .select { flex: 1 1 130px; width: auto; min-width: 0; }
  .check { align-items: center; white-space: nowrap; }
  .check input { margin-top: 0; }
}

.copy-field {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  .input { font-family: var(--font-family-mono); font-size: var(--font-size-sm); }
}

.kv-rows { display: grid; gap: var(--space-2); }
.kv-row { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: var(--space-2); align-items: center; }

/* ─── Callouts (flash messages and notes) ────────────────────────────────── */

.callout {
  align-items: flex-start;
  .callout-title { margin-bottom: 0; }
  ul { margin: var(--space-2) 0 0; padding-left: var(--space-5); font-size: var(--font-size-sm); }
  a { color: inherit; font-weight: 600; text-decoration: underline; }
  .icon { margin-top: 1px; }
}

/* ─── Zip chips (design system filter chips) ─────────────────────────────── */

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); max-height: 420px; overflow-y: auto; }
.chips .filter-chip { font-family: var(--font-family-mono); }
.chips .filter-chip[hidden] { display: none; }
.chips .filter-chip button:hover { background: var(--color-error-bg); color: var(--color-error-text); }

details.more summary { cursor: pointer; color: var(--color-text-muted); font-size: var(--font-size-sm); }
details.more[open] summary { margin-bottom: var(--space-3); }

/* ─── Misc ───────────────────────────────────────────────────────────────── */

.meta {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: var(--space-2) var(--space-3);
  margin: 0;
  dt { color: var(--color-text-muted); font-size: var(--font-size-sm); }
  dd { margin: 0; min-width: 0; }
}

.notes {
  padding: var(--space-3);
  background: var(--color-surface-sunken);
  border-radius: var(--border-radius-sm);
  white-space: pre-wrap;
}

.route-hero {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-sunken);
  border-radius: var(--border-radius);
  .strong { font-size: var(--font-size-md); }
  .icon { color: var(--color-text-muted); }
}

.code {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  max-height: 460px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--color-surface-sunken);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  line-height: 1.55;
  color: var(--color-text-body);
}

.empty-state .icon { color: var(--color-text-muted); }
.empty-state p { max-width: 420px; }

.pager { display: flex; align-items: center; gap: var(--space-2); justify-content: flex-end; }
.pager .muted { margin-right: auto; }

.checklist {
  ol { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
  li { display: flex; align-items: center; gap: var(--space-3); }
  .tick {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--color-border-strong);
    color: var(--color-text-on-interactive);
    flex-shrink: 0;
  }
  li.done .tick { background: var(--color-success-icon); border-color: var(--color-success-icon); }
  li.done span:last-child { color: var(--color-text-muted); text-decoration: line-through; }
}

.assign-form {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  .select { width: auto; min-width: 170px; flex: 1; }
  .check { align-items: center; white-space: nowrap; }
  .check input { margin-top: 0; }
}

.flow { display: flex; align-items: stretch; gap: var(--space-3); flex-direction: row; }
.flow-step {
  flex: 1;
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background: var(--color-surface-sunken);
  &.is-accent {
    border-color: var(--color-interactive);
    background: color-mix(in oklch, var(--color-interactive) 6%, var(--color-surface));
  }
}
.flow-title { font-weight: 600; color: var(--color-text-heading); margin-bottom: var(--space-1); }
.flow-arrow { align-self: center; color: var(--color-text-muted); }

.step { display: grid; grid-template-columns: 32px 1fr; gap: var(--space-4); }
.step-num {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: color-mix(in oklch, var(--color-interactive) 10%, var(--color-surface));
  color: var(--color-interactive);
  font-weight: 700;
}
.step-body { min-width: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.step-body ol, .step-body ul { margin: 0; padding-left: var(--space-5); display: grid; gap: var(--space-2); }

/* ─── Login (design system spec §12: split panel) ────────────────────────── */

.login-container { display: flex; min-height: 100vh; }

.login-brand-panel {
  position: relative;
  width: 45%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--color-surface-brand);

  /* Faint radial glow, bottom-left. */
  &::before {
    content: '';
    position: absolute;
    bottom: -20%;
    left: -20%;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, color-mix(in oklch, var(--color-interactive) 8%, transparent) 0%, transparent 70%);
    pointer-events: none;
  }
  /* 3px accent stripe on the right edge, fading out at the ends. */
  &::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(to bottom, transparent 0%, var(--color-interactive) 15%, var(--color-interactive) 85%, transparent 100%);
    pointer-events: none;
  }
}

.login-logo-img { position: relative; z-index: 1; height: 85px; width: auto; }

.login-right-panel {
  position: relative;
  width: 55%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
}

.login-content { width: 100%; max-width: 400px; padding: 0 var(--space-8); text-align: center; }

.login-app-title {
  margin: 0 0 var(--space-6);
  font-size: clamp(1.5rem, 2vw + 1rem, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--color-text-heading);
}

.login-prompt {
  margin: 0 0 var(--space-6);
  font-size: var(--font-size-md);
  line-height: 1.6;
  color: var(--color-text-body);
  strong { color: var(--color-text-heading); font-weight: 700; }
}

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

.login-error {
  margin-bottom: var(--space-6);
  padding: var(--space-3) var(--space-4);
  border: 1px solid color-mix(in oklch, var(--color-error-icon) 30%, var(--color-surface));
  border-radius: var(--border-radius);
  background: var(--color-error-bg);
  color: var(--color-error-text);
  font-weight: 500;
  line-height: 1.5;
  text-align: left;
}

.login-error-hint { margin-top: var(--space-2); font-weight: 400; font-size: var(--font-size-sm); }

.google-signin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--border-radius);
  background: var(--color-interactive);
  color: var(--color-text-on-interactive);
  font-family: inherit;
  font-size: var(--font-size-md);
  font-weight: 600;
  letter-spacing: -0.1px;
  cursor: pointer;
  transition:
    background-color 150ms var(--ease-out),
    box-shadow 150ms var(--ease-out),
    transform 150ms var(--ease-spring-snappy);

  &:hover {
    text-decoration: none;
    background: var(--color-interactive-hover);
    box-shadow: 0 4px 12px color-mix(in oklch, var(--color-interactive) 30%, transparent);
  }
  &:active {
    background: var(--color-interactive-active);
    box-shadow: 0 2px 6px color-mix(in oklch, var(--color-interactive) 20%, transparent);
    transform: scale(0.985);
  }
  &:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-focus-ring);
  }
}

/* White pill behind Google's multicolor "G" (Google's branding requires a white background). */
.google-icon-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--border-radius-sm);
  background: #fff;
  svg { width: 18px; height: 18px; }
}

.login-footer-note { margin-top: var(--space-5); font-size: var(--font-size-sm); color: var(--color-text-muted); }

.login-page-footer {
  position: absolute;
  bottom: var(--space-6);
  left: 0;
  right: 0;
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  line-height: 1.8;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .grid-2, .grid-wide-left { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar {
    position: static;
    height: auto;
    padding: var(--space-3) var(--space-4);
    gap: var(--space-3);
  }
  .sidebar-header { align-items: center; padding-left: 0; overflow: visible; }
  .sidebar-brand { padding-top: 0; }
  .sidebar-app-name, .sidebar-collapse { display: none; }
  .nav-toggle {
    display: inline-flex;
    margin-left: auto;
    color: var(--color-text-on-surface-brand);
    &:hover { background: var(--sidebar-hover); }
  }
  .sidebar-nav, .sidebar-footer { display: none; }
  .sidebar.is-open .sidebar-nav { display: flex; }
  .sidebar.is-open .sidebar-footer { display: block; }
  /* On phones the account menu expands in place, below the name. */
  .user-menu-panel { position: static; display: none; margin-top: var(--space-2); box-shadow: none; }
  .user-menu.is-open .user-menu-panel { display: flex; }
  .main { padding: 0 var(--space-4) var(--space-8); }
  .flow { flex-direction: column; }
  .flow-arrow { transform: rotate(90deg); }
}

@media (max-width: 767px) {
  .login-container { flex-direction: column; }
  .login-brand-panel {
    width: 100%;
    min-height: 120px;
    max-height: 140px;
    flex-shrink: 0;
    &::after {
      top: auto;
      bottom: 0;
      left: 0;
      width: 100%;
      height: 3px;
      background: linear-gradient(to right, transparent 0%, var(--color-interactive) 15%, var(--color-interactive) 85%, transparent 100%);
    }
  }
  .login-logo-img { height: 48px; }
  .login-right-panel { width: 100%; flex: 1; flex-direction: column; overflow-y: auto; }
  .login-content { padding: var(--space-8) var(--space-6); }
  .login-app-title { font-size: 24px; margin-bottom: var(--space-5); }
  .login-page-footer { position: static; margin: var(--space-8) 0 var(--space-6); }
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .table { min-width: 520px; }
  .table-kv, .table-compact { min-width: 0; }
  .kv-row { grid-template-columns: 1fr; }
  .meta { grid-template-columns: 1fr; gap: 2px; }
  .meta dd { margin-bottom: var(--space-2); }
}
