/* ==========================================================================
   ZephAI — base: design tokens, reset, typography, utilities,
   buttons, forms, badges, avatars, meters, alerts
   ========================================================================== */

:root {
  /* type */
  --font-display: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-3xs: 0.6875rem;
  --fs-2xs: 0.75rem;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-base: 0.9375rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.3125rem;
  --fs-2xl: 1.625rem;
  --fs-3xl: 2.125rem;
  --fs-4xl: 2.75rem;
  --fs-5xl: 3.5rem;

  /* space */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-7: 2rem;
  --sp-8: 2.5rem;
  --sp-9: 3rem;
  --sp-10: 4rem;
  --sp-11: 5.5rem;

  /* radius */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-2xl: 28px;
  --r-full: 999px;

  /* layout */
  --header-h: 68px;
  --container: 1240px;
  --sidebar-w: 258px;
  --sidebar-collapsed: 76px;
  --topbar-h: 64px;

  /* motion */
  --ease: cubic-bezier(0.32, 0.72, 0.28, 1);
  --dur: 0.22s;

  --z-header: 60;
  --z-drawer: 70;
  --z-popover: 80;
  --z-modal: 90;
  --z-toast: 100;
}

/* ---------- light theme (default) ---------- */
:root,
[data-theme='light'] {
  color-scheme: light;
  --bg: #f4f7f6;
  --bg-grad: radial-gradient(1200px 520px at 12% -8%, #dff6e9 0%, rgba(223, 246, 233, 0) 62%),
    radial-gradient(900px 460px at 92% 0%, #e4edff 0%, rgba(228, 237, 255, 0) 58%);
  --surface: #ffffff;
  --surface-2: #f3f6f5;
  --surface-3: #e9efed;
  --surface-inset: #f8faf9;
  --border: #e2e8e6;
  --border-strong: #cbd6d2;
  --text: #0b1310;
  --text-2: #46554e;
  --text-3: #788a83;
  --text-invert: #ffffff;

  --brand: #51bf85;
  --brand-600: #3fae76;
  --brand-700: #2f9264;
  --brand-soft: #e6f7ee;
  --brand-soft-2: #d3f0e1;
  --brand-text: #14754a;

  --ok: #1f9d5b;
  --ok-soft: #e3f6ec;
  --warn: #b7791f;
  --warn-soft: #fdf3e0;
  --danger: #d93b42;
  --danger-soft: #fdeaea;
  --info: #2f6fed;
  --info-soft: #e7eeff;
  --purple: #7c5cf0;
  --purple-soft: #efeaff;
  --cyan: #0e9bb5;
  --chart-8: #c2418c;
  --chart-9: #7a6a3a;
  --chart-10: #2f8f83;

  --shadow-xs: 0 1px 2px rgba(9, 20, 16, 0.05);
  --shadow-sm: 0 1px 2px rgba(9, 20, 16, 0.06), 0 2px 6px -2px rgba(9, 20, 16, 0.07);
  --shadow-md: 0 4px 10px -4px rgba(9, 20, 16, 0.1), 0 12px 28px -12px rgba(9, 20, 16, 0.16);
  --shadow-lg: 0 8px 20px -8px rgba(9, 20, 16, 0.14), 0 30px 60px -24px rgba(9, 20, 16, 0.24);
  --shadow-brand: 0 8px 22px -10px rgba(29, 143, 91, 0.65);

  --grid-line: rgba(11, 19, 16, 0.055);
  --scrim: rgba(9, 17, 14, 0.44);
  --chart-grid: #e7ecea;
}

/* ---------- dark theme ---------- */
[data-theme='dark'] {
  color-scheme: dark;
  --bg: #080b0a;
  --bg-grad: radial-gradient(1100px 520px at 10% -10%, rgba(35, 96, 68, 0.45) 0%, rgba(35, 96, 68, 0) 60%),
    radial-gradient(900px 480px at 95% -5%, rgba(38, 60, 128, 0.4) 0%, rgba(38, 60, 128, 0) 58%);
  --surface: #0f1514;
  --surface-2: #141b1a;
  --surface-3: #1a2321;
  --surface-inset: #0b100f;
  --border: #1f2a27;
  --border-strong: #2d3a36;
  --text: #e8f0ec;
  --text-2: #a2b3ac;
  --text-3: #74867f;
  --text-invert: #06110c;

  --brand: #4fc489;
  --brand-600: #5fd195;
  --brand-700: #7be0aa;
  --brand-soft: rgba(79, 196, 137, 0.14);
  --brand-soft-2: rgba(79, 196, 137, 0.22);
  --brand-text: #74e0a8;

  --ok: #4bc786;
  --ok-soft: rgba(75, 199, 134, 0.15);
  --warn: #e5a83c;
  --warn-soft: rgba(229, 168, 60, 0.15);
  --danger: #f1636a;
  --danger-soft: rgba(241, 99, 106, 0.15);
  --info: #6397f7;
  --info-soft: rgba(99, 151, 247, 0.16);
  --purple: #9a86f7;
  --purple-soft: rgba(154, 134, 247, 0.16);
  --cyan: #2ab6d0;
  --chart-8: #e875b3;
  --chart-9: #c9b36a;
  --chart-10: #63c9bb;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5), 0 2px 8px -2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 6px 14px -6px rgba(0, 0, 0, 0.7), 0 16px 34px -14px rgba(0, 0, 0, 0.75);
  --shadow-lg: 0 10px 26px -12px rgba(0, 0, 0, 0.8), 0 36px 70px -28px rgba(0, 0, 0, 0.85);
  --shadow-brand: 0 8px 24px -10px rgba(79, 196, 137, 0.55);

  --grid-line: rgba(255, 255, 255, 0.05);
  --scrim: rgba(3, 6, 5, 0.66);
  --chart-grid: #1d2725;
}

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 20px);
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv05' 1, 'ss01' 1;
  overflow-x: hidden;
}

body.is-locked { overflow: hidden; }

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
ul, ol { list-style: none; padding: 0; }
table { border-collapse: collapse; width: 100%; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

[hidden] { display: none !important; }

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

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
  text-wrap: balance;
}

p { text-wrap: pretty; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ==========================================================================
   Typography helpers
   ========================================================================== */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-text);
}
.eyebrow i { font-size: 0.7rem; }

.display-1 { font-size: clamp(2.4rem, 5.4vw, 4.1rem); line-height: 1.02; letter-spacing: -0.035em; }
.display-2 { font-size: clamp(2rem, 3.8vw, 2.9rem); line-height: 1.06; letter-spacing: -0.03em; }
.h3 { font-size: clamp(1.4rem, 2.2vw, 1.75rem); }
.h4 { font-size: var(--fs-xl); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--font-mono); font-variant-ligatures: none; }
.text-xs { font-size: var(--fs-xs); }
.text-2xs { font-size: var(--fs-2xs); }
.text-3xs { font-size: var(--fs-3xs); }
.text-sm { font-size: var(--fs-sm); }
.text-md { font-size: var(--fs-md); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-nowrap { white-space: nowrap; }
.text-brand { color: var(--brand-text); }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-faint { color: var(--text-3); }
.lead { font-size: var(--fs-lg); color: var(--text-2); line-height: 1.6; }
.underline-link { color: var(--brand-text); text-decoration: underline; text-underline-offset: 3px; }
.gradient-text {
  background: linear-gradient(96deg, var(--text) 6%, var(--brand) 58%, var(--info) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.inline-code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  padding: 1px 6px;
  color: var(--text);
  overflow-wrap: anywhere;
}
p code, li code, td code, dd code, .acc-panel code { overflow-wrap: anywhere; max-width: 100%; }

/* ==========================================================================
   Layout helpers
   ========================================================================== */
.container {
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
  padding-inline: clamp(1rem, 2.6vw, 2.75rem);
}
.container--wide { max-width: 100%; }
.container--narrow { max-width: 940px; }
@media (min-width: 2200px) {
  .container { max-width: 2160px; }
}

.section { padding-block: clamp(3.5rem, 7vw, 6.5rem); }
.section--tight { padding-block: clamp(2.5rem, 5vw, 4rem); }
.section--surface { background: var(--surface); border-block: 1px solid var(--border); }
.section--inset { background: var(--surface-inset); border-block: 1px solid var(--border); }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-5);
  margin-bottom: var(--sp-7);
  max-width: 1560px;
  margin-inline: auto;
}
/* section grids keep a comfortable measure on ultrawide screens */
.section .grid-2, .section .grid-3, .section .grid-4, .section .price-grid { max-width: 1560px; margin-inline: auto; }
.section .grid-4 { max-width: 1480px; }
.section-head--center { flex-direction: column; align-items: center; text-align: center; max-width: 760px; margin-inline: auto; }
.section-title { font-size: clamp(1.75rem, 3.2vw, 2.5rem); margin-top: 12px; }
.section-sub { color: var(--text-2); font-size: var(--fs-lg); max-width: 62ch; margin-top: 14px; }
.section-head--center .section-sub { margin-inline: auto; }

.grid { display: grid; gap: var(--sp-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-auto-sm { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); } .gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); }
.gap-7 { gap: var(--sp-7); }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); } .mt-6 { margin-top: var(--sp-6); } .mt-7 { margin-top: var(--sp-7); }
.mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); } .mb-5 { margin-bottom: var(--sp-5); }
.mb-6 { margin-bottom: var(--sp-6); }
.p-3 { padding: var(--sp-3); }
.pt-5 { padding-top: var(--sp-5); }
.pb-5 { padding-bottom: var(--sp-5); }
.ml-auto { margin-left: auto; }
.mr-2 { margin-right: var(--sp-2); }
.mx-auto { margin-inline: auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: 10px; left: 10px; z-index: 200;
  background: var(--brand); color: var(--text-invert);
  padding: 10px 16px; border-radius: var(--r-sm); font-weight: 600;
  transform: translateY(-160%); transition: transform var(--dur) var(--ease);
}
.skip-link:focus { transform: translateY(0); }

.divider { height: 1px; background: var(--border); border: 0; }
.divider--spaced { margin-block: var(--sp-6); }
.stack > * + * { margin-top: var(--sp-4); }

/* Grid / mesh backdrop */
.mesh-bg {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 78% 62% at 50% 34%, #000 30%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 78% 62% at 50% 34%, #000 30%, transparent 78%);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--text);
  --btn-bd: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding-inline: 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn i { font-size: 0.86em; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.55; pointer-events: none; }

.btn-primary {
  --btn-bg: var(--brand);
  --btn-fg: var(--text-invert);
  --btn-bd: var(--brand);
  box-shadow: var(--shadow-brand);
}
[data-theme='dark'] .btn-primary { --btn-fg: #04140d; }
.btn-primary:hover { --btn-bg: var(--brand-600); --btn-bd: var(--brand-600); }

.btn-outline { --btn-bd: var(--border-strong); --btn-bg: var(--surface); }
.btn-outline:hover { --btn-bd: var(--brand); --btn-fg: var(--brand-text); box-shadow: var(--shadow-sm); }

.btn-soft { --btn-bg: var(--brand-soft); --btn-fg: var(--brand-text); }
.btn-soft:hover { --btn-bg: var(--brand-soft-2); }

.btn-ghost { --btn-fg: var(--text-2); }
.btn-ghost:hover { --btn-bg: var(--surface-3); --btn-fg: var(--text); }

.btn-subtle { --btn-bg: var(--surface-2); --btn-fg: var(--text-2); --btn-bd: var(--border); }
.btn-subtle:hover { --btn-bg: var(--surface-3); --btn-fg: var(--text); }

.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: var(--danger); }
.btn-danger:hover { filter: brightness(1.06); }

.btn-dark { --btn-bg: var(--text); --btn-fg: var(--bg); --btn-bd: var(--text); }
.btn-dark:hover { opacity: 0.9; }

.btn-sm { height: 34px; padding-inline: 13px; font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-lg { height: 50px; padding-inline: 26px; font-size: var(--fs-md); border-radius: var(--r-lg); }
.btn-xs { height: 28px; padding-inline: 10px; font-size: var(--fs-2xs); border-radius: var(--r-sm); }
.btn-block { display: flex; width: 100%; }
.btn-pill { border-radius: var(--r-full); }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 16px; height: 16px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  color: var(--btn-fg); animation: spin 0.7s linear infinite;
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--r-md);
  color: var(--text-2); background: transparent;
  border: 1px solid transparent;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  position: relative; flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn--bordered { border-color: var(--border); background: var(--surface); }
.icon-btn--sm { width: 30px; height: 30px; font-size: var(--fs-xs); border-radius: var(--r-sm); }
.icon-btn.is-active { background: var(--brand-soft); color: var(--brand-text); }

.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--brand-text); font-size: var(--fs-xs); font-weight: 600;
}
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* Segmented control */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
}
.segmented button {
  padding: 6px 14px; border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: 600;
  color: var(--text-2); transition: all var(--dur) var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active, .segmented button[aria-pressed='true'] {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs);
}

/* ==========================================================================
   Badges, chips, tags, dots, avatars
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px; padding-inline: 8px; border-radius: var(--r-full);
  font-size: var(--fs-3xs); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--brand { background: var(--brand-soft); color: var(--brand-text); }
.badge--neutral { background: var(--surface-3); color: var(--text-2); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding-inline: 11px; border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-2);
  transition: all var(--dur) var(--ease); white-space: nowrap;
}
a.chip:hover, button.chip:hover { background: var(--brand-soft); border-color: var(--brand-soft-2); color: var(--brand-text); }
.chip--xs { height: 22px; padding-inline: 8px; font-size: var(--fs-3xs); gap: 4px; }
.chip--brand { background: var(--brand-soft); border-color: transparent; color: var(--brand-text); }
.chip--ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chip--warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip--danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.chip--info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.chip--purple { background: var(--purple-soft); border-color: transparent; color: var(--purple); }
.chip--outline { background: transparent; }
.chip--live { background: var(--surface); }
.chip.is-active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-text); }
.chip[aria-pressed='true'] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-text); }
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); display: inline-block; flex: none; }
.dot--ok { background: var(--ok); }
.dot--warn { background: var(--warn); }
.dot--danger { background: var(--danger); }
.dot--info { background: var(--info); }
.dot--brand { background: var(--brand); }
.dot--live { background: var(--ok); box-shadow: 0 0 0 0 rgba(31, 157, 91, 0.55); animation: pulse 2s infinite; }

/* status indicators use real icons, not bare circles */
.ico-status { font-size: 0.8em; line-height: 1; flex: none; }
.ico-status--live { color: var(--ok); animation: pulse 2s infinite; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(75, 199, 134, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(75, 199, 134, 0); }
  100% { box-shadow: 0 0 0 0 rgba(75, 199, 134, 0); }
}
@keyframes spin { to { transform: rotate(360deg); } }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-2);
  font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: 0.02em; flex: none; overflow: hidden;
  border: 1px solid var(--border);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--xs { width: 24px; height: 24px; font-size: 0.6rem; }
.avatar--sm { width: 30px; height: 30px; font-size: 0.68rem; }
.avatar--md { width: 42px; height: 42px; font-size: var(--fs-sm); }
.avatar--lg { width: 56px; height: 56px; font-size: var(--fs-md); }
.avatar--brand { background: var(--brand-soft); color: var(--brand-text); border-color: transparent; }
.avatar--info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.avatar--purple { background: var(--purple-soft); color: var(--purple); border-color: transparent; }
.avatar--warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { margin-left: -10px; box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ==========================================================================
   Forms
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 7px; }
.field + .field { margin-top: var(--sp-4); }
.label {
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-2);
  display: flex; align-items: center; justify-content: flex-start; gap: 5px;
}
.label .req { color: var(--danger); }
.label .hint-link { color: var(--brand-text); font-weight: 600; margin-left: auto; }
.label .faint { font-weight: 400; }

.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 13px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font-size: var(--fs-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.textarea { height: auto; min-height: 110px; padding: 11px 13px; line-height: 1.55; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.input:disabled, .textarea:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
.input[aria-invalid='true'], .textarea[aria-invalid='true'] { border-color: var(--danger); }
.input[aria-invalid='true']:focus { box-shadow: 0 0 0 3px var(--danger-soft); }

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
.select--sm { height: 34px; font-size: var(--fs-xs); background-position: calc(100% - 16px) 14px, calc(100% - 11px) 14px; }

.input-sm { height: 34px; font-size: var(--fs-xs); padding-inline: 11px; }
.input-mono { font-family: var(--font-mono); letter-spacing: -0.01em; }

.input-group { position: relative; display: flex; align-items: stretch; gap: 8px; }
.input-group .input { flex: 1; min-width: 0; }
.input-group--joined { gap: 0; }
.input-group--joined .input { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group--joined .btn { border-radius: 0 var(--r-md) var(--r-md) 0; }
.input-group .input-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: var(--fs-sm); pointer-events: none;
}
.input-group .has-icon { padding-left: 38px; }

.field-hint { font-size: var(--fs-xs); color: var(--text-3); }
.field-error { font-size: var(--fs-xs); color: var(--danger); display: flex; gap: 6px; align-items: center; }

/* checkbox / radio */
.check {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; line-height: 1.5;
}
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box {
  width: 18px; height: 18px; border-radius: var(--r-xs); flex: none; margin-top: 1px;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center; transition: all var(--dur) var(--ease);
}
.check .box::after {
  content: ''; width: 9px; height: 5px; border-left: 2px solid var(--text-invert);
  border-bottom: 2px solid var(--text-invert); transform: rotate(-45deg) scale(0);
  transition: transform var(--dur) var(--ease); margin-top: -2px;
}
.check input:checked + .box { background: var(--brand); border-color: var(--brand); }
.check input:checked + .box::after { transform: rotate(-45deg) scale(1); }
.check input:focus-visible + .box { outline: 2px solid var(--brand); outline-offset: 2px; }
.check:hover .box { border-color: var(--brand); }
.check--radio .box { border-radius: 50%; }
.check--radio .box::after { content: ''; width: 8px; height: 8px; border: 0; background: var(--text-invert); border-radius: 50%; margin: 0; transform: scale(0); }
.check--radio input:checked + .box::after { transform: scale(1); }

/* switch */
.switch-wrap { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fs-sm); color: var(--text-2); }
.switch-wrap input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch {
  width: 40px; height: 22px; border-radius: var(--r-full); flex: none;
  background: var(--border-strong); position: relative; transition: background var(--dur) var(--ease);
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  background: #fff; border-radius: 50%; transition: transform var(--dur) var(--ease);
  box-shadow: var(--shadow-xs);
}
.switch-wrap input:checked + .switch { background: var(--brand); }
.switch-wrap input:checked + .switch::after { transform: translateX(18px); }
.switch-wrap input:focus-visible + .switch { outline: 2px solid var(--brand); outline-offset: 2px; }

/* range */
.range { width: 100%; appearance: none; height: 6px; border-radius: var(--r-full); background: var(--surface-3); outline: none; }
.range::-webkit-slider-thumb {
  appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand); border: 3px solid var(--surface); box-shadow: var(--shadow-sm); cursor: pointer;
}
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--brand); border: 3px solid var(--surface); cursor: pointer; }

/* radio cards */
.radio-card {
  display: flex; gap: 12px; align-items: flex-start; padding: 16px;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); cursor: pointer; transition: all var(--dur) var(--ease);
}
.radio-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.radio-card input { position: absolute; opacity: 0; }
.radio-card.is-selected, .radio-card:has(input:checked) {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.radio-card .check-dot {
  width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex: none;
  display: grid; place-items: center;
}
.radio-card.is-selected .check-dot, .radio-card:has(input:checked) .check-dot { border-color: var(--brand); }
.radio-card.is-selected .check-dot::after, .radio-card:has(input:checked) .check-dot::after {
  content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--brand);
}

/* ==========================================================================
   Meters / progress
   ========================================================================== */
.meter { display: block; height: 7px; width: 100%; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; }
.meter-bar {
  display: block; height: 100%; width: var(--val, 0%); border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand), var(--brand-600));
  transition: width 0.9s var(--ease);
}
.meter--ok .meter-bar { background: linear-gradient(90deg, var(--ok), var(--brand)); }
.meter--warn .meter-bar { background: linear-gradient(90deg, var(--warn), #f0b95c); }
.meter--danger .meter-bar { background: linear-gradient(90deg, var(--danger), #f08a8a); }
.meter--info .meter-bar { background: linear-gradient(90deg, var(--info), var(--purple)); }
.meter--lg { height: 10px; }
.meter-label { display: flex; justify-content: space-between; font-size: var(--fs-2xs); color: var(--text-3); margin-bottom: 6px; }

/* radial progress */
.radial { position: relative; display: inline-grid; place-items: center; }
.radial svg { transform: rotate(-90deg); }
.radial .radial-track { stroke: var(--surface-3); }
.radial .radial-fill { stroke: var(--brand); stroke-linecap: round; transition: stroke-dashoffset 1.1s var(--ease); }
.radial-value {
  position: absolute; font-family: var(--font-display); font-weight: 600;
  font-size: var(--fs-md); color: var(--text);
}

/* ==========================================================================
   Alerts / banners
   ========================================================================== */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--r-lg);
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: var(--fs-sm); color: var(--text-2);
}
.alert i:first-child { margin-top: 3px; font-size: var(--fs-md); }
.alert strong { color: var(--text); }
.alert--info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.alert--info strong { color: var(--info); }
.alert--warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.alert--warn strong { color: var(--warn); }
.alert--danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert--danger strong { color: var(--danger); }
.alert--ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.alert--ok strong { color: var(--ok); }
.alert-body { flex: 1; color: inherit; }
.alert-body p { color: inherit; opacity: 0.92; }
.alert-close { color: inherit; opacity: 0.7; }
.alert-close:hover { opacity: 1; }

/* ==========================================================================
   Keyboard hint
   ========================================================================== */
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: var(--r-xs);
  font-family: var(--font-mono); font-size: 0.66rem; font-weight: 500; color: var(--text-3);
  line-height: 1;
}

/* ==========================================================================
   Tooltips
   ========================================================================== */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translate(-50%, 4px);
  background: var(--text); color: var(--bg);
  font-family: var(--font-sans); font-size: var(--fs-2xs); font-weight: 500; letter-spacing: 0;
  text-transform: none; padding: 5px 9px; border-radius: var(--r-sm);
  white-space: nowrap; pointer-events: none; opacity: 0;
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease);
  z-index: var(--z-popover); box-shadow: var(--shadow-md);
}
[data-theme='dark'] [data-tip]::after { background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong); }
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
[data-tip-bottom]::after, [data-tip][data-tip-pos='bottom']::after { bottom: auto; top: calc(100% + 8px); }
[data-tip-left]::after { left: auto; right: 0; transform: translate(0, 4px); }
[data-tip-left]:hover::after { transform: translate(0, 0); }

/* ==========================================================================
   Motion preferences
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .section-head { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
}
