:root {
  --brown-deep: #2C1A0E;
  --brown-mid: #5C3A1E;
  --brown-light: #8B5E3C;
  --cream: #F5EDD6;
  --cream-dark: #EAD9B8;
  --gold: #C8961E;
  --gold-light: #E8B84B;
  --gold-pale: #F5E4A8;
  --sage: #7A8C6E;
  --rust: #A63D2F;
  --white: #FDFAF5;
  --text-dark: #1A0F05;
  --text-mid: #4A3020;
  --text-light: #7A6050;
  --border: #D4B896;
  --border-light: #E8D8C0;
  --sidebar-w: 230px;
  --topbar-h: 56px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 2px 8px rgba(44,26,14,0.12);
  --shadow-md: 0 4px 16px rgba(44,26,14,0.16);
  --shadow-lg: 0 8px 32px rgba(44,26,14,0.20);
  --font-display: 'Playfair Display', serif;
  --font-body: 'Source Sans 3', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--text-dark);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

#app { display: flex; height: 100vh; }

/* ── SIDEBAR ── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--brown-deep);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid rgba(200,150,30,0.3);
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 28px; }
.brand-name { font-family: var(--font-display); color: var(--gold-light); font-size: 15px; font-weight: 700; line-height: 1.1; }
.brand-sub { color: rgba(245,237,214,0.5); font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; }

.show-selector-wrap {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.show-selector-wrap label {
  display: block;
  color: rgba(245,237,214,0.5);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.show-selector-wrap select {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(200,150,30,0.3);
  color: var(--cream);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
}
.show-selector-wrap select option { background: var(--brown-deep); }

.sidebar-nav { padding: 8px 0; flex: 1; }
.nav-group { margin-bottom: 8px; }
.nav-label {
  color: rgba(245,237,214,0.35);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 8px 16px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: rgba(245,237,214,0.7);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
  position: relative;
  border-radius: 0;
}
.nav-item:hover { color: var(--cream); background: rgba(255,255,255,0.06); }
.nav-item.active {
  color: var(--gold-light);
  background: rgba(200,150,30,0.15);
  border-right: 2px solid var(--gold);
}
.nav-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }

.badge {
  margin-left: auto;
  background: var(--rust);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.server-status { color: #6fc96f; font-size: 11px; }

/* ── MAIN ── */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(44,26,14,0.06);
}
.page-title {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--brown-deep);
  font-weight: 600;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }

#pageContent {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--cream);
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--brown-mid); color: var(--cream); }
.btn-primary:hover { background: var(--brown-deep); }
.btn-gold { background: var(--gold); color: var(--brown-deep); font-weight: 600; }
.btn-gold:hover { background: var(--gold-light); }
.btn-outline { background: transparent; color: var(--brown-mid); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--cream-dark); }
.btn-danger { background: var(--rust); color: white; }
.btn-danger:hover { background: #8A2F24; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── CARDS ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--brown-deep);
  font-weight: 600;
}
.card-body { padding: 20px; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 12px;
  background: var(--brown-deep);
  color: var(--gold-pale);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  white-space: nowrap;
}
th:first-child { border-radius: var(--radius-sm) 0 0 0; }
th:last-child { border-radius: 0 var(--radius-sm) 0 0; }
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(200,150,30,0.04); }
.td-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ── FORMS ── */
.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-dark);
  background: var(--white);
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(200,150,30,0.2);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 16px; align-items: flex-start; }
.form-section-title {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--brown-mid);
  margin: 12px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
}

/* ── STAT CARDS ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 11px; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 4px; }
.stat-value { font-family: var(--font-display); font-size: 28px; color: var(--brown-deep); font-weight: 700; line-height: 1; }
.stat-sub { font-size: 11px; color: var(--text-light); margin-top: 4px; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44,26,14,0.5);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 1;
}
.modal-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--brown-deep);
}
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-light); padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { background: var(--cream-dark); color: var(--text-dark); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--cream);
  border-radius: 0 0 var(--radius) var(--radius);
}
.modal-xl { max-width: 960px; }
.modal-lg { max-width: 800px; }

/* ── TOAST ── */
#toastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--brown-deep);
  color: var(--cream);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease;
  max-width: 320px;
  border-left: 3px solid var(--gold);
}
.toast.success { border-left-color: #6fc96f; }
.toast.error { border-left-color: var(--rust); }
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* ── TAGS / PILLS ── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.tag-active { background: rgba(111,201,111,0.15); color: #3d7a3d; }
.tag-scratch { background: rgba(166,61,47,0.1); color: var(--rust); text-decoration: line-through; }
.tag-pending { background: rgba(200,150,30,0.15); color: var(--gold); }
.tag-paid { background: rgba(111,201,111,0.15); color: #3d7a3d; }
.tag-balance { background: rgba(166,61,47,0.1); color: var(--rust); }
.tag-approved { background: rgba(111,201,111,0.15); color: #3d7a3d; }
.tag-rejected { background: rgba(166,61,47,0.1); color: var(--rust); }

/* ── SEARCH BAR ── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 36px;
}
.search-bar input {
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 13px;
  background: transparent;
  width: 200px;
  color: var(--text-dark);
}
.search-bar span { color: var(--text-light); }

/* ── FEE TABLE ── */
.fee-breakdown {
  background: var(--cream);
  border-radius: var(--radius);
  padding: 12px 16px;
  border: 1px solid var(--border-light);
}
.fee-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; }
.fee-row.total { font-weight: 700; font-size: 15px; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
.fee-row.credit { color: var(--sage); }
.fee-row.balance-due { color: var(--rust); font-size: 16px; font-weight: 700; }

/* ── ANNOUNCER / PRINT PREVIEW ── */
.print-card {
  background: var(--white);
  border: 2px solid var(--brown-light);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.print-card h2 { font-family: var(--font-display); color: var(--brown-deep); margin-bottom: 12px; }

/* ── CLASS LIST (entries) ── */
.class-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
}
.class-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.1s;
  font-size: 12px;
}
.class-checkbox:hover { border-color: var(--gold); background: var(--gold-pale); }
.class-checkbox input[type=checkbox]:checked + span { color: var(--brown-deep); font-weight: 600; }
.class-checkbox.selected { border-color: var(--gold); background: rgba(200,150,30,0.08); }

/* ── TABS ── */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border-light); margin-bottom: 20px; }
.tab {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.tab:hover { color: var(--text-dark); }
.tab.active { color: var(--brown-mid); border-bottom-color: var(--gold); font-weight: 600; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-light);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 15px; }

/* ── RESULTS ── */
.result-row {
  display: grid;
  grid-template-columns: 60px 80px 1fr 1fr 60px 60px;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
}
.place-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.place-1 { background: var(--gold); color: var(--brown-deep); }
.place-2 { background: #C0C0C0; color: #333; }
.place-3 { background: #CD7F32; color: white; }
.place-other { background: var(--cream-dark); color: var(--text-mid); }

/* ── PAYMENT ── */
.payment-method { display: flex; gap: 8px; }
.method-btn {
  flex: 1;
  padding: 8px;
  border: 2px solid var(--border);
  background: var(--white);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  font-family: var(--font-body);
  transition: all 0.15s;
}
.method-btn:hover { border-color: var(--gold); }
.method-btn.active { border-color: var(--gold); background: var(--gold-pale); font-weight: 600; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  #sidebar { width: 60px; }
  .brand-name, .brand-sub, .nav-label, .nav-item span:last-child,
  .show-selector-wrap label, .show-selector-wrap select,
  .sidebar-footer .server-status { display: none; }
  .nav-icon { margin: 0 auto; }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--brown-light); }

/* ── UTILS ── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-gold { color: var(--gold); }
.text-rust { color: var(--rust); }
.text-sage { color: var(--sage); }
.text-muted { color: var(--text-light); font-size: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.w-full { width: 100%; }
.font-bold { font-weight: 700; }
.font-display { font-family: var(--font-display); }
.hidden { display: none !important; }
