/* ============================================================
   GSDev — Admin Panel v4 "Stripi"
   Design System: Stripe dashboard track — deep-navy sidebar, white
   work surface, indigo accents, tabular figures everywhere.
   Spec: /docs/DESIGN-stripe.md
   ============================================================ */

/* ============================================================
   DESIGN TOKENS — Stripi
   ============================================================ */
:root {
  /* Surface — Stripi soft cool off-white feature band on work area */
  --a-bg:           #f6f9fc;          /* canvas-soft */
  --a-card:         #ffffff;
  --a-card-raised:  #ffffff;

  /* Sidebar — Stripi dark-app shell (deep navy, not pure black) */
  --a-sidebar:      #1c1e54;          /* brand-dark */
  --a-sidebar-w:    256px;
  --a-sidebar-item: rgba(255,255,255,0.04);
  --a-sidebar-active: rgba(83,58,253,0.32);
  --a-sidebar-hover:  rgba(255,255,255,0.07);

  /* Hairlines */
  --a-border:       #e3e8ee;          /* hairline */
  --a-border-mid:   #a8c3de;          /* hairline-input */

  /* Text — Stripi ink ramp */
  --a-text:         #0d253d;          /* ink */
  --a-text-mid:     #273951;          /* ink-secondary */
  --a-text-muted:   #64748d;          /* ink-mute */
  --a-text-subtle:  #61718a;          /* ink-mute-2 */

  /* Brand — Stripi indigo */
  --a-primary:      #533afd;
  --a-primary-d:    #4434d4;
  --a-primary-l:    #eeebff;          /* tinted indigo background */
  --a-primary-rgb:  83,58,253;

  /* Semantic */
  --a-accent:       #533afd;
  --a-danger:       #ea2261;          /* ruby */
  --a-danger-l:     #fef2f4;
  --a-warning:      #9b6829;          /* lemon */
  --a-warning-l:    #fdf6ec;
  --a-info:         #533afd;
  --a-info-l:       #eeebff;
  --a-success-l:    #eeebff;

  /* Backward-compat aliases */
  --a-bg-card:      var(--a-card);
  --a-purple:       var(--a-primary);

  /* Gradient — Stripi brand */
  --a-grad:         linear-gradient(135deg, #533afd 0%, #4434d4 100%);
  --a-grad-soft:    linear-gradient(135deg, rgba(83,58,253,0.06) 0%, rgba(83,58,253,0.03) 100%);

  /* Geometry — Stripi smaller radii */
  --a-radius:       8px;
  --a-radius-sm:    6px;
  --a-radius-lg:    12px;
  --a-radius-xl:    16px;

  /* Shadows — subtle navy-tinted lift per Stripi spec */
  --a-shadow-xs:    0 1px 2px rgba(0,55,112,0.05);
  --a-shadow:       0 1px 3px rgba(0,55,112,0.08);
  --a-shadow-md:    0 8px 24px rgba(0,55,112,0.08), 0 2px 6px rgba(0,55,112,0.04);
  --a-shadow-lg:    0 16px 40px rgba(0,55,112,0.12), 0 4px 12px rgba(0,55,112,0.06);
  --a-shadow-focus: 0 0 0 3px rgba(83,58,253,0.18);

  /* Motion */
  --a-ease:         cubic-bezier(0.4, 0, 0.2, 1);
  --a-ease-out:     cubic-bezier(0, 0, 0.2, 1);
  --a-dur:          160ms;
  --a-dur-slow:     240ms;

  /* Touch */
  --a-touch:        44px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--a-bg);
  color: var(--a-text);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 300;
  font-feature-settings: "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Money / numerics — tabular figures (Stripe financial-data signal) */
.admin-table td:where(.num, [data-num], .amount),
.stat-num, .stat-number, .an-metric-val,
.pricing-amount, td.amount, .number {
  font-feature-settings: "ss01", "tnum";
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; }

/* ============================================================
   ACCESSIBILITY — SKIP LINK
   ============================================================ */
.skip-to-content {
  position: absolute;
  top: -60px;
  left: 16px;
  z-index: 9999;
  background: var(--a-primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--a-radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  transition: top var(--a-dur) var(--a-ease-out);
}
.skip-to-content:focus { top: 16px; }

/* ============================================================
   FOCUS RING — keyboard users only, not on click
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--a-primary);
  outline-offset: 2px;
  border-radius: var(--a-radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* ============================================================
   LAYOUT
   ============================================================ */
.admin-wrap {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--a-sidebar-w);
  background: var(--a-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid rgba(255,255,255,0.05);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.18);
}

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 16px 18px;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar-logo-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--a-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 0.875rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}

.sidebar-logo-text {
  font-size: 0.9375rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.sidebar-logo-sub {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.02em;
  font-weight: 500;
  line-height: 1;
  margin-top: 2px;
}

/* Search button in sidebar */
#admin-search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 24px);
  margin: 12px 12px 4px;
  padding: 8px 12px;
  min-height: 36px;
  background: rgba(255,255,255,0.055);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: var(--a-radius-sm);
  color: rgba(255,255,255,0.45);
  font-size: 0.8125rem;
  cursor: pointer;
  text-align: left;
  transition: background var(--a-dur) var(--a-ease), border-color var(--a-dur) var(--a-ease);
  -webkit-tap-highlight-color: transparent;
}
#admin-search-btn:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.65);
}
#admin-search-btn kbd {
  margin-left: auto;
  font-size: 0.625rem;
  padding: 2px 5px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 4px;
  font-family: inherit;
  color: rgba(255,255,255,0.35);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 8px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-section-label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
  padding: 14px 10px 6px;
  margin-top: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  min-height: 38px;
  border-radius: var(--a-radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255,255,255,0.58);
  transition: background var(--a-dur) var(--a-ease), color var(--a-dur) var(--a-ease);
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}

.sidebar-link:hover {
  background: var(--a-sidebar-hover);
  color: rgba(255,255,255,0.9);
}

.sidebar-link.active {
  background: var(--a-sidebar-active);
  color: #fff;
  font-weight: 600;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 25%; bottom: 25%;
  width: 3px;
  background: var(--a-primary);
  border-radius: 0 3px 3px 0;
}

.sidebar-link.active .sidebar-icon { color: #a5b4fc; }

.sidebar-icon {
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.sidebar-badge {
  margin-left: auto;
  background: var(--a-danger);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}

/* Footer / user */
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--a-radius-sm);
  background: rgba(255,255,255,0.04);
  transition: background var(--a-dur) var(--a-ease);
}

.sidebar-user:hover { background: rgba(255,255,255,0.07); }

.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--a-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  line-height: 1.3;
}

.sidebar-user-email {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.42);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   MOBILE SIDEBAR TOGGLE
   ============================================================ */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 200;
  width: 44px; height: 44px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  background: var(--a-sidebar);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--a-radius-sm);
  cursor: pointer;
  transition: background var(--a-dur) var(--a-ease);
  -webkit-tap-highlight-color: transparent;
}

.sidebar-toggle:hover { background: rgba(255,255,255,0.1); }

.sidebar-toggle-bar {
  display: block;
  width: 18px; height: 2px;
  background: rgba(255,255,255,0.75);
  border-radius: 2px;
  transition: transform 0.22s var(--a-ease), opacity 0.22s var(--a-ease);
}

.sidebar-toggle[aria-expanded="true"] .sidebar-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.sidebar-toggle[aria-expanded="true"] .sidebar-toggle-bar:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.sidebar-toggle[aria-expanded="true"] .sidebar-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ============================================================
   SIDEBAR OVERLAY (mobile backdrop)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity var(--a-dur-slow) var(--a-ease);
}
.sidebar-overlay.visible { opacity: 1; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.admin-main {
  margin-left: var(--a-sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.admin-topbar {
  height: 60px;
  background: var(--a-card);
  border-bottom: 1px solid var(--a-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: box-shadow var(--a-dur) var(--a-ease);
  gap: 12px;
}

.admin-topbar.scrolled {
  box-shadow: 0 1px 12px rgba(0,0,0,0.07);
}

.admin-page-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--a-text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Breadcrumb */
.admin-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--a-text-muted);
  margin-bottom: 20px;
}

.admin-breadcrumb a {
  color: var(--a-primary);
  font-weight: 500;
}

.admin-breadcrumb-sep { color: var(--a-border-mid); }

/* ============================================================
   CONTENT AREA
   ============================================================ */
.admin-content {
  padding: 28px 32px;
  flex: 1;
  animation: a-fade-in var(--a-dur-slow) var(--a-ease) both;
}

@keyframes a-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   DASHBOARD STATS GRID
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--a-card);
  border-radius: var(--a-radius);
  padding: 20px;
  box-shadow: var(--a-shadow);
  border: 1px solid var(--a-border);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: box-shadow var(--a-dur) var(--a-ease), transform var(--a-dur) var(--a-ease);
  cursor: default;
}

.stat-card:hover {
  box-shadow: var(--a-shadow-md);
  transform: translateY(-1px);
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--a-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 20px; height: 20px;
  stroke-width: 1.75;
  fill: none;
  stroke: currentColor;
}

.stat-icon.blue   { background: rgba(var(--a-primary-rgb),0.1); color: var(--a-primary); }
.stat-icon.green  { background: rgba(16,185,129,0.1);  color: #059669; }
.stat-icon.purple { background: rgba(139,92,246,0.1);  color: #7c3aed; }
.stat-icon.orange { background: rgba(245,158,11,0.1);  color: #d97706; }
.stat-icon.red    { background: rgba(239,68,68,0.1);   color: var(--a-danger); }

.stat-num {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--a-text);
  line-height: 1;
  letter-spacing: -0.04em;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--a-text-muted);
  margin-top: 3px;
  font-weight: 500;
}

.dashboard-main-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  margin-top: 8px;
}

/* ============================================================
   CARDS
   ============================================================ */
.admin-card {
  background: var(--a-card);
  border-radius: var(--a-radius);
  border: 1px solid var(--a-border);
  box-shadow: var(--a-shadow);
  overflow: hidden;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--a-border);
  gap: 12px;
  min-height: 56px;
}

.admin-card-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--a-text);
  letter-spacing: -0.01em;
}

.admin-card-body {
  padding: 20px;
}

/* ============================================================
   TABLES
   ============================================================ */
.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .admin-table-wrap {
    mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
  }
  .admin-table-wrap::-webkit-scrollbar { height: 3px; }
  .admin-table-wrap::-webkit-scrollbar-track { background: var(--a-border); }
  .admin-table-wrap::-webkit-scrollbar-thumb {
    background: var(--a-primary);
    border-radius: 2px;
  }
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-table thead th {
  background: var(--a-bg);
  padding: 10px 16px;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--a-text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--a-border);
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 1px 0 var(--a-border);
}

.admin-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--a-border);
  vertical-align: middle;
  color: var(--a-text-mid);
}

.admin-table tr:last-child td { border-bottom: none; }

.admin-table tbody tr {
  transition: background var(--a-dur) var(--a-ease);
}

.admin-table tbody tr:hover td {
  background: rgba(var(--a-primary-rgb), 0.025);
}

.admin-table .title-cell {
  font-weight: 600;
  color: var(--a-text);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-table .actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* ============================================================
   PILLS & BADGES
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.4;
}

.pill-green  { background: #ecfdf5; color: #065f46; }
.pill-gray   { background: #f1f5f9; color: #475569; }
.pill-red    { background: #fef2f2; color: #991b1b; }
.pill-blue   { background: var(--a-primary-l); color: var(--a-primary-d); }
.pill-orange { background: #fffbeb; color: #92400e; }
.pill-info   { background: #eff6ff; color: #1d4ed8; }

/* ============================================================
   BUTTONS
   ============================================================ */
.a-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  height: 36px;
  min-width: 36px;
  border-radius: var(--a-radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition:
    background var(--a-dur) var(--a-ease),
    color var(--a-dur) var(--a-ease),
    border-color var(--a-dur) var(--a-ease),
    box-shadow var(--a-dur) var(--a-ease),
    transform var(--a-dur) var(--a-ease);
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  letter-spacing: -0.01em;
}

.a-btn:active { transform: scale(0.97); }

/* Primary */
.a-btn-primary {
  background: var(--a-primary);
  color: #fff;
  border-color: var(--a-primary);
  box-shadow: 0 1px 3px rgba(var(--a-primary-rgb),0.3),
              0 4px 12px rgba(var(--a-primary-rgb),0.2);
}

.a-btn-primary:hover {
  background: var(--a-primary-d);
  border-color: var(--a-primary-d);
  box-shadow: 0 1px 3px rgba(var(--a-primary-rgb),0.4),
              0 6px 16px rgba(var(--a-primary-rgb),0.3);
  transform: translateY(-1px);
}

/* Outline */
.a-btn-outline {
  background: transparent;
  color: var(--a-text-mid);
  border-color: var(--a-border-mid);
}

.a-btn-outline:hover {
  border-color: var(--a-primary);
  color: var(--a-primary);
  background: var(--a-primary-l);
}

/* Danger */
.a-btn-danger {
  background: transparent;
  color: var(--a-danger);
  border-color: rgba(239,68,68,0.3);
}

.a-btn-danger:hover {
  background: var(--a-danger);
  color: #fff;
  border-color: var(--a-danger);
}

/* Success */
.a-btn-success {
  background: transparent;
  color: #059669;
  border-color: rgba(5,150,105,0.3);
}

.a-btn-success:hover {
  background: #059669;
  color: #fff;
  border-color: #059669;
}

/* Small */
.a-btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 0.75rem;
  border-radius: 5px;
}

/* Icon-only */
.a-btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  flex-shrink: 0;
  border-radius: var(--a-radius-sm);
}

/* Icons inside buttons */
.a-btn svg {
  width: 14px; height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* Disabled */
.a-btn:disabled,
.a-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  transform: none !important;
  box-shadow: none !important;
}

/* ============================================================
   FORMS
   ============================================================ */
.a-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.a-form-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.a-form-group { margin-bottom: 0; }

.a-form-group.full { grid-column: 1 / -1; }

.a-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--a-text-mid);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.a-label .required { color: var(--a-danger); margin-left: 2px; }

.a-label .hint {
  font-weight: 400;
  color: var(--a-text-muted);
  font-size: 0.75rem;
  margin-left: 4px;
}

.a-input,
.a-textarea,
.a-select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--a-border-mid);
  border-radius: var(--a-radius-sm);
  font-size: 0.875rem;
  color: var(--a-text);
  background: #fff;
  transition:
    border-color var(--a-dur) var(--a-ease),
    box-shadow var(--a-dur) var(--a-ease);
  outline: none;
  font-family: inherit;
  line-height: 1.5;
}

.a-input:hover, .a-textarea:hover, .a-select:hover {
  border-color: #bfc4d4;
}

.a-input:focus,
.a-textarea:focus,
.a-select:focus {
  border-color: var(--a-primary);
  box-shadow: var(--a-shadow-focus);
  outline: none;
}

.a-input::placeholder,
.a-textarea::placeholder { color: #c0c4d0; }

.a-input:disabled,
.a-textarea:disabled,
.a-select:disabled {
  background: var(--a-bg);
  color: var(--a-text-muted);
  cursor: not-allowed;
  opacity: 0.75;
}

.a-input-sm {
  padding: 7px 10px;
  font-size: 0.8125rem;
  height: 34px;
}

.a-textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.65;
}

.a-textarea-lg { min-height: 220px; }

.a-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* Input prefix group */
.a-input-prefix {
  display: flex;
  border: 1.5px solid var(--a-border-mid);
  border-radius: var(--a-radius-sm);
  overflow: hidden;
  transition: border-color var(--a-dur) var(--a-ease), box-shadow var(--a-dur) var(--a-ease);
}

.a-input-prefix:focus-within {
  border-color: var(--a-primary);
  box-shadow: var(--a-shadow-focus);
}

.a-input-prefix .prefix {
  background: var(--a-bg);
  padding: 9px 11px;
  font-size: 0.8125rem;
  color: var(--a-text-muted);
  border-right: 1.5px solid var(--a-border-mid);
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.a-input-prefix input {
  flex: 1;
  padding: 9px 12px;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.875rem;
  background: transparent;
  color: var(--a-text);
}

/* Toggle */
.a-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.a-toggle input[type="checkbox"] {
  width: 38px; height: 21px;
  appearance: none;
  background: var(--a-border-mid);
  border-radius: 21px;
  cursor: pointer;
  transition: background var(--a-dur) var(--a-ease);
  position: relative;
  flex-shrink: 0;
}

.a-toggle input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: #fff;
  top: 2px; left: 2px;
  transition: transform var(--a-dur) var(--a-ease);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.a-toggle input[type="checkbox"]:checked { background: var(--a-primary); }
.a-toggle input[type="checkbox"]:checked::before { transform: translateX(17px); }

.a-toggle-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--a-text-mid);
}

/* File input */
.a-file-input {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 20px;
  border: 2px dashed var(--a-border-mid);
  border-radius: var(--a-radius);
  cursor: pointer;
  transition: border-color var(--a-dur) var(--a-ease), background var(--a-dur) var(--a-ease);
  text-align: center;
}

.a-file-input:hover {
  border-color: var(--a-primary);
  background: var(--a-primary-l);
}

.a-file-input input[type="file"] { display: none; }

.a-file-icon { width: 32px; height: 32px; color: var(--a-text-muted); }

.a-file-text { font-size: 0.8125rem; color: var(--a-text-muted); }
.a-file-text strong { color: var(--a-primary); }

.a-preview-img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--a-radius-sm);
  border: 1px solid var(--a-border);
  margin-top: 12px;
}

/* Form actions bar */
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 0 0;
  border-top: 1px solid var(--a-border);
  margin-top: 24px;
  flex-wrap: wrap;
}

/* Helper text */
.a-form-hint {
  font-size: 0.75rem;
  color: var(--a-text-muted);
  margin-top: 5px;
  line-height: 1.5;
}

.a-form-error {
  font-size: 0.75rem;
  color: var(--a-danger);
  margin-top: 5px;
  font-weight: 500;
}

.a-input.is-error { border-color: var(--a-danger); box-shadow: 0 0 0 3px rgba(239,68,68,0.12); }
.a-input.is-success { border-color: var(--a-accent); box-shadow: 0 0 0 3px rgba(16,185,129,0.12); }

/* ============================================================
   ALERTS (flash messages)
   ============================================================ */
.a-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--a-radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 20px;
  border-left: 3px solid;
}

.a-alert svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.a-alert-success {
  background: var(--a-success-l);
  border-color: var(--a-accent);
  color: #065f46;
}

.a-alert-error {
  background: var(--a-danger-l);
  border-color: var(--a-danger);
  color: #991b1b;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: var(--a-sidebar);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 560px; height: 560px;
  background: radial-gradient(circle, rgba(99,102,241,0.18) 0%, transparent 70%);
  top: -240px; left: -200px;
  border-radius: 50%;
  pointer-events: none;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 480px; height: 480px;
  background: radial-gradient(circle, rgba(139,92,246,0.14) 0%, transparent 70%);
  bottom: -180px; right: -180px;
  border-radius: 50%;
  pointer-events: none;
}

.login-box {
  width: 100%;
  max-width: 400px;
  position: relative;
  z-index: 1;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
  justify-content: center;
}

.login-logo-mark {
  width: 42px; height: 42px;
  border-radius: 11px;
  background: var(--a-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 8px 24px rgba(99,102,241,0.4);
}

.login-logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.03em;
}

.login-card {
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--a-radius-xl);
  padding: 36px;
}

.login-title {
  font-size: 1.375rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
  letter-spacing: -0.03em;
}

.login-subtitle {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.48);
  margin-bottom: 28px;
  line-height: 1.5;
}

.login-card .a-label { color: rgba(255,255,255,0.65); }

.login-card .a-input {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.1);
  color: #fff;
}

.login-card .a-input:hover { border-color: rgba(255,255,255,0.2); }

.login-card .a-input:focus {
  border-color: rgba(99,102,241,0.7);
  background: rgba(255,255,255,0.09);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.login-card .a-input::placeholder { color: rgba(255,255,255,0.22); }

.login-submit {
  width: 100%;
  height: 44px;
  background: var(--a-grad);
  color: #fff;
  border: none;
  border-radius: var(--a-radius-sm);
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--a-dur) var(--a-ease), box-shadow var(--a-dur) var(--a-ease);
  margin-top: 8px;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
  -webkit-tap-highlight-color: transparent;
}

.login-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(99,102,241,0.5);
}

.login-submit:active { transform: scale(0.98); }

.login-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.38);
}

.login-link a { color: #a5b4fc; font-weight: 600; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 56px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.empty-state-icon {
  width: 48px; height: 48px;
  margin: 0 auto 16px;
  color: var(--a-border-mid);
}

.empty-state-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--a-text);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.empty-state-desc {
  font-size: 0.875rem;
  color: var(--a-text-muted);
  margin-bottom: 20px;
  max-width: 320px;
  line-height: 1.6;
}

/* ============================================================
   MESSAGES
   ============================================================ */
.message-row { transition: background var(--a-dur) var(--a-ease); }
.message-row:hover { background: rgba(var(--a-primary-rgb),0.025); }
.message-row.unread td { background: rgba(var(--a-primary-rgb),0.03); }
.message-row.unread td:first-child { color: var(--a-text); font-weight: 600; }
.message-row.unread { border-left: 3px solid var(--a-primary); }

/* ============================================================
   RESPONSIVE — TABLET
   ============================================================ */
@media (max-width: 900px) {
  :root { --a-sidebar-w: 220px; }
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 900px) {
  .sidebar-toggle { display: flex; }
  .sidebar-overlay { display: block; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100dvh;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform var(--a-dur-slow) var(--a-ease);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-link {
    min-height: 44px;
    padding: 11px 10px;
  }

  .admin-main { margin-left: 0; }

  .admin-content {
    padding: 20px 16px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .admin-topbar {
    padding: 0 16px 0 68px;
    height: 64px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .admin-topbar::-webkit-scrollbar { display: none; }

  .admin-page-title { font-size: 0.9375rem; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .dashboard-main-grid { grid-template-columns: 1fr; }

  .a-form-grid { grid-template-columns: 1fr; }

  .admin-card-header { flex-wrap: wrap; gap: 10px; }

  .login-card { padding: 28px 24px; }

  .admin-table td,
  .admin-table th { padding: 11px 14px; }

  .admin-table .actions {
    flex-wrap: wrap;
    gap: 5px;
  }

  .admin-table .actions .a-btn-sm {
    height: 34px;
    padding: 0 10px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .admin-content { padding: 16px 12px; }

  .stat-card { padding: 16px; }

  .stat-num { font-size: 1.5rem; }

  .admin-card-body { padding: 16px; }

  .admin-card-header { padding: 14px 16px; }

  .topbar-actions .a-btn-sm {
    font-size: 0.7rem;
    padding: 0 8px;
    height: 28px;
  }
}

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

/* ============================================================
   SIDEBAR BADGE PULSE
   ============================================================ */
@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.45); }
  60%       { box-shadow: 0 0 0 4px rgba(239,68,68,0); }
}

.sidebar-badge {
  animation: badge-pulse 2.8s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-badge { animation: none; }
}

/* ============================================================
   KEYBOARD SHORTCUT FOCUS RING — buttons and sidebar links
   ============================================================ */
.a-btn:focus-visible,
.sidebar-link:focus-visible,
.sidebar-toggle:focus-visible {
  outline: 2px solid var(--a-primary);
  outline-offset: 2px;
  border-radius: var(--a-radius-sm);
}

.a-btn:focus:not(:focus-visible),
.sidebar-link:focus:not(:focus-visible),
.sidebar-toggle:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================================
   CARD — HOVERABLE VARIANT
   ============================================================ */
.admin-card.hoverable {
  transition: transform var(--a-dur) var(--a-ease), box-shadow var(--a-dur) var(--a-ease);
  cursor: pointer;
}

.admin-card.hoverable:hover {
  transform: translateY(-2px);
  box-shadow: var(--a-shadow-md);
}

/* ============================================================
   v4 STRIPI OVERRIDES — applied last for specificity
   ============================================================ */

/* Page titles — Stripe weight 300 with negative tracking */
.admin-page-title, .admin-card-title, .stat-num,
h1.admin-h1, h2.admin-h2 {
  font-weight: 300 !important;
  letter-spacing: -0.02em;
  color: var(--a-text);
}
h3, h4 { font-weight: 400; letter-spacing: -0.01em; }

/* Primary buttons — Stripe pill, indigo flat */
.a-btn, .a-btn-primary, .btn-primary {
  border-radius: 9999px !important;
  font-weight: 500;
  padding: 8px 16px;
  font-feature-settings: "ss01";
}
.a-btn-primary, .btn-primary {
  background: var(--a-primary) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: 0 1px 2px rgba(83,58,253,0.18);
}
.a-btn-primary:hover, .btn-primary:hover {
  background: var(--a-primary-d) !important;
  box-shadow: 0 4px 12px rgba(83,58,253,0.28);
}
.a-btn-outline {
  background: #fff !important;
  border: 1px solid var(--a-primary) !important;
  color: var(--a-primary) !important;
  border-radius: 9999px !important;
}
.a-btn-outline:hover { background: var(--a-primary-l) !important; }

/* Admin cards — Stripe hairline + subtle Level-1 shadow */
.admin-card, .stat-card {
  background: var(--a-card) !important;
  border: 1px solid var(--a-border) !important;
  border-radius: var(--a-radius-lg) !important;
  box-shadow: var(--a-shadow-xs);
  color: var(--a-text);
}
.admin-card-header { border-bottom: 1px solid var(--a-border); }

/* Sidebar — deep navy chrome, white text */
.sidebar { background: var(--a-sidebar) !important; }
.sidebar-logo-mark { background: var(--a-primary) !important; border-radius: var(--a-radius-sm); }
.sidebar-link {
  color: rgba(255,255,255,0.7);
  font-weight: 400;
  border-radius: var(--a-radius-sm);
}
.sidebar-link:hover { background: var(--a-sidebar-hover); color: #fff; }
.sidebar-link.active {
  background: var(--a-sidebar-active);
  color: #fff;
  font-weight: 500;
  border-left: 2px solid var(--a-primary);
}
.sidebar-section-label {
  color: rgba(255,255,255,0.45) !important;
  font-weight: 500;
  letter-spacing: 0.1em;
}
.sidebar-user-name { color: #fff; }
.sidebar-user-email { color: rgba(255,255,255,0.55); }
.sidebar-user-avatar { background: var(--a-primary); color: #fff; }
.sidebar-badge { background: var(--a-primary); color: #fff; }

/* Admin topbar */
.admin-topbar {
  background: var(--a-card);
  border-bottom: 1px solid var(--a-border);
  padding: 16px 28px;
}

/* Admin tables — hairline + tnum */
.admin-table { border-collapse: collapse; width: 100%; }
.admin-table th {
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--a-text-muted);
  border-bottom: 1px solid var(--a-border);
  padding: 12px 14px;
  text-align: left;
}
.admin-table td {
  border-bottom: 1px solid var(--a-border);
  padding: 12px 14px;
  font-weight: 300;
}
.admin-table tr:hover td { background: var(--a-bg); }

/* Forms */
.a-input, .a-textarea, .a-select,
input[type="text"], input[type="email"], input[type="tel"],
input[type="date"], input[type="password"], input[type="search"],
input[type="number"], input[type="url"], select, textarea {
  background: #fff !important;
  border: 1px solid var(--a-border-mid) !important;
  border-radius: var(--a-radius-sm) !important;
  color: var(--a-text) !important;
  padding: 8px 12px;
  font-weight: 300;
  font-feature-settings: "ss01";
}
.a-input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--a-primary) !important;
  outline: none !important;
  box-shadow: var(--a-shadow-focus) !important;
}

/* Stat icons — indigo tinted */
.stat-icon.blue, .stat-icon.purple, .stat-icon.green, .stat-icon.orange {
  background: var(--a-primary-l) !important;
  color: var(--a-primary) !important;
  border-radius: var(--a-radius-sm);
}

/* Realtime "active now" pill — indigo */
.an-realtime {
  background: var(--a-primary-l) !important;
  border-color: var(--a-primary-sub, rgba(83,58,253,0.18)) !important;
  color: var(--a-primary-d) !important;
}
.an-realtime .pulse { background: var(--a-primary) !important; }

/* Annotation lines on charts — Stripe ruby instead of amber */
