/* ==========================================================================
   Admin Dashboard — design tokens
   Palette kept from the original navy/gold academic brand, but restructured
   as CSS variables (Melody-dashboard style) so components stay consistent.
   ========================================================================== */
:root {
  --ink: #0d1b2a;
  --text: #172033;
  --muted: #6b6f80;
  --muted-2: #8a8fa3;

  --bg: #f3f1ec;
  --surface: #ffffff;
  --surface-2: #fbf9f5;

  --border: #e6e0d3;
  --border-soft: #eee9de;

  --accent: #c9972b;
  --accent-dark: #a87b1f;
  --accent-soft: #f7ecd4;
  --accent-contrast: #0d1b2a;

  --success: #17864f;
  --success-bg: #e8f6ee;
  --success-border: #b8e3ca;

  --danger: #b3261e;
  --danger-bg: #fdeeec;
  --danger-border: #f3c3bd;

  --info: #2563a8;
  --info-bg: #eaf2fb;
  --info-border: #c3dbf1;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-xs: 0 1px 2px rgba(13, 27, 42, .05);
  --shadow-sm: 0 4px 14px rgba(13, 27, 42, .06);
  --shadow-md: 0 12px 30px rgba(13, 27, 42, .08);
  --shadow-lg: 0 20px 45px rgba(13, 27, 42, .12);

  --transition: 180ms cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 100% 0%, rgba(201, 151, 43, .05), transparent 40%),
    radial-gradient(circle at 0% 100%, rgba(13, 27, 42, .04), transparent 40%);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body.sidebar-open { overflow: hidden; }

a {
  color: var(--accent-dark);
  text-decoration-color: rgba(168, 123, 31, .35);
}
a:hover { text-decoration-color: currentColor; }

::selection { background: var(--accent-soft); color: var(--ink); }

/* Scrollbars (sidebar / tables) */
.sidebar, main { scrollbar-width: thin; scrollbar-color: #d9d1bd transparent; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #d9d1bd; border-radius: 10px; }

/* Focus visibility (accessibility, not present before) */
a:focus-visible, button:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ==========================================================================
   Login / Auth Page
   ========================================================================== */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(201, 151, 43, .16), transparent 42%),
    radial-gradient(circle at 85% 85%, rgba(13, 27, 42, .12), transparent 45%),
    var(--bg);
}

/* Soft decorative blobs, echoing the Melody auth-screen backdrop */
.login-page::before,
.login-page::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  z-index: 0;
}

.login-page::before {
  width: 380px;
  height: 380px;
  top: -120px;
  left: -120px;
  background: radial-gradient(circle, rgba(201, 151, 43, .25), transparent 70%);
}

.login-page::after {
  width: 420px;
  height: 420px;
  bottom: -140px;
  right: -140px;
  background: radial-gradient(circle, rgba(13, 27, 42, .18), transparent 70%);
}

.login-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  display: grid;
  place-items: center;
}

.panel, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.login-card {
  width: min(440px, 100%);
  padding: 36px 34px;
  box-shadow: var(--shadow-lg);
  text-align: left;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.login-brand-mark {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--ink), #14263c);
  display: grid;
  place-items: center;
  font-size: 19px;
  box-shadow: var(--shadow-xs);
}

.login-brand-name {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .02em;
  color: var(--ink);
}

.login-setup-badge { margin-bottom: 10px; }

.login-card h1 { font-size: 24px; }
.login-card > p { margin-bottom: 20px; }

.login-form label:first-of-type { margin-top: 0; }

.login-form input {
  padding: 12px 14px;
  font-size: 15px;
}

.login-submit {
  width: 100%;
  margin-top: 18px;
  padding: 12px 16px;
  font-size: 14px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.login-back {
  margin: 22px 0 0;
  text-align: center;
}

.login-back a {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}

.login-back a:hover { color: var(--accent-dark); }

@media (max-width: 480px) {
  .login-card { padding: 28px 22px; }
}

h1, h2, h3 {
  margin: 0 0 12px;
  color: var(--ink);
  line-height: 1.3;
  letter-spacing: -.01em;
}
p { line-height: 1.6; color: var(--muted); }

/* ==========================================================================
   Forms
   ========================================================================== */
label {
  display: block;
  margin: 12px 0 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted-2);
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input::placeholder, textarea::placeholder { color: var(--muted-2); opacity: .8; }

input:hover, textarea:hover, select:hover { border-color: #cdc3ac; }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(201, 151, 43, .18);
}

textarea { min-height: 110px; resize: vertical; }

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236b6f80' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: normal;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
}

button:hover, .button:hover {
  background: var(--accent-dark);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

button:active, .button:active { transform: translateY(0); }

button:disabled, .button:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.button.secondary { background: var(--ink); color: #fff; }
.button.secondary:hover { background: #16273a; }

.button.danger, button.danger {
  background: var(--danger-bg);
  color: var(--danger);
  box-shadow: none;
  border: 1px solid var(--danger-border);
}
.button.danger:hover, button.danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

/* ==========================================================================
   Top Bar
   ========================================================================== */
.topbar {
  background: linear-gradient(135deg, var(--ink), #14263c);
  color: #fff;
  padding: 16px 5%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.topbar-title { min-width: 0; }

.topbar-title strong {
  display: block;
  font-size: 16px;
  letter-spacing: -.01em;
}

.topbar-title .muted { color: rgba(255, 255, 255, .6); }

.topbar-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.topbar a {
  color: rgba(255, 255, 255, .82);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
}

.topbar a:hover {
  background: rgba(255, 255, 255, .1);
  color: #f0c96b;
}

/* Hamburger Menu */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: transparent;
  border: none;
  padding: 6px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: none;
}
.menu-toggle:hover { background: transparent; transform: none; box-shadow: none; }

.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: #f0c96b;
  border-radius: 2px;
  transition: all 0.3s;
}

/* ==========================================================================
   Layout
   ========================================================================== */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 22px;
  padding: 24px 5%;
  position: relative;
  max-width: 1600px;
  margin: 0 auto;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 88px;
  align-self: start;
  padding: 14px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}

.sidebar-header {
  display: none;
  padding: 18px;
  border-bottom: 1px solid var(--border);
  justify-content: space-between;
  align-items: center;
  margin: -14px -14px 12px -14px;
}

.sidebar-header h3 { margin: 0; font-size: 18px; }

.sidebar-close {
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  line-height: 1;
  box-shadow: none;
}
.sidebar-close:hover { background: transparent; transform: none; color: var(--ink); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 14px;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border-left: 3px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.sidebar-nav a:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-left-color: var(--accent);
}

.sidebar-nav a:active,
.sidebar-nav a:target {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 27, 42, 0.6);
  backdrop-filter: blur(1px);
  z-index: 98;
}

/* ==========================================================================
   Main content
   ========================================================================== */
main { min-width: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.card {
  padding: 22px;
  margin-bottom: 18px;
  transition: box-shadow var(--transition);
}

/* First heading inside a card acts as a card header with a divider,
   matching the sectioned-widget look of the benchmark dashboard. */
.card > h1:first-child,
.card > h2:first-child {
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}

.card > h1:first-child + p,
.card > h2:first-child + p {
  margin-top: -8px;
}

/* ---- Stat / overview cards ---- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 20px;
  background: var(--accent-soft);
}

.stat-card.is-info .stat-card-icon { background: var(--info-bg); }
.stat-card.is-warn .stat-card-icon { background: #fdf1de; }

.stat-card-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}

.stat-card-label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}

/* ---- Alerts ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow-xs);
}

.alert.ok { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.alert.error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }

.alert::before { font-size: 16px; }
.alert.ok::before { content: '✓'; }
.alert.error::before { content: '!'; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.badge.is-muted { background: #eef0f4; color: var(--muted); }
.badge.is-success { background: var(--success-bg); color: var(--success); }
.badge.is-info { background: var(--info-bg); color: var(--info); }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table-wrap table { margin-top: 0; }

th, td {
  border-bottom: 1px solid var(--border-soft);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 700;
  z-index: 1;
}

tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.muted { color: var(--muted); font-size: 13px; }

.type-heading {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

/* Empty-state hint when a table body has no rows */
tbody:empty::after,
table:has(tbody:empty)::after {
  content: 'Nothing here yet.';
  display: block;
  padding: 24px;
  text-align: center;
  color: var(--muted-2);
  font-size: 13.5px;
}

/* ==========================================================================
   Tablet Responsive
   ========================================================================== */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 220px 1fr;
    gap: 18px;
    padding: 20px 3%;
  }
}

/* ==========================================================================
   Mobile Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .menu-toggle { display: flex; }

  .topbar { padding: 14px 4%; }

  .topbar-title strong { font-size: 15px; }
  .topbar-title .muted { font-size: 12px; }

  .layout {
    grid-template-columns: 1fr;
    padding: 16px 4%;
    gap: 0;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    padding: 0;
    z-index: 99;
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    max-height: 100vh;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-header { display: flex; }

  .sidebar-nav { padding: 10px 14px 18px; }

  .sidebar-overlay.active { display: block; }

  .grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

  .card { padding: 18px; border-radius: var(--radius-sm); }

  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
}

/* ==========================================================================
   Small Mobile
   ========================================================================== */
@media (max-width: 600px) {
  .topbar { padding: 12px 4%; }
  .topbar-title strong { font-size: 14px; }
  .topbar-actions a { font-size: 13px; padding: 6px 8px; }

  .layout { padding: 12px 4%; }

  .card { padding: 16px; }

  h1 { font-size: 22px; }
  h2 { font-size: 18px; }

  .stat-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card-icon { width: 36px; height: 36px; min-width: 36px; font-size: 16px; }
  .stat-card-value { font-size: 18px; }

  table { font-size: 13px; }
  th, td { padding: 9px 8px; }

  button, .button { padding: 9px 13px; font-size: 14px; }

  input, textarea, select { font-size: 16px; /* Prevents zoom on iOS */ }
}

/* ==========================================================================
   Extra Small Mobile
   ========================================================================== */
@media (max-width: 400px) {
  .topbar-title br { display: none; }

  .topbar-title strong::after {
    content: ' • ';
    color: var(--muted-2);
    font-weight: normal;
    font-size: 12px;
  }

  .sidebar { width: 260px; }

  .stat-row { grid-template-columns: 1fr; }

  table { font-size: 12px; }
  th, td { padding: 7px 6px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}