/*
 * HDR Endorsement & Review Portal
 * Developed by Dr. M. Bilal Amin
 * ICT, University of Tasmania (UTAS)
 * bilal.amin@utas.edu.au
 *
 * Unauthorised reproduction of any code or part of this application
 * is not allowed. All rights reserved © Dr. M. Bilal Amin, UTAS.
 */

/* ── Reset & Variables ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:    #002B5C;
  --navy-l:  #003D7A;
  --navy-ll: #00509A;
  --utas-red: #EE3124;
  --gold:    #c9a84c;
  --gold-l:  #e8c76a;
  --gold-bg: #fdf6e3;
  --white:   #ffffff;
  --off:     #f7f8fa;
  --border:  #e4e8ef;
  --text:    #1a2535;
  --muted:   #6b7894;
  --red:     #d94f4f;
  --green:   #2a9d6a;
  --amber:   #e07a1c;
  --blue:    #2563eb;

  --sidebar-w: 240px;
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.12);

  --font-head: 'Montserrat', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body { height: 100%; font-family: var(--font-body); background: var(--off); color: var(--text); font-size: 14px; line-height: 1.6; }

/* ── Layout ────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

#sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--navy); color: rgba(255,255,255,.75);
  display: flex; flex-direction: column;
  padding: 0;
  border-top: 4px solid var(--utas-red);
}

#main {
  flex: 1; overflow-y: auto;
  padding: 32px;
  background: var(--off);
}

/* ── Sidebar ───────────────────────────────────────── */
.sidebar-brand {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 16px 18px; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-logo-wrap {
  background: #fff; border-radius: 6px;
  padding: 7px 14px;
  display: flex; align-items: center; justify-content: center;
  width: 100%;
}
.sidebar-logo { width: 100%; max-width: 170px; height: auto; display: block; }
.brand-text { text-align: center; }
.brand-title { display: block; font-size: 11px; font-weight: 600; color: rgba(255,255,255,.8); letter-spacing: .06em; text-transform: uppercase; }
.brand-sub   { display: block; font-size: 10px; color: rgba(255,255,255,.4); margin-top: 3px; }

.sidebar-nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 1px; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 5px;
  color: rgba(255,255,255,.6); font-size: 13px; font-weight: 500;
  text-decoration: none; transition: background .12s, color .12s;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.rounds-subnav { display: flex; flex-direction: column; gap: 1px; padding: 0 0 4px 28px; }
.rounds-subnav-link { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 5px; color: rgba(255,255,255,.45); font-size: 12px; font-weight: 500; text-decoration: none; transition: background .12s, color .12s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rounds-subnav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.rounds-subnav-link.active { background: rgba(255,255,255,.12); color: #fff; }
.rounds-subnav-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; opacity: .6; }
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-link.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  font-weight: 600;
}

.sidebar-footer { padding: 14px 10px 18px; border-top: 1px solid rgba(255,255,255,.12); }

.round-badge {
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  color: #5e7a94; text-transform: uppercase; margin-bottom: 10px;
}

.export-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px; border-radius: 6px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  color: #8aa0b4; font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all .15s; font-family: var(--font-body);
}
.export-btn svg { width: 14px; height: 14px; }
.export-btn:hover { background: rgba(255,255,255,.1); color: #d0dbe8; }

/* ── Page Header ───────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-header h1 {
  font-family: var(--font-head); font-size: 26px; font-weight: 500;
  color: var(--navy); letter-spacing: -.02em;
}
.page-header p { color: var(--muted); margin-top: 4px; font-size: 14px; }

.header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

/* ── Stats Bar ─────────────────────────────────────── */
.stats-bar { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }

.stat-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 20px;
  min-width: 120px; flex: 1;
}
.stat-card .stat-val { font-size: 26px; font-weight: 600; font-family: var(--font-head); color: var(--navy); line-height: 1; }
.stat-card .stat-lbl { font-size: 11px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .06em; }

/* ── Filters ───────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--white); font-family: var(--font-body); font-size: 13px; color: var(--text);
  outline: none; transition: border-color .15s;
}
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--gold); }
.filter-bar input { flex: 1; min-width: 180px; }
.sort-btn-group { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.sort-btn {
  padding: 8px 13px; background: var(--white); border: none; cursor: pointer;
  font-family: var(--font-body); font-size: 12.5px; font-weight: 500; color: var(--muted);
  transition: background .12s, color .12s;
}
.sort-btn + .sort-btn { border-left: 1px solid var(--border); }
.sort-btn:hover { background: var(--off); color: var(--text); }
.sort-btn.active { background: var(--navy); color: #fff; }

/* ── Table ─────────────────────────────────────────── */
.table-wrap {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; }
th {
  background: var(--off); padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
tbody tr { cursor: pointer; transition: background .1s; }

.rank-num {
  font-family: var(--font-head); font-size: 18px; font-weight: 500;
  color: var(--navy); min-width: 28px; display: inline-block;
}
.rank-empty { color: var(--border); font-size: 14px; }

.group-header-row td {
  background: var(--bg); padding: 7px 14px;
  border-top: 2px solid var(--border); border-bottom: 1px solid var(--border);
}
.group-header-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--navy); }
.group-header-count { font-size: 11px; color: var(--muted); margin-left: 6px; }

.applicant-name { font-weight: 600; color: var(--navy); }
.applicant-school { font-size: 11px; color: var(--muted); margin-top: 2px; }

.score-total {
  font-weight: 700; font-size: 16px; color: var(--navy);
}
.score-max { font-size: 11px; color: var(--muted); }

.score-bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.score-bar-bg { flex: 1; height: 6px; background: #edf0f5; border-radius: 3px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--gold), var(--gold-l)); transition: width .3s; }

/* ── Status Badges ─────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
  letter-spacing: .03em; white-space: nowrap;
}
.badge-endorsed              { background: #e6f7f0; color: #1a7a4f; }
.badge-conditional           { background: #fff4e0; color: #995c00; }
.badge-draft                 { background: #f0f2f5; color: #5e6d80; }
.badge-under_review          { background: #e8f0fe; color: #1a56c4; }
.badge-ready_for_endorsement { background: #f3e8ff; color: #6b21a8; }
.badge-rejected              { background: #fce8e8; color: #b52a2a; }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 6px; font-family: var(--font-body);
  font-size: 13px; font-weight: 500; cursor: pointer; border: none;
  transition: all .15s; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--navy); color: white; }
.btn-primary:hover { background: var(--navy-l); }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: var(--gold-l); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--navy); color: var(--navy); background: var(--off); }
.btn-danger { background: transparent; border: 1px solid #f5c0c0; color: var(--red); }
.btn-danger:hover { background: #fce8e8; }
.btn svg { width: 15px; height: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── Application Detail ────────────────────────────── */
.app-header {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 28px; margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.app-header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.app-title { font-family: var(--font-head); font-size: 22px; font-weight: 500; color: var(--navy); }
.app-meta { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 8px; }
.app-meta-item { font-size: 13px; color: var(--muted); }
.app-meta-item strong { color: var(--text); font-weight: 600; }

.app-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ── Tabs ──────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab {
  padding: 10px 20px; font-size: 13px; font-weight: 500; color: var(--muted);
  cursor: pointer; border: none; background: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all .15s; font-family: var(--font-body);
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); border-bottom-color: var(--gold); font-weight: 600; }

/* ── Cards & Forms ─────────────────────────────────── */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card-title {
  font-family: var(--font-head); font-size: 16px; font-weight: 500;
  color: var(--navy); margin-bottom: 18px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-title-row { display: flex; align-items: center; justify-content: space-between; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
}
.field input, .field select, .field textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-family: var(--font-body); font-size: 13px; color: var(--text);
  background: var(--white); outline: none; transition: border-color .15s;
  resize: vertical;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,.12); }
.field textarea { min-height: 90px; line-height: 1.6; }
.field textarea.tall { min-height: 140px; }

/* ── Scoring Criteria ──────────────────────────────── */
.criterion-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 16px; background: var(--white);
}
.criterion-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--off); border-bottom: 1px solid var(--border);
}
.criterion-name { font-family: 'Montserrat', sans-serif; font-weight: 600; font-size: 13px; color: var(--navy); }
.criterion-max  { font-size: 11px; color: var(--muted); }
.criterion-body { padding: 18px; display: grid; grid-template-columns: 1fr 140px; gap: 16px; align-items: start; }

.score-input-wrap { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.score-input {
  width: 80px; height: 60px; text-align: center;
  font-size: 28px; font-family: var(--font-head); font-weight: 500;
  border: 2px solid var(--border); border-radius: var(--radius);
  color: var(--navy); outline: none; transition: all .15s;
}
.score-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,.15); }
.score-of { font-size: 11px; color: var(--muted); text-align: center; }
.score-fill-bar { width: 80px; height: 4px; background: #edf0f5; border-radius: 2px; overflow: hidden; }
.score-fill { height: 100%; background: var(--gold); border-radius: 2px; transition: width .3s; }

/* ── Endorsements ──────────────────────────────────── */
.endorsement-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.endorsement-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: box-shadow .15s;
}
.endorsement-card:hover { box-shadow: var(--shadow); }
.endorsement-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.school-tag {
  font-size: 12px; font-weight: 700; letter-spacing: .06em;
  padding: 3px 10px; border-radius: 4px;
  background: var(--navy); color: var(--gold);
}
.endorse-toggle { display: flex; align-items: center; gap: 8px; }
.endorse-toggle label { font-size: 12px; font-weight: 500; color: var(--muted); cursor: pointer; }
.toggle-switch {
  position: relative; width: 38px; height: 22px;
  display: inline-block; flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: #dde2e8;
  border-radius: 11px; cursor: pointer; transition: .2s;
}
.toggle-slider::before {
  content: ''; position: absolute; width: 16px; height: 16px;
  left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--green); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── Thread / Conversation ─────────────────────── */
.thread-header { cursor: pointer; user-select: none; }
.thread-header:hover { background: var(--off); }

.thread-count { font-size: 11px; color: var(--muted); white-space: nowrap; }

.thread-chevron {
  width: 16px; height: 16px; color: var(--muted);
  transition: transform .2s ease; flex-shrink: 0;
}

.thread-body {
  overflow: hidden;
  max-height: 600px;
  transition: max-height .3s ease, opacity .2s ease;
  opacity: 1;
}
.thread-body.collapsed { max-height: 0; opacity: 0; pointer-events: none; }

.thread-messages {
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: 280px; overflow-y: auto;
  border-bottom: 1px solid var(--border);
}

.thread-empty {
  font-size: 12px; color: var(--muted); text-align: center;
  padding: 12px 0; font-style: italic;
}

.thread-msg { display: flex; flex-direction: column; gap: 3px; }
.thread-msg-meta { display: flex; align-items: center; gap: 8px; }
.thread-msg-author { font-size: 12px; font-weight: 600; color: var(--navy); }
.thread-msg-time   { font-size: 11px; color: var(--muted); }
.thread-msg-text   { font-size: 13px; color: var(--text); line-height: 1.5; white-space: pre-wrap; }

.thread-reply {
  padding: 8px 12px; display: flex; gap: 8px; align-items: flex-end;
  background: var(--off);
}
.thread-textarea {
  flex: 1; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-family: var(--font-body); font-size: 12px;
  color: var(--text); resize: none; outline: none;
  min-height: 36px; max-height: 100px; overflow-y: auto;
  transition: border-color .15s; background: var(--white); line-height: 1.4;
}
.thread-textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,.1); }

.thread-send-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px; background: var(--navy); color: white;
  border: none; border-radius: 6px; font-size: 12px; font-weight: 500;
  cursor: pointer; font-family: var(--font-body); white-space: nowrap; flex-shrink: 0;
  transition: background .15s;
}
.thread-send-btn:hover { background: var(--navy-l); }
.thread-send-btn svg { width: 12px; height: 12px; }

.thread-controls {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
}
.thread-author-row  { display: flex; align-items: center; gap: 8px; }
.thread-author-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.thread-author-input {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-family: var(--font-body); font-size: 12px; color: var(--text);
  outline: none; transition: border-color .15s; width: 180px; background: var(--white);
}
.thread-author-input:focus { border-color: var(--gold); }

/* ── SE Review ─────────────────────────────────────── */
.score-summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.score-summary-item {
  background: var(--off); border: 1px solid var(--border);
  border-radius: 6px; padding: 14px 16px;
}
.score-summary-item .s-name { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.score-summary-item .s-val {
  font-size: 22px; font-family: var(--font-head); font-weight: 500;
  color: var(--navy); margin-top: 2px;
}
.score-summary-item .s-max { font-size: 11px; color: var(--muted); }

.total-score-card {
  background: var(--navy); color: white; border-radius: var(--radius);
  padding: 20px 24px; margin-bottom: 24px; display: flex;
  align-items: center; justify-content: space-between;
}
.total-score-card .t-label { font-size: 12px; opacity: .6; text-transform: uppercase; letter-spacing: .08em; }
.total-score-card .t-val {
  font-family: var(--font-head); font-size: 42px; font-weight: 500; color: var(--gold);
  line-height: 1;
}
.total-score-card .t-max { font-size: 18px; opacity: .5; }

.endorsement-summary { margin-bottom: 24px; }
.endorsement-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.endorse-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.endorse-chip.yes { background: #e6f7f0; color: #1a7a4f; }
.endorse-chip.no  { background: #f0f2f5; color: #8a96a8; }

.ranking-row { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.ranking-input {
  width: 80px; padding: 10px 12px; text-align: center;
  font-size: 24px; font-family: var(--font-head); font-weight: 500;
  border: 2px solid var(--border); border-radius: var(--radius);
  color: var(--navy); outline: none;
}
.ranking-input:focus { border-color: var(--gold); }

.status-select {
  padding: 9px 14px; border: 1px solid var(--border); border-radius: 6px;
  font-family: var(--font-body); font-size: 13px; color: var(--text);
  background: var(--white); outline: none;
}
.status-select:focus { border-color: var(--gold); }

/* ── Breadcrumb ────────────────────────────────────── */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); margin-bottom: 20px;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--navy); }
.breadcrumb span { opacity: .4; }

/* ── Toast ─────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 28px; right: 28px; z-index: 9999;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; font-family: var(--font-body);
  background: var(--navy); color: white;
  box-shadow: var(--shadow-md);
  transform: translateY(80px); opacity: 0;
  transition: all .25s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none; max-width: 320px;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { background: var(--green); }
#toast.error   { background: var(--red); }

/* ── Loading ───────────────────────────────────────── */
.loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 300px; gap: 12px; color: var(--muted);
}
.spinner {
  width: 22px; height: 22px; border: 2px solid var(--border);
  border-top-color: var(--gold); border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ───────────────────────────────────── */
.empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .3; }
.empty h3 { font-family: var(--font-head); font-size: 18px; color: var(--navy); margin-bottom: 6px; }

/* ── Misc ──────────────────────────────────────────── */
.save-bar {
  position: sticky; bottom: 0; left: 0; right: 0;
  background: white; border-top: 1px solid var(--border);
  padding: 14px 24px; display: flex; justify-content: flex-end; gap: 10px;
  box-shadow: 0 -4px 16px rgba(0,0,0,.06);
  margin: 24px -32px -32px;
}

.help-text { font-size: 11px; color: var(--muted); margin-top: 4px; }

.divider { height: 1px; background: var(--border); margin: 20px 0; }

.flag-english { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; }
.flag-english.met { color: var(--green); }
.flag-english.conditional { color: var(--amber); }
.flag-english.not_met { color: var(--red); }

.text-right { text-align: right; }
.flex-end { display: flex; justify-content: flex-end; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .score-summary-grid { grid-template-columns: 1fr 1fr; }
  .criterion-body { grid-template-columns: 1fr; }
  .endorsement-grid { grid-template-columns: 1fr; }
}

/* ── Login page ────────────────────────────────────── */
.auth-body {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--navy);
}
.auth-card {
  background: var(--white); border-radius: 12px;
  padding: 40px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.auth-logo { text-align: center; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.auth-logo-img { width: 160px; height: auto; margin: 0 auto 18px; display: block; }
.auth-title {
  font-family: 'Montserrat', sans-serif; font-size: 16px;
  color: var(--navy); margin-bottom: 0; font-weight: 500;
  letter-spacing: .02em;
}
.auth-sub { font-size: 13px; color: var(--muted); }
.auth-error {
  background: #fce8e8; color: #b52a2a; border-radius: 6px;
  padding: 10px 14px; font-size: 13px; margin-bottom: 16px;
  border: 1px solid #f5c0c0;
}
.auth-form { display: flex; flex-direction: column; gap: 0; }
.auth-submit {
  width: 100%; justify-content: center;
  padding: 11px; margin-top: 20px; font-size: 14px;
}
.auth-footer {
  text-align: center; font-size: 12px; color: var(--muted);
  margin-top: 20px;
}
.auth-roles {
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.auth-role-title {
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 2px;
}
.auth-role-item {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 11.5px; color: var(--muted); line-height: 1.4;
}
.auth-role-badge {
  flex-shrink: 0; margin-top: 1px;
}

/* ── Sidebar user badge & sign-out ─────────────────── */
.sidebar-user {
  padding: 8px 12px; margin-bottom: 6px;
  border-radius: 6px; background: rgba(255,255,255,.06);
}
.sidebar-user-name { font-size: 12px; font-weight: 600; color: #e8eef4; }
.sidebar-user-role { font-size: 11px; color: #8aa0b4; margin-top: 1px; text-transform: capitalize; }

/* ── Read-only banner ──────────────────────────────── */
.readonly-banner {
  background: #fff4e0; color: #7a4a00;
  border: 1px solid #ffe0a0; border-radius: 6px;
  padding: 10px 14px; font-size: 12px; font-weight: 500;
  margin-bottom: 16px;
}

/* ── Flash messages ────────────────────────────────── */
.flash-msg {
  padding: 12px 16px; border-radius: 6px;
  font-size: 13px; font-weight: 500; margin-bottom: 16px;
}
.flash-success { background: #e6f7f0; color: #1a7a4f; border: 1px solid #b3e8d0; }
.flash-error   { background: #fce8e8; color: #b52a2a; border: 1px solid #f5c0c0; }

/* ── Role badges ───────────────────────────────────── */
.role-badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 4px;
  font-size: 11px; font-weight: 600;
  text-transform: capitalize; letter-spacing: .03em;
}
.role-admin      { background: rgba(201,168,76,.2); color: #7a5c00; }
.role-reviewer   { background: #e8f0fe; color: #1a56c4; }
.role-school_rep { background: #e6f7f0; color: #1a7a4f; }

/* ── Admin panel ───────────────────────────────────── */
.admin-details summary { list-style: none; }
.admin-details summary::-webkit-details-marker { display: none; }
.admin-details[open] summary { opacity: .7; }

.admin-role-hints { margin-top: 10px; }
.role-hint {
  font-size: 12px; color: var(--muted); padding: 8px 12px;
  background: var(--off); border-radius: 6px; border: 1px solid var(--border);
  line-height: 1.5;
}
.role-hint strong { color: var(--text); }

/* ── Audit log ─────────────────────────────────────── */
.audit-log {
  max-height: 480px; overflow-y: auto;
  margin-top: 16px; font-size: 12px;
}
.audit-entry {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--border); line-height: 1.4;
}
.audit-entry:last-child { border-bottom: none; }
.audit-ts     { color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.audit-who    { font-weight: 600; color: var(--navy); flex-shrink: 0; min-width: 80px; }
.audit-action { color: var(--text); font-weight: 500; flex-shrink: 0; }
.audit-detail { color: var(--muted); }

/* ── Round status badges ───────────────────────────── */
.round-status-badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
.round-active    { background: #e6f7f0; color: #1a7a4f; }
.round-shelved   { background: #f0eeff; color: #5a3fa0; }
.round-finalised { background: #fff4e0; color: #7a5000; }
.round-archived  { background: #f0f2f5; color: #6b7a8d; }
.round-readonly  { background: #fff0f0; color: #a03030; border: 1px solid #f5c0c0; }

/* ── Round cards (Rounds list page) ───────────────── */
.round-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 20px 24px; margin-bottom: 14px;
  transition: box-shadow .15s;
}
.round-card:hover { box-shadow: 0 4px 16px rgba(21,34,51,.08); }
.round-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.round-card-name { font-size: 16px; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.round-card-meta { font-size: 12px; color: var(--muted); }
.round-card-desc { font-size: 13px; color: var(--text); margin-top: 6px; }

/* ── Lock icon in dashboard rows ─────────────────── */
.lock-icon { font-size: 11px; vertical-align: middle; opacity: .7; }

/* ── Mini criteria bars (dashboard rows) ─── */
.mini-criteria-bars { display: flex; gap: 2px; margin-top: 4px; }
.mini-bar-wrap { flex: 1; }
.mini-bar-bg { height: 4px; background: #edf0f5; border-radius: 2px; overflow: hidden; }
.mini-bar-fill { height: 100%; border-radius: 2px; background: var(--gold); transition: width .3s; }

/* ── Endorsement dots (dashboard rows) ────── */
.endorse-dots { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 4px; }
.edot { width: 10px; height: 10px; border-radius: 50%; background: #e0e5ee; display: inline-block; }
.edot.yes { background: var(--green); }

/* ── Compare float bar ───────────────────────────── */
.compare-float {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 20px; border-radius: 30px;
  display: flex; align-items: center; gap: 14px; z-index: 8000;
  box-shadow: 0 4px 20px rgba(0,0,0,.25); font-size: 13px;
  animation: slideUp .18s ease;
}
@keyframes slideUp { from { opacity:0; transform: translateX(-50%) translateY(12px); } }
.compare-float-names { font-weight: 500; opacity: .85; }
.compare-float button { padding: 6px 16px; border-radius: 20px; border: none; cursor: pointer; font-size: 12.5px; font-weight: 600; }
.compare-float .btn-compare-go { background: var(--gold); color: var(--navy); }
.compare-float .btn-compare-clear { background: rgba(255,255,255,.15); color: #fff; }

/* ── Compare modal ───────────────────────────────── */
.compare-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 9100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 20px; overflow-y: auto;
}
.compare-box {
  background: #fff; border-radius: 12px; width: 100%; max-width: min(98vw, 1400px);
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
}
.compare-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.compare-header h2 { font-size: 17px; font-weight: 600; color: var(--navy); margin: 0; }
.compare-grid { display: flex; overflow-x: auto; }
.compare-col { padding: 20px 24px; min-width: 240px; flex: 1; }
.compare-col + .compare-col { border-left: 1px solid var(--border); }
.compare-col-name { font-size: 16px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.compare-col-meta { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.compare-score-big { font-size: 32px; font-weight: 700; color: var(--navy); font-family: var(--font-head); }
.compare-score-max { font-size: 16px; color: var(--muted); font-weight: 400; }
.compare-criterion { margin: 8px 0; }
.compare-criterion-label { font-size: 11px; color: var(--muted); margin-bottom: 3px; display: flex; justify-content: space-between; }
.compare-bar-bg { height: 6px; background: #edf0f5; border-radius: 3px; overflow: hidden; }
.compare-bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--gold), var(--gold-l)); }
.compare-win { color: var(--green); font-weight: 700; }
.compare-lose { color: var(--muted); }

/* ── Deadline badge ──────────────────────────────── */
.deadline-badge {
  font-size: 11px; font-weight: 500; color: var(--muted);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 9px; display: inline-flex; align-items: center; gap: 4px;
}
.deadline-badge.urgent { color: #a03030; background: #fff0f0; border-color: #f5c0c0; }
.deadline-badge.passed { color: #a03030; background: #fff0f0; border-color: #f5c0c0; font-weight: 600; }

/* ── Rounds button guide ─────────────────────────── */
.btn-guide-panel {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden;
}
.btn-guide-summary {
  display: flex; align-items: center; gap: 7px; padding: 11px 16px;
  font-size: 13px; font-weight: 600; color: var(--navy); cursor: pointer;
  list-style: none; user-select: none;
}
.btn-guide-summary::-webkit-details-marker { display: none; }
.btn-guide-summary::after { content: '›'; margin-left: auto; font-size: 16px; color: var(--muted); transition: transform .18s; }
details[open] .btn-guide-summary::after { transform: rotate(90deg); }
.btn-guide-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border-top: 1px solid var(--border);
}
.btn-guide-row {
  display: flex; gap: 10px; padding: 9px 16px;
  border-bottom: 1px solid var(--border); align-items: baseline;
}
.btn-guide-row:nth-last-child(-n+2) { border-bottom: none; }
.btn-guide-label {
  font-size: 12px; font-weight: 600; color: var(--navy);
  white-space: nowrap; min-width: 130px; flex-shrink: 0;
}
.btn-guide-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }
