/*
 * Canonical SaaS design tokens.
 *
 * This file is loaded after legacy/page compatibility styles so the effective
 * palette, typography and geometry cannot fall back to earlier visual themes.
 */

:root {
  color-scheme: light;

  /* Typography */
  --font-sans: Inter, "Noto Sans SC", "PingFang SC", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-md: 13px;
  --font-size-base: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 20px;
  --font-size-2xl: 28px;
  --line-height-tight: 1.3;
  --line-height-base: 1.5715;
  --line-height-relaxed: 1.7;

  /* Neutral surfaces */
  --bg: #f6f7f9;
  --layout-bg: #f6f7f9;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --panel-soft: #f9fafb;
  --surface-muted: #f9fafb;
  --surface-subtle: #f3f4f6;
  --surface-tint: #f8f9ff;
  --surface-selected: #eef2ff;
  --surface-info: #eff6ff;
  --surface-success: #ecfdf5;
  --surface-warning: #fffbeb;
  --surface-danger: #fef2f2;

  /* Text */
  --text: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #6b7280;
  --text-disabled: #9ca3af;
  --muted: #6b7280;
  --text-inverse: #ffffff;

  /* Borders */
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --line-subtle: #f0f1f3;
  --line-selected: #a5b4fc;

  /* Brand */
  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-active: #3730a3;
  --brand-strong: #4338ca;
  --brand-soft: #eef2ff;
  --brand-border: #c7d2fe;
  --brand-ring: rgba(79, 70, 229, 0.2);

  /* Semantic colors. Base colors may be used for graphics; text variants are
     selected to meet normal-text contrast on white surfaces. */
  --ok: #059669;
  --ok-text: #047857;
  --ok-border: #a7f3d0;
  --warn: #d97706;
  --warn-text: #92400e;
  --warn-border: #fde68a;
  --error: #dc2626;
  --danger: #dc2626;
  --error-text: #b91c1c;
  --error-border: #fecaca;
  --error-ring: rgba(220, 38, 38, 0.14);
  --info: #2563eb;
  --info-text: #1d4ed8;
  --info-border: #bfdbfe;

  /* Geometry */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-pill: 999px;
  --control-height-sm: 30px;
  --control-height: 36px;
  --control-height-lg: 40px;

  /* Elevation and motion */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 22px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.14);
  --focus-ring: 0 0 0 3px var(--brand-ring);
  --motion-fast: 140ms;
  --motion-base: 180ms;
  --motion-slow: 240ms;

  /* Application shell */
  --saas-sidebar-width: 224px;
  --saas-topbar-height: 64px;
  --page-inline-padding: 24px;
  --page-block-padding: 22px;
  --page-max-width: 1600px;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

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

[hidden] {
  display: none !important;
}

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button,
input,
select,
textarea,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}

button,
[role="button"],
summary,
label,
select {
  touch-action: manipulation;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 650;
  letter-spacing: -0.012em;
}

p {
  margin-top: 0;
}

code,
pre,
kbd,
samp,
.tool-code,
.management-cell-code {
  font-family: var(--font-mono);
}

::selection {
  background: #c7d2fe;
  color: var(--text);
}

@media (max-width: 1180px) {
  :root {
    --saas-sidebar-width: 204px;
    --page-inline-padding: 20px;
  }
}

@media (max-width: 860px) {
  :root {
    --page-inline-padding: 14px;
    --page-block-padding: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
