/* ============================================================
   ProStore Laundry — Theme & Design System
   Modern fintech / SaaS aesthetic. Used across all pages.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500&display=swap');

/* ---------- TOKENS ---------- */
:root {
  /* Brand */
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-300: #a5b4fc;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-800: #3730a3;
  --brand-900: #312e81;

  --accent-500: #8b5cf6;
  --accent-600: #7c3aed;

  /* Semantic */
  --success-50:  #ecfdf5;
  --success-100: #d1fae5;
  --success-500: #10b981;
  --success-600: #059669;
  --success-700: #047857;

  --warning-50:  #fffbeb;
  --warning-100: #fef3c7;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;

  --danger-50:  #fff1f2;
  --danger-100: #ffe4e6;
  --danger-500: #f43f5e;
  --danger-600: #e11d48;
  --danger-700: #be123c;

  --info-50:  #f0f9ff;
  --info-100: #e0f2fe;
  --info-500: #0ea5e9;
  --info-600: #0284c7;
  --info-700: #0369a1;

  /* Neutrals (slate) */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Surfaces */
  --app-bg:     #f6f7fb;
  --surface:    #ffffff;
  --surface-2:  #f8fafc;
  --surface-3:  #f1f5f9;

  /* Text */
  --text:       var(--slate-900);
  --text-muted: var(--slate-500);
  --text-soft:  var(--slate-400);
  --text-on-brand: #ffffff;

  /* Borders */
  --border:        var(--slate-200);
  --border-strong: var(--slate-300);

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .06), 0 2px 4px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .08), 0 4px 6px rgba(15, 23, 42, .03);
  --shadow-xl: 0 20px 50px rgba(15, 23, 42, .12);
  --shadow-glow: 0 0 0 4px rgba(99, 102, 241, .15);

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius:    10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 999px;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Layout */
  --sidebar-w: 256px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 64px;
  --content-max: 1280px;

  /* Transitions */
  --t-fast: 120ms ease;
  --t: 180ms ease;
  --t-slow: 280ms ease;
}

/* ---------- DARK MODE TOKENS ---------- */
html[data-theme="dark"] {
  --app-bg:     #0b1020;
  --surface:    #111729;
  --surface-2:  #1a2236;
  --surface-3:  #232c45;

  --text:       #e6e9f2;
  --text-muted: #94a3b8;
  --text-soft:  #6b7488;
  --text-on-brand: #ffffff;

  --border:        #233048;
  --border-strong: #2f3a55;

  /* Dim semantic backgrounds so pills/alerts don't glow */
  --success-50:  #052e22;
  --success-100: #0a4434;
  --warning-50:  #2a1c08;
  --warning-100: #3d2a0e;
  --danger-50:   #2c0e15;
  --danger-100:  #3f1722;
  --info-50:     #082233;
  --info-100:    #0c3149;
  --brand-50:    #1c2050;
  --brand-100:   #262a64;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4), 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .45), 0 2px 4px rgba(0, 0, 0, .25);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .55), 0 4px 6px rgba(0, 0, 0, .25);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, .65);
  --shadow-glow: 0 0 0 4px rgba(129, 140, 248, .25);
}

/* Dark mode select arrow & search icon — use lighter strokes so they're
   visible against the dark surface. */
html[data-theme="dark"] .select {
  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='%23cbd5e1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}
html[data-theme="dark"] .input--search {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
}
/* Brand mark in sidebar reads OK on dark — but soften its shadow */
html[data-theme="dark"] .sidebar__brand-mark {
  box-shadow: 0 4px 12px rgba(99, 102, 241, .35);
}
/* Auth brand panel is already a gradient; force its text colors */
html[data-theme="dark"] .auth__brand p,
html[data-theme="dark"] .auth__bullets li { color: rgba(255,255,255,.92); }

/* Pill text legibility in dark — most pills use `*-700` text colors which
   are too dark on `*-50` dark surfaces. Brighten the text. */
html[data-theme="dark"] .pill--pending,
html[data-theme="dark"] .pill--partial,
html[data-theme="dark"] .pill--unpaid,
html[data-theme="dark"] .pill--in_process,
html[data-theme="dark"] .pill--in-process,
html[data-theme="dark"] .pill--ready,
html[data-theme="dark"] .pill--completed,
html[data-theme="dark"] .pill--paid,
html[data-theme="dark"] .pill--cancelled,
html[data-theme="dark"] .pill--active,
html[data-theme="dark"] .pill--inactive,
html[data-theme="dark"] .pill--neutral,
html[data-theme="dark"] .pill--brand {
  color: #fff;
}
html[data-theme="dark"] .alert--success { color: #d1fae5; }
html[data-theme="dark"] .alert--warning { color: #fde68a; }
html[data-theme="dark"] .alert--danger  { color: #fecaca; }
html[data-theme="dark"] .alert--info    { color: #bae6fd; }

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.app-body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--app-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* Auth screens use body without app shell */
body { font-family: var(--font-sans); color: var(--text); }
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }
p  { margin: 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); background-clip: content-box; border: 2px solid transparent; }

/* ---------- APP SHELL ---------- */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
}
.app__sidebar,
.app > .sidebar  { grid-area: sidebar; }
.app__topbar,
.app > .topbar   { grid-area: topbar; }
.app__main       { grid-area: main; padding: var(--space-6) var(--space-8); }

@media (max-width: 1024px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .app__main { padding: var(--space-5); }
}
@media (max-width: 600px) {
  .app__main { padding: var(--space-4); }
}

.page-container {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* Page header */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.page-head h1 { font-size: 1.5rem; }
.page-head__sub { color: var(--text-muted); font-size: 0.9375rem; margin-top: 2px; }
.page-head__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- CARDS ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}
.card--pad { padding: var(--space-6); }
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}
.card__head h2 { font-size: 1rem; font-weight: 600; }
.card__body { padding: var(--space-5) var(--space-6); }

/* ---------- KPI CARDS ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.kpi {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.kpi__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}
.kpi__label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}
.kpi__icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand-50);
  color: var(--brand-600);
  flex-shrink: 0;
}
.kpi__icon svg { width: 18px; height: 18px; }
.kpi__icon--success { background: var(--success-50); color: var(--success-600); }
.kpi__icon--warning { background: var(--warning-50); color: var(--warning-600); }
.kpi__icon--danger  { background: var(--danger-50);  color: var(--danger-600); }
.kpi__icon--info    { background: var(--info-50);    color: var(--info-600); }
.kpi__icon--accent  { background: #f5f3ff;           color: var(--accent-600); }

.kpi__value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.kpi__delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--space-2);
  font-size: 0.8125rem;
  font-weight: 500;
}
.kpi__delta--up   { color: var(--success-600); }
.kpi__delta--down { color: var(--danger-600); }
.kpi__delta--flat { color: var(--text-muted); }

/* ---------- BUTTONS ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border);
  --btn-bg-hover: var(--surface-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--t), border-color var(--t), color var(--t), box-shadow var(--t), transform var(--t-fast);
  user-select: none;
}
.btn:hover { background: var(--btn-bg-hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-glow); }
.btn svg { width: 16px; height: 16px; }

.btn--primary {
  --btn-bg: var(--brand-600);
  --btn-fg: #fff;
  --btn-border: var(--brand-600);
  --btn-bg-hover: var(--brand-700);
  box-shadow: var(--shadow-sm);
}
.btn--success {
  --btn-bg: var(--success-600);
  --btn-fg: #fff;
  --btn-border: var(--success-600);
  --btn-bg-hover: var(--success-700);
}
.btn--danger {
  --btn-bg: var(--danger-600);
  --btn-fg: #fff;
  --btn-border: var(--danger-600);
  --btn-bg-hover: var(--danger-700);
}
.btn--ghost { --btn-border: transparent; }
.btn--ghost:hover { background: var(--surface-3); }

.btn--sm { padding: 5px 10px; font-size: 0.8125rem; }
.btn--lg { padding: 11px 18px; font-size: 0.9375rem; }
.btn--block { width: 100%; }
.btn[disabled], .btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Icon-only button */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn--danger:hover { background: var(--danger-50); color: var(--danger-600); border-color: var(--danger-100); }
.icon-btn--success:hover { background: var(--success-50); color: var(--success-600); border-color: var(--success-100); }

/* ---------- FORM CONTROLS ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 0.8125rem; font-weight: 500; color: var(--slate-700); }
.field__hint  { font-size: 0.75rem; color: var(--text-muted); }
.field__error { font-size: 0.75rem; color: var(--danger-600); }

.input,
.select,
.textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--shadow-glow);
}
.input::placeholder, .textarea::placeholder { color: var(--text-soft); }
.select {
  appearance: none;
  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 10px center;
  padding-right: 32px;
}

.input--search {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  background-repeat: no-repeat;
  background-position: 12px center;
  padding-left: 38px;
}

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  margin-bottom: var(--space-5);
}
.filter-bar > .field {
  flex: 1 1 160px;
  min-width: 0;
}
.filter-bar > .field:first-child { flex: 2 1 260px; }
.filter-bar > div:last-child { display: flex; gap: 6px; flex-shrink: 0; }

@media (max-width: 600px) {
  .filter-bar > .field { flex: 1 1 100%; }
  .filter-bar > div:last-child { width: 100%; }
  .filter-bar > div:last-child .btn { flex: 1; }
}

/* ---------- STATUS PILLS ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1.4;
}
.pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
.pill--pending     { background: var(--warning-50);  color: var(--warning-700); border-color: var(--warning-100); }
.pill--in_process,
.pill--in-process,
.pill--processing  { background: var(--info-50);     color: var(--info-700);    border-color: var(--info-100); }
.pill--ready       { background: #f5f3ff;            color: var(--accent-600);  border-color: #ede9fe; }
.pill--completed   { background: var(--success-50);  color: var(--success-700); border-color: var(--success-100); }
.pill--cancelled,
.pill--canceled    { background: var(--danger-50);   color: var(--danger-700);  border-color: var(--danger-100); }

.pill--paid        { background: var(--success-50);  color: var(--success-700); border-color: var(--success-100); }
.pill--partial     { background: var(--warning-50);  color: var(--warning-700); border-color: var(--warning-100); }
.pill--unpaid      { background: var(--danger-50);   color: var(--danger-700);  border-color: var(--danger-100); }

.pill--active      { background: var(--success-50);  color: var(--success-700); border-color: var(--success-100); }
.pill--inactive    { background: var(--slate-100);   color: var(--slate-600);   border-color: var(--slate-200); }

.pill--neutral     { background: var(--slate-100);   color: var(--slate-700);   border-color: var(--slate-200); }
.pill--brand       { background: var(--brand-50);    color: var(--brand-700);   border-color: var(--brand-100); }

/* ---------- TABLE ---------- */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.table-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  gap: var(--space-3);
  flex-wrap: wrap;
}
.table-card__head h2 { font-size: 1rem; font-weight: 600; }
.table-scroll { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}
.table th, .table td {
  padding: 12px 16px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: nowrap; }

.table-foot {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.8125rem;
  background: var(--surface-2);
}

/* ---------- AVATAR ---------- */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand-100);
  color: var(--brand-700);
  display: inline-grid;
  place-items: center;
  font-weight: 600;
  font-size: 0.75rem;
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar--lg { width: 44px; height: 44px; font-size: 0.875rem; }
.avatar--sm { width: 24px; height: 24px; font-size: 0.6875rem; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell__name { font-weight: 600; color: var(--text); }
.user-cell__sub  { color: var(--text-muted); font-size: 0.75rem; }

/* ---------- ALERTS / TOASTS ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: var(--space-4);
  border: 1px solid;
}
.alert__icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 2px; }
.alert--success { background: var(--success-50);  color: var(--success-700); border-color: var(--success-100); }
.alert--warning { background: var(--warning-50);  color: var(--warning-700); border-color: var(--warning-100); }
.alert--danger  { background: var(--danger-50);   color: var(--danger-700);  border-color: var(--danger-100); }
.alert--info    { background: var(--info-50);     color: var(--info-700);    border-color: var(--info-100); }

/* ---------- EMPTY STATE ---------- */
.empty {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}
.empty__icon {
  width: 56px; height: 56px;
  margin: 0 auto var(--space-4);
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--text-soft);
}
.empty__title { font-weight: 600; color: var(--text); margin-bottom: 4px; font-size: 0.9375rem; }
.empty__desc { font-size: 0.875rem; }

/* ---------- QUICK ACTION TILES ---------- */
.quick-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.quick-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  transition: all var(--t);
  box-shadow: var(--shadow-xs);
}
.quick-tile:hover {
  border-color: var(--brand-300);
  background: var(--brand-50);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}
.quick-tile__icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand-50);
  color: var(--brand-600);
  flex-shrink: 0;
  transition: all var(--t);
}
.quick-tile:hover .quick-tile__icon { background: var(--brand-600); color: #fff; }
.quick-tile__icon svg { width: 18px; height: 18px; }
.quick-tile__label { font-size: 0.875rem; font-weight: 600; }
.quick-tile__sub   { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ---------- WIDGET GRID (dashboard) ---------- */
.widget-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-5);
}
@media (max-width: 1024px) {
  .widget-grid { grid-template-columns: 1fr; }
}

/* ---------- PAGINATION ---------- */
.pagination {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pagination a, .pagination span {
  display: inline-grid; place-items: center;
  min-width: 32px; height: 32px;
  padding: 0 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--t);
}
.pagination a:hover { background: var(--surface-3); border-color: var(--border-strong); }
.pagination a.active, .pagination .active { background: var(--brand-600); color: #fff; border-color: var(--brand-600); pointer-events: none; }

/* ---------- UTILITIES ---------- */
.muted { color: var(--text-muted); }
.soft  { color: var(--text-soft); }
.mono  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.bold { font-weight: 600; }
.divider { height: 1px; background: var(--border); margin: var(--space-5) 0; border: 0; }

.hidden-mobile { display: initial; }
.show-mobile   { display: none; }
@media (max-width: 768px) {
  .hidden-mobile { display: none; }
  .show-mobile   { display: initial; }
}

/* ---------- AUTH SCREEN ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--app-bg);
}
.auth__panel {
  display: grid;
  place-items: center;
  padding: var(--space-12);
}
.auth__brand {
  background:
    radial-gradient(at 20% 20%, rgba(139, 92, 246, .25), transparent 50%),
    radial-gradient(at 80% 80%, rgba(99, 102, 241, .35), transparent 55%),
    linear-gradient(135deg, var(--brand-700), var(--brand-900));
  color: #fff;
  position: relative;
  overflow: hidden;
}
.auth__brand-inner { max-width: 460px; }
.auth__brand h2 { color: #fff; font-size: 2rem; margin-bottom: var(--space-3); }
.auth__brand p  { color: rgba(255,255,255,.85); font-size: 1rem; line-height: 1.6; }
.auth__form { width: 100%; max-width: 420px; }
.auth__form h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth__form p.lead { color: var(--text-muted); margin-bottom: var(--space-6); }
.auth__logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.125rem; color: #fff;
  margin-bottom: var(--space-8);
}
.auth__logo-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,.15);
  display: grid; place-items: center;
  backdrop-filter: blur(8px);
}
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth__brand { display: none; }
}

/* ---------- TOAST NOTIFICATIONS ---------- */
.toast-region {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  min-width: 280px;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  color: var(--text);
  pointer-events: auto;
  animation: toast-in 220ms cubic-bezier(.16,1,.3,1);
  will-change: transform, opacity;
}
.toast--leaving { animation: toast-out 180ms ease forwards; }
.toast__icon {
  flex-shrink: 0;
  width: 20px; height: 20px;
  border-radius: 6px;
  display: grid; place-items: center;
}
.toast__icon svg { width: 14px; height: 14px; }
.toast__body { flex: 1; line-height: 1.4; }
.toast__close {
  background: transparent;
  border: 0;
  color: var(--text-soft);
  cursor: pointer;
  padding: 2px;
  margin: -2px -2px 0 0;
  border-radius: 4px;
  flex-shrink: 0;
}
.toast__close:hover { color: var(--text); background: var(--surface-3); }
.toast__close svg { width: 14px; height: 14px; display: block; }

.toast--success .toast__icon { background: var(--success-100); color: var(--success-600); }
.toast--danger  .toast__icon { background: var(--danger-100);  color: var(--danger-600); }
.toast--warning .toast__icon { background: var(--warning-100); color: var(--warning-600); }
.toast--info    .toast__icon { background: var(--info-100);    color: var(--info-600); }

.toast--success { border-left: 3px solid var(--success-500); }
.toast--danger  { border-left: 3px solid var(--danger-500); }
.toast--warning { border-left: 3px solid var(--warning-500); }
.toast--info    { border-left: 3px solid var(--info-500); }

@keyframes toast-in {
  from { transform: translateY(8px) scale(.98); opacity: 0; }
  to   { transform: translateY(0)    scale(1);   opacity: 1; }
}
@keyframes toast-out {
  from { transform: translateY(0)   scale(1);   opacity: 1; }
  to   { transform: translateY(-8px) scale(.98); opacity: 0; }
}

/* ---------- LEGACY PHP MESSAGES (compat shim) ---------- */
.success-msg, .error-msg {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  font-size: 0.875rem;
  border: 1px solid;
}
.success-msg { background: var(--success-50); color: var(--success-700); border-color: var(--success-100); }
.error-msg   { background: var(--danger-50);  color: var(--danger-700);  border-color: var(--danger-100); }

/* ============================================================
   COMPAT LAYER — neutralize legacy page wrappers
   For pages still using their old per-page CSS that wraps content
   in a card (services-page, settings-page, users-page, etc.). The
   shell already provides the centered content area, so we flatten
   the wrapper and strip its borrowed card chrome.
   ============================================================ */
body.app-body .services-page,
body.app-body .settings-page,
body.app-body .users-page,
body.app-body .profile-page,
body.app-body .levels-page,
body.app-body .staff-page,
body.app-body .inventory-page,
body.app-body .analytics-page,
body.app-body .order-page,
body.app-body .crm-page,
body.app-body .dashboard-page,
body.app-body .history-inventory-page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}
/* Legacy headers inside those wrappers */
body.app-body .services-header h1,
body.app-body .settings-header h1,
body.app-body .users-header h1,
body.app-body .profile-header h1,
body.app-body .levels-header h1 {
  color: var(--text);
  font-size: 1.5rem;
}

/* Legacy buttons — map to new look */
body.app-body .btn-primary {
  background: var(--brand-600);
  color: #fff;
  border: 0;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t);
  display: inline-flex; align-items: center; gap: 6px;
}
body.app-body .btn-primary:hover { background: var(--brand-700); }
body.app-body .btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
}
body.app-body .btn-add {
  background: var(--success-600);
  color: #fff;
  border: 0;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
body.app-body .btn-add:hover { background: var(--success-700); }

/* Legacy tbl-btn pattern → pill-shaped action buttons */
body.app-body .tbl-btn {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--brand-700);
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  margin-right: 4px;
  transition: all var(--t);
}
body.app-body .tbl-btn:hover { background: var(--brand-100); }
body.app-body .tbl-btn.warn { color: var(--danger-700); background: var(--danger-50); border-color: var(--danger-100); }
body.app-body .tbl-btn.warn:hover { background: var(--danger-100); }
body.app-body .tbl-btn.ok { color: var(--success-700); background: var(--success-50); border-color: var(--success-100); }
body.app-body .tbl-btn.ok:hover { background: var(--success-100); }

/* Legacy tables — global polish */
body.app-body table.services-table,
body.app-body table.levels-table,
body.app-body table.users-table,
body.app-body table.staff-table,
body.app-body table.inventory-table,
body.app-body table.settings-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
body.app-body table.services-table th,
body.app-body table.services-table td,
body.app-body table.levels-table th,
body.app-body table.levels-table td,
body.app-body table.users-table th,
body.app-body table.users-table td,
body.app-body table.staff-table th,
body.app-body table.staff-table td,
body.app-body table.inventory-table th,
body.app-body table.inventory-table td,
body.app-body table.settings-table th,
body.app-body table.settings-table td {
  padding: 12px 16px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border);
}
body.app-body table.services-table thead th,
body.app-body table.levels-table thead th,
body.app-body table.users-table thead th,
body.app-body table.staff-table thead th,
body.app-body table.inventory-table thead th,
body.app-body table.settings-table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
body.app-body table.services-table tbody tr:hover,
body.app-body table.levels-table tbody tr:hover,
body.app-body table.users-table tbody tr:hover,
body.app-body table.staff-table tbody tr:hover,
body.app-body table.inventory-table tbody tr:hover,
body.app-body table.settings-table tbody tr:hover { background: var(--surface-2); }
body.app-body table.services-table tbody tr:last-child td,
body.app-body table.levels-table tbody tr:last-child td,
body.app-body table.users-table tbody tr:last-child td,
body.app-body table.staff-table tbody tr:last-child td,
body.app-body table.inventory-table tbody tr:last-child td,
body.app-body table.settings-table tbody tr:last-child td { border-bottom: 0; }

/* Legacy h1 / section headings inside pages — softer color */
body.app-body main h1 { color: var(--text); }
body.app-body main h2 { color: var(--text); }

/* Generic form-row patterns from legacy pages */
body.app-body main form input[type="text"],
body.app-body main form input[type="email"],
body.app-body main form input[type="number"],
body.app-body main form input[type="date"],
body.app-body main form input[type="password"],
body.app-body main form input[type="tel"],
body.app-body main form input[type="search"],
body.app-body main form input[type="url"],
body.app-body main form select,
body.app-body main form textarea {
  /* Only apply if the input doesn't already have an explicit class */
  font-family: var(--font-sans);
  font-size: 0.875rem;
}
body.app-body main form input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not(.input):not(.select):not(.qty-input):focus,
body.app-body main form select:not(.select):focus,
body.app-body main form textarea:not(.textarea):focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--shadow-glow);
}

/* Legacy pagination links */
body.app-body nav.pagination > a { font-family: var(--font-sans); }

/* Legacy KPI cards (CRM-style spans/smalls) */
body.app-body .kpi-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
body.app-body .kpi-wrap .kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
  text-align: left;
}
body.app-body .kpi-wrap .kpi-card span {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
body.app-body .kpi-wrap .kpi-card small {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Status labels (active / inactive text used widely) */
body.app-body .status-active   { color: var(--success-700); font-weight: 600; }
body.app-body .status-inactive { color: var(--danger-700);  font-weight: 600; }

/* Catch-all polish for any <table> inside a page-container that didn't
   get a specific class above. Lower specificity, so the more-specific
   rules above win. */
body.app-body .page-container table:not(.table):not(.cart-table) {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  margin: var(--space-3) 0 var(--space-5);
}
body.app-body .page-container table:not(.table):not(.cart-table) th,
body.app-body .page-container table:not(.table):not(.cart-table) td {
  padding: 12px 16px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
body.app-body .page-container table:not(.table):not(.cart-table) thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
body.app-body .page-container table:not(.table):not(.cart-table) tbody tr:hover { background: var(--surface-2); }
body.app-body .page-container table:not(.table):not(.cart-table) tbody tr:last-child td { border-bottom: 0; }

/* Legacy ".action-btn" used on users page */
body.app-body .action-btn {
  display: inline-flex; align-items: center;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--t);
}
body.app-body .action-btn:hover { background: var(--surface-3); border-color: var(--border-strong); }

/* Map .danger / .deactivate-btn / .submit-btn legacy color classes */
body.app-body .danger-btn, body.app-body .deactivate-btn,
body.app-body button.deactivate, body.app-body a.deactivate {
  background: var(--danger-600);
  color: #fff;
  border: 0;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
body.app-body .danger-btn:hover, body.app-body .deactivate-btn:hover,
body.app-body button.deactivate:hover, body.app-body a.deactivate:hover { background: var(--danger-700); }
