@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ===========================
   Party Teller — Admin Portal
   Internal tool for employees:
   admin, manager, customer service.
   Extends partner design system.
   =========================== */

:root {
  /* Brand colors (shared with consumer/partner) */
  --color-primary: #E11D48;
  --color-on-primary: #FFFFFF;
  --color-secondary: #FB7185;
  --color-accent: #2563EB;
  --color-background: #F4F5F7;
  --color-foreground: #881337;
  --color-muted: #EEF0F3;
  --color-border: #E2E5EA;
  --color-destructive: #DC2626;
  --color-ring: #4F46E5;
  --color-success: #16A34A;
  --color-warning: #F59E0B;
  --color-star: #FBBF24;
  --color-info: #0EA5E9;

  /* Surfaces */
  --color-surface: #FFFFFF;
  --color-surface-alt: #F8F9FB;
  --color-text-primary: #1F2937;
  --color-text-secondary: #6B7280;
  --color-text-muted: #9CA3AF;

  /* Role accents — internal staff */
  --color-admin: #4F46E5;
  --color-admin-soft: #EEF2FF;
  --color-manager: #0D9488;
  --color-manager-soft: #CCFBF1;
  --color-cs: #EA580C;
  --color-cs-soft: #FFEDD5;

  /* Typography */
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;

  /* Spacing (8px rhythm) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.10);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Layout */
  --container-max: 1280px;
  --header-height: 64px;
  --sidebar-width: 260px;
  --sidebar-collapsed: 76px;
}

/* Dark mode */
[data-theme="dark"] {
  --color-primary: #FB7185;
  --color-on-primary: #1A0A12;
  --color-secondary: #F43F5E;
  --color-accent: #60A5FA;
  --color-background: #14161A;
  --color-foreground: #FDA4AF;
  --color-muted: #1F2228;
  --color-border: #2A2E36;
  --color-surface: #1B1E23;
  --color-surface-alt: #23262C;
  --color-text-primary: #F9FAFB;
  --color-text-secondary: #D1D5DB;
  --color-text-muted: #9CA3AF;

  --color-admin: #818CF8;
  --color-admin-soft: #2A2740;
  --color-manager: #2DD4BF;
  --color-manager-soft: #11302E;
  --color-cs: #FB923C;
  --color-cs-soft: #3A2418;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.6);
}

/* ===========================
   Reset & Base
   =========================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-body);
  background: var(--color-background);
  color: var(--color-text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text-primary);
}

a { color: var(--color-accent); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-primary); }

img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }

/* ===========================
   Utilities
   =========================== */
.container { max-width: var(--container-max); margin: 0 auto; padding: 0 var(--space-5); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }
.text-muted { color: var(--color-text-secondary); }
.text-primary { color: var(--color-primary); }
.text-accent { color: var(--color-accent); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-destructive); }
.text-admin { color: var(--color-admin); }
.text-manager { color: var(--color-manager); }
.text-cs { color: var(--color-cs); }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.grid { display: grid; gap: var(--space-5); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ===========================
   Brand / Logo
   =========================== */
.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
}
.logo:hover { color: var(--color-text-primary); }
.logo__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: #fff;
  flex-shrink: 0;
}

/* ===========================
   Buttons
   =========================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 18px;
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  line-height: 1.2;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--color-primary); color: var(--color-on-primary); }
.btn--primary:hover { background: #BE123C; color: var(--color-on-primary); }
.btn--secondary { background: var(--color-surface); color: var(--color-text-primary); border-color: var(--color-border); }
.btn--secondary:hover { background: var(--color-surface-alt); color: var(--color-text-primary); }
.btn--accent { background: var(--color-accent); color: #fff; }
.btn--accent:hover { background: #1D4ED8; color: #fff; }
.btn--admin { background: var(--color-admin); color: #fff; }
.btn--admin:hover { background: #4338CA; color: #fff; }
.btn--outline { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn--outline:hover { background: var(--color-primary); color: var(--color-on-primary); }
.btn--ghost { background: transparent; color: var(--color-text-secondary); }
.btn--ghost:hover { background: var(--color-muted); color: var(--color-text-primary); }
.btn--danger { background: var(--color-destructive); color: #fff; }
.btn--danger:hover { background: #B91C1C; color: #fff; }
.btn--sm { padding: 6px 12px; font-size: var(--text-xs); }
.btn--lg { padding: 14px 24px; font-size: var(--text-base); }
.btn--block { width: 100%; }
.btn--icon { padding: 8px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-base);
}
.icon-btn:hover { background: var(--color-muted); color: var(--color-text-primary); }

/* ===========================
   Cards
   =========================== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card__body { padding: var(--space-5); }
.card__header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.card__title { font-size: var(--text-lg); font-weight: 600; }
.card__footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}

/* ===========================
   Forms
   =========================== */
.form-group { margin-bottom: var(--space-4); }
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: var(--space-2);
  color: var(--color-text-primary);
}
.form-label .req { color: var(--color-primary); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: var(--text-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control::placeholder { color: var(--color-text-muted); }
.form-control:focus {
  outline: none;
  border-color: var(--color-ring);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.form-control:disabled { background: var(--color-muted); cursor: not-allowed; }
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.form-hint { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-1); }
.form-error { font-size: var(--text-xs); color: var(--color-destructive); margin-top: var(--space-1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }

/* ===========================
   Badges & Pills
   =========================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--color-muted);
  color: var(--color-text-secondary);
}
.badge--primary { background: rgba(225, 29, 72, 0.12); color: var(--color-primary); }
.badge--success { background: rgba(22, 163, 74, 0.12); color: var(--color-success); }
.badge--warning { background: rgba(245, 158, 11, 0.15); color: #B45309; }
.badge--danger { background: rgba(220, 38, 38, 0.12); color: var(--color-destructive); }
.badge--info { background: rgba(14, 165, 233, 0.12); color: var(--color-info); }
.badge--admin { background: var(--color-admin-soft); color: var(--color-admin); }
.badge--manager { background: var(--color-manager-soft); color: var(--color-manager); }
.badge--cs { background: var(--color-cs-soft); color: var(--color-cs); }

/* ===========================
   Tables
   =========================== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--color-border); }
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  font-size: var(--text-sm);
}
.table thead th {
  text-align: left;
  padding: 12px var(--space-4);
  background: var(--color-surface-alt);
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.table tbody td {
  padding: 14px var(--space-4);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-primary);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--color-surface-alt); }
.table .cell-primary { font-weight: 600; }
.table .cell-muted { color: var(--color-text-secondary); }
.table .cell-mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: var(--text-xs); }

/* ===========================
   Auth pages (login / register)
   =========================== */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--color-background);
}
.auth-aside {
  background: linear-gradient(135deg, #1E1B4B 0%, #4F46E5 55%, #E11D48 100%);
  color: #fff;
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-aside::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 80%, rgba(255,255,255,0.15), transparent 50%),
              radial-gradient(circle at 80% 20%, rgba(255,255,255,0.10), transparent 50%);
  pointer-events: none;
}
.auth-aside__brand { display: flex; align-items: center; gap: var(--space-3); position: relative; z-index: 1; }
.auth-aside__brand .logo__icon { background: rgba(255,255,255,0.18); }
.auth-aside__brand .logo { color: #fff; font-size: var(--text-xl); }
.auth-aside__hero { position: relative; z-index: 1; max-width: 460px; }
.auth-aside__hero h1 { color: #fff; font-size: var(--text-4xl); margin-bottom: var(--space-4); line-height: 1.15; }
.auth-aside__hero p { font-size: var(--text-lg); opacity: 0.92; }
.auth-aside__features { display: flex; flex-direction: column; gap: var(--space-3); position: relative; z-index: 1; }
.auth-aside__feature { display: flex; align-items: flex-start; gap: var(--space-3); }
.auth-aside__feature svg { flex-shrink: 0; margin-top: 2px; }
.auth-aside__feature span { font-size: var(--text-sm); opacity: 0.95; }
.auth-aside__footer { position: relative; z-index: 1; font-size: var(--text-xs); opacity: 0.75; }

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-7) var(--space-5);
}
.auth-card { width: 100%; max-width: 480px; }
.auth-card__title { font-size: var(--text-2xl); margin-bottom: var(--space-2); }
.auth-card__subtitle { color: var(--color-text-secondary); margin-bottom: var(--space-6); }

/* Role tabs (3 roles) */
.role-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  padding: 4px;
  background: var(--color-muted);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-5);
}
.role-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  transition: all var(--transition-base);
}
.role-tab:hover { color: var(--color-text-primary); }
.role-tab[aria-selected="true"] {
  background: var(--color-surface);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-sm);
}
.role-tab__icon { display: inline-flex; }
.role-tab[aria-selected="true"].role-tab--admin .role-tab__icon { color: var(--color-admin); }
.role-tab[aria-selected="true"].role-tab--manager .role-tab__icon { color: var(--color-manager); }
.role-tab[aria-selected="true"].role-tab--cs .role-tab__icon { color: var(--color-cs); }
.role-tab__label { font-size: 11px; color: var(--color-text-muted); font-weight: 400; text-align: center; }
.role-tab[aria-selected="true"] .role-tab__label { color: var(--color-text-secondary); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-5) 0;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.auth-foot { margin-top: var(--space-5); text-align: center; font-size: var(--text-sm); color: var(--color-text-secondary); }
.auth-foot a { font-weight: 600; }

/* Role-picker cards on the landing page.
   Desktop: stacked (icon on top, title, description).
   Mobile:  horizontal (icon left, text right) — see responsive section. */
.role-cards { margin-top: var(--space-6); }
.role-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
  color: inherit;
}
.role-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-admin);
  color: inherit;
}
.role-card .stat-card__icon { margin-bottom: 0; }
.role-card__text { display: flex; flex-direction: column; gap: 4px; }
.role-card__title { font-size: var(--text-lg); font-weight: 600; color: var(--color-text-primary); }
.role-card__desc { font-size: var(--text-sm); color: var(--color-text-secondary); line-height: 1.5; }

.demo-hint {
  margin-top: var(--space-4);
  padding: var(--space-3);
  background: var(--color-surface-alt);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}
.demo-hint code {
  background: var(--color-muted);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: var(--color-text-primary);
}

/* ===========================
   App shell (dashboard)
   =========================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__brand {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--header-height);
}
.sidebar__brand .logo { font-size: var(--text-base); }
.sidebar__brand-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--color-muted);
  margin-left: auto;
}
.sidebar__role {
  margin: var(--space-4) var(--space-4);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.sidebar__role-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar__role--admin .sidebar__role-icon { background: var(--color-admin-soft); color: var(--color-admin); }
.sidebar__role--manager .sidebar__role-icon { background: var(--color-manager-soft); color: var(--color-manager); }
.sidebar__role--cs .sidebar__role-icon { background: var(--color-cs-soft); color: var(--color-cs); }
.sidebar__role-name { font-size: var(--text-sm); font-weight: 600; }
.sidebar__role-label { font-size: var(--text-xs); color: var(--color-text-muted); }

.sidebar__nav { flex: 1; padding: var(--space-3) var(--space-3); display: flex; flex-direction: column; gap: 2px; }
.sidebar__section { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); padding: var(--space-3) var(--space-3) var(--space-1); font-weight: 600; }
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
  width: 100%;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.nav-item:hover { background: var(--color-surface-alt); color: var(--color-text-primary); }
.nav-item[aria-current="page"] {
  background: var(--color-admin-soft);
  color: var(--color-admin);
  font-weight: 600;
}
.sidebar__role--manager ~ .sidebar__nav .nav-item[aria-current="page"],
.nav-item--manager-active[aria-current="page"] {
  background: var(--color-manager-soft);
  color: var(--color-manager);
}
.nav-item__icon { flex-shrink: 0; display: inline-flex; }
.nav-item__badge {
  margin-left: auto;
  background: var(--color-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
}
.sidebar__foot {
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
}

/* Main column */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  position: sticky;
  top: 0;
  z-index: 10;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
}
.topbar > * { flex-shrink: 0; }
.topbar__heading { flex-shrink: 1; min-width: 0; overflow: hidden; }
.topbar__title { font-size: var(--text-lg); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__subtitle { font-size: var(--text-xs); color: var(--color-text-muted); }
.topbar__search {
  flex: 1;
  flex-shrink: 1;
  min-width: 0;
  max-width: 420px;
  position: relative;
}
.topbar__search input {
  width: 100%;
  padding: 9px 12px 9px 38px;
  font-size: var(--text-sm);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
}
.topbar__search input:focus { outline: none; border-color: var(--color-ring); box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }
.topbar__search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
}
.topbar__spacer { flex: 1; flex-shrink: 1; min-width: 0; }
.topbar__actions { display: flex; align-items: center; gap: var(--space-2); }

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-full);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.user-chip:hover { background: var(--color-muted); }
.user-chip__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-admin), var(--color-primary));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
}
.user-chip__name { font-size: var(--text-sm); font-weight: 600; }

.content {
  padding: var(--space-6);
  flex: 1;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.page-head__title { font-size: var(--text-2xl); font-weight: 700; }
.page-head__subtitle { color: var(--color-text-secondary); font-size: var(--text-sm); margin-top: 2px; }
.page-head__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ===========================
   Stat cards
   =========================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: relative;
  overflow: hidden;
}
.stat-card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(79, 70, 229, 0.10);
  color: var(--color-admin);
}
.stat-card--accent .stat-card__icon { background: rgba(37, 99, 235, 0.10); color: var(--color-accent); }
.stat-card--success .stat-card__icon { background: rgba(22, 163, 74, 0.12); color: var(--color-success); }
.stat-card--warning .stat-card__icon { background: rgba(245, 158, 11, 0.15); color: #B45309; }
.stat-card--danger .stat-card__icon { background: rgba(220, 38, 38, 0.12); color: var(--color-destructive); }
.stat-card--admin .stat-card__icon { background: var(--color-admin-soft); color: var(--color-admin); }
.stat-card--manager .stat-card__icon { background: var(--color-manager-soft); color: var(--color-manager); }
.stat-card--cs .stat-card__icon { background: var(--color-cs-soft); color: var(--color-cs); }
.stat-card__label { font-size: var(--text-sm); color: var(--color-text-secondary); }
.stat-card__value { font-size: var(--text-3xl); font-weight: 700; line-height: 1; }
.stat-card__delta { font-size: var(--text-xs); display: inline-flex; align-items: center; gap: 4px; }
.stat-card__delta--up { color: var(--color-success); }
.stat-card__delta--down { color: var(--color-destructive); }

/* ===========================
   Misc UI
   =========================== */
.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-5);
  color: var(--color-text-secondary);
}
.empty-state__icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-muted);
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
}
.empty-state__title { font-size: var(--text-lg); color: var(--color-text-primary); margin-bottom: var(--space-1); }
.empty-state__text { font-size: var(--text-sm); max-width: 360px; margin: 0 auto var(--space-4); }

.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.alert--info { background: rgba(14, 165, 233, 0.10); color: #075985; border: 1px solid rgba(14, 165, 233, 0.25); }
.alert--success { background: rgba(22, 163, 74, 0.10); color: #14532D; border: 1px solid rgba(22, 163, 74, 0.25); }
.alert--warning { background: rgba(245, 158, 11, 0.12); color: #78350F; border: 1px solid rgba(245, 158, 11, 0.30); }
.alert--danger { background: rgba(220, 38, 38, 0.10); color: #7F1D1D; border: 1px solid rgba(220, 38, 38, 0.25); }
[data-theme="dark"] .alert--info { color: #BAE6FD; }
[data-theme="dark"] .alert--success { color: #BBF7D0; }
[data-theme="dark"] .alert--warning { color: #FDE68A; }
[data-theme="dark"] .alert--danger { color: #FECACA; }

/* Progress bar */
.progress {
  height: 8px;
  background: var(--color-muted);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: var(--color-admin);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}
.progress__bar--success { background: var(--color-success); }
.progress__bar--warning { background: var(--color-warning); }
.progress__bar--danger { background: var(--color-destructive); }

/* Avatar */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-admin), var(--color-primary));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-sm);
  flex-shrink: 0;
}
.avatar--sm { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar--lg { width: 56px; height: 56px; font-size: var(--text-lg); }
.avatar--manager { background: linear-gradient(135deg, var(--color-manager), #14B8A6); }
.avatar--cs { background: linear-gradient(135deg, var(--color-cs), #F97316); }

/* Thumb */
.thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-muted), var(--color-surface-alt));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* Tabs (page-level) */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
  overflow-x: auto;
}
.tab {
  padding: 10px var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.tab:hover { color: var(--color-text-primary); }
.tab[aria-selected="true"] { color: var(--color-admin); border-bottom-color: var(--color-admin); }

/* Toast */
.toast-stack {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 9999;
}
.toast {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-admin);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  min-width: 240px;
  max-width: 360px;
  animation: toast-in 200ms ease;
}
.toast--success { border-left-color: var(--color-success); }
.toast--danger { border-left-color: var(--color-destructive); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 12, 20, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  z-index: 1000;
  animation: fade-in 150ms ease;
}
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in 200ms ease;
}
.modal__header { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; }
.modal__title { font-size: var(--text-lg); font-weight: 600; }
.modal__body { padding: var(--space-5); }
.modal__footer { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: var(--space-2); background: var(--color-surface-alt); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Two-column dashboard layout (main + side rail). Collapses on tablet. */
.cols-2-1 {
  grid-template-columns: 2fr 1fr;
  align-items: start;
}
.cols-3-1 {
  grid-template-columns: 2fr 1fr 1fr;
  align-items: start;
}

/* Bar chart (CSS-only) */
.bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-2);
  height: 220px;
  padding-top: var(--space-4);
}
.bar-chart__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}
.bar-chart__bar {
  width: 100%;
  max-width: 36px;
  background: linear-gradient(180deg, var(--color-admin), var(--color-primary));
  border-radius: 6px 6px 0 0;
  transition: height var(--transition-slow);
  position: relative;
}
.bar-chart__bar--manager { background: linear-gradient(180deg, var(--color-manager), #14B8A6); }
.bar-chart__bar--cs { background: linear-gradient(180deg, var(--color-cs), #F97316); }
.bar-chart__bar--success { background: linear-gradient(180deg, var(--color-success), #4ADE80); }
.bar-chart__label { font-size: var(--text-xs); color: var(--color-text-muted); }

/* Donut (CSS conic) */
.donut {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto;
}
.donut::after {
  content: '';
  width: 90px;
  height: 90px;
  background: var(--color-surface);
  border-radius: 50%;
  grid-area: 1/1;
}
.donut__label { grid-area: 1/1; z-index: 1; text-align: center; }
.donut__value { font-size: var(--text-xl); font-weight: 700; }
.donut__sub { font-size: 10px; color: var(--color-text-muted); }

/* Permission chip (used on role dashboards) */
.perm-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
}
.perm-chip svg { color: var(--color-success); }
.perm-chip--denied svg { color: var(--color-destructive); }

/* Activity feed */
.feed-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.feed-item:last-child { border-bottom: none; }
.feed-item__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-admin);
  margin-top: 7px;
  flex-shrink: 0;
}
.feed-item__dot--success { background: var(--color-success); }
.feed-item__dot--warning { background: var(--color-warning); }
.feed-item__dot--danger { background: var(--color-destructive); }
.feed-item__body { flex: 1; min-width: 0; }
.feed-item__title { font-size: var(--text-sm); font-weight: 500; }
.feed-item__meta { font-size: var(--text-xs); color: var(--color-text-muted); }

/* ===========================
   Responsive
   =========================== */
@media (max-width: 1024px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-aside { display: none; }

  /* Auth card role-picker grids: collapse to a single column on tablet */
  .auth-card .grid--3,
  .auth-card .grid--2 { grid-template-columns: 1fr; }

  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    width: 280px;
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    display: none;
  }
  .sidebar-backdrop.is-open { display: block; }
  .menu-toggle { display: inline-flex !important; }

  .topbar {
    padding: 0 var(--space-4);
    gap: var(--space-3);
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .topbar__search { display: none; }
  .topbar__spacer { display: none; }

  .cols-2-1, .cols-3-1 { grid-template-columns: 1fr; }

  /* Stats: 2 columns on tablet to match the collapsed content grid */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1025px) {
  .menu-toggle { display: none !important; }
}

@media (max-width: 768px) {
  .content { padding: var(--space-4); }
  .topbar__subtitle { display: none; }
  .topbar__title { font-size: var(--text-base); white-space: nowrap; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head__actions { width: 100%; }
  .page-head__actions .btn { flex: 1; }
  .stats-grid { grid-template-columns: 1fr; gap: var(--space-3); }
  .stat-card { padding: var(--space-4); }
  .stat-card__value { font-size: var(--text-2xl); }
  .card__body { padding: var(--space-4); }
  .card__header { padding: var(--space-3) var(--space-4); }
  .card__footer { padding: var(--space-3) var(--space-4); }
  .table thead th { padding: 10px var(--space-3); }
  .table tbody td { padding: 10px var(--space-3); }
  .role-tabs { grid-template-columns: 1fr; }
  .role-tab { flex-direction: row; justify-content: flex-start; padding: 10px var(--space-3); }

  /* Auth card: tighten padding & shrink heading on mobile */
  .auth-main { padding: var(--space-5) var(--space-4); }
  .auth-card__title { font-size: var(--text-xl); }
  .auth-card__subtitle { font-size: var(--text-sm); margin-bottom: var(--space-5); }

  /* Role-picker cards: horizontal layout (icon left, text right) for thumb reach */
  .role-card {
    flex-direction: row;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
  }
  .role-card .stat-card__icon { width: 44px; height: 44px; flex-shrink: 0; }
  .role-card__title { font-size: var(--text-base); }
  .role-card__desc { font-size: var(--text-xs); }
}

@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .user-chip { padding: 4px; }
  .user-chip__name { display: none; }
  .page-head__title { font-size: var(--text-xl); }
  .tabs { gap: 0; }
  .tab { padding: 10px var(--space-3); }
  .alert { flex-direction: row; }
  .alert svg { flex-shrink: 0; }
  .modal-backdrop { padding: var(--space-3); }
  .modal { max-width: 100%; }
  .modal__body { padding: var(--space-4); }
  .modal__footer { flex-direction: column-reverse; gap: var(--space-2); }
  .modal__footer .btn { width: 100%; }
  .toast-stack { left: var(--space-3); right: var(--space-3); bottom: var(--space-3); }
  .toast { min-width: 0; max-width: 100%; }
  .bar-chart { height: 160px; }
}

@media (max-width: 380px) {
  .topbar { padding: 0 var(--space-3); }
  .content { padding: var(--space-3); }
  .stats-grid { gap: var(--space-2); }
  .stat-card { padding: var(--space-3); }
}

.menu-toggle { display: none; }
