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

:root {
  --gold: #C9A96E;
  --gold-light: #E8D5A3;
  --gold-dark: #8B6914;
  --navy: #0D1B2A;
  --navy-mid: #162236;
  --navy-light: #1E3248;
  --navy-card: #192840;
  --cream: #F5F0E8;
  --text: #D4DEED;
  --text-muted: #6B7E99;
  --text-dim: #4A5A70;
  --border: rgba(201,169,110,0.12);
  --border-bright: rgba(201,169,110,0.25);
  --success: #4CAF8E;
  --warning: #E8A84A;
  --danger: #E05560;
  --info: #5B9BD5;
  --sidebar-w: 260px;
}

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--navy);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── LAYOUT ── */
body { display: flex; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy-mid);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, min-width 0.3s ease;
  overflow: hidden;
  z-index: 100;
}
.sidebar.collapsed {
  width: 60px;
  min-width: 60px;
}
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .user-details { display: none; }
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo { flex-shrink: 0; }
.sidebar-brand-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--gold);
  white-space: nowrap;
}
.sidebar-brand-sub {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}
.sidebar-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  transition: transform 0.3s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--gold); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.nav-section-label {
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 10px 4px;
  font-weight: 500;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.15s;
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  margin-bottom: 1px;
}
.nav-item:hover { background: rgba(201,169,110,0.06); color: var(--text); }
.nav-item.active {
  background: rgba(201,169,110,0.1);
  color: var(--gold);
  font-weight: 500;
}
.nav-icon {
  font-size: 14px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  opacity: 0.7;
}
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  flex-shrink: 0;
}
.user-name { font-size: 12px; font-weight: 500; color: var(--text); }
.user-role { font-size: 10px; color: var(--text-dim); text-transform: capitalize; }
.btn-logout {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ── TOPBAR ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--navy-mid);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.mobile-toggle { display: none; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.bc-root { color: var(--text-dim); }
.bc-sep { color: var(--text-dim); }
.bc-current { color: var(--text); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-date { font-size: 12px; color: var(--text-dim); }
.btn-icon { background: none; border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; padding: 6px 10px; border-radius: 4px; font-size: 13px; transition: all 0.15s; }
.btn-icon:hover { border-color: var(--gold); color: var(--gold); }

/* ── CONTENT ── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.section { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── PAGE HEADER ── */
.page-header { margin-bottom: 28px; }
.page-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 32px;
  font-weight: 400;
  color: var(--cream);
  line-height: 1.1;
}
.page-title em { font-style: italic; color: var(--gold); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 6px; font-weight: 300; }

/* ── CARDS ── */
.card {
  background: var(--navy-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 24px;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-bright); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  font-weight: 400;
  color: var(--cream);
}
.card-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(201,169,110,0.1);
  color: var(--gold);
  border: 1px solid rgba(201,169,110,0.2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

/* ── STAT CARDS ── */
.stat-card {
  background: var(--navy-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gold);
  opacity: 0;
  transition: opacity 0.2s;
}
.stat-card:hover::before { opacity: 1; }
.stat-card:hover { border-color: var(--border-bright); }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 8px; font-weight: 400; }
.stat-value { font-family: 'Cormorant Garamond', serif; font-size: 28px; font-weight: 400; color: var(--cream); line-height: 1; }
.stat-unit { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-gold { border-left: 2px solid var(--gold); padding-left: 18px; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(201,169,110,0.06);
  color: var(--text);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(201,169,110,0.03); }

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.badge-success { background: rgba(76,175,142,0.15); color: var(--success); }
.badge-warning { background: rgba(232,168,74,0.15); color: var(--warning); }
.badge-danger { background: rgba(224,85,96,0.15); color: var(--danger); }
.badge-info { background: rgba(91,155,213,0.15); color: var(--info); }
.badge-gold { background: rgba(201,169,110,0.15); color: var(--gold); }
.badge-admin { background: rgba(201,169,110,0.15); color: var(--gold); }
.badge-adviser { background: rgba(91,155,213,0.15); color: var(--info); }
.badge-staff { background: rgba(76,175,142,0.15); color: var(--success); }

/* ── RATIO BARS ── */
.ratio-bar-wrap { display: flex; align-items: center; gap: 12px; }
.ratio-bar-bg { flex: 1; height: 4px; background: rgba(255,255,255,0.06); border-radius: 2px; overflow: hidden; }
.ratio-bar-fill { height: 100%; border-radius: 2px; transition: width 0.6s ease; }
.ratio-good { background: var(--success); }
.ratio-warn { background: var(--warning); }
.ratio-bad { background: var(--danger); }
.ratio-na { background: var(--text-dim); }

/* ── ACTION PLAN ── */
.action-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid rgba(201,169,110,0.06);
  align-items: flex-start;
}
.action-item:last-child { border-bottom: none; }
.action-date-box {
  background: rgba(201,169,110,0.08);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  text-align: center;
  flex-shrink: 0;
  min-width: 80px;
}
.action-date-day { font-family: 'Cormorant Garamond', serif; font-size: 24px; font-weight: 400; color: var(--gold); line-height: 1; }
.action-date-month { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-top: 2px; }
.action-content { flex: 1; }
.action-title { font-weight: 500; color: var(--cream); margin-bottom: 4px; }
.action-desc { font-size: 12px; color: var(--text-muted); }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(201,169,110,0.15);
  border-radius: 3px;
  padding: 10px 12px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  transition: all 0.2s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(201,169,110,0.4);
  background: rgba(255,255,255,0.06);
}
select { cursor: pointer; }
select option { background: var(--navy-mid); }

/* ── BUTTONS ── */
.btn-primary {
  background: var(--gold);
  color: var(--navy);
  border: none;
  padding: 10px 20px;
  border-radius: 3px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary:hover { background: var(--gold-light); }
.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 3px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--border-bright); color: var(--text); }
.btn-danger { background: rgba(224,85,96,0.1); color: var(--danger); border: 1px solid rgba(224,85,96,0.2); }
.btn-danger:hover { background: rgba(224,85,96,0.2); }
.btn-sm { padding: 6px 12px; font-size: 11px; }
.btn-add {
  display: flex; align-items: center; gap: 6px;
  background: rgba(201,169,110,0.08); border: 1px solid var(--border-bright);
  color: var(--gold); padding: 8px 16px; border-radius: 3px;
  cursor: pointer; font-size: 12px; font-weight: 500; transition: all 0.2s;
}
.btn-add:hover { background: rgba(201,169,110,0.15); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(5,12,22,0.85);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--navy-mid);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  width: 520px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  animation: fadeSlideUp 0.2s ease;
}
@keyframes fadeSlideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-family: 'Cormorant Garamond', serif; font-size: 20px; font-weight: 400; color: var(--cream); }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal-error { color: var(--danger); font-size: 12px; margin-top: 10px; min-height: 16px; }

/* ── MISC ── */
.gold-text { color: var(--gold); }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.mono { font-family: 'Courier New', monospace; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.loading-state { text-align: center; padding: 60px; color: var(--text-dim); }
.loading-spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 48px; color: var(--text-muted); }
.empty-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.4; }

/* ── PROGRESS ── */
.progress-ring { display: inline-block; position: relative; }

/* ── KEY VALUE ── */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.kv-item { padding: 12px 16px; background: rgba(255,255,255,0.02); border: 1px solid var(--border); border-radius: 3px; }
.kv-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim); margin-bottom: 4px; }
.kv-value { font-size: 15px; color: var(--cream); font-weight: 400; }

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3 { grid-column: span 1; }
  .content { padding: 20px 16px; }
  .mobile-toggle { display: block; }
  .sidebar { position: fixed; left: -260px; transition: left 0.3s; }
  .sidebar.mobile-open { left: 0; }
}

/* ── SIDEBAR COLLAPSED REOPEN FIX ── */
.sidebar.collapsed {
  overflow: visible !important;
}
.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 16px 4px;
}
.sidebar.collapsed .sidebar-toggle {
  position: fixed;
  left: 48px;
  top: 12px;
  background: var(--navy-mid);
  border: 1px solid var(--border-bright);
  border-radius: 0 4px 4px 0;
  width: 20px;
  height: 32px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  z-index: 200;
  color: var(--gold);
}
.sidebar.collapsed .sidebar-footer {
  justify-content: center;
  padding: 12px 4px;
}
.sidebar.collapsed .btn-logout {
  margin: 0;
}
