/* =========================================================
   redu CRM — Lumen Desk Design System (Consolidated)
   Cool mist canvas · ink rail · azure primary · orchid AI
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  /* Apple 系统灰阶（iOS/macOS） */
  --ink-950: #1c1c1e;
  --ink-900: #1c1c1e;
  --ink-800: #2c2c2e;
  --ink-700: #3a3a3c;
  --ink-600: #48484a;
  --ink-500: #636366;
  --ink-400: #8e8e93;
  --ink-300: #aeaeb2;
  --ink-200: #d1d1d6;
  --ink-100: #e5e5ea;
  --ink-50: #f2f2f7;

  /* Apple System Blue */
  --azure-50: #f2f7ff;
  --azure-100: #e8f1ff;
  --azure-200: #c8dcff;
  --azure-400: #3395ff;
  --azure-500: #007aff;
  --azure-600: #0a84ff;
  --azure-700: #0060df;

  /* Apple System Indigo/Purple（保留语义名） */
  --orchid-50: #f5f2ff;
  --orchid-100: #ece7ff;
  --orchid-400: #6e5ce6;
  --orchid-500: #5856d6;
  --orchid-600: #5e5ce6;

  /* Apple System Green */
  --mint-50: #f2fdf7;
  --mint-100: #dcf8e9;
  --mint-500: #28a745;
  --mint-600: #1f9d43;

  /* Apple System Orange */
  --amber-50: #fff7ea;
  --amber-100: #ffeed1;
  --amber-500: #ff9500;
  --amber-600: #d97e00;

  /* Apple System Red */
  --rose-50: #fff2f1;
  --rose-100: #ffe3e2;
  --rose-500: #ff3b30;
  --rose-600: #e02e24;

  --white: #ffffff;
  --black: #000000;

  /* Surfaces & borders（Apple 亮色） */
  --bg: #f2f2f7;
  --bg-mesh-a: transparent;
  --bg-mesh-b: transparent;
  --surface: #ffffff;
  --surface-2: #f7f7f9;
  --surface-3: #efeff4;
  --border: rgba(60, 60, 67, 0.16);
  --border-strong: rgba(60, 60, 67, 0.29);
  --text: #1c1c1e;
  --text-2: #48484a;
  --text-3: #8e8e93;
  --text-inv: #ffffff;

  --primary: var(--azure-500);
  --primary-hover: var(--azure-600);
  --primary-active: var(--azure-700);
  --primary-fg: var(--white);
  --primary-soft: var(--azure-50);
  --primary-200: var(--azure-200);
  --primary-ring: rgba(0, 122, 255, 0.28);

  --accent: var(--orchid-500);
  --accent-soft: var(--orchid-50);

  --success: #34c759;
  --success-soft: #e6faec;
  --warning: #ff9500;
  --warning-soft: #fff7ea;
  --error: #ff3b30;
  --error-soft: #fff2f1;
  --info: #0a84ff;
  --info-soft: #f2f7ff;

  --sidebar-w: 248px;
  --sidebar-bg: #ffffff;
  --sidebar-border: rgba(60, 60, 67, 0.16);
  --sidebar-text: #48484a;
  --sidebar-text-strong: #1c1c1e;
  --sidebar-hover: rgba(0, 122, 255, 0.08);
  --sidebar-active: rgba(0, 122, 255, 0.12);

  /* 圆角：Apple 标准 10/14/20 */
  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* 阴影：极轻单层 */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1.5px 4px rgba(0, 0, 0, 0.07);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.16);
  --shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.22);
  --shadow-glow: 0 0 0 3px var(--primary-ring);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.125rem;

  --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;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 150ms;
  --dur: 220ms;
  --dur-slow: 320ms;

  --color-primary: var(--primary);
  --color-primary-hover: var(--primary-hover);
  --color-primary-foreground: var(--primary-fg);
  --color-background: var(--bg);
  --color-foreground: var(--text);
  --color-surface: var(--surface);
  --color-muted: var(--surface-3);
  --color-muted-foreground: var(--text-3);
  --color-error: var(--error);
  --color-success: var(--success);
  --color-border: var(--border);
}

/* ---------- Dark mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-mesh-a: transparent;
    --bg-mesh-b: transparent;
    --surface: #1c1c1e;
    --surface-2: #222225;
    --surface-3: #2c2c2e;
    --border: rgba(255, 255, 255, 0.14);
    --border-strong: rgba(255, 255, 255, 0.25);
    --text: #f5f5f7;
    --text-2: #aeaeb2;
    --text-3: #8e8e93;
    --sidebar-bg: #1c1c1e;
    --sidebar-border: rgba(255, 255, 255, 0.14);
    --sidebar-text: #aeaeb2;
    --sidebar-text-strong: #f5f5f7;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(10, 132, 255, 0.22);
    --primary: #0a84ff;
    --primary-soft: rgba(10, 132, 255, 0.15);
    --primary-ring: rgba(10, 132, 255, 0.4);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1.5px 4px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.7);
  }
}
[data-theme="dark"] {
  --bg: #000000;
  --bg-mesh-a: transparent;
  --bg-mesh-b: transparent;
  --surface: #1c1c1e;
  --surface-2: #222225;
  --surface-3: #2c2c2e;
  --border: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.25);
  --text: #f5f5f7;
  --text-2: #aeaeb2;
  --text-3: #8e8e93;
  --sidebar-bg: #1c1c1e;
  --sidebar-border: rgba(255, 255, 255, 0.14);
  --sidebar-text: #aeaeb2;
  --sidebar-text-strong: #f5f5f7;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: rgba(10, 132, 255, 0.22);
  --primary: #0a84ff;
  --primary-soft: rgba(10, 132, 255, 0.15);
  --primary-ring: rgba(10, 132, 255, 0.4);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1.5px 4px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.7);
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--dur-slow) var(--ease), color var(--dur-slow) var(--ease);
}
body.ai-drawer-open { overflow: hidden; }
img, svg { display: inline-block; vertical-align: middle; max-width: 100%; }
a { color: var(--primary); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--primary-hover); }
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; border: none; background: none; }
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin: 0;
  color: var(--text);
}
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
hr.rule {
  border: 0;
  height: 1px;
  margin: var(--space-4) 0 0;
  background: var(--border);
  opacity: 1;
}

/* ---------- App shell ---------- */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: calc(14px + env(safe-area-inset-left));
  z-index: 60;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 1.15rem;
  color: var(--text);
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.sidebar {
  position: fixed;
  inset: 12px auto 12px 12px;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  z-index: 40;
  overflow: hidden;
}
.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: none;
}
.sidebar-brand,
.sidebar-nav,
.sidebar-footer { position: relative; z-index: 1; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
}
.brand-dot {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background:
    linear-gradient(135deg, var(--azure-400), var(--orchid-500) 70%);
  box-shadow: 0 8px 20px rgba(0, 122, 255, 0.35);
  position: relative;
  flex-shrink: 0;
}
.brand-dot::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 5px;
  border: 1.5px solid rgba(255,255,255,0.85);
  transform: rotate(12deg);
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
  color: var(--sidebar-text-strong);
}
.brand-name-inv {
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  display: block;
}
.brand-tag {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: 2px;
}
.brand-tag-inv {
  font-size: var(--text-sm);
  color: var(--text-3);
  margin-top: 4px;
  display: block;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 14px 12px 8px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-weight: 550;
  font-size: var(--text-sm);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sidebar-link:hover {
  background: var(--surface-3);
  color: var(--sidebar-text-strong);
}
.sidebar-link.is-active {
  background: var(--sidebar-active);
  color: var(--primary);
  font-weight: 650;
}
.sidebar-icon-wrap {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  flex-shrink: 0;
}
.sidebar-link.is-active .sidebar-icon-wrap {
  background: var(--primary-soft);
  color: var(--primary);
}
.sidebar-icon-wrap svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
}
.sidebar-logout {
  color: var(--error) !important;
}
.sidebar-logout:hover {
  background: var(--error-soft) !important;
  color: var(--error) !important;
}

.content-area {
  margin-left: calc(var(--sidebar-w) + 24px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.content-spine { display: none; }
.content-scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.main {
  flex: 1;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 28px 28px 100px;
  transition: padding var(--dur) var(--ease);
}
.site-footer {
  text-align: center;
  padding: 20px;
  font-size: var(--text-xs);
  color: var(--text-3);
  letter-spacing: 0.02em;
}

/* ---------- Page headings ---------- */
.page-heading {
  margin-bottom: var(--space-6);
}
.heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.page-heading h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.022em;
}
.page-heading .sub,
.sub {
  margin-top: 6px;
  color: var(--text-3);
  font-size: var(--text-sm);
}
.page-heading-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.current-time {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-xs);
}
.greeting-text { color: var(--primary); font-weight: 600; }
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: var(--space-8) 0 var(--space-4);
}
.section-head h2 {
  font-size: var(--text-lg);
  font-weight: 750;
}
.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: var(--font-mono);
}

/* ---------- Cards ---------- */
.card,
.detail-card,
.customer-summary,
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5) var(--space-6);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.card-header h2,
.card-header h3 {
  font-size: var(--text-md);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-center { max-width: 420px; margin: 0 auto; }
.mb-lg { margin-bottom: var(--space-6); }
.mb-sm { margin-bottom: var(--space-2); }
.mt-sm { margin-top: var(--space-3); }
.mt-md { margin-top: var(--space-4); }
.mt-lg { margin-top: var(--space-6); }
.sub-text, .hint {
  color: var(--text-3);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.hint { margin-top: 6px; }

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.stat-card {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.stat-card::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -20px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: transparent;
  opacity: 0.9;
  pointer-events: none;
}
.stat-card:hover {
  border-color: var(--border-strong);
}
.stat-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}
.stat-icon-wrap svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.stat-icon-wrap-green {
  background: var(--success-soft);
  color: var(--success);
}
.stat-icon-wrap-blue {
  background: var(--accent-soft);
  color: var(--accent);
}
.stat-label {
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-top: 2px;
  color: var(--text);
}

/* Quick actions (home) */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: var(--space-6);
}
.quick-action {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.quick-action:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}
.quick-action-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--azure-50);
  color: var(--primary);
}
.quick-action-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.quick-action-icon.is-mint { background: var(--mint-50); color: var(--mint-600); }
.quick-action-icon.is-orchid { background: var(--orchid-50); color: var(--orchid-600); }
.quick-action-icon.is-amber { background: var(--amber-50); color: var(--amber-600); }
.quick-action-title {
  font-weight: 750;
  font-size: var(--text-sm);
  letter-spacing: -0.01em;
}
.quick-action-desc {
  font-size: var(--text-xs);
  color: var(--text-3);
  line-height: 1.4;
}
.panel-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.panel-block .table-wrap {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.panel-toolbar h2 {
  font-size: var(--text-md);
  font-weight: 750;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--text-sm);
  line-height: 1;
  border: 1px solid transparent;
  transition:
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    opacity var(--dur-fast) var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn:active { opacity: 0.7; }
.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow);
}
.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: var(--text-xs);
  border-radius: 8px;
}
.btn-block { width: 100%; }
.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: var(--primary-fg);
}
.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--primary);
}
.btn-outline:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}
.btn-ghost {
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text);
}
.btn-danger {
  background: var(--error);
  color: white;
}
.btn-danger:hover {
  background: var(--rose-600);
  color: white;
}
.btn-delete { color: var(--error) !important; }
.btn-delete:hover { background: var(--error-soft) !important; color: var(--error) !important; }
.btn-stamp {
  background: var(--success);
  color: white;
}
.btn-stamp:hover {
  background: var(--mint-600);
  color: white;
}

/* ---------- Forms ---------- */
.form, form { width: 100%; }
.form-group { margin-bottom: var(--space-4); }
.form-group label,
.appt-add-form label {
  display: block;
  margin-bottom: 7px;
  font-size: var(--text-sm);
  font-weight: 650;
  color: var(--text-2);
}
.required { color: var(--rose-500); }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: var(--space-5);
  flex-wrap: wrap;
}
.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}
.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: var(--text-sm);
}
.form-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
textarea { min-height: 96px; resize: vertical; }
input:hover, select:hover, textarea:hover {
  border-color: var(--ink-300);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
.input-sm { min-height: 34px; padding: 6px 10px; font-size: var(--text-sm); }
.input-readonly {
  background: var(--surface-2);
  color: var(--text-2);
  cursor: not-allowed;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th {
  text-align: left;
  padding: 12px 14px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}
.table tbody tr {
  transition: background var(--dur-fast) var(--ease);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:active { background: var(--surface-3); }
.cell-name {
  font-weight: 700;
  color: var(--text);
}
.cell-muted { color: var(--text-3); }
.cell-time {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-2);
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: var(--space-5);
  padding: 14px 18px;
  flex-wrap: wrap;
}
.page-info {
  min-width: 30px;
  text-align: center;
  color: var(--text-3);
  font-size: var(--text-sm);
  padding: 0 4px;
}
.page-current {
  min-width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: var(--text-xs);
}

/* ---------- Flash / empty ---------- */
.flash {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  border: 1px solid var(--border);
  overflow: hidden;
  animation: slideDown var(--dur) var(--ease);
}
.flash-success { background: var(--success-soft); border-color: rgba(52, 199, 89, 0.3); color: #1d8a3f; }
.flash-error { background: var(--error-soft); border-color: rgba(255, 59, 48, 0.3); color: var(--error); }
.flash-warning { background: var(--warning-soft); border-color: rgba(255, 149, 0, 0.3); color: #b46b00; }
.flash-info { background: var(--info-soft); border-color: rgba(10, 132, 255, 0.3); color: var(--info); }
.flash-close {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 0.7;
  margin-left: auto;
  transition: background var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
.flash-close:hover { opacity: 1; background: rgba(0,0,0,0.06); }
.flash-progress {
  position: absolute;
  left: 0; bottom: 0;
  height: 3px;
  width: 100%;
  background: currentColor;
  opacity: 0.25;
  transform-origin: left;
  animation: progressShrink 3s linear forwards;
}
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.empty-state p {
  font-size: var(--text-md);
  margin-bottom: 16px;
}
.empty-inline {
  border: 0;
  background: transparent;
  padding: 28px 12px;
}

/* ---------- Search ---------- */
.search-box {
  display: flex;
  gap: 8px;
  align-items: center;
}
.search-box input {
  flex: 1;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.result-meta {
  margin-bottom: 12px;
  color: var(--text-3);
  font-size: var(--text-sm);
}
.ai-query-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  padding: 4px 14px 14px;
}
.ai-query-toggle {
  cursor: pointer;
  font-weight: 650;
  font-size: var(--text-sm);
  color: var(--primary);
  padding: 10px 0;
  display: inline-flex;
  align-items: center;
  list-style: none;
}
.ai-query-toggle::-webkit-details-marker { display: none; }
.ai-query-body {
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}
.ai-query-result {
  margin-top: 12px;
  white-space: pre-wrap;
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--text-2);
}

/* ---------- Customer cards (checkin) ---------- */
.customer-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}
.customer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.customer-card:hover {
  border-color: var(--border-strong);
}
.cc-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.cc-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.cc-name {
  font-weight: 750;
  font-size: var(--text-md);
  letter-spacing: -0.02em;
}
.cc-phone {
  font-size: var(--text-xs);
  color: var(--text-3);
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.cc-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.cc-count-number {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--primary);
  line-height: 1;
}
.cc-count-label {
  font-size: var(--text-xs);
  color: var(--text-3);
  font-weight: 650;
}
.cc-stats {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--text-3);
}
.cc-stats .num { font-weight: 700; color: var(--text-2); font-family: var(--font-mono); }
.cc-stats-divider {
  display: inline-block;
  width: 1px;
  height: 10px;
  background: var(--border-strong);
  margin: 0 6px;
  vertical-align: middle;
}
.cc-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}
.dots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transition: transform var(--dur) var(--ease-spring);
}
.dot-filled {
  background: var(--primary);
}
.dot-empty {
  background: var(--ink-100);
  border: 1px solid var(--ink-200);
}

/* ---------- Detail ---------- */
.detail-section {
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--border);
}
.detail-section:last-child { border-bottom: 0; padding-bottom: 0; }
.detail-section:first-child { padding-top: 0; }
.detail-section h3 {
  font-size: var(--text-sm);
  font-weight: 750;
  margin-bottom: var(--space-4);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.detail-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.detail-label {
  font-size: var(--text-xs);
  font-weight: 650;
  color: var(--text-3);
  letter-spacing: 0.02em;
}
.detail-value {
  font-weight: 650;
  color: var(--text);
  word-break: break-word;
}
.detail-time { font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 500; }
.cs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.cs-stat {
  text-align: center;
  padding: 14px 10px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.cs-stat-value {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--primary);
}
.cs-stat-label {
  margin-top: 4px;
  font-size: var(--text-xs);
  color: var(--text-3);
  font-weight: 650;
}
.cs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.cs-head h2 { font-size: var(--text-xl); }
.detail-card {
  padding: var(--space-6);
}
.detail-card .form-inline {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.detail-card .form-inline input,
.detail-card .form-inline select {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

/* ---------- Timeline ---------- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-left: 8px;
}
.tl-entry {
  display: flex;
  gap: 14px;
  position: relative;
  padding: 10px 0 10px 8px;
}
.tl-entry::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-strong);
}
.tl-entry:first-child::before { top: 18px; }
.tl-entry:last-child::before { bottom: calc(100% - 18px); }
.tl-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid var(--primary-soft);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  margin-top: 3px;
}
.tl-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-xs);
  flex: 1;
}
.tl-date { font-weight: 700; font-size: var(--text-sm); }
.tl-time { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-3); }
.tl-label {
  margin-left: auto;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--mint-600);
  background: var(--mint-50);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}
.tl-time-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px dashed transparent;
  color: inherit;
  font: inherit;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tl-time-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary-200, var(--azure-200));
}
.tl-time-btn:focus-visible {
  outline: none;
  border-color: var(--primary);
  background: var(--primary-soft);
}
.tl-edit-icon {
  color: var(--text-3);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.tl-time-btn:hover .tl-edit-icon,
.tl-time-btn:focus-visible .tl-edit-icon {
  opacity: 1;
}
.tl-edit-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  width: 100%;
}
.tl-edit-input {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
}
.tl-edit-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

/* ---------- Reminders ---------- */
.reminders-card { margin-bottom: var(--space-5); }
.customer-notify-card {
  border-color: rgba(0, 122, 255, 0.25);
  background: var(--info-soft);
}
.customer-notify-hint { margin-bottom: 12px; margin-top: 0; }
.reminder-list { 
  display: flex; 
  flex-direction: column; 
  gap: 8px; 
  margin-top: 12px;
}
.reminder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-wrap: wrap;
  transition: border-color var(--dur-fast) var(--ease);
}
.reminder-item:hover { border-color: var(--border-strong); }
.reminder-missing-wa {
  border-left: 3px solid var(--amber-500);
  background: var(--amber-50);
}
.reminder-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.reminder-msg { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.reminder-meta { font-size: var(--text-xs); color: var(--text-3); font-family: var(--font-mono); }
.reminder-actions { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }

/* ---------- Appointments calendar ---------- */
.appt-calendar { padding: var(--space-5) var(--space-6); }
.appt-cal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}
.appt-cal-title {
  font-size: var(--text-lg);
  font-weight: 750;
  min-width: 120px;
  text-align: center;
  letter-spacing: -0.03em;
}
.appt-cal-arrow {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full) !important;
  font-size: 1.2rem;
}
.appt-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
  text-align: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.04em;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.appt-cal-weekend { color: var(--rose-500); }
.appt-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 4px 0;
}
.appt-cal-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 550;
  transition: background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  position: relative;
}
.appt-cal-cell:hover {
  background: var(--azure-50);
  color: var(--primary);
}
.appt-cal-cell.is-other-month {
  opacity: 0.5;
  color: var(--text-3);
  background: transparent;
}
.appt-cal-cell.is-today .appt-cal-daynum {
  background: var(--primary);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.appt-cal-cell.is-selected {
  background: var(--azure-50);
  box-shadow: inset 0 0 0 2px var(--primary);
}
.appt-cal-cell.has-appt:not(.is-selected) {
  background: var(--orchid-50);
}
.appt-cal-daynum { font-size: var(--text-sm); line-height: 1; }
.appt-cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  position: relative;
}
.appt-cal-dot-count {
  position: absolute;
  top: -6px;
  right: -10px;
  font-size: 9px;
  font-weight: 700;
  color: var(--primary);
}
.appt-slot-table .appt-slot-time {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-3);
  white-space: nowrap;
  width: 60px;
  vertical-align: top;
  padding-top: 12px !important;
}
.appt-slot-time-col { width: 72px; }
.appt-slot-filled td { }
.appt-slot-empty td { opacity: 0.55; }
.appt-slot-items-cell { padding: 8px 10px !important; }
.appt-slot-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin: 4px 0;
  transition: border-color var(--dur-fast) var(--ease);
}
.appt-slot-item:hover { border-color: var(--primary); }
.appt-slot-item-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr auto;
  gap: 12px;
  align-items: center;
  font-size: var(--text-sm);
}
.appt-slot-ooh { opacity: 0.7; }
.appt-ooh-tag, .appt-time-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  vertical-align: middle;
}
.appt-ooh-tag { background: var(--amber-50); color: var(--amber-600); }
.appt-time-tag { background: var(--primary-soft); color: var(--primary); }
.appt-add-form {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.appt-add-form > div { min-width: 0; }
.appt-add-form label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 650;
  color: var(--text-3);
  margin-bottom: 4px;
}
.appt-add-form select,
.appt-add-form input {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}
.appt-slot-row { cursor: pointer; transition: background var(--dur-fast) var(--ease); }
.appt-slot-row:hover .appt-slot-time { color: var(--primary); }
.appt-slot-row.is-selected { background: var(--primary-soft); }
.appt-slot-row.is-selected .appt-slot-time { color: var(--primary); }
.appt-time-picker input[readonly] {
  background: var(--surface-2);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-weight: 700;
  cursor: default;
}
.appt-time-picker input[readonly].has-value { color: var(--primary); }
.appt-customer-search { position: relative; }
.appt-customer-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  z-index: 50;
}
.appt-customer-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: var(--text-sm);
}
.appt-customer-option:hover,
.appt-customer-option.is-highlighted { background: var(--surface-2); }
.appt-customer-option-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-customer-option-phone { color: var(--text-3); font-size: var(--text-xs); white-space: nowrap; }
.appt-customer-empty { padding: 10px; color: var(--text-3); font-size: var(--text-sm); text-align: center; }

/* ---------- AI insight / drafts ---------- */
.insight-output, .draft-output { margin-top: 14px; }
.ai-response,
.insight-text {
  white-space: pre-wrap;
  line-height: 1.65;
  font-size: var(--text-sm);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-top: 12px;
}
.draft-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.draft-select {
  max-width: 200px;
  min-height: 34px !important;
}
.draft-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-top: 10px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.draft-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-ring);
}
.draft-text {
  flex: 1;
  white-space: pre-wrap;
  font-size: var(--text-sm);
  line-height: 1.6;
}
.ai-loading { color: var(--orchid-600); font-size: var(--text-sm); }
.ai-error { color: var(--rose-600); font-size: var(--text-sm); }

/* ---------- Settings ---------- */
.ai-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.ai-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.ai-status.is-on {
  background: var(--mint-50);
  color: var(--mint-600);
}
.ai-status.is-on::before {
  background: var(--success);
}
.ai-status.is-off {
  background: var(--rose-50);
  color: var(--rose-600);
}
.ai-status.is-off::before {
  background: var(--rose-500);
}
.model-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.model-row input { flex: 1; }
.model-select {
  margin-top: 10px;
  width: 100%;
  min-height: 140px !important;
  padding: 8px !important;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.fallback-config { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Stats charts ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}
.chart-card {
  padding: var(--space-5) var(--space-6);
}
.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  gap: 10px;
}
.chart-card-header h3 {
  font-size: var(--text-sm);
  font-weight: 750;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
}
.chart-wrap {
  position: relative;
  max-height: 220px;
}
.chart-wrap-doughnut {
  display: flex;
  justify-content: center;
  padding: 12px 0;
}
.chart-center-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  pointer-events: none;
}
.chart-center-label strong { display: block; }
.chart-center-label span {
  font-size: var(--text-xs);
  color: var(--text-3);
  display: block;
}

/* ---------- Pricing / subscription ---------- */
.pricing-container, .subscription-container {
  max-width: 1000px;
  margin: 0 auto;
}
.pricing-header, .subscription-header {
  text-align: center;
  margin-bottom: var(--space-8);
}
.pricing-header h1, .subscription-header h1 {
  font-size: var(--text-2xl);
  margin-bottom: 8px;
}
.pricing-header p, .subscription-header p { color: var(--text-3); }
.pricing-alert {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-full);
  background: var(--amber-50);
  color: var(--amber-600);
  font-size: var(--text-sm);
  font-weight: 650;
  border: 1px solid rgba(255, 149, 0, 0.25);
}
.pricing-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-4);
  align-items: stretch;
}
.pricing-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  text-align: center;
}
.pricing-card:hover {
  border-color: var(--border-strong);
}
.pricing-card-popular {
  border-color: rgba(0, 122, 255, 0.4);
  background: var(--primary-soft);
  box-shadow: var(--shadow-md);
}
.pricing-card-badge {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 750;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.pricing-card-header { text-align: center; margin-bottom: 18px; }
.pricing-tier-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-2);
}
.pricing-tier-icon svg { width: 24px; height: 24px; }
.pricing-tier-icon-popular {
  background: var(--primary-soft);
  color: var(--primary);
}
.pricing-card h2 {
  font-size: var(--text-lg);
  margin-bottom: 8px;
}
.pricing-price {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}
.price-amount {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
}
.price-period { color: var(--text-3); font-size: var(--text-sm); }
.pricing-annual {
  margin-top: 6px;
  font-size: var(--text-xs);
  color: var(--text-3);
}
.pricing-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.pricing-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0 20px;
  flex: 1;
}
.pricing-features li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--text-2);
  justify-content: center;
}
.feature-included { color: var(--text); }
.feature-excluded { color: var(--text-3); opacity: 0.7; }
.feature-check, .feature-cross {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.feature-check { color: var(--mint-600); }
.feature-cross { color: var(--ink-300); }

.subscription-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-card);
}
.subscription-info {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.level-badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
}
.level-free { background: var(--ink-100); color: var(--text-3); }
.level-standard { background: var(--azure-100); color: var(--azure-700); }
.level-pro { background: var(--orchid-100); color: var(--orchid-600); }
.level-max { background: var(--primary-soft); color: var(--primary); }
.subscription-details p {
  margin: 6px 0;
  font-size: var(--text-sm);
  color: var(--text-2);
}
.status-active { color: var(--mint-600); font-weight: 700; }
.subscription-features h3 {
  font-size: var(--text-sm);
  margin-bottom: 12px;
}
.subscription-features ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.subscription-features li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.subscription-actions {
  margin-top: 24px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.sub-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin: var(--space-4) 0;
}
.sub-detail-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}
.sub-detail-item .stat-value { font-size: 1.5rem; }
.sub-detail-item .stat-label {
  font-size: var(--text-xs);
  color: var(--text-3);
  font-weight: 650;
  margin-top: 4px;
}

/* ---------- Login ---------- */
body.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}
body.login-page .content-area {
  margin: 0;
  width: 100%;
  min-height: auto;
}
body.login-page .content-scroll { min-height: auto; }
body.login-page .main {
  width: min(440px, 100%);
  padding: 0;
  margin: 0 auto;
}
body.login-page .site-footer { display: none; }
body.login-page .sidebar-toggle { display: none; }
.login-brand {
  text-align: center;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.login-dot {
  width: 48px !important;
  height: 48px !important;
  border-radius: 16px !important;
}
.login-brand-name {
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  display: block;
}
.login-subtitle {
  color: var(--text-3);
  font-size: var(--text-sm);
  font-weight: 550;
}
.login-card {
  padding: 28px 28px 24px !important;
  border-radius: var(--radius-xl) !important;
  box-shadow: var(--shadow-lg) !important;
  border: 1px solid var(--border) !important;
  background: var(--surface) !important;
}
.login-card-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--border);
}
.login-card .card-header {
  justify-content: center;
  margin-bottom: 18px;
}
.login-card .card-header h2 {
  font-size: var(--text-xl);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.48);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: modalFadeIn 0.2s var(--ease);
}
.modal-overlay.is-open { display: flex; }
.modal {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  padding: 22px;
  animation: popIn var(--dur) var(--ease-spring);
}
.modal-header-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.modal-text {
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--text);
  font-weight: 550;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- AI drawer ---------- */
.ai-drawer-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 45;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: 14px 0 0 14px;
  background: var(--primary);
  color: white;
  box-shadow: -4px 8px 24px rgba(0, 122, 255, 0.3);
  transition: right var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.ai-drawer-tab:hover { padding-right: 12px; }
.ai-drawer-tab.is-open { right: min(400px, 100vw); }
.ai-drawer-tab-label {
  writing-mode: vertical-rl;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}
.ai-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
  z-index: 46;
}
.ai-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}
.ai-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(400px, 100vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease);
  z-index: 47;
  display: flex;
  flex-direction: column;
}
.ai-drawer.is-open { transform: translateX(0); }
.ai-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.ai-drawer-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-drawer-title {
  font-size: var(--text-md);
  font-weight: 800;
}
.ai-drawer-header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.perm-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.perm-shield { color: var(--text-3); flex-shrink: 0; }
.perm-select {
  flex: 1;
  min-height: 34px !important;
  padding: 6px 10px !important;
  font-size: var(--text-xs) !important;
  font-weight: 650;
}
.perm-badge {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
}
.perm-chat { background: var(--azure-100); color: var(--azure-700); }
.perm-edit { background: var(--amber-100); color: var(--amber-600); }
.perm-root { background: var(--rose-100); color: var(--rose-600); }
.ai-skills-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.skill-tag {
  font-size: 0.68rem;
  font-weight: 650;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.skill-tag-root {
  background: var(--error-soft);
  color: var(--error);
  border-color: rgba(255, 59, 48, 0.25);
}
.ai-drawer-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.assistant-single { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface-2);
}
.chat-msg {
  display: flex;
  max-width: 92%;
}
.chat-msg.is-user { align-self: flex-end; }
.chat-msg.is-assistant, .chat-msg.is-system { align-self: flex-start; }
.chat-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: var(--text-sm);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-xs);
}
.chat-msg.is-user .chat-bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 5px;
}
.chat-msg.is-assistant .chat-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 5px;
}
.chat-msg.is-pending .chat-bubble {
  opacity: 0.75;
  font-style: italic;
}
.chat-composer {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: flex-end;
}
.chat-composer textarea {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  resize: none;
  border-radius: 12px;
  padding: 10px 12px;
}
.chat-composer .btn { min-width: 42px; height: 42px; padding: 0; border-radius: 12px; }
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 4px;
}
.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orchid-400);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

/* ---------- Task tray ---------- */
.task-tray {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(20px);
  width: min(560px, calc(100vw - 32px));
  z-index: 55;
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.task-tray.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: rgba(28, 28, 30, 0.92);
  color: white;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  font-size: var(--text-sm);
  animation: slideUp var(--dur) var(--ease);
}
.task-text { flex: 1; min-width: 0; line-height: 1.4; }
.task-actions { display: flex; gap: 6px; flex-shrink: 0; }
.task-item .btn {
  border-color: rgba(255,255,255,0.18);
  color: white;
  background: rgba(255,255,255,0.08);
}
.task-item .btn:hover { background: rgba(255,255,255,0.16); color: white; }
.task-item .btn-danger {
  background: var(--rose-500);
  border-color: transparent;
}
.task-item.task-done { background: #34c759; }
.task-item.task-error { background: #ff3b30; }
.task-item.task-confirm { background: #007aff; }
.task-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* ---------- CMD debug ---------- */
.cmd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.cmd-window {
  width: min(720px, 100%);
  height: min(480px, 80vh);
  background: #1c1c1e;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-mono);
}
.cmd-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #2c2c2e;
  color: #0a84ff;
  font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.cmd-close-btn {
  color: #8e8e93;
  font-size: 18px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
}
.cmd-close-btn:hover { background: rgba(255,255,255,0.1); color: white; }
.cmd-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  color: #e5e5ea;
  font-size: 12.5px;
  line-height: 1.55;
}
.cmd-welcome { color: #0a84ff; font-weight: 700; }
.cmd-success { color: #30d158; }
.cmd-error { color: #ff453a; }
.cmd-info { color: #64d2ff; }
.cmd-title { color: #bf5af2; font-weight: 700; }
.cmd-prompt { color: #ffd60a; }
.cmd-input-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: #000000;
  color: #0a84ff;
  font-size: 12.5px;
}
.cmd-input-line input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  color: #f5f5f7;
  min-height: auto;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  box-shadow: none !important;
}

/* ---------- Animations ---------- */
.animate-in {
  animation: fadeUp 0.4s var(--ease) both;
}
.animate-in-subtle {
  animation: fadeIn 0.4s var(--ease) both;
}
.animate-delay-1 { animation-delay: 0.08s; }
.animate-delay-2 { animation-delay: 0.16s; }
.animate-delay-3 { animation-delay: 0.24s; }
.animate-delay-4 { animation-delay: 0.32s; }
.animate-delay-5 { animation-delay: 0.4s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes progressShrink {
  from { width: 100%; }
  to { width: 0%; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-4px); opacity: 1; }
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Custom scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }

/* =========================================================
   Mobile-First Responsive 策略
   默认 = 手机尺寸 (≤ 480px)
   Breakpoints: sm=640px, md=768px, lg=1024px, xl=1280px
   ========================================================= */

/* ---- Mobile (≤ 480px) ---- */
@media (max-width: 480px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 85vw;
    max-width: 320px;
    border-radius: 0;
    border: none;
    transform: translateX(-105%);
    transition: transform var(--dur-slow) var(--ease);
    z-index: 50;
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .content-area { margin-left: 0; }
  .main {
    padding: 72px 14px 100px;
    width: 100%;
  }

  /* Stats → single column */
  .stats { grid-template-columns: 1fr; gap: 10px; }
  .stat-card { padding: 14px 16px; gap: 12px; }
  .stat-value { font-size: 1.35rem; }
  .stat-icon-wrap { width: 40px; height: 40px; border-radius: 12px; }
  .stat-icon-wrap svg { width: 18px; height: 18px; }

  /* Quick actions → 2 columns */
  .quick-actions { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .quick-action { padding: 12px; }
  .quick-action-title { font-size: var(--text-xs); }
  .quick-action-desc { display: none; }

  /* Tables → horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 480px; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; justify-content: center; }

  /* Detail grid */
  .detail-grid { grid-template-columns: 1fr; }
  .cs-grid { grid-template-columns: 1fr; }
  .sub-detail-grid { grid-template-columns: 1fr; }
  .appt-add-form { grid-template-columns: 1fr; }
  .appt-slot-item-grid { grid-template-columns: 1fr; gap: 4px; }

  /* Headings */
  .heading-row { flex-direction: column; gap: 10px; }
  .page-heading h1 { font-size: var(--text-xl); }
  .page-heading-actions { width: 100%; flex-wrap: wrap; }

  /* Search */
  .search-box { flex-direction: column; align-items: stretch; }
  .search-filters { grid-template-columns: 1fr; }

  /* Login */
  .login-card { padding: 22px 18px !important; border-radius: var(--radius-lg) !important; }
  body.login-page { padding: 16px; }

  /* AI drawer → full screen on mobile */
  .ai-drawer { width: 100vw; }
  .ai-drawer-tab.is-open { right: 0; opacity: 0; pointer-events: none; }
  .ai-drawer-backdrop.is-open { opacity: 0; pointer-events: auto; }

  /* Subscription */
  .subscription-features ul { grid-template-columns: 1fr; }
  .pricing-cards { grid-template-columns: 1fr; max-width: 100%; }

  /* Safe area for modern phones */
  .main { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); padding-bottom: max(100px, env(safe-area-inset-bottom)); }
  body.login-page { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

  /* Buttons - touch-friendly */
  .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  input, select, textarea { font-size: 16px !important; }
}

/* ---- Tablet (481px - 767px) ---- */
@media (min-width: 481px) and (max-width: 767px) {
  .sidebar {
    inset: 0 auto 0 0;
    width: 75vw;
    max-width: 280px;
    border-radius: 0;
    border: none;
    transform: translateX(-105%);
    transition: transform var(--dur-slow) var(--ease);
    z-index: 50;
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .content-area { margin-left: 0; }
  .main { padding: 72px 20px 110px; width: 100%; }
  .stats { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .cs-grid { grid-template-columns: 1fr; }
  .appt-slot-item-grid { grid-template-columns: 1fr; gap: 4px; }
  .appt-add-form { grid-template-columns: 1fr; }
  .ai-drawer { width: 100vw; }
  .ai-drawer-tab.is-open { right: 0; opacity: 0; pointer-events: none; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .sub-detail-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- Desktop small (768px - 1023px) ---- */
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar { width: 210px; }
  .content-area { margin-left: calc(210px + 20px); }
  .main { padding: 24px 24px 80px; width: min(960px, 100%); }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .quick-actions { grid-template-columns: repeat(4, 1fr); }
  .sub-detail-grid { grid-template-columns: repeat(2, 1fr); }
  .pricing-cards { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Desktop standard (1024px - 1279px) ---- */
@media (min-width: 1024px) and (max-width: 1279px) {
  .main { padding: 28px 32px 100px; width: min(1040px, 100%); }
}

/* ---- Desktop large (1280px+) ---- */
@media (min-width: 1280px) {
  .main { padding: 32px 40px 100px; width: min(1200px, 100%); }
  .stats { gap: var(--space-5); }
  .quick-actions { gap: var(--space-4); }
}

/* ---------- Utilities ---------- */
.d-none { display: none !important; }
.d-inline { display: inline !important; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-center { text-align: center; }
.mb-sm { margin-bottom: var(--space-2); }
.mb-md { margin-bottom: var(--space-4); }
.mb-lg { margin-bottom: var(--space-6); }
.mt-sm { margin-top: var(--space-3); }
.mt-md { margin-top: var(--space-4); }
.mt-lg { margin-top: var(--space-6); }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.max-w-sm { max-width: 640px; }
.gap-sm { gap: var(--space-2); }
.gap-md { gap: var(--space-4); }

/* ==========================================================
   Micro-interactions
   ========================================================== */
.btn,
.sidebar-toggle,
.sidebar-link,
.sidebar-icon-wrap,
.quick-action,
.stat-card,
.customer-card,
.draft-card,
.pricing-card,
.skill-tag,
.appt-cal-cell,
.appt-slot-row,
.pagination .page-info,
.tl-time-btn,
.cmd-close-btn,
.ai-drawer-tab {
  -webkit-tap-highlight-color: transparent;
}

.btn {
  position: relative;
  overflow: hidden;
  transition:
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    opacity var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}
.btn.is-loading {
  pointer-events: none;
  opacity: 0.8;
}
.btn.is-loading { color: transparent; }
.btn.is-loading > * { opacity: 0; }
.btn.is-loading::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(28, 28, 30, 0.55);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.sidebar-link {
  position: relative;
  transition:
    background var(--dur) var(--ease),
    color var(--dur) var(--ease);
}
.sidebar-link::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 3px;
  background: var(--primary);
  opacity: 0;
  transform: scaleY(0.35);
  transition: transform var(--dur) var(--ease-spring), opacity var(--dur) var(--ease);
}
.sidebar-link.is-active::before { opacity: 1; transform: scaleY(1); }

.table tbody tr td {
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.table tbody tr:hover .cell-name { color: var(--primary); }

.pagination .page-info {
  border-radius: 7px;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.pagination a.page-info:not(.page-current):hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.form-checkbox input[type="checkbox"] { cursor: pointer; }

.flash {
  animation: flashIn 0.32s var(--ease-spring) both;
}
.flash.is-leaving {
  animation: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}
.flash-close {
  transition: background var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}

.modal-overlay.is-closing { animation: modalFadeOut 0.16s var(--ease) both; }
.modal-overlay.is-closing .modal { animation: popOut 0.16s var(--ease) both; }

.ai-drawer-tab,
.skill-tag,
.appt-slot-row,
.tl-time-btn,
.cmd-close-btn {
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

@keyframes flashIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modalFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes popOut {
  from { opacity: 1; transform: scale(1) translateY(0); }
  to { opacity: 0; transform: scale(0.96) translateY(6px); }
}

@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;
  }
}
