/* ─── Design Tokens (White-Label) ──────────────────────────────── */
:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #dbeafe;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 12px;
  --radius-sm: 8px;
  --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);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-w: 960px;
}

/* ─── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-family: var(--font); font-size: 15px; color: var(--gray-800); background: var(--gray-50); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font: inherit; }

/* ─── Shell ────────────────────────────────────────────────────── */
.shell { display: flex; flex-direction: column; min-height: 100dvh; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: 56px;
  background: var(--primary); color: #fff;
  box-shadow: var(--shadow-md);
}
.topbar .brand-logo { height: 28px; width: auto; display: none; border-radius: 4px; }
.topbar .brand-name { font-weight: 700; font-size: 1.1rem; }
.topbar .spacer { flex: 1; }
.topbar .user-pill {
  font-size: 0.8rem; background: rgba(255,255,255,.18); padding: 4px 12px; border-radius: 20px;
}
.topbar a { color: rgba(255,255,255,.85); font-size: 0.85rem; }
.topbar a:hover { color: #fff; }

/* Nav */
.nav {
  display: flex; gap: 2px; background: #fff; border-bottom: 1px solid var(--gray-200);
  padding: 0 20px; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.nav a {
  padding: 12px 16px; font-size: 0.85rem; font-weight: 500; color: var(--gray-500);
  border-bottom: 2px solid transparent; white-space: nowrap; transition: all .15s;
}
.nav a:hover { color: var(--gray-700); }
.nav a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Main content */
.main { flex: 1; padding: 24px 20px; max-width: var(--max-w); margin: 0 auto; width: 100%; }

/* ─── Cards ────────────────────────────────────────────────────── */
.card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--gray-100); padding: 24px; margin-bottom: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h2 { font-size: 1.05rem; font-weight: 600; }

/* ─── Stat Cards Row ───────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--gray-100);
  padding: 20px; text-align: center;
}
.stat .value { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.stat .label { font-size: 0.8rem; color: var(--gray-500); margin-top: 4px; }

/* ─── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px;
  border-radius: var(--radius-sm); font-weight: 600; font-size: 0.9rem; border: none; cursor: pointer;
  transition: all .15s; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-outline {
  background: transparent; color: var(--primary); border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-icon { padding: 8px; border-radius: 8px; background: var(--gray-100); border: none; cursor: pointer; }
.btn-icon:hover { background: var(--gray-200); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .03em; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  background: #fff; font-size: 0.95rem; transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ─── Table ────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; padding: 10px 12px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-500); border-bottom: 2px solid var(--gray-200); }
td { padding: 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:hover td { background: var(--gray-50); }
tr.clickable { cursor: pointer; }

/* ─── Upload Zone ──────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--gray-300); border-radius: var(--radius); padding: 40px 20px;
  text-align: center; cursor: pointer; transition: all .2s; background: var(--gray-50);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary); background: var(--primary-light);
}
.upload-zone .icon { font-size: 2rem; margin-bottom: 8px; }
.upload-zone .text { font-size: 0.9rem; color: var(--gray-500); }

/* ─── Receipt Preview ──────────────────────────────────────────── */
.receipt-preview {
  max-width: 300px; border-radius: var(--radius-sm); border: 1px solid var(--gray-200); overflow: hidden;
}
.receipt-preview img { width: 100%; height: auto; }

/* ─── Badge ────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 0.75rem; font-weight: 600; color: #fff;
}
.badge-submitted { background: var(--warning); }
.badge-approved { background: var(--success); }
.badge-rejected { background: var(--danger); }
.badge-paid { background: var(--primary); }
.badge-draft { background: var(--gray-400); }

/* ─── Modal ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 28px;
}
.modal h3 { font-size: 1.1rem; margin-bottom: 16px; }

/* ─── Toast ────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm); color: #fff; font-size: 0.9rem; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: slideIn .3s ease;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── Empty State ──────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-400); }
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.95rem; }

/* ─── Loading Spinner ──────────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--gray-200);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .6s linear infinite; margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Color Picker ─────────────────────────────────────────────── */
input[type="color"] { width: 48px; height: 36px; padding: 2px; cursor: pointer; }

/* ─── Responsive ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .main { padding: 16px 12px; }
  .topbar { padding: 0 12px; }
  .nav { padding: 0 8px; }
  .nav a { padding: 10px 12px; font-size: 0.8rem; }
  .card { padding: 16px; }
}
