/* ============================================================
   VPS Client Management Panel — Admin UI Stylesheet
   PHP 8.2 compatible · Premium SaaS Dashboard
   ============================================================
   Sections:
    1.  Reset & Tokens (colors, spacing, typography)
    2.  Theme: dark (default) + light
    3.  Layout: sidebar + main-wrap
    4.  Topbar
    5.  Sidebar nav
    6.  Content area
    7.  Cards & sections
    8.  KPI grid
    9.  Forms & inputs
    10. Buttons
    11. Tables
    12. Badges & chips
    13. Lists (clients/activities)
    14. Modals
    15. Toasts
    16. Alerts & flash
    17. Filters & pagination
    18. Utility classes
    19. Responsive breakpoints
    20. Animations
    21. Login page
    22. Print
   ============================================================ */

/* ============================================================
   1. RESET & TOKENS
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; padding: 0; }
img, svg, video { max-width: 100%; height: auto; display: block; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

:root {
  /* Spacing */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;

  /* Shadow */
  --sh-sm: 0 1px 2px rgba(0,0,0,.06);
  --sh-md: 0 4px 12px rgba(0,0,0,.08);
  --sh-lg: 0 12px 32px rgba(0,0,0,.14);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;

  /* Brand */
  --brand: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-soft: rgba(99,102,241,.14);

  /* Semantic */
  --green: #10b981;
  --green-soft: rgba(16,185,129,.15);
  --amber: #f59e0b;
  --amber-soft: rgba(245,158,11,.15);
  --red: #ef4444;
  --red-soft: rgba(239,68,68,.15);
  --blue: #3b82f6;
  --blue-soft: rgba(59,130,246,.15);
  --teal: #14b8a6;
  --teal-soft: rgba(20,184,166,.15);
  --purple: #a855f7;
  --purple-soft: rgba(168,85,247,.15);

  /* Layout */
  --sidebar-w: 260px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 68px;

  /* Transitions */
  --t-fast: 140ms ease;
  --t-base: 220ms ease;
  --t-slow: 360ms cubic-bezier(.4,0,.2,1);
}

/* ============================================================
   2. THEMES
   ============================================================ */
:root,
[data-theme="dark"] {
  --bg: #0f172a;
  --bg-2: #111c33;
  --surface: #1a2438;
  --surface-2: #212e47;
  --surface-3: #2a3854;
  --border: #2e3b53;
  --border-soft: rgba(255,255,255,.06);
  --text: #e5ecf7;
  --text-2: #b3bfd4;
  --muted: #7e8ca6;
  --input-bg: #141d30;
  --shadow-color: rgba(0,0,0,.4);
}

[data-theme="light"] {
  --bg: #f5f7fb;
  --bg-2: #eef2f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eff3f9;
  --border: #e4e8ef;
  --border-soft: rgba(0,0,0,.05);
  --text: #0f172a;
  --text-2: #3a4a63;
  --muted: #6b7a90;
  --input-bg: #ffffff;
  --shadow-color: rgba(15,23,42,.08);
}

/* ============================================================
   3. BODY + LAYOUT
   ============================================================ */
body {
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  transition: background var(--t-base), color var(--t-base);
}

.admin-body {
  display: flex;
  min-height: 100vh;
}

.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-w);
  transition: margin-left var(--t-base);
}

html[data-sidebar="collapsed"] .main-wrap {
  margin-left: var(--sidebar-w-collapsed);
}

/* ============================================================
   4. TOPBAR
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border-soft);
}

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  transition: all var(--t-fast);
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

/* Theme toggle icon swap */
.theme-icon { font-size: 16px; line-height: 1; }
[data-theme="dark"]  .theme-icon-dark  { display: none; }
[data-theme="light"] .theme-icon-light { display: none; }

/* User menu */
.user-menu { position: relative; }
.user-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 40px;
  padding: 4px 10px 4px 6px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  transition: background var(--t-fast);
}
.user-btn:hover { background: var(--surface-3); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--purple));
  color: #fff;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: .5px;
}
.avatar.lg { width: 40px; height: 40px; font-size: 15px; }

.user-name {
  font-weight: 600;
  font-size: 13.5px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  padding: var(--sp-2);
  display: none;
  z-index: 100;
  animation: slideDown var(--t-base);
}
.user-menu.is-open .user-dropdown { display: block; }

.user-dropdown-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: var(--sp-2);
}
.user-dropdown-head strong { display: block; font-size: 13.5px; }
.user-dropdown-head small { color: var(--muted); font-size: 12px; }

.user-dropdown a,
.user-dropdown button {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: 9px var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--text-2);
  background: transparent;
  border: none;
  text-align: left;
  font-size: 13.5px;
  transition: background var(--t-fast), color var(--t-fast);
}
.user-dropdown a:hover,
.user-dropdown button:hover { background: var(--surface-2); color: var(--text); }

.dropdown-divider { height: 1px; background: var(--border-soft); margin: var(--sp-2) 0; }
.dropdown-danger { color: var(--red) !important; }
.dropdown-danger:hover { background: var(--red-soft) !important; }

/* ============================================================
   5. SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transition: width var(--t-base), transform var(--t-base);
}
html[data-sidebar="collapsed"] .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  height: var(--topbar-h);
  padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}
.brand-logo,
.brand-logo-fallback {
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  flex: 0 0 34px;
}
.brand-logo { object-fit: cover; }
.brand-logo-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand), var(--purple));
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}
.brand-name {
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-sidebar="collapsed"] .brand-name,
html[data-sidebar="collapsed"] .sidebar-footer { display: none; }

.sidebar-close { display: none; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-3) var(--sp-2);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.nav-group { margin-bottom: var(--sp-3); }
.nav-group-label {
  padding: var(--sp-2) var(--sp-3);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-3);
  margin: 2px 4px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-weight: 500;
  font-size: 13.5px;
  transition: all var(--t-fast);
  position: relative;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.is-active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: var(--brand);
}
.nav-icon {
  flex: 0 0 20px;
  display: inline-flex;
  color: currentColor;
}
.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-sidebar="collapsed"] .nav-label { display: none; }

.nav-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--r-full);
}

.sidebar-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--muted);
}
.sidebar-tip { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.sidebar-tip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
  animation: pulse 2s infinite;
}
.sidebar-links a { color: var(--muted); }
.sidebar-links a:hover { color: var(--brand); }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 55;
  animation: fadeIn var(--t-base);
}

/* ============================================================
   6. CONTENT AREA
   ============================================================ */
.content {
  flex: 1;
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  max-width: 100%;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 12.5px;
}
.page-footer a { color: var(--muted); }
.page-footer a:hover { color: var(--brand); }
.page-footer .sep { margin: 0 var(--sp-2); }

/* ============================================================
   7. CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--sh-sm);
  transition: box-shadow var(--t-base), transform var(--t-base);
}
.card-highlight {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-soft);
}
.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.1px;
}
.card-head h2 small {
  font-weight: 500;
  color: var(--muted);
  font-size: 12.5px;
}
.card-head .link-sm {
  font-size: 12.5px;
  color: var(--brand);
  font-weight: 600;
}
.card-head .link-sm:hover { text-decoration: underline; }

.card-body { padding: var(--sp-5); }
.card-body.p-0 { padding: 0; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--sp-5);
}

/* ============================================================
   8. KPI GRID
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--sp-4);
}
.kpi-grid-tight { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.kpi-card {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  color: var(--text);
  transition: all var(--t-base);
  position: relative;
  overflow: hidden;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
  border-color: var(--border);
}
.kpi-card::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--brand);
}

.kpi-card.accent-indigo::after  { background: #6366f1; }
.kpi-card.accent-green::after   { background: var(--green); }
.kpi-card.accent-amber::after   { background: var(--amber); }
.kpi-card.accent-red::after     { background: var(--red); }
.kpi-card.accent-blue::after    { background: var(--blue); }
.kpi-card.accent-teal::after    { background: var(--teal); }
.kpi-card.accent-emerald::after { background: #059669; }
.kpi-card.accent-purple::after  { background: var(--purple); }

.kpi-icon { font-size: 22px; }
.kpi-body { flex: 1; min-width: 0; }
.kpi-value {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.1;
}
.kpi-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.kpi-arrow {
  color: var(--muted);
  font-size: 16px;
  transition: transform var(--t-fast);
}
.kpi-card:hover .kpi-arrow { transform: translateX(3px); color: var(--brand); }

/* Revenue strip */
.rev-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-4);
  padding: var(--sp-5);
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
}
.rev-item { padding: 0 var(--sp-3); border-right: 1px solid var(--border-soft); }
.rev-item:last-child { border-right: none; }
.rev-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.rev-value { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.trend-up { color: var(--green); }
.trend-down { color: var(--red); }

/* Detail stats row */
.detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
}
.detail-stat { padding: var(--sp-2) var(--sp-3); }
.detail-stat-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.detail-stat-value { font-size: 15px; font-weight: 700; }

/* ============================================================
   9. FORMS
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-4) var(--sp-5);
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--sp-4);
}
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.form-group label small { font-weight: 400; color: var(--muted); }
.req { color: var(--red); }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13.5px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
input:read-only {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}
textarea { resize: vertical; min-height: 80px; font-family: inherit; }

.has-error input,
.has-error select,
.has-error textarea { border-color: var(--red); }
.field-error {
  color: var(--red);
  font-size: 12px;
  margin-top: 2px;
}
.field-hint {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 2px;
}
.field-hint code {
  background: var(--surface-3);
  padding: 1px 5px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-family: var(--font-mono);
}

/* Inputs with prefix (currency) */
.input-prefix { position: relative; }
.input-prefix .prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  pointer-events: none;
}
.input-prefix input { padding-left: 32px; }

/* Inputs with trailing eye button */
.input-group { position: relative; }
.btn-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 14px;
  color: var(--muted);
  padding: 4px 6px;
  border-radius: var(--r-sm);
}
.btn-eye:hover { color: var(--text); background: var(--surface-2); }

/* Copy row (link + copy button) */
.copy-row,
.share-row {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  align-items: stretch;
}
.copy-row input,
.share-row input { flex: 1; min-width: 200px; font-family: var(--font-mono); font-size: 12.5px; }
.share-row { margin-bottom: var(--sp-4); }

/* Switches */
.switch-label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  user-select: none;
}
.switch-label input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  position: relative;
  display: inline-block;
  width: 40px; height: 22px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  transition: background var(--t-base);
  flex: 0 0 40px;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t-base);
  box-shadow: var(--sh-sm);
}
.switch-label input:checked + .switch { background: var(--brand); }
.switch-label input:checked + .switch::after { transform: translateX(18px); }
.switch-text { font-size: 13.5px; color: var(--text-2); }
.switch-text small { color: var(--muted); font-size: 11.5px; }

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.toggle-group { grid-column: 1 / -1; }

/* Chip checkboxes (reminder days) */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12.5px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.chip-check:hover { border-color: var(--brand); }
.chip-check input { margin: 0; }
.chip-check:has(input:checked) {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}

/* Event tiles (telegram) */
.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-3);
}
.event-tile {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
}
.event-tile:hover { border-color: var(--brand); }
.event-tile.is-checked {
  background: var(--brand-soft);
  border-color: var(--brand);
}
.event-tile input { margin: 0; }
.event-tile-body { display: flex; flex-direction: column; }
.event-tile-title { font-size: 13px; font-weight: 600; }
.event-tile-key { font-size: 11px; color: var(--muted); }

/* Upload preview */
.upload-preview {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-2);
}
.upload-preview img { border-radius: var(--r-sm); background: var(--surface-3); }
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

/* Form actions */
.form-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) 0;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, transparent, var(--bg) 60%);
  z-index: 20;
}
.form-actions .spacer { flex: 1; }

/* Key-value lists */
.kv {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr;
  gap: var(--sp-2) var(--sp-4);
  margin: 0;
}
.kv dt {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 0;
}
.kv dd {
  margin: 0;
  padding: 6px 0;
  word-break: break-word;
}

.notes-box {
  background: var(--surface-2);
  border-left: 3px solid var(--brand);
  padding: var(--sp-3) var(--sp-4);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Tabs */
.tabs {
  display: flex;
  gap: var(--sp-1);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  overflow-x: auto;
}
.tab {
  padding: 8px 16px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: all var(--t-fast);
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.is-active { background: var(--brand); color: #fff; }

.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fadeIn var(--t-base); }

/* Steps list */
.steps {
  margin: 0;
  padding-left: var(--sp-6);
  color: var(--text-2);
  font-size: 13.5px;
}
.steps li { margin-bottom: var(--sp-3); }

/* ============================================================
   10. BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--t-fast);
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled,
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none !important; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #059669; }

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

.btn-warning { background: var(--amber); color: #fff; }
.btn-warning:hover { background: #d97706; }

.btn-info { background: var(--blue); color: #fff; }
.btn-info:hover { background: #2563eb; }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-xs { padding: 5px 10px; font-size: 11.5px; border-radius: var(--r-sm); }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: var(--r-md); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 14px;
  transition: all var(--t-fast);
}
.btn-icon:hover { background: var(--surface-2); color: var(--brand); border-color: var(--brand); }

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

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table thead th {
  text-align: left;
  padding: 12px 16px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr { transition: background var(--t-fast); }
.table-hover tbody tr:hover { background: var(--surface-2); }
.table-sm thead th,
.table-sm tbody td { padding: 10px 14px; }

.cell-title {
  font-weight: 600;
  color: var(--text);
  font-size: 13.5px;
}
.cell-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.cell-title a { color: inherit; }
.cell-title a:hover { color: var(--brand); }

.th-check { width: 40px; }
.th-actions { text-align: right; width: 60px; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.arrow { color: var(--muted); padding: 0 6px; }

.th-sort {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 700;
}
.th-sort:hover { color: var(--brand); }

/* Row actions menu */
.row-actions { position: relative; display: inline-block; }
.row-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  padding: var(--sp-2);
  z-index: 100;
  animation: slideDown var(--t-base);
}
.row-menu a,
.row-menu button {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  background: transparent;
  border: none;
  text-align: left;
  font-size: 13px;
  transition: background var(--t-fast), color var(--t-fast);
}
.row-menu a:hover,
.row-menu button:hover { background: var(--surface-2); color: var(--text); }
.row-menu .menu-sep {
  height: 1px;
  background: var(--border-soft);
  margin: var(--sp-2) 0;
}
.row-menu .menu-disabled {
  display: block;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 12.5px;
  font-style: italic;
}
.inline-action { display: inline; }
.inline-action button { all: unset; display: flex; align-items: center; gap: var(--sp-2); width: 100%; padding: 8px 12px; border-radius: var(--r-sm); color: var(--text-2); font-size: 13px; cursor: pointer; }
.inline-action button:hover { background: var(--surface-2); color: var(--text); }
.inline-action button.dropdown-danger { color: var(--red); }
.inline-action button.dropdown-danger:hover { background: var(--red-soft); }
.inline-form { display: inline; margin: 0; }

/* ============================================================
   12. BADGES & CHIPS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-lg { padding: 5px 12px; font-size: 12.5px; }

.badge-success { background: var(--green-soft);  color: #059669; }
.badge-warning { background: var(--amber-soft);  color: #b45309; }
.badge-danger  { background: var(--red-soft);    color: #dc2626; }
.badge-info    { background: var(--blue-soft);   color: #2563eb; }
.badge-muted   { background: var(--surface-3);   color: var(--muted); }

[data-theme="dark"] .badge-success { color: #34d399; }
[data-theme="dark"] .badge-warning { color: #fbbf24; }
[data-theme="dark"] .badge-danger  { color: #f87171; }
[data-theme="dark"] .badge-info    { color: #60a5fa; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: 12px;
  color: var(--text-2);
  margin: 2px 4px 2px 0;
}
.chip-static { cursor: default; }
.chip a { color: var(--muted); font-weight: 700; }
.chip a:hover { color: var(--red); }

/* ============================================================
   13. LISTS (clients/activities)
   ============================================================ */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border-soft);
  transition: background var(--t-fast);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-2); }
.list-main { flex: 1; min-width: 0; }
.list-side {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex: 0 0 auto;
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.activity-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border-soft);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  flex: 0 0 34px;
  font-size: 15px;
}
.activity-icon-inline { margin-right: 6px; }
.activity-main { flex: 1; min-width: 0; }
.activity-meta {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}
.activity-meta small { display: block; }

/* Empty states */
.empty-state {
  text-align: center;
  padding: var(--sp-8) var(--sp-5);
  color: var(--muted);
}
.empty-state.small { padding: var(--sp-6) var(--sp-4); }
.empty-state.large { padding: var(--sp-10) var(--sp-6); }
.empty-icon {
  font-size: 34px;
  margin-bottom: var(--sp-3);
  opacity: .7;
}
.empty-state h3 {
  margin: 0 0 var(--sp-2);
  color: var(--text);
  font-size: 15px;
}
.empty-state p {
  margin: 0 0 var(--sp-4);
  font-size: 13px;
}

/* ============================================================
   14. MODALS
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.72);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  animation: fadeIn var(--t-fast);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  max-width: 480px;
  width: 100%;
  padding: var(--sp-6);
  animation: slideUp var(--t-base);
}
.modal-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin: 0 auto var(--sp-4);
}
.modal-icon-warning { background: var(--amber-soft); color: var(--amber); }
.modal-title {
  margin: 0 0 var(--sp-2);
  font-size: 17px;
  font-weight: 700;
  text-align: center;
}
.modal-text {
  color: var(--text-2);
  font-size: 13.5px;
  text-align: center;
  margin: 0 0 var(--sp-5);
}
.modal-actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  margin-top: var(--sp-5);
}
.modal .form-group { text-align: left; }
.mp-summary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  font-size: 13px;
}
.mp-amount { font-size: 20px; font-weight: 800; margin-top: 6px; color: var(--brand); }

.qr-holder {
  display: flex;
  justify-content: center;
  padding: var(--sp-4);
  background: #fff;
  border-radius: var(--r-md);
  margin: var(--sp-4) 0;
}

/* ============================================================
   15. TOASTS
   ============================================================ */
.toast-stack {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: 380px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  font-size: 13.5px;
  color: var(--text);
  pointer-events: auto;
  animation: toastIn var(--t-base);
  max-width: 100%;
}
.toast.is-hiding { animation: toastOut var(--t-base) forwards; }
.toast-icon { font-size: 16px; flex: 0 0 auto; }
.toast-body { flex: 1; min-width: 0; }
.toast-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.toast-success { border-left-color: var(--green); }
.toast-success .toast-icon { color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-error .toast-icon { color: var(--red); }
.toast-warning { border-left-color: var(--amber); }
.toast-warning .toast-icon { color: var(--amber); }
.toast-info { border-left-color: var(--blue); }
.toast-info .toast-icon { color: var(--blue); }

/* ============================================================
   16. ALERTS
   ============================================================ */
.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: 13.5px;
  border: 1px solid transparent;
  margin-bottom: var(--sp-3);
}
.alert-success { background: var(--green-soft);  border-color: var(--green);  color: var(--text); }
.alert-error   { background: var(--red-soft);    border-color: var(--red);    color: var(--text); }
.alert-warning { background: var(--amber-soft);  border-color: var(--amber);  color: var(--text); }
.alert-info    { background: var(--blue-soft);   border-color: var(--blue);   color: var(--text); }
.alert strong { font-weight: 700; }
.alert a { color: var(--brand); text-decoration: underline; }

/* ============================================================
   17. FILTERS & PAGINATION
   ============================================================ */
.filter-bar {
  padding: var(--sp-4) var(--sp-5);
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}
.filter-row > * { flex: 0 0 auto; }
.filter-row input[type="date"] { width: auto; min-width: 140px; }
.filter-search {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
}
.filter-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}
.filter-search input {
  width: 100%;
  padding-left: 34px;
}
.filter-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-soft);
  font-size: 12.5px;
  color: var(--muted);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-soft);
}
.pagination-info { font-size: 12.5px; color: var(--muted); }
.pagination-links { display: flex; gap: 4px; }
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--t-fast);
}
.page-link:hover { background: var(--surface-2); color: var(--text); border-color: var(--brand); }
.page-link.is-current {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* Bulk action bar */
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  background: var(--brand-soft);
  border: 1px solid var(--brand);
  border-radius: var(--r-md);
  animation: slideDown var(--t-fast);
}
.bulk-bar span { font-size: 13.5px; }
.bulk-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ============================================================
   18. UTILITIES
   ============================================================ */
.hide-sm, .hide-md { display: table-cell; }
.p-0 { padding: 0 !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.small { font-size: 12px; }
.w-100 { width: 100%; }
.spacer { flex: 1; }

/* ============================================================
   19. RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .hide-md { display: none !important; }
}

@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
    box-shadow: var(--sh-lg);
  }
  html[data-sidebar="open"] .sidebar { transform: translateX(0); }
  .main-wrap { margin-left: 0 !important; }
  .sidebar-close { display: inline-flex; }
  html[data-sidebar="collapsed"] .sidebar .brand-name,
  html[data-sidebar="collapsed"] .sidebar .nav-label,
  html[data-sidebar="collapsed"] .sidebar .sidebar-footer { display: inline; }

  .content { padding: var(--sp-4); }
  .topbar { padding: 0 var(--sp-4); }
  .topbar-title h1 { font-size: 17px; }
  .user-name { display: none; }

  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .form-actions .spacer { display: none; }
  .form-actions .btn { width: 100%; }
}

@media (max-width: 620px) {
  .hide-sm { display: none !important; }
  .topbar { gap: var(--sp-2); }
  .page-footer { flex-direction: column; gap: var(--sp-2); text-align: center; }
  .modal { padding: var(--sp-5); }
  .toast-stack { left: 12px; right: 12px; top: 12px; max-width: none; }
}

/* ============================================================
   20. ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .7; transform: scale(1.15); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  z-index: 400;
  animation: fadeIn var(--t-fast);
}
.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--surface-3);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.loading-text { color: var(--text-2); font-size: 13px; }

/* ============================================================
   21. LOGIN PAGE
   ============================================================ */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  background:
    radial-gradient(1000px 600px at 10% -10%, rgba(99,102,241,.18), transparent 60%),
    radial-gradient(800px 500px at 110% 110%, rgba(168,85,247,.15), transparent 60%),
    var(--bg);
}
.login-wrap { width: 100%; max-width: 420px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-8) var(--sp-6);
  box-shadow: var(--sh-lg);
  animation: slideUp var(--t-slow);
}
.login-brand {
  text-align: center;
  margin-bottom: var(--sp-6);
}
.login-logo,
.login-logo-fallback {
  width: 56px; height: 56px;
  border-radius: var(--r-md);
  margin: 0 auto var(--sp-3);
}
.login-logo { object-fit: contain; }
.login-logo-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand), var(--purple));
  color: #fff;
  font-weight: 800;
  font-size: 20px;
}
.login-brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.3px;
}
.login-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}
.login-footer {
  text-align: center;
  margin-top: var(--sp-6);
  color: var(--muted);
  font-size: 12px;
}

/* ============================================================
   22. AUTO-REFRESH TOGGLE
   ============================================================ */
.auto-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: 12px;
  color: var(--muted);
}
.auto-refresh .switch { transform: scale(.85); }
.auto-refresh-label { font-weight: 600; }

/* ============================================================
   23. PRINT
   ============================================================ */
@media print {
  .sidebar, .topbar, .form-actions, .bulk-bar, .sidebar-backdrop, .toast-stack { display: none !important; }
  .main-wrap { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  body { background: #fff; color: #000; }
}