/* AppTrack — built from scratch to match the shadcn dashboard aesthetic.
   Geist font, neutral HSL palette, refined spacing, dot-style badges,
   trend pills, segmented toggles, sidebar Quick Create CTA. */

:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --success: 142 71% 36%;
  --warning: 38 92% 50%;
  --info: 217 91% 60%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5% 64.9%;
  --radius: 0.75rem;

  /* surface tints used for stat-card gradients */
  --surface-tint: 240 5.9% 97%;

  /* Typography scale */
  --font-sans: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --text-xs:    12px;
  --text-sm:    13px;
  --text-base:  14px;
  --text-md:    15px;
  --text-lg:    16px;
  --text-xl:    18px;
  --text-2xl:   22px;
  --text-3xl:   28px;
  --text-4xl:   36px;
  --leading-tight:   1.2;
  --leading-snug:    1.35;
  --leading-normal:  1.5;
  --leading-relaxed: 1.65;
  --tracking-tight:  -0.02em;
  --tracking-snug:   -0.01em;

  /* Layout */
  --container-max: 1400px;
  --sidebar-w: 256px;
  --topbar-h: 56px;
  --page-px: 32px;
  --page-py: 28px;
}
@media (max-width: 768px) {
  :root { --page-px: 16px; --page-py: 20px; }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; font-size: 16px; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* Heading hierarchy */
h1, .h1 { font-size: var(--text-3xl); font-weight: 600; letter-spacing: var(--tracking-tight); line-height: var(--leading-tight); }
h2, .h2 { font-size: var(--text-2xl); font-weight: 600; letter-spacing: var(--tracking-tight); line-height: var(--leading-tight); }
h3, .h3 { font-size: var(--text-lg); font-weight: 600; letter-spacing: var(--tracking-snug); line-height: var(--leading-snug); }
h4, .h4 { font-size: var(--text-md); font-weight: 600; letter-spacing: var(--tracking-snug); line-height: var(--leading-snug); }
h5, .h5 { font-size: var(--text-base); font-weight: 600; line-height: var(--leading-snug); }
h6, .h6 { font-size: var(--text-sm); font-weight: 600; line-height: var(--leading-snug); }

p { line-height: var(--leading-relaxed); }
small { font-size: var(--text-xs); color: hsl(var(--muted-foreground)); }
code, kbd, samp { font-family: var(--font-mono); font-size: 0.92em; }
strong, b { font-weight: 600; }

::selection { background: hsl(var(--primary) / 0.15); color: hsl(var(--foreground)); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 999px; border: 2px solid hsl(var(--background)); }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--ring)); }

/* ── Layout shell ─────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; width: 100%; }
.main   { flex: 1; display: flex; flex-direction: column; min-width: 0; background: hsl(var(--background)); }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  position: sticky; top: 0;
  width: var(--sidebar-w); height: 100vh; flex-shrink: 0;
  background: hsl(var(--background));
  border-right: 1px solid hsl(var(--border));
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 12px;
}
.brand-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 13px; font-weight: 600;
}
.brand-icon [data-lucide] { width: 16px; height: 16px; }
.brand-name { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub  { font-size: 11px; color: hsl(var(--muted-foreground)); margin-top: 1px; }

/* Quick Create CTA + secondary icon button in sidebar */
.sidebar-cta { display: flex; gap: 6px; padding: 4px 8px 8px; }
.sidebar-cta .btn-cta {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: flex-start; gap: 8px;
  height: 36px; padding: 0 12px;
  border: none; border-radius: 8px;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .12s;
}
.sidebar-cta .btn-cta:hover { background: hsl(var(--primary) / 0.88); }
.sidebar-cta .btn-cta [data-lucide] { width: 16px; height: 16px; }
.sidebar-cta .btn-icon-sq {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  cursor: pointer; text-decoration: none;
  transition: background-color .12s;
}
.sidebar-cta .btn-icon-sq:hover { background: hsl(var(--accent)); }
.sidebar-cta .btn-icon-sq [data-lucide] { width: 16px; height: 16px; }

/* Nav */
.sidebar-nav { flex: 1; padding: 6px 8px; }
.nav-label {
  padding: 14px 10px 6px;
  font-size: 12px; font-weight: 500;
  color: hsl(var(--muted-foreground));
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin-bottom: 1px;
  border-radius: 8px;
  font-size: var(--text-sm); font-weight: 500;
  color: hsl(var(--foreground));
  text-decoration: none;
  transition: background-color .12s, color .12s;
}
.nav-item:hover { background: hsl(var(--accent)); }
.nav-item.active { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.nav-item.active [data-lucide] { color: hsl(var(--primary-foreground)); }
.nav-item.nav-danger:hover { background: hsl(var(--destructive) / 0.08); color: hsl(var(--destructive)); }
.nav-item.nav-external { color: hsl(var(--muted-foreground)); }
.nav-item [data-lucide] { width: 16px; height: 16px; flex-shrink: 0; color: hsl(var(--muted-foreground)); }
.nav-divider { height: 1px; background: hsl(var(--border)); margin: 8px 4px; }

.badge-red {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 6px; margin-left: auto;
  border-radius: 999px;
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  font-size: 10px; font-weight: 600;
}
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid hsl(var(--border));
  display: flex; align-items: center; gap: 10px;
  font-size: 12px;
  color: hsl(var(--muted-foreground));
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--page-px);
  background: hsl(var(--background));
  border-bottom: 1px solid hsl(var(--border));
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: none; background: transparent; border-radius: 8px;
  color: hsl(var(--foreground)); cursor: pointer;
}
.topbar-toggle:hover { background: hsl(var(--accent)); }
.topbar-toggle [data-lucide] { width: 16px; height: 16px; }
.topbar-sep { width: 1px; height: 18px; background: hsl(var(--border)); }
.topbar-title { font-size: var(--text-base); font-weight: 500; letter-spacing: var(--tracking-snug); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar [data-lucide] { width: 14px; height: 14px; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}

.page-body {
  flex: 1; overflow-y: auto;
  padding: var(--page-py) var(--page-px) calc(var(--page-py) + 12px);
  background: hsl(var(--background));
}
.page-container { width: 100%; max-width: var(--container-max); margin: 0 auto; }
.page-narrow    { width: 100%; max-width: 720px; margin: 0 auto; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header h1, .page-header .page-title { font-size: var(--text-2xl); font-weight: 600; letter-spacing: var(--tracking-tight); line-height: var(--leading-tight); margin: 0; }
.page-header .page-subtitle { margin-top: 4px; font-size: var(--text-sm); color: hsl(var(--muted-foreground)); line-height: var(--leading-snug); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 1px 2px hsl(var(--foreground) / 0.04);
}
.card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
  padding: 22px 24px 16px;
}
.card-title { font-size: var(--text-md); font-weight: 600; letter-spacing: var(--tracking-snug); line-height: var(--leading-snug); }
.card-subtitle { margin-top: 4px; font-size: var(--text-sm); color: hsl(var(--muted-foreground)); line-height: var(--leading-snug); }
.card-body   { padding: 0 24px 24px; }
.card-body.compact { padding: 0; }
.card-actions { display: flex; align-items: center; gap: 8px; }
.card-divider { height: 1px; background: hsl(var(--border)); }

/* ── Stat cards (shadcn dashboard pattern) ────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 24px; }
@media (min-width: 640px)  { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
  position: relative;
  display: flex; flex-direction: column;
  gap: 4px;
  padding: 20px 22px 22px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: linear-gradient(180deg, hsl(var(--surface-tint)) 0%, hsl(var(--card)) 100%);
  box-shadow: 0 1px 2px hsl(var(--foreground) / 0.03);
  min-height: 148px;
}
.stat-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.stat-card-label { font-size: var(--text-sm); color: hsl(var(--muted-foreground)); font-weight: 500; }
.stat-card-value { font-size: var(--text-3xl); font-weight: 600; letter-spacing: -0.035em; line-height: 1.1; color: hsl(var(--foreground)); font-variant-numeric: tabular-nums; }
.stat-card-footer { margin-top: auto; padding-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.stat-card-trend  { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); font-weight: 500; color: hsl(var(--foreground)); }
.stat-card-trend [data-lucide] { width: 14px; height: 14px; }
.stat-card-note   { font-size: var(--text-xs); color: hsl(var(--muted-foreground)); }

/* Trend pill (small badge in top-right of stat card) */
.trend-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
  color: hsl(var(--foreground));
  line-height: 1.4;
}
.trend-pill [data-lucide] { width: 12px; height: 12px; }
.trend-pill.up    { color: hsl(var(--foreground)); }
.trend-pill.down  { color: hsl(var(--foreground)); }

/* Legacy compact stat-card (used by some EJS pages); shrink to grid item */
.stat-card.legacy { flex-direction: row; align-items: center; gap: 14px; min-height: 0; padding: 18px 20px; background: hsl(var(--card)); }
.stat-card.legacy .stat-icon { width: 38px; height: 38px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 10px; background: hsl(var(--accent)); font-size: 16px; }
.stat-card.legacy .stat-body { display: flex; flex-direction: column; }
.stat-card.legacy .stat-value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.stat-card.legacy .stat-label { margin-top: 2px; font-size: 12px; color: hsl(var(--muted-foreground)); }

/* ── Segmented toggle group ──────────────────────────────────────────────── */
.toggle-group {
  display: inline-flex;
  padding: 3px;
  border: 1px solid hsl(var(--border));
  border-radius: 9px;
  background: hsl(var(--background));
}
.toggle-group .toggle {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 14px;
  border: none; background: transparent;
  border-radius: 6px;
  font-size: 13px; font-weight: 500;
  color: hsl(var(--muted-foreground));
  cursor: pointer; text-decoration: none;
  transition: background-color .12s, color .12s;
}
.toggle-group .toggle:hover { color: hsl(var(--foreground)); }
.toggle-group .toggle.active {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px hsl(var(--foreground) / 0.05);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px;
  border-radius: 8px; border: 1px solid transparent;
  font-family: inherit; font-size: var(--text-sm); font-weight: 500;
  line-height: 1; white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s, color .12s, border-color .12s, opacity .12s;
}
.btn:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn [data-lucide] { width: 14px; height: 14px; }
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: hsl(var(--primary)); }
.btn-primary:hover { background: hsl(var(--primary) / 0.88); }
.btn-ghost   { background: hsl(var(--background)); color: hsl(var(--foreground)); border-color: hsl(var(--input)); }
.btn-ghost:hover { background: hsl(var(--accent)); }
.btn-danger  { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); border-color: hsl(var(--destructive)); }
.btn-danger:hover { background: hsl(var(--destructive) / 0.9); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; border-radius: 7px; }
.btn-xs { height: 26px; padding: 0 10px; font-size: 11px; border-radius: 6px; }
.btn-lg { height: 40px; padding: 0 20px; font-size: 14px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-icon  { padding: 0; width: 36px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 500; color: hsl(var(--foreground)); line-height: 1; }
.form-hint  { margin-top: 6px; font-size: 12.5px; color: hsl(var(--muted-foreground)); line-height: 1.5; }
.form-input {
  display: block; width: 100%;
  height: 38px; padding: 0 14px;
  font-family: inherit; font-size: var(--text-sm);
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  border-radius: 9px;
  transition: border-color .12s, box-shadow .12s;
}
.form-input::placeholder { color: hsl(var(--muted-foreground)); }
.form-input:focus { outline: none; border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / 0.18); }
.form-input-sm { width: auto; height: 32px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
textarea.form-input { height: auto; padding: 12px 14px; min-height: 100px; line-height: 1.5; resize: vertical; }
select.form-input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  -webkit-appearance: none; appearance: none;
}

/* Input group with leading icon */
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input-icon { position: absolute; left: 12px; width: 16px; height: 16px; color: hsl(var(--muted-foreground)); pointer-events: none; }
.input-group .form-input { padding-left: 38px; }

/* ── Filter bar ───────────────────────────────────────────────────────────── */
.filter-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-search { flex: 1; min-width: 220px; max-width: 360px; }
.filter-select { width: auto; min-width: 140px; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.table th {
  height: 44px;
  padding: 0 24px;
  text-align: left;
  background: transparent;
  border-bottom: 1px solid hsl(var(--border));
  font-size: var(--text-xs); font-weight: 500;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}
.table td {
  padding: 14px 24px;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: hsl(var(--muted) / 0.5); }

/* ── Badge / status pills ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 9px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  line-height: 1.4;
}
.badge.has-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge-dark { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: hsl(var(--primary)); }

.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 9px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  color: hsl(var(--foreground));
  text-transform: capitalize;
  line-height: 1.4;
}
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.status-pill-xs { padding: 2px 7px; font-size: 10.5px; }
.status-green  { color: hsl(142 64% 24%); }
.status-yellow { color: hsl(31 81% 30%); }
.status-blue   { color: hsl(224 76% 40%); }
.status-red    { color: hsl(0 70% 40%); }
.status-gray   { color: hsl(var(--muted-foreground)); }

/* Priority dots */
.priority-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.priority-urgent { background: hsl(var(--destructive)); }
.priority-high   { background: hsl(var(--warning)); }
.priority-normal { background: hsl(var(--info)); }
.priority-low    { background: hsl(var(--success)); }

/* ── Grid helpers ─────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ── Text utilities ───────────────────────────────────────────────────────── */
.text-sm     { font-size: 13px; }
.text-xs     { font-size: 12px; }
.text-muted  { color: hsl(var(--muted-foreground)); }
.text-center { text-align: center; }
.text-mono   { font-family: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }
.link-primary { color: hsl(var(--foreground)); font-weight: 500; text-decoration: none; }
.link-primary:hover { text-decoration: underline; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-page  { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; background: hsl(var(--muted) / 0.4); }
.login-card  { width: 100%; max-width: 400px; padding: 32px; border: 1px solid hsl(var(--border)); border-radius: 14px; background: hsl(var(--card)); box-shadow: 0 8px 30px hsl(var(--foreground) / 0.06); }
.login-logo  { width: 48px; height: 48px; margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.login-logo [data-lucide] { width: 22px; height: 22px; }
.login-title { font-size: 22px; font-weight: 600; text-align: center; letter-spacing: -0.02em; }
.login-sub   { margin: 4px 0 24px; font-size: 13px; color: hsl(var(--muted-foreground)); text-align: center; }

/* Alerts */
.alert { margin-bottom: 16px; padding: 12px 14px; border: 1px solid transparent; border-radius: 9px; font-size: 13px; }
.alert-danger { background: hsl(var(--destructive) / 0.08); color: hsl(0 70% 40%); border-color: hsl(var(--destructive) / 0.22); }
.alert-info   { background: hsl(217 91% 60% / 0.08); color: hsl(224 76% 40%); border-color: hsl(217 91% 60% / 0.22); }

/* ── Shop / apps / journey / ticket / KB editor / modal / pagination ─────── */
.shop-cell   { display: flex; align-items: center; gap: 10px; }
.shop-avatar { width: 32px; height: 32px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: hsl(var(--accent)); font-size: 12px; font-weight: 600; }
.shop-domain { font-size: 13.5px; font-weight: 500; }

.apps-grid       { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.app-card        { overflow: hidden; border: 1px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--card)); transition: border-color .12s, box-shadow .12s; }
.app-card:hover  { border-color: hsl(var(--ring)); box-shadow: 0 2px 8px hsl(var(--foreground) / 0.04); }
.app-card-header { display: flex; align-items: center; gap: 12px; padding: 18px 18px 12px; }
.app-big-icon    { font-size: 1.6rem; }
.app-card-name   { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.app-card-slug   { font-size: 12px; color: hsl(var(--muted-foreground)); }
.app-card-body   { padding: 0 18px 16px; }
.key-row         { display: flex; align-items: center; gap: 6px; padding: 7px 10px; margin-bottom: 8px; background: hsl(var(--muted) / 0.5); border-radius: 8px; }
.key-label       { font-size: 11px; font-weight: 600; color: hsl(var(--muted-foreground)); white-space: nowrap; }
.key-val         { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: 'Geist Mono', ui-monospace, monospace; font-size: 11.5px; }
.app-desc        { margin-bottom: 8px; font-size: 12.5px; color: hsl(var(--muted-foreground)); }
.app-card-actions{ display: flex; flex-wrap: wrap; gap: 6px; }
.app-card-footer { padding: 10px 18px; border-top: 1px solid hsl(var(--border)); background: hsl(var(--muted) / 0.4); }
.app-row         { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid hsl(var(--border)); }
.app-row:last-child { border-bottom: none; }
.app-row-left    { display: flex; align-items: center; gap: 10px; }
.app-dot         { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: hsl(var(--accent)); font-size: 14px; }
.app-row-name    { font-size: 13.5px; font-weight: 500; }
.app-row-right   { display: flex; align-items: center; gap: 8px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: hsl(var(--foreground) / 0.5); backdrop-filter: blur(2px); }
.modal         { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); border: 1px solid hsl(var(--border)); border-radius: 12px; background: hsl(var(--background)); box-shadow: 0 20px 50px hsl(var(--foreground) / 0.25); }
.modal-header  { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid hsl(var(--border)); }
.modal-header h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.modal-close   { padding: 4px 8px; border: none; background: none; border-radius: 6px; font-size: 18px; color: hsl(var(--muted-foreground)); cursor: pointer; }
.modal-close:hover { background: hsl(var(--accent)); }
.modal-body    { padding: 22px; }
.modal-footer  { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid hsl(var(--border)); }

/* Journey */
.journey-header   { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.journey-shop-info{ display: flex; align-items: center; gap: 14px; }
.shop-big-avatar  { width: 52px; height: 52px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: hsl(var(--accent)); font-size: 1.2rem; font-weight: 600; }
.journey-domain   { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.journey-meta     { display: flex; align-items: center; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.journey-grid     { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .journey-grid { grid-template-columns: 1fr 1fr; } }

.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: hsl(var(--border)); }
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-dot { position: absolute; left: -22px; top: 2px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid hsl(var(--background)); }
.dot-green { background: hsl(var(--success)); }
.dot-red   { background: hsl(var(--destructive)); }
.dot-blue  { background: hsl(var(--info)); }
.timeline-event { font-size: 13.5px; font-weight: 500; }
.timeline-time  { margin-top: 2px; font-size: 11.5px; color: hsl(var(--muted-foreground)); }

.page-bar-row    { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.page-bar-label  { width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.page-bar-track  { flex: 1; height: 6px; background: hsl(var(--secondary)); border-radius: 999px; overflow: hidden; }
.page-bar-fill   { height: 100%; background: hsl(var(--primary)); border-radius: 999px; }
.page-bar-count  { width: 36px; text-align: right; font-size: 12.5px; color: hsl(var(--muted-foreground)); }

.session-row  { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid hsl(var(--border)); }
.session-row:last-child { border-bottom: none; }
.session-icon { font-size: 1.1rem; }

.ticket-row     { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid hsl(var(--border)); }
.ticket-row:last-child { border-bottom: none; }
.ticket-subject { font-size: 13.5px; font-weight: 500; color: hsl(var(--foreground)); text-decoration: none; }
.ticket-subject:hover { text-decoration: underline; }

.type-pill      { display: inline-flex; align-items: center; gap: 5px; padding: 2.5px 9px; border: 1px solid hsl(var(--border)); background: hsl(var(--background)); border-radius: 999px; font-size: 11.5px; font-weight: 500; }
.type-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.type-page_view { color: hsl(263 70% 35%); }
.type-event     { color: hsl(224 76% 40%); }
.type-identify  { color: hsl(142 64% 24%); }

/* Ticket detail */
.ticket-detail-layout { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 900px) { .ticket-detail-layout { grid-template-columns: 1fr 300px; } }
.ticket-title  { margin-bottom: 6px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.ticket-meta   { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.message-bubble { margin-bottom: 12px; padding: 14px 16px; border: 1px solid hsl(var(--border)); border-radius: 10px; }
.message-shop  { background: hsl(var(--muted) / 0.6); }
.message-admin { background: hsl(var(--primary) / 0.05); border-color: hsl(var(--primary) / 0.15); }
.message-header { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 12px; color: hsl(var(--muted-foreground)); }
.message-body  { font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.reply-form    { margin-top: 16px; padding-top: 16px; border-top: 1px solid hsl(var(--border)); }
.reply-input   { margin-bottom: 10px; }
.reply-actions { display: flex; gap: 8px; }
.info-row      { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid hsl(var(--border)); }
.info-row:last-child { border-bottom: none; }
.info-row > span:first-child { font-size: 12px; font-weight: 500; color: hsl(var(--muted-foreground)); }
.ticket-sidebar .card-body { padding: 16px; }
.other-ticket  { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid hsl(var(--border)); }
.other-ticket:last-child { border-bottom: none; }

/* KB editor */
.editor-layout { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 900px) { .editor-layout { grid-template-columns: 1fr 300px; } }
.editor-title-input { width: 100%; margin-bottom: 14px; padding: 0 0 14px; border: none; border-bottom: 1px solid hsl(var(--border)); background: transparent; font: 600 24px/1 inherit; letter-spacing: -0.02em; color: hsl(var(--foreground)); }
.editor-title-input:focus { outline: none; border-bottom-color: hsl(var(--ring)); }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.editor-toolbar button { padding: 6px 12px; border: 1px solid hsl(var(--input)); border-radius: 8px; background: hsl(var(--background)); font-family: inherit; font-size: 12px; color: hsl(var(--foreground)); cursor: pointer; transition: background-color .12s; }
.editor-toolbar button:hover { background: hsl(var(--accent)); }
.editor-textarea { width: 100%; padding: 14px; border: 1px solid hsl(var(--input)); border-radius: 9px; background: hsl(var(--background)); color: hsl(var(--foreground)); font-family: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.7; resize: vertical; }
.editor-textarea:focus { outline: none; border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / 0.18); }
.editor-preview { min-height: 300px; padding: 18px; border: 1px solid hsl(var(--border)); border-radius: 9px; background: hsl(var(--card)); }
.editor-preview h1, .editor-preview h2, .editor-preview h3 { margin: 14px 0 8px; font-weight: 600; letter-spacing: -0.01em; }
.editor-preview p { margin-bottom: 10px; line-height: 1.7; }
.editor-preview code { padding: 1px 6px; background: hsl(var(--muted)); border-radius: 4px; font-family: 'Geist Mono', ui-monospace, monospace; font-size: 12px; }
.editor-preview pre { margin-bottom: 10px; padding: 14px; background: hsl(var(--muted)); border-radius: 8px; overflow-x: auto; }
.editor-preview ul, .editor-preview ol { padding-left: 22px; margin-bottom: 10px; }
.editor-sidebar .form-input { font-size: 12px; }

/* Pagination */
.pagination { display: flex; gap: 4px; padding: 16px 20px; align-items: center; }
.pagination.with-border { border-top: 1px solid hsl(var(--border)); }
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: hsl(var(--muted-foreground));
  font-size: 12.5px; font-weight: 500;
  text-decoration: none;
  transition: background-color .12s, color .12s;
}
.page-btn:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.page-btn.active { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: hsl(var(--primary)); }

/* Empty state */
.empty-state { padding: 32px 24px; text-align: center; font-size: 13px; color: hsl(var(--muted-foreground)); }
.empty-state.large { padding: 56px 24px; }
.empty-state .empty-icon {
  width: 48px; height: 48px;
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}
.empty-state .empty-icon [data-lucide] { width: 22px; height: 22px; }
.empty-state.large h3 { margin: 4px 0 6px; font-size: 18px; font-weight: 600; color: hsl(var(--foreground)); letter-spacing: -0.01em; }
.empty-state.large p  { margin-bottom: 16px; max-width: 360px; margin-left: auto; margin-right: auto; }

/* ── Accordion ────────────────────────────────────────────────────────────── */
.accordion { border-bottom: 1px solid hsl(var(--border)); }
.accordion-item { border-top: 1px solid hsl(var(--border)); }
.accordion-trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 16px 0;
  background: transparent; border: none;
  font: 500 14px/1.4 inherit; color: hsl(var(--foreground));
  cursor: pointer; text-align: left;
}
.accordion-trigger:hover { text-decoration: underline; }
.accordion-trigger [data-lucide] {
  width: 16px; height: 16px; flex-shrink: 0;
  color: hsl(var(--muted-foreground));
  transition: transform .18s;
}
.accordion-item[open] .accordion-trigger [data-lucide] { transform: rotate(180deg); }
.accordion-content {
  padding: 0 0 16px;
  font-size: 13.5px; color: hsl(var(--muted-foreground)); line-height: 1.65;
}

/* ── Tabs (underline style) ───────────────────────────────────────────────── */
.tabs { display: flex; flex-direction: column; gap: 16px; }
.tabs-list {
  display: inline-flex; gap: 2px;
  padding: 4px;
  background: hsl(var(--muted));
  border-radius: 9px;
}
.tabs-trigger {
  padding: 6px 14px;
  border: none; background: transparent;
  border-radius: 6px;
  font: 500 13px/1 inherit; color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: background-color .12s, color .12s;
}
.tabs-trigger:hover { color: hsl(var(--foreground)); }
.tabs-trigger.active { background: hsl(var(--background)); color: hsl(var(--foreground)); box-shadow: 0 1px 2px hsl(var(--foreground) / 0.06); }
.tabs-panel { display: none; }
.tabs-panel.active { display: block; }

/* Underline variant */
.tabs-list.underline { padding: 0; background: transparent; gap: 4px; border-bottom: 1px solid hsl(var(--border)); border-radius: 0; }
.tabs-list.underline .tabs-trigger { padding: 10px 14px; border-radius: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs-list.underline .tabs-trigger.active { background: transparent; border-bottom-color: hsl(var(--primary)); color: hsl(var(--foreground)); box-shadow: none; }

/* ── Breadcrumb ───────────────────────────────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: hsl(var(--muted-foreground)); margin-bottom: 10px; }
.breadcrumb a { color: hsl(var(--muted-foreground)); text-decoration: none; transition: color .12s; }
.breadcrumb a:hover { color: hsl(var(--foreground)); }
.breadcrumb [data-lucide] { width: 14px; height: 14px; flex-shrink: 0; }
.breadcrumb .current { color: hsl(var(--foreground)); font-weight: 500; }

/* ── Dropdown menu (CSS hover) ────────────────────────────────────────────── */
.menu { position: relative; display: inline-block; }
.menu-content {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  min-width: 200px;
  padding: 4px;
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  box-shadow: 0 10px 30px hsl(var(--foreground) / 0.10);
  opacity: 0; visibility: hidden;
  transform: translateY(-4px);
  transition: opacity .14s, transform .14s, visibility .14s;
}
.menu.open > .menu-content,
.menu:focus-within > .menu-content,
.menu:hover > .menu-content { opacity: 1; visibility: visible; transform: translateY(0); }
.menu-label { padding: 8px 10px 6px; font-size: 11px; font-weight: 500; color: hsl(var(--muted-foreground)); }
.menu-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border: none; background: transparent;
  border-radius: 7px;
  font: 500 13px/1.4 inherit; color: hsl(var(--foreground));
  cursor: pointer; text-decoration: none; text-align: left;
}
.menu-item:hover { background: hsl(var(--accent)); }
.menu-item [data-lucide] { width: 14px; height: 14px; color: hsl(var(--muted-foreground)); flex-shrink: 0; }
.menu-item.destructive { color: hsl(var(--destructive)); }
.menu-item.destructive [data-lucide] { color: hsl(var(--destructive)); }
.menu-item.destructive:hover { background: hsl(var(--destructive) / 0.08); }
.menu-shortcut { margin-left: auto; font-size: 11px; color: hsl(var(--muted-foreground)); letter-spacing: 0.04em; }
.menu-separator { height: 1px; background: hsl(var(--border)); margin: 4px 0; }

/* ── Switch (toggle) ──────────────────────────────────────────────────────── */
.switch {
  appearance: none; -webkit-appearance: none;
  position: relative;
  width: 36px; height: 20px;
  border: none; border-radius: 999px;
  background: hsl(var(--input));
  cursor: pointer;
  transition: background-color .15s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: hsl(var(--background));
  box-shadow: 0 1px 3px hsl(var(--foreground) / 0.2);
  transition: transform .15s;
}
.switch:checked { background: hsl(var(--primary)); }
.switch:checked::after { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
.switch-label { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }

/* ── Skeleton (loading placeholder) ──────────────────────────────────────── */
@keyframes skel-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.skeleton { background: hsl(var(--muted)); border-radius: 6px; animation: skel-pulse 1.6s ease-in-out infinite; }
.skeleton-text { height: 14px; }
.skeleton-text.lg { height: 20px; }
.skeleton-circle { border-radius: 50%; }

/* ── Tooltip (CSS-only hover) ────────────────────────────────────────────── */
.tooltip { position: relative; display: inline-flex; }
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  padding: 5px 9px;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  border-radius: 6px;
  font-size: 11.5px; font-weight: 500; line-height: 1.3; white-space: nowrap;
  pointer-events: none;
  opacity: 0; visibility: hidden;
  transition: opacity .12s, visibility .12s;
  z-index: 60;
}
.tooltip:hover::after { opacity: 1; visibility: visible; }

/* ── Separator ────────────────────────────────────────────────────────────── */
.separator { height: 1px; background: hsl(var(--border)); margin: 16px 0; border: none; }
.separator-vertical { width: 1px; height: 16px; background: hsl(var(--border)); margin: 0 12px; }

/* ── Toast (notification) ─────────────────────────────────────────────────── */
.toast-region { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast {
  padding: 14px 16px;
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--popover));
  box-shadow: 0 10px 30px hsl(var(--foreground) / 0.10);
  font-size: 13.5px;
  display: flex; align-items: flex-start; gap: 10px;
}
.toast [data-lucide] { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-title { font-weight: 600; }
.toast-desc  { color: hsl(var(--muted-foreground)); margin-top: 2px; }
.toast.success [data-lucide] { color: hsl(var(--success)); }
.toast.danger  [data-lucide] { color: hsl(var(--destructive)); }
.toast.info    [data-lucide] { color: hsl(var(--info)); }

/* ── Sheet (slide drawer) ─────────────────────────────────────────────────── */
.sheet-overlay { position: fixed; inset: 0; z-index: 50; background: hsl(var(--foreground) / 0.5); backdrop-filter: blur(2px); }
.sheet-overlay:not(.open) { display: none; }
.sheet {
  position: fixed; right: 0; top: 0; bottom: 0; z-index: 51;
  width: 100%; max-width: 440px;
  background: hsl(var(--background));
  border-left: 1px solid hsl(var(--border));
  box-shadow: -10px 0 30px hsl(var(--foreground) / 0.10);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s ease;
}
.sheet.open { transform: translateX(0); }
.sheet-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid hsl(var(--border)); }
.sheet-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.sheet-body { flex: 1; overflow-y: auto; padding: 22px; }
.sheet-footer { padding: 14px 22px; border-top: 1px solid hsl(var(--border)); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Description list (key:value rows for cards) ──────────────────────────── */
.dl { display: flex; flex-direction: column; }
.dl-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid hsl(var(--border));
}
.dl-row:last-child { border-bottom: none; }
.dl-key { font-size: 12.5px; color: hsl(var(--muted-foreground)); }
.dl-val { font-size: 13.5px; color: hsl(var(--foreground)); text-align: right; word-break: break-word; }

/* ── Action group: small icon-only buttons in row endings ─────────────────── */
.row-actions { display: inline-flex; align-items: center; gap: 4px; }

/* ── Color swatch for app brand pickers ───────────────────────────────────── */
.swatch {
  display: inline-block;
  width: 16px; height: 16px;
  border-radius: 4px;
  border: 1px solid hsl(var(--border));
  vertical-align: middle;
}

/* ── Helpers ──────────────────────────────────────────────────────────────── */
.stack    { display: flex; flex-direction: column; }
.inline   { display: inline-flex; align-items: center; gap: 8px; }
.row      { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread   { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gap-2    { gap: 8px; }
.gap-3    { gap: 12px; }
.w-full   { width: 100%; }
.flex-1   { flex: 1; }

/* ── Card list (rows wrapped inside .card-body) ───────────────────────────── */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid hsl(var(--border));
}
.list-item:first-child { padding-top: 0; }
.list-item:last-child { padding-bottom: 0; border-bottom: none; }
