/* ===== Admin dashboard — navy + gold ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --navy: #14213d; --navy-dk: #0c1730; --royal: #1e40af; --gold: #f6c700;
  --ink: #1b2540; --muted: #6b7690; --line: #e6e8ef; --bg: #f5f7fb; --card: #fff;
  --danger: #d64545; --ok: #0ea5a4; --radius: 14px;
}
body.admin {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased;
}
a { color: inherit; }

/* ---- Sidebar ---- */
.admin-sidebar {
  position: fixed; top: 0; left: 0; width: 240px; height: 100vh;
  background: var(--navy); color: #cfd6ea; display: flex; flex-direction: column;
  padding: 1.2rem .9rem; z-index: 60;
}
.admin-brand { display: flex; align-items: center; gap: .6rem; padding: .3rem .5rem 1.3rem; border-bottom: 1px solid rgba(255,255,255,.1); }
.admin-brand img { height: 30px; }
.admin-brand span { font-weight: 700; color: #fff; font-size: .95rem; }
.admin-nav { display: flex; flex-direction: column; gap: .25rem; margin-top: 1rem; }
.admin-nav a, .admin-logout {
  display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem;
  border-radius: 10px; text-decoration: none; color: #cfd6ea; font-weight: 500; font-size: .93rem;
}
.admin-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.admin-nav a.is-active { background: var(--royal); color: #fff; }
.admin-nav a.is-active .ico { filter: none; }
.ico { width: 1.2rem; text-align: center; }
.admin-logout { margin-top: auto; color: #f3b4b4; }
.admin-logout:hover { background: rgba(214,69,69,.15); }

/* ---- Main ---- */
.admin-main { margin-left: 240px; min-height: 100vh; }
.admin-topbar {
  display: flex; align-items: center; gap: 1rem; background: #fff;
  padding: 1rem 1.6rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40;
}
.admin-topbar h1 { font-size: 1.25rem; }
.admin-who { margin-left: auto; color: var(--muted); font-size: .9rem; }
.sidebar-burger { display: none; font-size: 1.4rem; cursor: pointer; line-height: 1; }
.sidebar-scrim { display: none; }
/* Raised from 1200px on 2026-07-28: the Committee table is 9 columns wide and was
   forced into horizontal scrolling while the right of a desktop screen sat empty.
   Still capped rather than full-bleed so text-heavy pages (forms, Reports) don't
   stretch into unreadably long lines on an ultrawide monitor. */
.admin-content { padding: 1.6rem; max-width: 1600px; }

/* ---- KPI tiles ---- */
.kpi-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 1.8rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem 1.4rem; }
.kpi__label { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.kpi__value { font-size: 2.2rem; font-weight: 800; margin-top: .3rem; }
.kpi__value .ico { font-size: 1.4rem; }
.kpi--gold { border-top: 4px solid var(--gold); }
.kpi--royal { border-top: 4px solid var(--royal); }
.kpi--teal { border-top: 4px solid var(--ok); }

/* ---- Cards ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; margin-bottom: 1.6rem; }
.card > h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h2 { font-size: 1.1rem; }
/* More than one button on the right of a card head (Committee: Add + Export). */
.card-head__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---- Tables ---- */
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.data-table th, .data-table td { text-align: left; padding: .75rem .9rem; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: middle; }
.data-table th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; }
.data-table tbody tr:hover { background: #fafbfe; }
.data-table .thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); }
/* Same silhouette as the public gallery (helpers.php photo_placeholder). */
.data-table .thumb--empty { display: grid; place-items: center; background: var(--bg); }
.data-table .thumb--empty svg {
  width: 60%; height: auto; fill: none;
  stroke: var(--line); stroke-width: 4; stroke-linecap: round;
}
.empty { color: var(--muted); padding: 1.4rem 0; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 700; }
.badge--staff { background: rgba(30,64,175,.12); color: var(--royal); }
.badge--student { background: rgba(214,168,0,.18); color: #8a6d00; }
.badge--parent { background: rgba(14,165,164,.15); color: #0a7a79; }
.badge--ok { background: #e9f7ef; color: #146b3f; }
.badge--muted { background: rgba(0,0,0,.06); color: #6b7280; }

/* ---- Buttons ---- */
.btn { display: inline-block; background: var(--royal); color: #fff; border: none; border-radius: 9px; padding: .6rem 1.1rem; font-weight: 600; text-decoration: none; cursor: pointer; font-size: .9rem; }
.btn:hover { background: #172554; }
.btn-sm { padding: .4rem .7rem; font-size: .82rem; border-radius: 7px; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #f0c4c4; }
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ---- Filters ---- */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; }
.filter-chip { padding: .38rem .8rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; font-size: .85rem; color: var(--muted); }
.filter-chip.is-active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---- Reports: charts ---- */
.report-grid { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; }
.chart-card h3 { font-size: 1rem; margin-bottom: 1rem; }
.donut-wrap { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.chart-donut { width: 150px; height: 150px; flex-shrink: 0; }
.donut-total { font-size: 30px; font-weight: 800; fill: var(--ink); }
.chart-legend { list-style: none; display: flex; flex-direction: column; gap: .5rem; font-size: .9rem; }
.chart-legend .dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: .5rem; }
.bar-chart { display: flex; flex-direction: column; gap: .7rem; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 34px; align-items: center; gap: .7rem; font-size: .88rem; }
.bar-label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--bg); border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; }
.bar-val { font-weight: 700; text-align: right; }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--navy); padding: 1rem; }
.login-card { background: #fff; border-radius: 18px; padding: 2.2rem; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card img { height: 40px; margin-bottom: 1.2rem; }
.login-card h1 { font-size: 1.4rem; margin-bottom: .3rem; }
.login-card p.sub { color: var(--muted); margin-bottom: 1.4rem; font-size: .92rem; }
.login-card label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 1rem; }
.login-card input { display: block; width: 100%; margin-top: .4rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 9px; font-size: 1rem; }
.login-card input:focus { outline: none; border-color: var(--royal); box-shadow: 0 0 0 3px rgba(30,64,175,.15); }
.login-card .btn { width: 100%; margin-top: .5rem; text-align: center; }
/* Admin login has no top nav (it does not use the public header), so this is the
   only way back to the site without editing the URL. */
.login-back { margin-top: 1.1rem; text-align: center; font-size: .9rem; }
.login-back a { color: var(--muted); text-decoration: none; }
.login-back a:hover { color: var(--royal); text-decoration: underline; }
.alert-error { background: #fdecec; border: 1px solid #f5b5b5; color: #9b1c1c; padding: .8rem 1rem; border-radius: 9px; margin-bottom: 1.2rem; font-size: .9rem; }
.alert-note { background: #fff8e1; border: 1px solid #f0d98a; color: #7a5c00; padding: .8rem 1rem; border-radius: 9px; margin-bottom: 1.2rem; font-size: .9rem; }
/* Editable cells on the Units page (inputs sit inside the table, not .admin-form). */
.data-table input[type=text], .data-table input[type=number] {
  padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 7px;
  font: inherit; color: var(--ink); background: #fff;
}
.data-table input:focus { outline: none; border-color: var(--royal); box-shadow: 0 0 0 3px rgba(30,64,175,.15); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---- Row actions (edit + delete) ---- */
.row-actions { display: flex; gap: .4rem; align-items: center; }
.row-actions form { margin: 0; }

/* Icon-only row actions. Every one carries a title + aria-label, so the meaning
   survives both a hover and a screen reader. */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); cursor: pointer; transition: all .12s ease;
}
.icon-btn svg {
  width: 17px; height: 17px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.icon-btn:hover { background: var(--bg); color: var(--royal); border-color: var(--royal); }
.icon-btn:focus-visible { outline: 2px solid var(--royal); outline-offset: 2px; }
.icon-btn--danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.nowrap { white-space: nowrap; }

/* Committee table. These two columns used to carry fixed `min-width`s (20rem /
   9.5rem) to stop names and phone numbers wrapping — but a fixed minimum on a
   9-column table is exactly what forced the whole thing into horizontal
   scrolling. Removed 2026-07-28: the table now sizes to its container, and the
   wider .admin-content gives the name column plenty of room on its own (auto
   table layout hands the widest content the biggest share). A very long name may
   wrap on a small laptop, which is the better trade against sideways scrolling.
   `nowrap` stays on the phone so a number never breaks mid-digit. */
.data-table .col-phone { white-space: nowrap; }

/* Filter bar (Committee list): search + unit + category, all combining. */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: .7rem;
  margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line);
}
.filter-field { display: flex; flex-direction: column; gap: .25rem; }
.filter-field--grow { flex: 1 1 16rem; min-width: 12rem; }
.filter-field > span {
  color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
}
.filter-field input, .filter-field select {
  padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: .9rem; color: var(--ink); background: #fff; width: 100%;
}
.filter-field input:focus, .filter-field select:focus {
  outline: none; border-color: var(--royal); box-shadow: 0 0 0 3px rgba(30,64,175,.15);
}
.filter-actions { display: flex; gap: .4rem; }

/* Sortable column headers. The whole header is the click target, and the arrow
   slot is always rendered so the row doesn't shift width when sorting changes. */
.data-table th.th-sort { padding: 0; }
.data-table th.th-sort > a {
  display: block; padding: .75rem .9rem; color: inherit; text-decoration: none;
  white-space: nowrap; cursor: pointer;
}
.data-table th.th-sort > a:hover { color: var(--royal); background: var(--bg); }
.data-table th.th-sort.is-sorted > a { color: var(--royal); }
.th-sort__arr { display: inline-block; min-width: .85em; font-size: .9em; }

/* Pagination */
.pager {
  display: flex; flex-wrap: wrap; gap: .8rem 1rem;
  align-items: center; justify-content: space-between;
  margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--line);
}
.pager__count { color: var(--muted); font-size: .85rem; }
.pager__links { display: flex; flex-wrap: wrap; gap: .3rem; }
.pager__link {
  display: inline-block; min-width: 32px; padding: .35rem .6rem;
  border: 1px solid var(--line); border-radius: 7px;
  color: var(--ink); text-decoration: none; text-align: center;
  font-size: .85rem; font-weight: 600;
}
.pager__link:hover { background: var(--bg); border-color: var(--royal); color: var(--royal); }
.pager__link.is-current { background: var(--royal); border-color: var(--royal); color: #fff; }
.pager__link.is-disabled { opacity: .4; pointer-events: none; }

.alert-ok { background: #e9f7ef; border: 1px solid #a7dcbd; color: #146b3f; padding: .8rem 1rem; border-radius: 9px; margin-bottom: 1.2rem; font-size: .9rem; }

/* ---- Flash ---- */
.flash-ok { background: #e7f7ee; border: 1px solid #9fdcbb; color: #1a7a4a; padding: .7rem 1rem; border-radius: 9px; margin-bottom: 1.2rem; font-size: .9rem; }

/* ---- Admin form (edit) ---- */
.admin-form { max-width: 520px; }
.admin-form label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 1rem; }
.admin-form input[type=text], .admin-form input[type=email], .admin-form input[type=tel],
.admin-form input[type=number], .admin-form select {
  display: block; width: 100%; margin-top: .4rem; padding: .65rem .8rem;
  border: 1px solid var(--line); border-radius: 9px; font-size: 1rem;
}
.admin-form input:focus, .admin-form select:focus { outline: none; border-color: var(--royal); box-shadow: 0 0 0 3px rgba(30,64,175,.15); }
.admin-form fieldset { border: none; margin-bottom: 1rem; }
.admin-form legend { font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }
.admin-form .radio-group { display: flex; gap: .7rem; flex-wrap: wrap; }
.admin-form .radio-option { display: flex; align-items: center; gap: .45rem; padding: .5rem .9rem; border: 1px solid var(--line); border-radius: 9px; font-weight: 500; cursor: pointer; }
.admin-form .radio-option input { accent-color: var(--royal); }
.admin-form .radio-option:has(input:checked) { border-color: var(--royal); background: rgba(30,64,175,.06); }
.current-photo { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: .4rem 0 1rem; }
.current-photo img { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); }
.form-actions { display: flex; gap: .7rem; margin-top: .5rem; }
.hint { font-size: .82rem; }

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .admin-sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  #sidebar-toggle:checked ~ .admin-sidebar { transform: none; }
  #sidebar-toggle:checked ~ .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; }
  .admin-main { margin-left: 0; }
  .sidebar-burger { display: inline-block; }
  .admin-who { display: none; }
}

/* ---- Enquiry messages (expandable cell) ---- */
.msg { max-width: 32rem; }
.msg summary { cursor: pointer; color: var(--muted); }
.msg[open] summary { color: var(--ink); font-weight: 600; }
.msg__full { margin-top: .5rem; white-space: pre-wrap; line-height: 1.55; }

/* ---- Bulk photo upload (/admin/gallery.php) ---- */
.bulk__drop {
  border: 2px dashed var(--line, #d7dbe6); border-radius: 12px;
  padding: 1.6rem 1rem; text-align: center; cursor: pointer;
  color: var(--muted, #5a6478); background: #fbfcfe;
  transition: border-color .15s ease, background .15s ease;
}
.bulk__drop:hover, .bulk__drop:focus-visible { border-color: var(--gold, #f6c700); background: #fffdf3; }
.bulk__drop.is-over { border-color: var(--gold, #f6c700); background: #fff8dc; }
.bulk__drop.is-busy { cursor: default; opacity: .6; }
.bulk__lead { margin: .5rem 0 .2rem; color: var(--ink, #14213d); }

.bulk__bar {
  height: 6px; border-radius: 99px; background: #e9edf5;
  margin: 1rem 0 .6rem; overflow: hidden;
}
.bulk__bar > span { display: block; height: 100%; width: 0; background: var(--gold, #f6c700); transition: width .2s ease; }
.bulk__status { font-size: .85rem; }

.bulk__list { list-style: none; margin: .6rem 0 0; padding: 0; max-height: 20rem; overflow-y: auto; }
.bulk__row {
  display: flex; align-items: center; gap: .7rem;
  padding: .4rem .2rem; border-top: 1px solid var(--line, #e6e8ef); font-size: .88rem;
}
.bulk__thumb { flex: 0 0 34px; height: 34px; border-radius: 6px; overflow: hidden; background: #eef1f7; }
.bulk__thumb img { width: 34px; height: 34px; object-fit: cover; display: block; }
.bulk__name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bulk__state { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--muted, #5a6478); }
.bulk__row.is-ok  .bulk__state { color: #1a7f45; font-weight: 600; }
.bulk__row.is-bad .bulk__state { color: #b3261e; font-weight: 600; }
