/* ===== Tokens ===== */
:root {
  --ink: #211f1d;
  --muted: #726f6a;
  --paper: #f2f3f1;
  --surface: #ffffff;
  --line: #dedbd6;
  --garnet: #922b33;
  --garnet-deep: #6b1f26;
  --garnet-wash: #fbeceb;
  --sage: #4c6b4f;
  --danger: #a63a2f;
  --radius-panel: 12px;
  --radius-control: 8px;
  --font-main: 'Manrope', ui-sans-serif, "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-main);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  font-size: 16.5px;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-weight: 700; margin: 0 0 14px; letter-spacing: -0.01em; }
h1 { font-size: 27px; }
h2 { font-size: 19px; font-weight: 700; }
a { color: var(--garnet); }

/* ===================================================== */
/* Brand block (logo + name), used in both sidebars       */
/* ===================================================== */
.brand-block { display: flex; align-items: center; justify-content: center; padding: 20px; border-bottom: 1px solid var(--line); text-decoration: none; }
.brand-logo { width: 76px; height: 76px; object-fit: contain; flex-shrink: 0; }
.brand-text { display: none; }

/* ===================================================== */
/* Staff sidebar shell                                    */
/* ===================================================== */
.staff-body { display: flex; min-height: 100vh; background: var(--paper); align-items: flex-start; }

.sidebar {
  width: 244px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
  transition: transform .2s ease;
}
.side-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 9px;
  color: var(--ink); text-decoration: none; font-size: 14.5px; font-weight: 600;
}
.side-nav a:hover { background: var(--paper); }
.side-nav a.active { background: var(--garnet-wash); color: var(--garnet-deep); }
.nav-icon { width: 19px; height: 19px; flex-shrink: 0; }
.side-footer { padding: 14px 18px; border-top: 1px solid var(--line); }
.side-user { font-size: 14px; font-weight: 700; margin-bottom: 6px; display: flex; flex-direction: column; }
.role-tag { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: capitalize; }
.side-logout { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); text-decoration: none; }
.side-logout:hover { color: var(--garnet); }

.staff-content { margin-left: 244px; flex: 1; padding: 36px 40px 60px; max-width: 1280px; }

.top-actions {
  position: fixed; top: 14px; right: 14px; z-index: 50;
  display: flex; align-items: center; gap: 8px;
}

.notif-bell-wrap { position: relative; }
.notif-bell {
  display: flex; align-items: center; justify-content: center; position: relative;
  width: 38px; height: 38px; padding: 0; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.notif-bell:hover { border-color: var(--garnet); color: var(--garnet-deep); }
.notif-bell:focus-visible { outline: 2px solid var(--garnet); outline-offset: 2px; }
.notif-badge {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--garnet); color: #fff; font-size: 10.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; line-height: 1; border: 2px solid var(--paper);
}
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; width: 320px; max-width: calc(100vw - 28px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel);
  box-shadow: 0 12px 28px rgba(20,16,15,.14); max-height: 380px; display: flex; flex-direction: column; overflow: hidden;
}
.notif-dropdown-head { padding: 12px 16px; font-weight: 700; border-bottom: 1px solid var(--line); font-size: 14px; }
.notif-dropdown .plain-list { overflow-y: auto; padding: 4px 0; }
.notif-dropdown .plain-list li { padding: 9px 16px; font-size: 13.5px; line-height: 1.4; }
.notif-dropdown .plain-list li:not(.notif-msg):hover { background: var(--paper); }
.notif-dropdown .notif-time { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.notif-msg { color: var(--muted); }

@media (max-width: 420px) {
  .notif-dropdown { width: calc(100vw - 28px); }
}
.mobile-logout { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .staff-content { margin-left: 0; padding: 20px 16px 92px; }
  .mobile-logout {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; padding: 0; border-radius: 8px; border: 1px solid var(--line);
    background: var(--surface); color: var(--ink);
  }
}

/* Defensive: every link/button keeps explicit, readable colors in every state —
   no relying on inheritance, so nothing can silently fall back to a dark default. */
a:visited { color: var(--garnet); }
.button-danger:hover { background: #7c2c22; color: #fff; }
.bg-chip.selected:hover { color: #fff; border-color: var(--garnet); }
.side-nav a.active:hover { background: var(--garnet-wash); color: var(--garnet-deep); }
.bottom-nav a.active:hover { color: var(--garnet-deep); }
.donor-avatar { color: #fff; }

.container { max-width: 700px; margin: 0 auto; padding: 24px 16px 70px; }
.guest-header { display: flex; align-items: center; justify-content: center; padding: 18px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.guest-header .brand-logo { width: 64px; height: 64px; object-fit: contain; }
.guest-header strong, .guest-header span { display: none; }
.page-head h1 { margin-bottom: 4px; }
.page-head p { margin: 0; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 12px;
}
.stat-card-icon {
  width: 36px; height: 36px; border-radius: 9px; background: var(--garnet-wash); color: var(--garnet-deep);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-card-icon svg { width: 18px; height: 18px; }
.stat-card-num { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1; }
.stat-card-label { font-size: 13.5px; color: var(--muted); font-weight: 500; }

.stat-card-link { text-decoration: none; color: inherit; position: relative; transition: border-color .15s, transform .15s; }
.stat-card-link:hover { border-color: var(--garnet); transform: translateY(-1px); }
.stat-card-link:focus-visible { outline: 2px solid var(--garnet); outline-offset: 2px; }
.stat-card-link::after {
  content: ''; position: absolute; top: 18px; right: 18px; width: 8px; height: 8px;
  border-top: 1.8px solid var(--muted); border-right: 1.8px solid var(--muted); transform: rotate(45deg);
}

#logBook { max-height: 360px; overflow-y: auto; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 4px; }
.table-scroll .data-table { min-width: 480px; }
.data-table tbody tr:hover { background: var(--paper); }

@media (max-width: 860px) {
  .stat-cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .stat-card { padding: 14px 16px; }
}

/* ===================================================== */
/* Student shell — sidebar on desktop, bottom bar on mobile */
/* ===================================================== */
.student-body { display: flex; min-height: 100vh; background: var(--paper); align-items: flex-start; }

.student-sidebar {
  width: 244px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 20;
}
.student-content { margin-left: 244px; flex: 1; padding: 32px 40px 50px; max-width: 1200px; width: 100%; }

.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--surface); border-top: 1px solid var(--line);
  height: 66px; align-items: stretch; justify-content: space-around; padding: 0 4px;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 700; flex: 1; text-decoration: none;
}
.bottom-nav a.active { color: var(--garnet-deep); }
.bottom-nav .nav-icon { width: 22px; height: 22px; }
.bottom-nav-fab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1; text-decoration: none; padding-bottom: 6px; }
.bottom-nav-fab .fab-circle {
  width: 54px; height: 54px; border-radius: 50%; background: var(--garnet); color: #fff;
  display: flex; align-items: center; justify-content: center;
  position: absolute; top: -24px; box-shadow: 0 8px 18px rgba(146,43,51,.4);
}
.bottom-nav-fab .fab-circle svg { width: 24px; height: 24px; }
.bottom-nav-fab span.fab-label { margin-top: 32px; font-size: 11px; font-weight: 800; color: var(--garnet-deep); }

@media (max-width: 860px) {
  .student-sidebar { display: none; }
  .student-content { margin-left: 0; padding: 20px 16px 92px; }
  .bottom-nav { display: flex; }
}

/* ===================================================== */
/* Hero (student home)                                    */
/* ===================================================== */
.hero {
  background: linear-gradient(180deg, var(--garnet-wash) 0%, var(--paper) 100%);
  border-radius: var(--radius-panel);
  padding: 32px 24px;
  text-align: center;
  margin-bottom: 24px;
}
.hero-num {
  display: block; font-size: 46px; font-weight: 800; color: var(--garnet-deep);
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.hero-label { display: block; color: var(--muted); margin-top: 2px; font-size: 15.5px; }
.hero-breakdown {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 18px;
  margin: 20px 0 18px; padding-top: 18px; border-top: 1px solid rgba(146,43,51,0.15);
}
.hero-group { display: flex; flex-direction: column; align-items: center; min-width: 40px; }
.hero-group-count { font-size: 19px; font-weight: 750; font-variant-numeric: tabular-nums; }
.hero-group-label { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ===================================================== */
/* Panels & sections                                      */
/* ===================================================== */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel);
  padding: 24px; margin-bottom: 20px;
}
.panel-narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.section { padding: 20px 0; border-top: 1px solid var(--line); }
.section:first-child { border-top: none; }

/* ===================================================== */
/* Forms                                                  */
/* ===================================================== */
label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
label input[type="text"], label input[type="email"], label input[type="password"],
label input[type="date"], label input[type="file"], label select, label textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px 13px;
  border: 1px solid var(--line); border-radius: var(--radius-control); font-size: 16px;
  color: var(--ink); background: var(--paper); font-family: inherit;
}
label textarea { resize: vertical; }
.required-mark { color: var(--garnet); }

.password-field { position: relative; display: block; }
.password-field input[type="password"], .password-field input[type="text"] { padding-right: 44px; }
.password-toggle {
  position: absolute; top: 50%; right: 3px; transform: translateY(-50%);
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0; margin: 0; cursor: pointer; color: var(--muted);
  -webkit-tap-highlight-color: transparent;
}
.password-toggle:hover { color: var(--ink); }
.password-toggle:focus-visible { outline: 2px solid var(--garnet); outline-offset: 1px; border-radius: 6px; }
.password-toggle .icon-eye-off { display: none; }
.password-toggle.is-visible .icon-eye { display: none; }
.password-toggle.is-visible .icon-eye-off { display: block; }

button, .button, .button-outline, .button-small, .button-danger {
  display: inline-block; border: none; padding: 13px 22px; border-radius: var(--radius-control);
  font-size: 15.5px; font-weight: 600; cursor: pointer; text-decoration: none; font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
button, .button { background: var(--garnet); color: #fff; }
button:hover, .button:hover { background: var(--garnet-deep); }
button:active, .button:active { transform: scale(0.98); }
.button-outline { background: transparent; color: var(--garnet); border: 1px solid var(--garnet); }
.button-outline:hover { background: var(--garnet); color: #fff; }
.button-danger { background: var(--danger); color: #fff; }
.button-small { padding: 9px 15px; font-size: 13.5px; }
.inline-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.alert { padding: 11px 15px; border-radius: var(--radius-control); font-size: 14.5px; margin-bottom: 14px; }
.alert-error { background: #fbe9e7; color: #8a2f24; }
.alert-success { background: #e6f0e7; color: #345a37; }

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

/* ===================================================== */
/* Toggle switches (replaces plain checkboxes)            */
/* ===================================================== */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 15px; color: var(--ink); font-weight: 500;
}
.toggle-row:last-of-type { border-bottom: none; }
.toggle-row .toggle-copy { flex: 1; }
.toggle-row .toggle-hint { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.toggle-row-locked { opacity: .85; }
.toggle { position: relative; display: inline-block; width: 48px; height: 28px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .15s; cursor: pointer; }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.toggle input:checked ~ .toggle-track { background: var(--garnet); }
.toggle input:checked ~ .toggle-track .toggle-thumb { transform: translateX(20px); }
.toggle input:focus-visible ~ .toggle-track { outline: 2px solid var(--garnet); outline-offset: 2px; }

/* ===================================================== */
/* Lists                                                  */
/* ===================================================== */
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list > li { padding: 13px 0; border-bottom: 1px solid var(--line); }
.plain-list > li:last-child { border-bottom: none; }
.row-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stars { color: var(--garnet); letter-spacing: 1px; }

/* ===================================================== */
/* Blood group chips                                      */
/* ===================================================== */
.bg-chip-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 6px; }
.bg-chip {
  padding: 16px 0; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface);
  font-size: 16.5px; font-weight: 700; color: var(--ink); cursor: pointer; transition: background .12s, border-color .12s, color .12s;
  -webkit-tap-highlight-color: transparent;
}
.bg-chip:hover { border-color: var(--garnet); }
.bg-chip.selected { background: var(--garnet); border-color: var(--garnet); color: #fff; }
.filters { margin-top: 12px; }
.filters summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-bottom: 10px; font-weight: 600; }
.filters .toggle-row { margin-top: 4px; }
.filter-grid { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filter-grid label { flex: 1 1 150px; margin-bottom: 0; }
.filter-grid button { flex: 0 0 auto; height: 44px; }
.filter-grid .link-small { align-self: center; }

/* ===================================================== */
/* Donor result cards                                     */
/* ===================================================== */
#resultsSection { transition: opacity .15s ease; }
#resultsSection.is-loading { opacity: .55; }

.donor-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 17px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.donor-card:last-child { border-bottom: none; }
.donor-avatar-img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--line); }
.donor-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--garnet); color: #fff; font-weight: 700; font-size: 16px;
}
.donor-info { flex: 1; min-width: 180px; }
.donor-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: 56px; }
.revealed-number { font-weight: 700; font-variant-numeric: tabular-nums; }
.row-actions-secondary { margin-top: 6px; }
.link-small { font-size: 13px; margin-right: 14px; color: var(--muted); text-decoration: underline; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.badge-ok { background: #e6f0e7; color: #345a37; }
.badge-off { background: #ece9e4; color: var(--muted); }
.badge-warn { background: var(--garnet-wash); color: var(--garnet-deep); }
.badge-info { background: #e8eef5; color: #34506e; }

.empty-state { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-icon { width: 30px; height: 30px; margin-bottom: 10px; }
.empty-state p { margin: 0; font-size: 15px; }

/* ===================================================== */
/* Tables                                                 */
/* ===================================================== */
.data-table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 14.5px; }
.data-table th, .data-table td { text-align: left; padding: 11px 9px; border-bottom: 1px solid var(--line); }
.data-table th { color: var(--muted); font-weight: 700; font-size: 13px; }

/* ===================================================== */
/* Tabs                                                   */
/* ===================================================== */
.tabs { display: flex; gap: 22px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tab-btn { background: none; border: none; padding: 10px 0; color: var(--muted); cursor: pointer; font-size: 14.5px; font-weight: 600; border-bottom: 2px solid transparent; font-family: inherit; }
.tab-btn.active { color: var(--garnet); border-bottom-color: var(--garnet); }

/* ===================================================== */
/* Search form (staff student search)                     */
/* ===================================================== */
.search-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.search-form > input[type="text"] { padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-control); flex: 1; min-width: 200px; background: var(--paper); font-size: 16px; }

/* ===================================================== */
/* Profile                                                */
/* ===================================================== */
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.profile-head h1 { margin-bottom: 2px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--line); flex-shrink: 0; }

@media (max-width: 480px) {
  .hero-breakdown { gap: 12px; }
  .stat-row { gap: 20px; }
  .donor-actions { margin-left: 0; width: 100%; }
}

@media (max-width: 360px) {
  .panel { padding: 16px; }
  .bg-chip-grid { gap: 6px; }
}

/* ===================================================== */
/* Install-as-app banner                                  */
/* ===================================================== */
.install-banner {
  display: none; align-items: center; justify-content: space-between; gap: 12px;
  position: fixed; left: 50%; bottom: 82px; transform: translateX(-50%);
  width: calc(100% - 32px); max-width: 420px;
  background: var(--ink); color: #fff; border-radius: 12px; padding: 13px 10px 13px 16px;
  box-shadow: 0 10px 30px rgba(20,18,17,.28); z-index: 45; font-size: 13.5px;
}
.install-banner.visible { display: flex; }
.install-banner span { line-height: 1.35; }
.install-banner .btn-row { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.install-banner button.button { padding: 9px 15px; font-size: 13.5px; }
.install-dismiss {
  background: none; border: none; color: rgba(255,255,255,.65); font-size: 15px;
  cursor: pointer; padding: 6px 8px; line-height: 1;
}
.install-dismiss:hover { color: #fff; }
@media (min-width: 861px) { .install-banner { bottom: 16px; } }
