/*
 * CrashDesk design tokens — the single source of truth for colour, type,
 * spacing, control size, radius, elevation, focus, motion and stacking.
 *
 * These values are the ones already used across the product, promoted to named
 * tokens. Adopting a token must never change how a screen looks today; it only
 * makes the next screen match the last one. The legacy `--ink`, `--muted`,
 * `--line`, `--soft`, `--blue`, `--navy`, `--green`, `--gold` and `--red`
 * variables in globals.css are kept as aliases so existing rules keep working.
 *
 * New CSS must use these tokens. Raw hex, arbitrary z-index numbers and
 * one-off spacing values are rejected by .cursor/rules/crashdesk-css.mdc.
 */

:root {
  /* Surfaces */
  --cd-canvas: #eef2f7;
  --cd-surface: #ffffff;
  --cd-surface-subtle: #f8fafc;
  --cd-surface-sunken: #f5f7fa;

  /* Ink */
  --cd-ink-strong: #111827;
  --cd-ink-heading: #15213a;
  --cd-ink-muted: #657086;
  --cd-ink-quiet: #788398;
  --cd-ink-inverse: #ffffff;

  /* Lines */
  --cd-border: #d6dee8;
  --cd-border-strong: #cbd4df;
  --cd-border-quiet: #dfe3eb;

  /* Brand and semantics */
  --cd-primary: #155eef;
  --cd-primary-dark: #174eaf;
  --cd-primary-surface: #eaf1ff;
  --cd-navy: #152446;
  --cd-navy-deep: #111c35;
  --cd-success-ink: #087757;
  --cd-success: #0b8f63;
  --cd-success-surface: #e8f8f1;
  --cd-warning-ink: #8a5a0b;
  --cd-warning: #b7791f;
  --cd-warning-surface: #fff2d9;
  --cd-danger-ink: #b42318;
  --cd-danger: #d92d20;
  --cd-danger-surface: #ffebe9;
  --cd-accent-ink: #5a3fa8;
  --cd-accent: #7656c9;
  --cd-accent-surface: #f1ecfd;

  /* Typography */
  --cd-font-sans: var(--font-geist-sans), "Geist", Arial, sans-serif;
  --cd-font-mono: var(--font-geist-mono), "Geist Mono", ui-monospace, monospace;
  --cd-text-kicker: 13px;
  --cd-text-small: 13px;
  --cd-text-control: 14px;
  --cd-text-body: 16px;
  --cd-text-lead: 17px;
  --cd-text-section: 22px;
  --cd-text-page: 30px;
  --cd-text-metric: 28px;
  --cd-leading-tight: 1.15;
  --cd-leading-body: 1.5;
  --cd-tracking-kicker: 0.08em;
  --cd-tracking-section: -0.025em;
  --cd-tracking-page: -0.035em;
  --cd-weight-body: 500;
  --cd-weight-medium: 600;
  --cd-weight-strong: 750;
  --cd-weight-heavy: 850;

  /* Spacing scale (4px rhythm) */
  --cd-hairline: 1px;
  --cd-space-half: 2px;
  --cd-space-1: 4px;
  --cd-space-2: 8px;
  --cd-space-3: 12px;
  --cd-space-4: 16px;
  --cd-space-5: 20px;
  --cd-space-6: 24px;
  --cd-space-7: 32px;
  --cd-space-8: 40px;

  /* Layout rhythm — the only correct source for page and panel spacing */
  --cd-gutter: var(--cd-space-6);
  --cd-panel-pad: var(--cd-space-5);
  --cd-panel-gap: var(--cd-space-4);
  --cd-section-gap: var(--cd-space-6);
  --cd-field-gap: var(--cd-space-3);
  --cd-topbar-h: 76px;
  --cd-max-content: 1500px;

  /* Controls */
  --cd-control-h: 40px;
  --cd-control-h-lg: 44px;
  --cd-control-h-sm: 32px;
  --cd-control-pad-x: 14px;

  /* Shape */
  --cd-radius-xs: 6px;
  --cd-radius-sm: 8px;
  --cd-radius-md: 10px;
  --cd-radius-lg: 12px;
  --cd-radius-xl: 14px;
  --cd-radius-pill: 999px;

  /* Elevation */
  --cd-shadow-panel: 0 7px 22px rgb(28 43 68 / 6%);
  --cd-shadow-row: 0 5px 16px rgb(26 43 72 / 7%);
  --cd-shadow-overlay: 0 24px 70px rgb(9 18 34 / 30%);
  --cd-scrim: rgb(17 28 53 / 60%);

  /* Focus */
  --cd-focus-ring: 0 0 0 3px rgb(21 94 239 / 16%);
  --cd-focus-ring-danger: 0 0 0 3px rgb(217 45 32 / 18%);

  /* Motion */
  --cd-motion-fast: 160ms;
  --cd-motion: 200ms;
  --cd-motion-slow: 240ms;
  --cd-ease: cubic-bezier(0.2, 0, 0.2, 1);

  /*
   * Named overlay layers. Never write a bare z-index in CrashDesk CSS: pick the
   * layer that describes the intent, so a new overlay cannot land between two
   * existing ones by accident.
   */
  --cd-layer-base: 1;
  --cd-layer-sticky: 20;
  --cd-layer-topbar: 40;
  --cd-layer-dropdown: 60;
  --cd-layer-drawer: 80;
  --cd-layer-dialog: 100;
  --cd-layer-toast: 120;
  /* Portaled firm inbox must remain above full-screen contact records. */
  --cd-layer-action-center: 360;

  /*
   * Chat, ported from chat.bosseo.com.
   *
   * Kept as its own `--cdchat-*` family rather than folded into the tokens
   * above, because these are a faithful copy of another product's transcript
   * surface: its 23px avatars, 9px row rhythm and near-black send button are
   * not CrashDesk's control scale and must not drift into it. Naming them here
   * is what lets app/chat.css be written entirely in var() and start at zero
   * token debt.
   */
  --cdchat-surface: var(--cd-surface);
  --cdchat-rail-bg: #f8f9fc;
  --cdchat-divider: #e6e8ef;
  --cdchat-row-hover: #fafafd;
  --cdchat-header-h: 68px;
  --cdchat-rail-w: 236px;
  --cdchat-panel-w: min(1180px, 96vw);
  --cdchat-panel-h: min(860px, 92vh);

  /* Off the 4px scale on purpose: this is the source product's rhythm. */
  --cdchat-row-pad: 9px;
  --cdchat-row-radius: 9px;
  --cdchat-gap-tight: 6px;
  --cdchat-gap: 9px;
  --cdchat-avatar: 23px;
  --cdchat-avatar-lg: 26px;
  --cdchat-avatar-radius: 7px;
  /* Column gap between the avatar and the message, and the trailing gutter that
   * keeps the hover edit/delete controls off the end of a long line. The old
   * 25px time column is gone: the time sits beside the name, where it fits. */
  --cdchat-gap-row: 10px;
  --cdchat-row-gutter: 58px;
  --cdchat-stat-col: 86px;
  --cdchat-menu-max: 208px;
  --cdchat-shot-w: 168px;
  --cdchat-shot-h: 120px;
  --cdchat-thumb: 26px;
  --cdchat-file-chip-max: 244px;
  --cdchat-mic-w: 8px;
  --cdchat-mic-h: 13px;
  --cdchat-mic-stand: 3px;
  --cdchat-mic-pulse: 6px;
  --cdchat-send-size: 47px;
  --cdchat-composer-max: 150px;

  --cdchat-text-name: 14px;
  --cdchat-text-body: 14px;
  --cdchat-text-chip: 12px;
  --cdchat-text-meta: 11px;
  --cdchat-leading-body: 1.6;

  --cdchat-accent: #6a5bf0;
  --cdchat-accent-ring: rgb(107 92 241 / 10%);
  --cdchat-link: #1d4ed8;
  --cdchat-composer-border: #d4d6de;
  --cdchat-send-bg: #101317;
  --cdchat-send-bg-hover: #262b33;

  /* Unread treatment: green border plus a breathing glow. */
  --cdchat-unread: #1bd37a;
  --cdchat-unread-inset: rgb(27 211 122 / 35%);
  --cdchat-unread-ring: rgb(27 211 122 / 18%);
  --cdchat-unread-glow: rgb(27 211 122 / 42%);
  --cdchat-unread-glow-wide: rgb(27 211 122 / 0%);

  /* Skinny dark scrollbars, never the platform default. */
  --cdchat-scroll-size: 4px;
  --cdchat-scroll-thumb: #2a3142;
  --cdchat-scroll-thumb-hover: #3d4658;

  /* Avatar tone gradients, one per rep, assigned by rep id. */
  --cdchat-tone-coral: linear-gradient(145deg, #ff8175, #dd4438);
  --cdchat-tone-blue: linear-gradient(145deg, #5aabff, #1c6cdd);
  --cdchat-tone-gold: linear-gradient(145deg, #ffc75d, #dd9710);
  --cdchat-tone-violet: linear-gradient(145deg, #ac8fff, #6a49dd);
  --cdchat-tone-mint: linear-gradient(145deg, #62e2b3, #12a877);
  --cdchat-tone-slate: linear-gradient(145deg, #9daabf, #5a6883);
  --cdchat-tone-ink: linear-gradient(145deg, #6e7a8b, #29313d);
}

@media (max-width: 900px) {
  :root {
    --cd-gutter: var(--cd-space-4);
    --cd-panel-pad: var(--cd-space-4);
    --cd-section-gap: var(--cd-space-5);
    --cd-text-page: 26px;
    --cd-text-section: 20px;
    --cd-topbar-h: 68px;
  }
}

@media (max-width: 640px) {
  :root {
    --cd-panel-pad: var(--cd-space-4);
    --cd-control-h: 42px;
    --cd-control-h-lg: 44px;
    --cd-text-page: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --cd-motion-fast: 1ms;
    --cd-motion: 1ms;
    --cd-motion-slow: 1ms;
  }
}
