/* ══════════════════════════════════════════════════════════════════
   VIUCraft App Shell — authenticated dashboard chrome
   Dark-first. Blue → cyan accent. Light mode via [data-theme="light"].
   Icon sidebar (56px) ↔ expanded (240px), mobile bottom tab bar,
   command palette, toasts. Inter UI + JetBrains Mono for code.
   ══════════════════════════════════════════════════════════════════ */

:root {
  --app-bg: #07070e;
  --surface: #0e0e1a;
  --surface-2: #14141f;
  --surface-3: #1b1b2b;
  --elevated: #191926;
  --edge: rgba(255, 255, 255, 0.08);
  --edge-strong: rgba(255, 255, 255, 0.14);
  --text: #f1f5f9;
  --text-2: #c3ccda;
  --text-muted: #8b95a7;
  --text-faint: #737d94;

  --accent: #0ea5e9;
  --accent-strong: #38bdf8;
  --accent-2: #06b6d4;
  --grad: linear-gradient(135deg, #2563eb 0%, #0ea5e9 55%, #06b6d4 100%);
  --grad-text: linear-gradient(104deg, #bae6fd 0%, #60a5fa 42%, #22d3ee 100%);
  --accent-soft: rgba(14, 165, 233, 0.13);
  --accent-ring: rgba(14, 165, 233, 0.32);

  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --ok-soft: rgba(16, 185, 129, 0.14);
  --warn-soft: rgba(245, 158, 11, 0.14);
  --danger-soft: rgba(239, 68, 68, 0.14);

  --mono: "JetBrains Mono", "SF Mono", ui-monospace, "Fira Code", monospace;
  --ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --r-sm: 7px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 6px 20px -6px rgba(0,0,0,0.55);
  --shadow-lg: 0 24px 56px -20px rgba(0,0,0,0.7);
  --shadow-pop: 0 16px 48px -12px rgba(0,0,0,0.75);
  --t-fast: 130ms cubic-bezier(0.4,0,0.2,1);
  --t-base: 220ms cubic-bezier(0.16,1,0.3,1);

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 60px;
}

[data-theme="light"] {
  --app-bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --surface-3: #eef1f6;
  --elevated: #ffffff;
  --edge: rgba(15, 23, 42, 0.09);
  --edge-strong: rgba(15, 23, 42, 0.16);
  --text: #0f172a;
  --text-2: #334155;
  --text-muted: #64748b;
  --text-faint: #5e6b7f;
  --accent: #2563eb;
  --accent-2: #0891b2;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.09);
  --accent-ring: rgba(37, 99, 235, 0.26);
  --grad: linear-gradient(135deg, #2563eb 0%, #3b82f6 55%, #0891b2 100%);
  --grad-text: linear-gradient(104deg, #1e40af 0%, #2563eb 42%, #0891b2 100%);
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.07);
  --shadow-md: 0 6px 20px -8px rgba(15,23,42,0.18);
  --shadow-lg: 0 24px 56px -20px rgba(15,23,42,0.22);
  --shadow-pop: 0 16px 48px -12px rgba(15,23,42,0.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--ui);
  background: var(--app-bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--accent-ring); color: #fff; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
:focus:not(:focus-visible) { outline: none; }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--edge-strong); border-radius: var(--r-full); border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--t-base);
}
.app.is-expanded { grid-template-columns: var(--sidebar-w) 1fr; }


/* ══════════════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════════════ */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--edge);
  overflow: hidden; z-index: 40;
}

/* ── Header: workspace-first ── */
.sidebar-head { display: flex; align-items: center; gap: 0.4rem; height: 56px; padding: 0 0.5rem; flex-shrink: 0; }
.app:not(.is-expanded) .sidebar-head { justify-content: center; padding: 0; }

.ws-trigger {
  display: flex; align-items: center; gap: 0.55rem; flex: 1; min-width: 0;
  height: 44px; padding: 0 0.35rem; border: none; background: transparent; cursor: pointer;
  border-radius: var(--r-md); color: var(--text); transition: background var(--t-fast);
}
.ws-trigger:hover { background: var(--surface-3); }
.app:not(.is-expanded) .ws-trigger { flex: none; justify-content: center; padding: 0; gap: 0; }
.ws-avatar {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 0.7rem; letter-spacing: 0.02em;
  background: var(--grad); box-shadow: 0 3px 10px -3px rgba(14,165,233,0.6), inset 0 1px 0 rgba(255,255,255,0.18);
}
.ws-info { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; flex: 1; line-height: 1.18; opacity: 0; transition: opacity var(--t-fast); }
.app.is-expanded .ws-info { opacity: 1; }
.app:not(.is-expanded) .ws-info, .app:not(.is-expanded) .ws-caret { display: none; }
.ws-name { font-size: 0.86rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ws-plan { font-size: 0.67rem; color: var(--text-muted); font-weight: 500; letter-spacing: 0.01em; }
.ws-caret { margin-left: auto; font-size: 0.62rem; color: var(--text-faint); flex-shrink: 0; opacity: 0; transition: opacity var(--t-fast); }
.app.is-expanded .ws-caret { opacity: 1; }

.sidebar-logo { width: 30px; height: 30px; border-radius: 9px; background: var(--grad); display: grid; place-items: center; color: #fff; font-size: 0.82rem; flex-shrink: 0; box-shadow: 0 3px 10px -3px rgba(14,165,233,0.6); }
.sidebar-wordmark { font-weight: 700; font-size: 1rem; letter-spacing: -0.02em; white-space: nowrap; flex: 1; margin-left: 0.55rem; opacity: 0; transition: opacity var(--t-fast); }
.app.is-expanded .sidebar-wordmark { opacity: 1; }
.app:not(.is-expanded) .sidebar-wordmark { display: none; }

.sidebar-pin {
  width: 30px; height: 30px; border: none; background: transparent; color: var(--text-faint);
  cursor: pointer; border-radius: var(--r-sm); display: grid; place-items: center; flex-shrink: 0; font-size: 0.78rem;
  opacity: 0; transition: opacity var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.app.is-expanded .sidebar-head:hover .sidebar-pin { opacity: 0.85; }
.sidebar-pin:hover { background: var(--surface-3); color: var(--text); opacity: 1; }
.sidebar-pin.pinned { opacity: 1; color: var(--accent-strong); }
.app:not(.is-expanded) .sidebar-pin { display: none; }

/* ── Nav: no group labels for customers, subtle dividers ── */
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0.5rem 0.5rem 1rem; }
.sidebar-nav::-webkit-scrollbar { width: 0; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-sep { height: 1px; background: var(--edge); margin: 0.5rem 0.7rem; }
.app:not(.is-expanded) .nav-sep { margin: 0.45rem 0.9rem; }

.nav-group-label { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase; color: var(--text-faint); padding: 0.6rem 0.75rem 0.3rem; white-space: nowrap; overflow: hidden; opacity: 0; transition: opacity var(--t-fast); }
.app.is-expanded .nav-group-label { opacity: 1; }
.app:not(.is-expanded) .nav-group-label { height: 0.6rem; }

.sidebar .nav-item {
  position: relative; display: flex; align-items: center; gap: 0.8rem;
  height: 38px; padding: 0 0.7rem; border-radius: var(--r-md);
  color: var(--text-muted); font-size: 0.875rem; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.app:not(.is-expanded) .sidebar .nav-item { justify-content: center; padding: 0; gap: 0; }
.sidebar .nav-item > i:first-child { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; color: var(--text-faint); transition: color var(--t-fast); }
.sidebar .nav-item .nav-label { opacity: 0; transition: opacity var(--t-fast); }
.app.is-expanded .nav-item .nav-label { opacity: 1; }
.app:not(.is-expanded) .nav-item .nav-label { display: none; }
.sidebar .nav-item:hover { background: var(--surface-3); color: var(--text); }
.sidebar .nav-item:hover > i:first-child { color: var(--text-2); }
.sidebar .nav-item.active { color: var(--text); background: var(--accent-soft); }
.sidebar .nav-item.active > i:first-child { color: var(--accent-strong); }
.sidebar .nav-item.active::before {
  content: ""; position: absolute; left: -0.5rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: var(--r-full); background: var(--grad);
}

.sidebar .nav-item .nav-badge {
  margin-left: auto; font-size: 0.58rem; font-weight: 700; min-width: 18px; text-align: center;
  padding: 0.08rem 0.35rem; border-radius: var(--r-full); background: var(--danger); color: #fff; opacity: 0; transition: opacity var(--t-fast);
}
.app.is-expanded .nav-item .nav-badge { opacity: 1; }
.sidebar .nav-item .nav-dot-badge { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.app.is-expanded .nav-item .nav-dot-badge { display: none; }

.sidebar .nav-item[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: var(--elevated); color: var(--text); border: 1px solid var(--edge);
  padding: 0.3rem 0.6rem; border-radius: var(--r-sm); font-size: 0.78rem; font-weight: 500;
  white-space: nowrap; pointer-events: none; opacity: 0; box-shadow: var(--shadow-md);
  transition: opacity var(--t-fast); z-index: 60;
}
.app:not(.is-expanded) .sidebar-nav .nav-item:hover::after,
.app:not(.is-expanded) .sidebar-foot .nav-item:hover::after { opacity: 1; }

/* ── Onboarding: compact progress chip ── */
.sidebar-onboarding { margin: 0 0.5rem 0.5rem; flex-shrink: 0; }
.onboarding-mini {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--edge); cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast); text-decoration: none; color: inherit;
}
.onboarding-mini:hover { background: var(--surface-3); border-color: var(--edge-strong); }
.app:not(.is-expanded) .onboarding-mini { justify-content: center; padding: 0.45rem 0; }
.onboarding-ring {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--accent-strong) calc(var(--p) * 1%), var(--edge-strong) 0);
}
.onboarding-ring::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--surface-2); }
.onboarding-mini:hover .onboarding-ring::after { background: var(--surface-3); }
.onboarding-ring-num { position: relative; font-size: 0.64rem; font-weight: 700; color: var(--accent-strong); z-index: 1; }
.onboarding-mini-text { display: flex; flex-direction: column; min-width: 0; flex: 1; opacity: 0; transition: opacity var(--t-fast); }
.app.is-expanded .onboarding-mini-text { opacity: 1; }
.app:not(.is-expanded) .onboarding-mini-text, .app:not(.is-expanded) .onboarding-dismiss { display: none; }
.om-title { font-size: 0.78rem; font-weight: 600; color: var(--text); line-height: 1.2; }
.om-sub { font-size: 0.67rem; color: var(--text-muted); }
.onboarding-dismiss {
  width: 22px; height: 22px; border: none; background: transparent; color: var(--text-faint); cursor: pointer;
  border-radius: var(--r-sm); display: grid; place-items: center; font-size: 0.66rem; flex-shrink: 0;
  opacity: 0; transition: opacity var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.onboarding-mini:hover .onboarding-dismiss { opacity: 1; }
.onboarding-dismiss:hover { background: var(--surface-3); color: var(--text); }

/* ── Footer: status (incident-only) + minimal user chip ── */
.sidebar-foot { flex-shrink: 0; padding: 0.5rem; border-top: 1px solid var(--edge); }
.sidebar-status {
  display: none; align-items: center; gap: 0.55rem; height: 30px; padding: 0 0.6rem;
  margin-bottom: 0.3rem; font-size: 0.76rem; font-weight: 500; white-space: nowrap;
  border-radius: var(--r-sm);
}
.sidebar-status.has-incident { display: flex; }
.sidebar-status.is-warn { color: #fbbf24; background: var(--warn-soft); }
.sidebar-status.is-down { color: #f87171; background: var(--danger-soft); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent); }
.sidebar-status .status-label { opacity: 0; transition: opacity var(--t-fast); }
.app.is-expanded .sidebar-status .status-label { opacity: 1; }
.app:not(.is-expanded) .sidebar-status { justify-content: center; padding: 0; }
.app:not(.is-expanded) .sidebar-status .status-label { display: none; }

.user-chip {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; height: 44px; padding: 0 0.5rem;
  border: none; background: transparent; cursor: pointer; border-radius: var(--r-md); color: var(--text);
  transition: background var(--t-fast);
}
.user-chip:hover { background: var(--surface-3); }
.app:not(.is-expanded) .user-chip { justify-content: center; padding: 0; }
.user-avatar {
  position: relative; width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1, #06b6d4); display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 0.7rem;
}
.user-chip .user-name { font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; text-align: left; opacity: 0; transition: opacity var(--t-fast); }
.app.is-expanded .user-chip .user-name { opacity: 1; }
.app:not(.is-expanded) .user-chip .user-name { display: none; }
.user-chip .user-caret { margin-left: auto; color: var(--text-faint); font-size: 0.62rem; flex-shrink: 0; opacity: 0; transition: opacity var(--t-fast); }
.app.is-expanded .user-chip .user-caret { opacity: 1; }
.app:not(.is-expanded) .user-chip .user-caret { display: none; }

/* ── Workspace switcher dropdown ── */
.workspace-switcher {
  position: fixed; top: 54px; left: 8px; width: 264px;
  background: var(--elevated); border: 1px solid var(--edge); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); z-index: 70;
  opacity: 0; transform: translateY(-4px) scale(0.98); pointer-events: none;
  transition: opacity var(--t-fast), transform var(--t-fast);
  max-height: 420px; display: flex; flex-direction: column;
}
.workspace-switcher.open { opacity: 1; transform: none; pointer-events: auto; }
.ws-switch-search { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--edge); }
.ws-switch-search > i { color: var(--text-faint); font-size: 0.8rem; }
.ws-switch-input { flex: 1; border: none; background: transparent; color: var(--text); font-size: 0.84rem; outline: none; padding: 0; }
.ws-switch-input::placeholder { color: var(--text-faint); }
.ws-switch-esc { font-size: 0.6rem; padding: 0.15rem 0.35rem; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-faint); border: 1px solid var(--edge); font-family: var(--mono); line-height: 1; }
.ws-switch-list { padding: 0.2rem 0.35rem 0.35rem; overflow-y: auto; flex: 1; min-height: 0; }
.ws-switch-foot { padding: 0.35rem; border-top: 1px solid var(--edge); }
.ws-switch-item {
  display: flex; align-items: center; gap: 0.55rem; width: 100%;
  padding: 0.45rem 0.5rem; border: none; background: transparent; cursor: pointer;
  border-radius: var(--r-sm); color: var(--text-2); font-size: 0.84rem; text-align: left;
  transition: background var(--t-fast);
}
.ws-switch-item:hover { background: var(--surface-3); }
.ws-switch-item.active { background: var(--surface-2); }
.ws-switch-item:disabled { opacity: 1; }
.ws-switch-item .ws-avatar { width: 26px; height: 26px; font-size: 0.6rem; box-shadow: none; }
.ws-switch-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; font-weight: 500; }
.ws-switch-check { font-size: 0.72rem; color: var(--accent-strong); flex-shrink: 0; }
.ws-switch-plan { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.02em; padding: 0.1rem 0.4rem; border-radius: var(--r-full); border: 1px solid var(--edge); color: var(--text-muted); background: var(--surface-2); }
.ws-switch-create { color: var(--text-muted); }
.ws-switch-create:hover { color: var(--text); }
.ws-switch-create > i { width: 26px; text-align: center; font-size: 0.78rem; }
.ws-switch-create .ws-switch-name { font-weight: 600; color: var(--text); }
.ws-switch-create .ws-switch-sub { display: block; font-size: 0.68rem; color: var(--text-muted); font-weight: 400; }

/* ── User menu ── */
.user-menu {
  position: fixed; bottom: 54px; left: 8px; width: 236px;
  background: var(--elevated); border: 1px solid var(--edge); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); padding: 0.4rem; z-index: 70;
  opacity: 0; transform: translateY(8px) scale(0.98); pointer-events: none;
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.user-menu.open { opacity: 1; transform: none; pointer-events: auto; }
.user-menu-head { padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--edge); margin-bottom: 0.3rem; }
.user-menu-head .um-name { font-size: 0.86rem; font-weight: 600; }
.user-menu-head .um-email { font-size: 0.74rem; color: var(--text-muted); }
.user-menu-item { display: flex; align-items: center; gap: 0.7rem; width: 100%; padding: 0.55rem 0.7rem; border: none; background: transparent; cursor: pointer; border-radius: var(--r-sm); color: var(--text-2); font-size: 0.85rem; text-align: left; transition: background var(--t-fast), color var(--t-fast); }
.user-menu-item i { width: 16px; text-align: center; color: var(--text-muted); }
.user-menu-item:hover { background: var(--surface-3); color: var(--text); }
.user-menu-sep { height: 1px; background: var(--edge); margin: 0.3rem 0; }

.theme-seg { margin-left: auto; display: inline-flex; background: var(--surface-2); border: 1px solid var(--edge); border-radius: var(--r-full); padding: 2px; }
.theme-seg button { width: 26px; height: 22px; border: none; background: transparent; color: var(--text-muted); border-radius: var(--r-full); cursor: pointer; font-size: 0.72rem; }
.theme-seg button.active { background: var(--grad); color: #fff; }


.main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 1rem;
  height: 60px; padding: 0 1.5rem;
  background: color-mix(in srgb, var(--app-bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--edge);
}
.topbar-cmd {
  display: inline-flex; align-items: center; gap: 0.6rem;
  height: 36px; padding: 0 0.7rem 0 0.85rem; min-width: 240px;
  background: var(--surface-2); border: 1px solid var(--edge); border-radius: var(--r-md);
  color: var(--text-muted); font-size: 0.85rem; cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.topbar-cmd:hover { border-color: var(--edge-strong); }
.topbar-cmd .kbd { margin-left: auto; display: inline-flex; gap: 2px; }
.kbd kbd, .topbar-cmd kbd {
  font-family: var(--mono); font-size: 0.66rem; color: var(--text-2);
  background: var(--surface-3); border: 1px solid var(--edge); border-radius: 4px;
  padding: 0.05rem 0.32rem; line-height: 1.4;
}
.topbar-spacer { flex: 1; }
.topbar-btn {
  position: relative;
  width: 40px; height: 40px; border-radius: var(--r-md);
  border: 1px solid var(--edge); background: var(--surface-2); color: var(--text-2);
  cursor: pointer; display: grid; place-items: center; font-size: 0.95rem;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.topbar-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--edge-strong); }
.topbar-btn .bell-dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--app-bg); }

.content { flex: 1; padding: 1.6rem 1.9rem 4rem; max-width: 1320px; width: 100%; margin: 0 auto; }
.content.content-wide { max-width: 1600px; }
.view { display: none; animation: viewIn var(--t-base); }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.breadcrumb { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.6rem; }
.breadcrumb a:hover { color: var(--accent-strong); }
.breadcrumb .sep { opacity: 0.45; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.6rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.025em; margin: 0; }
.page-head .page-sub { color: var(--text-muted); font-size: 0.92rem; margin: 0.25rem 0 0; }
.page-head .page-actions { margin-left: auto; display: flex; gap: 0.6rem; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  height: 40px; padding: 0 1rem; border-radius: var(--r-md);
  font-size: 0.875rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.btn:active { transform: translateY(1px); }
.btn-primary { color: #fff; background: var(--grad); box-shadow: 0 6px 16px -6px rgba(14,165,233,0.6), inset 0 1px 0 rgba(255,255,255,0.2); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 24px -6px rgba(14,165,233,0.75), inset 0 1px 0 rgba(255,255,255,0.2); transform: translateY(-1px); }
.btn-primary:disabled, .btn-primary[disabled] { opacity: 0.4; cursor: not-allowed; background: var(--surface-3); box-shadow: none; transform: none; pointer-events: none; }
.btn-ghost { background: var(--surface-2); border-color: var(--edge); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--edge-strong); }
.btn-subtle { background: transparent; color: var(--text-muted); }
.btn-subtle:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: #fca5a5; border-color: rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.22); color: #fff; }
.btn-sm { height: 34px; padding: 0 0.75rem; font-size: 0.8rem; }
.btn-icon { width: 40px; padding: 0; }
.btn-block { width: 100%; }

.card {
  background: var(--surface); border: 1px solid var(--edge); border-radius: var(--r-lg);
  transition: border-color var(--t-base), box-shadow var(--t-base), transform var(--t-base);
}
.card-pad { padding: 1.25rem; }
.card-hover:hover { border-color: var(--accent-ring); box-shadow: var(--shadow-md); }
.card-guest { border-color: rgba(245,158,11,0.3); background: linear-gradient(135deg, var(--surface) 0%, rgba(245,158,11,0.04) 100%); }
.card-guest .card-head { border-bottom-color: rgba(245,158,11,0.2); }
.card-guest .card-title-i { color: #f59e0b; }
.card-head { display: flex; align-items: center; gap: 0.7rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--edge); }
.card-head h3 { margin: 0; font-size: 0.98rem; font-weight: 700; }
.card-head .card-head-action { margin-left: auto; }
.card-title-i { color: var(--accent-strong); }

.badge { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.72rem; font-weight: 700; padding: 0.2rem 0.6rem; border-radius: var(--r-full); border: 1px solid var(--edge); color: var(--text-2); background: var(--surface-2); letter-spacing: 0.02em; }
.badge-accent { color: var(--accent-strong); background: var(--accent-soft); border-color: var(--accent-ring); }
.badge-ok { color: #34d399; background: var(--ok-soft); border-color: rgba(16,185,129,0.3); }
.badge-warn { color: #fbbf24; background: var(--warn-soft); border-color: rgba(245,158,11,0.3); }
.badge-danger { color: #f87171; background: var(--danger-soft); border-color: rgba(239,68,68,0.3); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.mono { font-family: var(--mono); }
.code-inline { font-family: var(--mono); font-size: 0.82em; color: var(--accent-strong); background: var(--accent-soft); border: 1px solid var(--accent-ring); border-radius: var(--r-sm); padding: 0.08em 0.4em; }
.code-block {
  font-family: var(--mono); font-size: 0.82rem; line-height: 1.7; color: #cdd6f4;
  background: #0b0b14; border: 1px solid var(--edge); border-radius: var(--r-md);
  padding: 1rem 1.1rem; overflow-x: auto; white-space: pre;
}
[data-theme="light"] .code-block { background: #f1f5f9; color: #1e293b; border-color: var(--edge); }
[data-theme="light"] .code-block .c-cm { color: #64748b; }
[data-theme="light"] .code-block .c-fn { color: #16a34a; font-weight: 600; }
[data-theme="light"] .code-block .c-str { color: #2563eb; }
[data-theme="light"] .code-block .c-par { color: #d97706; }
.code-block .c-cm { color: #6b7191; }
.code-block .c-fn { color: #7fe0a8; font-weight: 600; }
.code-block .c-str { color: #9fd0ff; }
.code-block .c-par { color: #fbd38d; }

.cmdk-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3, 3, 8, 0.55); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center; padding-top: 14vh;
  opacity: 0; pointer-events: none; transition: opacity var(--t-fast);
}
.cmdk-overlay.open { opacity: 1; pointer-events: auto; }
.cmdk {
  width: min(620px, 92vw); background: var(--elevated); border: 1px solid var(--edge-strong);
  border-radius: var(--r-xl); box-shadow: var(--shadow-pop); overflow: hidden;
  transform: translateY(-10px) scale(0.98); transition: transform var(--t-base);
}
.cmdk-overlay.open .cmdk { transform: none; }
.cmdk-input-row { display: flex; align-items: center; gap: 0.75rem; padding: 0 1.1rem; border-bottom: 1px solid var(--edge); }
.cmdk-input-row > i { color: var(--text-muted); }
.cmdk-input { flex: 1; height: 56px; border: none; background: transparent; color: var(--text); font-size: 1.02rem; outline: none; }
.cmdk-input::placeholder { color: var(--text-faint); }
.cmdk-esc { font-size: 0.66rem; }
.cmdk-list { max-height: 52vh; overflow-y: auto; padding: 0.5rem; }
.cmdk-group-label { font-size: 0.64rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-faint); padding: 0.6rem 0.7rem 0.3rem; }
.cmdk-item { display: flex; align-items: center; gap: 0.8rem; padding: 0.6rem 0.7rem; border-radius: var(--r-md); cursor: pointer; color: var(--text-2); font-size: 0.9rem; }
.cmdk-item i:first-child { width: 18px; text-align: center; color: var(--text-muted); }
.cmdk-item .cmdk-hint { margin-left: auto; font-size: 0.72rem; color: var(--text-faint); }
.cmdk-item.active, .cmdk-item:hover { background: var(--accent-soft); color: var(--text); }
.cmdk-item.active i:first-child { color: var(--accent-strong); }
.cmdk-empty { padding: 2rem; text-align: center; color: var(--text-muted); font-size: 0.9rem; }

.toast-stack { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 120; display: flex; flex-direction: column; gap: 0.6rem; width: 340px; max-width: calc(100vw - 2rem); }
.toast {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.85rem 0.95rem;
  background: var(--elevated); border: 1px solid var(--edge-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); animation: toastIn var(--t-base);
}
.toast.leaving { animation: toastOut 0.2s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
.toast .toast-i { width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center; flex-shrink: 0; font-size: 0.85rem; }
.toast-ok { border-left: 3px solid #34d399; }
.toast-ok .toast-i { background: var(--ok-soft); color: #34d399; }
.toast-ok .toast-title { color: #34d399; }
.toast-warn { border-left: 3px solid #fbbf24; }
.toast-warn .toast-i { background: var(--warn-soft); color: #fbbf24; }
.toast-warn .toast-title { color: #fbbf24; }
.toast-danger, .toast-err { border-left: 3px solid #f87171; }
.toast-danger .toast-i, .toast-err .toast-i { background: var(--danger-soft); color: #f87171; }
.toast-danger .toast-title, .toast-err .toast-title { color: #f87171; }
.toast-info { border-left: 3px solid var(--accent-strong); }
.toast-info .toast-i { background: var(--accent-soft); color: var(--accent-strong); }
.toast-info .toast-title { color: var(--accent-strong); }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 0.86rem; font-weight: 600; margin-bottom: 0.1rem; }
.toast-msg { font-size: 0.8rem; color: var(--text-muted); line-height: 1.45; }
.toast-close { border: none; background: transparent; color: var(--text-faint); cursor: pointer; padding: 0.1rem; }
.toast-close:hover { color: var(--text); }

.mobile-bar, .mobile-bell, .mobile-sheet, .mobile-sheet-overlay { display: none; }

@media (max-width: 860px) {
  .app, .app.is-expanded { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 0 1rem; }
  .topbar-cmd { min-width: 0; flex: 1; }
  .content { padding: 1.1rem 1rem 6rem; }

  .mobile-bell {
    display: grid; place-items: center;
    width: 40px; height: 40px; border-radius: var(--r-md);
    border: 1px solid var(--edge); background: var(--surface-2); color: var(--text-2);
    position: relative; cursor: pointer;
  }
  .mobile-bell .bell-dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--app-bg); }

  .mobile-bar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; height: 62px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(16px); border-top: 1px solid var(--edge);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: none; background: transparent; color: var(--text-muted); font-size: 0.62rem; font-weight: 600; cursor: pointer; }
  .mobile-tab i { font-size: 1.15rem; }
  .mobile-tab.active { color: var(--accent-strong); }

  .mobile-sheet-overlay { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(3,3,8,0.5); opacity: 0; pointer-events: none; transition: opacity var(--t-fast); }
  .mobile-sheet-overlay.open { opacity: 1; pointer-events: auto; }
  .mobile-sheet {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 56;
    background: var(--elevated); border-top-left-radius: var(--r-xl); border-top-right-radius: var(--r-xl);
    border-top: 1px solid var(--edge-strong); padding: 0.75rem 0.75rem calc(1rem + env(safe-area-inset-bottom));
    transform: translateY(100%); transition: transform var(--t-base); box-shadow: var(--shadow-pop);
  }
  .mobile-sheet.open { transform: none; }
  .mobile-sheet-grip { width: 40px; height: 4px; border-radius: var(--r-full); background: var(--edge-strong); margin: 0.25rem auto 0.75rem; }
  .mobile-sheet .nav-item { height: 48px; }
  .mobile-sheet .nav-item .nav-label { opacity: 1; }
}

[data-theme="light"] .badge-ok { color: #059669; }
[data-theme="light"] .badge-warn { color: #d97706; }
[data-theme="light"] .badge-danger { color: #dc2626; }
[data-theme="light"] .btn-danger { color: #dc2626; }

.stripe-test-bar { display: flex; align-items: center; gap: 0.5rem; justify-content: center; padding: 0.35rem 1rem; background: linear-gradient(135deg, #d97706, #f59e0b); color: #1c1917; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; }
.imp-bar { display: flex; align-items: center; gap: 0.7rem; justify-content: center; padding: 0.45rem 1rem; background: linear-gradient(135deg,#1d4ed8,#2563eb); color: #fff; font-size: 0.82rem; font-weight: 600; position: sticky; top: 0; z-index: 50; }
.imp-exit { display: inline-flex; align-items: center; gap: 0.35rem; margin-left: 0.5rem; padding: 0.2rem 0.65rem; background: rgba(255,255,255,0.2); border-radius: var(--r-full); text-decoration: none; color: #fff; transition: background var(--t-fast); }
.imp-exit:hover { background: rgba(255,255,255,0.35); }

@media (pointer: coarse) {
  .btn, .topbar-btn { min-height: 44px; }
  .btn-sm { min-height: 44px; }
  .btn-icon { min-width: 44px; min-height: 44px; }
  .sidebar-pin { width: 44px; height: 44px; }
  .sidebar .nav-item { min-height: 44px; }
  .settings-tab { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
