/* ============================================================
   ACKMORRE Design System
   Mobile-first, Android-compatible, CSS variables
   ============================================================ */

:root {
  --primary:        #1a56db;
  --primary-dark:   #1440a8;
  --primary-light:  #ebf0ff;
  --secondary:      #6b7280;
  --success:        #057a55;
  --success-light:  #def7ec;
  --danger:         #e02424;
  --danger-light:   #fde8e8;
  --warning:        #c27803;
  --warning-light:  #fdf6b2;
  --info:           #0e9f6e;
  --bg:             #f3f4f6;
  --surface:        #ffffff;
  --surface-2:      #f9fafb;
  --border:         #e5e7eb;
  --border-dark:    #d1d5db;
  --text:           #111827;
  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;
  --sidebar-bg:     #1e2538;
  --sidebar-text:   #cbd5e1;
  --sidebar-active: #ffffff;
  --sidebar-hover:  rgba(255,255,255,.08);
  --sidebar-accent: #1a56db;
  --sidebar-w:      250px;
  --topbar-h:       60px;
  --radius:         8px;
  --radius-lg:      12px;
  --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:      0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --transition:     .18s ease;
  --font:           'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Dark mode variables ─────────────────────────────────────── */
[data-theme="dark"] {
  --primary:        #3b82f6;
  --primary-dark:   #2563eb;
  --primary-light:  #1e3a5f;
  --secondary:      #9ca3af;
  --success:        #10b981;
  --success-light:  #064e3b;
  --danger:         #f87171;
  --danger-light:   #4c1111;
  --warning:        #fbbf24;
  --warning-light:  #451a03;
  --info:           #34d399;
  --bg:             #0f1117;
  --surface:        #1a1d2e;
  --surface-2:      #1f2235;
  --border:         #2d3148;
  --border-dark:    #3a3f5c;
  --text:           #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --sidebar-bg:     #12151f;
  --sidebar-text:   #94a3b8;
  --sidebar-active: #f1f5f9;
  --sidebar-hover:  rgba(255,255,255,.06);
  --sidebar-accent: #3b82f6;
  --shadow:         0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-md:      0 4px 6px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.3);
}

/* ── Dark mode badge/status overrides ────────────────────────── */
[data-theme="dark"] .badge-success  { background: #064e3b; color: #10b981; }
[data-theme="dark"] .badge-danger   { background: #4c1111; color: #f87171; }
[data-theme="dark"] .badge-warning  { background: #451a03; color: #fbbf24; }
[data-theme="dark"] .badge-info     { background: #0c2d48; color: #38bdf8; }
[data-theme="dark"] .badge-secondary{ background: #1f2235; color: #94a3b8; }
[data-theme="dark"] .badge-primary  { background: #1e3a5f; color: #3b82f6; }

[data-theme="dark"] .status-accepted   { background: #1f2235; color: #94a3b8; }
[data-theme="dark"] .status-placed     { background: #0c2d48; color: #38bdf8; }
[data-theme="dark"] .status-processing { background: #451a03; color: #fbbf24; }
[data-theme="dark"] .status-delivered  { background: #064e3b; color: #10b981; }
[data-theme="dark"] .status-failed     { background: #4c1111; color: #f87171; }
[data-theme="dark"] .status-refunded   { background: #2d1b69; color: #a78bfa; }

[data-theme="dark"] .alert-success { background: #064e3b; border-color: #10b981; color: #6ee7b7; }
[data-theme="dark"] .alert-danger  { background: #4c1111; border-color: #f87171; color: #fca5a5; }
[data-theme="dark"] .alert-warning { background: #451a03; border-color: #fbbf24; color: #fde68a; }
[data-theme="dark"] .alert-info    { background: #0c2d48; border-color: #38bdf8; color: #7dd3fc; }

[data-theme="dark"] select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%2394a3b8' d='m7 10 5 5 5-5z'/%3E%3C/svg%3E");
}

/* ── Theme toggle button ─────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border-dark);
  border-radius: 50px;
  padding: 5px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--primary);
}
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { width: 15px; height: 15px; flex-shrink: 0; }

/* Show sun in dark mode, moon in light mode */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ── Typography ─────────────────────────────────────────────── */
h1 { font-size: clamp(1.4rem, 4vw, 1.8rem); font-weight: 700; }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
h4 { font-size: 1rem;   font-weight: 600; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius);
  font-size: .875rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: var(--transition);
  white-space: nowrap; text-decoration: none; line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary   { background: var(--primary);  color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); text-decoration: none; }
.btn-success   { background: var(--success);  color: #fff; border-color: var(--success); }
.btn-success:hover { opacity: .9; text-decoration: none; }
.btn-danger    { background: var(--danger);   color: #fff; border-color: var(--danger); }
.btn-danger:hover  { opacity: .9; text-decoration: none; }
.btn-secondary { background: var(--surface);  color: var(--text); border-color: var(--border-dark); }
.btn-secondary:hover { background: var(--surface-2); text-decoration: none; }
.btn-outline   { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); text-decoration: none; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; border-radius: var(--radius); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .4rem; color: var(--text); }
.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control {
  display: block; width: 100%;
  padding: 9px 13px; border-radius: var(--radius);
  border: 1px solid var(--border-dark);
  background: var(--surface); color: var(--text);
  font-size: .9rem; font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none; appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { background: var(--bg); cursor: not-allowed; }

select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%236b7280' d='m7 10 5 5 5-5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint  { font-size: .78rem; color: var(--text-muted); margin-top: .25rem; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: .25rem; }

.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input[type=checkbox],
.form-check input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
  background: var(--surface);
}
.card-title { font-size: 1rem; font-weight: 600; }
.card-body  { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ── Stat cards ──────────────────────────────────────────────── */
.stat-card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 20px; display: flex; flex-direction: column; gap: 6px;
}
.stat-card .stat-label { font-size: .8rem; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-card .stat-sub   { font-size: .8rem; color: var(--text-muted); }
.stat-card .stat-icon  { font-size: 1.4rem; margin-bottom: 4px; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-lg); }
.table {
  width: 100%; border-collapse: collapse; font-size: .875rem;
  min-width: 540px;
}
.table th {
  background: var(--surface-2); color: var(--text-secondary);
  font-size: .75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; padding: 11px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap; text-align: left;
}
.table td {
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle; color: var(--text);
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table-sm th, .table-sm td { padding: 8px 12px; }

/* ── Badges / Status ─────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 50px; font-size: .72rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap;
}
.badge-success  { background: var(--success-light); color: var(--success); }
.badge-danger   { background: var(--danger-light);  color: var(--danger); }
.badge-warning  { background: var(--warning-light); color: var(--warning); }
.badge-info     { background: #e0f2fe; color: #0369a1; }
.badge-secondary{ background: #f3f4f6; color: var(--secondary); }
.badge-primary  { background: var(--primary-light); color: var(--primary); }

/* Status map */
.status-accepted   { background: #f3f4f6; color: var(--secondary); }
.status-placed     { background: #e0f2fe; color: #0369a1; }
.status-processing { background: var(--warning-light); color: var(--warning); }
.status-delivered  { background: var(--success-light); color: var(--success); }
.status-failed     { background: var(--danger-light);  color: var(--danger); }
.status-refunded   { background: #f5f3ff; color: #6d28d9; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  border-left: 4px solid; font-size: .875rem;
  display: flex; align-items: flex-start; gap: 10px;
  position: relative;
}
.alert-close { position: absolute; top: 10px; right: 12px; background: none; border: none; cursor: pointer; font-size: 1.1rem; color: inherit; opacity: .6; }
.alert-close:hover { opacity: 1; }
.alert-success { background: var(--success-light); border-color: var(--success); color: var(--success); }
.alert-danger  { background: var(--danger-light);  border-color: var(--danger);  color: var(--danger); }
.alert-warning { background: var(--warning-light); border-color: var(--warning); color: var(--warning); }
.alert-info    { background: #e0f2fe; border-color: #0ea5e9; color: #0369a1; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 10px;
  border-radius: var(--radius); border: 1px solid var(--border);
  font-size: .85rem; color: var(--text); transition: var(--transition);
  text-decoration: none;
}
.page-link:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link.disabled { opacity: .45; pointer-events: none; }

/* ── Modals ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 1000; display: none; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); width: 100%; max-width: 500px;
  max-height: calc(100vh - 40px); overflow-y: auto;
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title  { font-size: 1rem; font-weight: 600; }
.modal-close  { background: none; border: none; cursor: pointer; font-size: 1.3rem; color: var(--text-muted); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Admin Layout ────────────────────────────────────────────── */
.admin-wrap { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 200; transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar-brand {
  padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand img { width: 32px; height: 32px; border-radius: 6px; object-fit: contain; }
.sidebar-brand .brand-name { font-size: 1rem; font-weight: 700; color: #fff; }

.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-section-label {
  padding: 10px 20px 4px; font-size: .68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: rgba(255,255,255,.35);
}
.sidebar a.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: var(--sidebar-text);
  font-size: .875rem; transition: var(--transition); text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar a.nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-active); }
.sidebar a.nav-link.active { background: var(--sidebar-hover); color: var(--sidebar-active); border-left-color: var(--sidebar-accent); }
.sidebar a.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }

.admin-main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border); padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.hamburger {
  display: none; background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: var(--radius); color: var(--text);
}
.hamburger:hover { background: var(--bg); }
.hamburger svg { width: 22px; height: 22px; display: block; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user  { display: flex; align-items: center; gap: 8px; font-size: .875rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }

.page-content { padding: 24px; flex: 1; }
.page-header  { margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.page-title   { font-size: 1.3rem; font-weight: 700; }

/* Sidebar overlay for mobile */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 199; }

/* ── Client Layout ───────────────────────────────────────────── */
.client-wrap { display: flex; flex-direction: column; min-height: 100vh; }

.client-nav {
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow); position: sticky; top: 0; z-index: 100;
}
.client-nav-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 20px;
  height: var(--topbar-h); display: flex; align-items: center;
  justify-content: space-between; gap: 16px;
}
.client-nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1rem; color: var(--text); text-decoration: none; }
.client-nav .brand img { height: 32px; width: auto; object-fit: contain; }
.client-nav .brand:hover { text-decoration: none; }

.client-nav-links { display: flex; align-items: center; gap: 4px; }
.client-nav-links a {
  padding: 7px 13px; border-radius: var(--radius);
  font-size: .875rem; color: var(--text-secondary); transition: var(--transition);
  text-decoration: none; white-space: nowrap;
}
.client-nav-links a:hover  { background: var(--bg); color: var(--text); text-decoration: none; }
.client-nav-links a.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }

.client-main  { flex: 1; max-width: 1200px; margin: 0 auto; padding: 28px 20px; width: 100%; }
.client-footer {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 16px 20px; text-align: center;
  font-size: .78rem; color: var(--text-muted);
}

/* Balance chip */
.balance-chip {
  background: var(--primary-light); color: var(--primary);
  padding: 5px 12px; border-radius: 50px; font-size: .82rem;
  font-weight: 600; white-space: nowrap;
}

/* Mobile hamburger for client nav */
.client-hamburger { display: none; }
.client-nav-mobile {
  display: none; flex-direction: column;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 8px 0;
}
.client-nav-mobile.open { display: flex; }
.client-nav-mobile a { padding: 11px 20px; font-size: .9rem; color: var(--text-secondary); text-decoration: none; border-left: 3px solid transparent; }
.client-nav-mobile a:hover  { background: var(--bg); color: var(--text); }
.client-nav-mobile a.active { color: var(--primary); border-left-color: var(--primary); background: var(--primary-light); }

/* ── Auth pages ──────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.auth-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 36px 32px; width: 100%; max-width: 420px; }
.auth-logo  { text-align: center; margin-bottom: 24px; }
.auth-logo img { height: 48px; margin: 0 auto 8px; }
.auth-logo .site-name { font-size: 1.3rem; font-weight: 700; }
.auth-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 20px; text-align: center; }

/* ── Grid helpers ────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* ── Utilities ───────────────────────────────────────────────── */
.d-flex    { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted); }
.text-small   { font-size: .82rem; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.fw-600 { font-weight: 600; }
.w-100  { width: 100%; }
.mono   { font-family: ui-monospace, monospace; font-size: .85rem; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar { transform: translateX(-250px); width: 250px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }

  .admin-main { margin-left: 0; }
  .hamburger  { display: flex; }

  .page-content { padding: 16px; }
  .topbar       { padding: 0 16px; }

  .client-nav-links { display: none; }
  .client-hamburger { display: flex; }

  .auth-card { padding: 24px 18px; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .btn { padding: 10px 16px; }
  .btn-sm { padding: 7px 12px; }
  .modal { max-width: 100%; }

  .table th, .table td { padding: 9px 10px; font-size: .82rem; }

  .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .auth-card  { padding: 20px 14px; }
  .card-body  { padding: 14px; }
  .card-header{ padding: 12px 14px; }
  .stat-card  { padding: 14px; }
  .stat-card .stat-value { font-size: 1.4rem; }
}