/* ── Variables ───────────────────────────────────────── */
:root {
  --sidebar-w: 248px;
  --sidebar-bg: #0f172a;
  --sidebar-border: rgba(255,255,255,.06);
  --sidebar-text: #94a3b8;
  --sidebar-hover-bg: rgba(255,255,255,.07);
  --sidebar-active-bg: rgba(37,99,235,.18);
  --sidebar-active-text: #93c5fd;
  --topbar-h: 60px;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.06);
  --shadow-lg: 0 8px 32px rgba(15,23,42,.14);
}

/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100%;
}
a { text-decoration: none; }
button { cursor: pointer; font: inherit; }
svg { display: block; flex-shrink: 0; }

/* ── Layout ──────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
}
.brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  flex-shrink: 0;
}
.brand-icon svg { width: 18px; height: 18px; }
.brand-name {
  font-size: .95rem;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.2;
}

.sidebar-nav {
  flex: 1;
  padding: .75rem .75rem 0;
  overflow-y: auto;
}

.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  padding: .6rem .5rem .35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--sidebar-hover-bg); color: #e2e8f0; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }

.sidebar-footer {
  padding: .75rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-action {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem .75rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: background .15s, color .15s;
}
.sidebar-action svg { width: 15px; height: 15px; }
.sidebar-action:hover { background: var(--sidebar-hover-bg); color: #e2e8f0; }

/* ── Overlay (mobile) ────────────────────────────────── */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 29;
}

/* ── Main wrapper ────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Topbar ──────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 20;
}
.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: .25rem;
}
.menu-toggle svg { width: 22px; height: 22px; }
.topbar h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Content ─────────────────────────────────────────── */
.content {
  padding: 1.5rem;
  flex: 1;
}
.view { display: flex; flex-direction: column; gap: 1.25rem; }

/* ── View header ─────────────────────────────────────── */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.view-title {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--text);
}
.view-title svg { width: 22px; height: 22px; color: var(--primary); }
.view-title h2 { font-size: 1.3rem; font-weight: 700; }

/* ── Buttons ─────────────────────────────────────────── */
.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  border: none;
  white-space: nowrap;
  transition: background .15s, box-shadow .15s;
}
.btn-primary svg, .btn-secondary svg { width: 15px; height: 15px; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37,99,235,.25);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 6px rgba(37,99,235,.35); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }

.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* icon-only action buttons in table rows */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  padding: .35rem .6rem;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  transition: all .15s;
  white-space: nowrap;
}
.btn-icon svg { width: 13px; height: 13px; }
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon.danger { color: var(--danger); border-color: #fecaca; background: #fff5f5; }
.btn-icon.danger:hover { background: var(--danger-light); }
.btn-icon.success { color: var(--success); border-color: #a7f3d0; background: #f0fdf4; }
.btn-icon.success:hover { background: var(--success-light); }

/* ── Stats grid ──────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .875rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-card.warn { border-left: 3px solid var(--warning); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.stat-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat-value { font-size: 1.35rem; font-weight: 700; color: var(--text); line-height: 1.2; }

/* stat icon colour themes */
.c-blue   { background: #dbeafe; color: #2563eb; }
.c-violet { background: #ede9fe; color: #7c3aed; }
.c-emerald{ background: #d1fae5; color: #059669; }
.c-sky    { background: #e0f2fe; color: #0284c7; }
.c-amber  { background: #fef3c7; color: #d97706; }
.c-orange { background: #ffedd5; color: #ea580c; }

/* ── Panels (dashboard) ──────────────────────────────── */
.panel-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #fafcff;
}
.panel-header svg { width: 16px; height: 16px; color: var(--primary); }
.panel-header h3 { font-size: .9rem; font-weight: 600; color: var(--text); }

/* ── Card ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* ── Filters ─────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 1rem;
  padding: .85rem 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.filters select {
  font: inherit;
  font-size: .875rem;
  padding: .4rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  min-width: 180px;
}

/* ── Table ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
thead { position: sticky; top: 0; z-index: 1; }
th {
  background: #f8fafc;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: .7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: .75rem 1rem;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f8fafc; }

.row-actions { display: flex; gap: .35rem; justify-content: flex-end; white-space: nowrap; }

.empty-state {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
}

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; }
.badge.paid    { background: var(--success-light); color: #065f46; }
.badge.pending { background: var(--warning-light); color: #92400e; }
.badge.active  { background: var(--primary-light); color: #1e40af; }
.badge.ended   { background: #f1f5f9; color: var(--muted); }

/* ── Modal ───────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  z-index: 50;
  backdrop-filter: blur(2px);
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-header .btn-icon {
  background: transparent;
  border: none;
  padding: .35rem;
  color: var(--muted);
}
.modal-header .btn-icon svg { width: 18px; height: 18px; }

/* ── Form ────────────────────────────────────────────── */
#modal-form {
  display: flex;
  flex-direction: column;
  gap: .875rem;
  padding: 1.25rem;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-size: .75rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  font: inherit;
  font-size: .9rem;
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field textarea { min-height: 68px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
  margin-top: .25rem;
}

/* ── Misc ────────────────────────────────────────────── */
td.muted { color: var(--muted); font-size: .82rem; }

.category-chip {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  .panel-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .overlay.open { display: block; }
  .main-wrapper { margin-left: 0; }
  .menu-toggle { display: flex; }
  .content { padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 480px) {
  .field-row { grid-template-columns: 1fr; }
  .view-header { flex-direction: column; align-items: flex-start; }
}
