/* SchoolScan Dashboard — Branding Guide Colors */
:root {
  --navy: #1F4E79;
  --blue: #2F80ED;
  --teal: #1FA7A1;
  --coral: #E66A5C;
  --cloud: #F4F7FA;
  --white: #FFFFFF;
  --slate: #2E3A46;
  --border: #DCE3EA;
  --muted: #64748B;
  --light: #F8FAFC;
  --red: #DC2626;
  --orange: #EA580C;
  --amber: #D97706;
  --green: #16A34A;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--cloud);
  color: var(--slate);
  min-height: 100vh;
}

/* ── Shell Layout ──────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
}

.main {
  flex: 1;
  margin-left: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar-logo {
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.sidebar-logo img {
  width: 200px;
  height: auto;
}

.sidebar-logo .tagline {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  text-align: center;
}

.sidebar-section {
  padding: 16px 16px 8px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-sort {
  display: flex;
  gap: 2px;
}

.sidebar-sort button {
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  color: rgba(255,255,255,0.35);
  font-size: 0.55rem;
  font-weight: 600;
  font-family: var(--font);
  padding: 2px 6px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: 0.15s;
}

.sidebar-sort button:hover { color: rgba(255,255,255,0.7); border-color: rgba(255,255,255,0.3); }
.sidebar-sort button.active { color: #fff; background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.3); }

.district-item {
  display: flex;
  align-items: center;
  padding: 0;
  border-left: 3px solid transparent;
  transition: 0.15s;
  color: #fff;
}

.district-item:hover { background: rgba(255,255,255,0.08); }
.district-item.active { background: rgba(255,255,255,0.12); border-left-color: var(--blue); }

.district-all {
  padding: 10px 16px;
  gap: 10px;
  display: flex;
  align-items: center;
  text-decoration: none;
  color: #fff;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.district-all .district-grade {
  display: flex;
  align-items: center;
  justify-content: center;
}

.district-select {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 10px 16px;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: #fff;
  cursor: pointer;
}

.district-open {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  flex-shrink: 0;
  color: rgba(255,255,255,0.3);
  text-decoration: none;
  transition: 0.15s;
  padding: 10px 8px 10px 0;
}

.district-open:hover { color: rgba(255,255,255,0.8); }

.district-grade {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  color: #fff;
}

.district-info { min-width: 0; }
.district-info .name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.district-info .sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  font-size: 0.68rem;
  color: rgba(255,255,255,0.3);
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* (user email moved to top bar) */

/* ── Top Bar / Header ──────────────────────────────────────── */
.topbar {
  background: linear-gradient(135deg, var(--navy) 0%, #1e5a8c 100%);
  color: #fff;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.topbar-left { flex: 1; min-width: 200px; }
.topbar-left h2 { font-size: 1.3rem; font-weight: 700; }
.topbar-left p { font-size: 0.78rem; color: rgba(255,255,255,0.65); margin-top: 3px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.65);
  background: rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 6px 14px;
}

.score-badge {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 12px 18px;
}

.grade-big {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
}

.score-detail { text-align: center; }
.score-detail .score-num { font-size: 1.3rem; font-weight: 700; }
.score-detail .score-label { font-size: 0.6rem; color: rgba(255,255,255,0.6); margin-top: 2px; }

/* ── Stats Bar ─────────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 20px 24px 0;
}

.stat-card {
  background: var(--white);
  border-radius: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.stat-body .val { font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.stat-body .lbl { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  padding: 20px 24px 0;
  border-bottom: 0;
}

.tab {
  padding: 10px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: 0.15s;
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font);
}

.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab:hover:not(.active) { color: var(--slate); }

.tab-content { display: none; padding: 20px 24px 32px; flex: 1; }
.tab-content.active { display: block; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Grid Helpers ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.mb16 { margin-bottom: 16px; }
.mb20 { margin-bottom: 20px; }

/* ── Domain Score Cards ────────────────────────────────────── */
.domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.domain-card {
  background: var(--white);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.domain-grade-chip {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
  color: #fff;
}

.domain-body { flex: 1; min-width: 0; }
.domain-body .name { font-size: 0.85rem; font-weight: 600; margin-bottom: 3px; }
.domain-body .meta { font-size: 0.72rem; color: var(--muted); }

.domain-bar-wrap {
  margin-top: 8px;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.domain-bar { height: 100%; border-radius: 3px; transition: 0.3s; }

/* ── Severity Badges ───────────────────────────────────────── */
.sev-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

/* ── Status Badges ─────────────────────────────────────────── */
.status-badge {
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-pending { background: #EEF2FF; color: #4338CA; }
.status-approved { background: #F0FDF4; color: #15803D; }
.status-remediated { background: #EFF6FF; color: #1D4ED8; }
.status-rejected { background: #F1F5F9; color: #64748B; }
.status-needs_re_review { background: #FEF2F2; color: var(--red); }
.status-expired { background: #FDF4FF; color: #7C3AED; }

/* ── Breach Tag ───────────────────────────────────────────── */
.breach-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #FEF2F2;
  color: #DC2626;
  border: 1px solid #FECACA;
  margin-right: 4px;
  vertical-align: middle;
}

/* ── Risk Pills ────────────────────────────────────────────── */
.risk-bar {
  display: flex;
  gap: 10px;
  padding: 12px 24px 0;
  flex-wrap: wrap;
}

.risk-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid;
}

.risk-pill.critical { background: #FEF2F2; color: var(--red); border-color: #FECACA; }
.risk-pill.high { background: #FFF7ED; color: var(--orange); border-color: #FED7AA; }
.risk-pill.medium { background: #FEFCE8; color: var(--amber); border-color: #FEF08A; }
.risk-pill.low { background: #F0FDF4; color: var(--green); border-color: #BBF7D0; }

/* ── Findings Table ────────────────────────────────────────── */
.findings-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.findings-toolbar input {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: var(--font);
  outline: none;
}

.findings-toolbar input:focus { border-color: var(--blue); }

.findings-toolbar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: var(--font);
  outline: none;
  background: var(--white);
}

.findings-count { font-size: 0.78rem; color: var(--muted); margin-left: auto; }

.table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }

thead tr {
  background: var(--light);
  border-bottom: 1px solid var(--border);
}

th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

th:hover { color: var(--slate); }
th .sort-arrow { font-size: 0.6rem; margin-left: 3px; opacity: 0.4; }
th.sorted .sort-arrow { opacity: 1; color: var(--blue); }

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fbff; }

/* Row status tinting */
tr.row-approved td { background: #F0FDF4; }
tr.row-approved:hover td { background: #DCFCE7; }
tr.row-remediated td { background: #EFF6FF; }
tr.row-remediated:hover td { background: #DBEAFE; }
tr.row-rejected td { background: #F8FAFC; }
tr.row-rejected:hover td { background: #F1F5F9; }
tr.row-needs_re_review td { background: #FEF2F2; }
tr.row-needs_re_review:hover td { background: #FEE2E2; }
tr.row-expired td { background: #FDF4FF; }
tr.row-expired:hover td { background: #FAE8FF; }

.url-cell {
  font-size: 0.72rem;
  color: var(--blue);
  word-break: break-all;
  max-width: 200px;
}

.url-cell a { color: var(--blue); text-decoration: none; }
.url-cell a:hover { text-decoration: underline; }

.desc-cell {
  max-width: 320px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--slate);
}

/* ── Review Form (expandable) ──────────────────────────────── */
.review-row { display: none; }
.review-row.open { display: table-row; }

.review-panel {
  background: var(--light);
  border-radius: 10px;
  padding: 16px;
}

.review-panel .full-desc {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 0.8rem;
  line-height: 1.6;
}

.review-panel .full-desc .label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.review-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.review-form .full-width { grid-column: 1 / -1; }

.review-form label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 4px;
  font-weight: 600;
}

.review-form select,
.review-form input,
.review-form textarea {
  width: 100%;
  background: var(--white);
  color: var(--slate);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  font-family: var(--font);
}

.review-form textarea { min-height: 80px; resize: vertical; }
.review-form .actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }

.decision-info {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.75rem;
  line-height: 1.5;
  margin-bottom: 12px;
}

.decision-info .di-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  padding: 7px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--slate);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font);
  transition: 0.15s;
}

.btn:hover { background: var(--light); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-sm { padding: 4px 10px; font-size: 0.75rem; }
.btn-teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-teal:hover { background: #178f8a; }

/* ── MCDA Breakdown ────────────────────────────────────────── */
.mcda-row { margin-bottom: 18px; }

.mcda-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.mcda-name { font-size: 0.85rem; color: var(--slate); font-weight: 500; }
.mcda-name .weight { color: var(--muted); font-weight: 400; }
.mcda-value { font-size: 0.85rem; font-weight: 700; font-family: 'JetBrains Mono', monospace; }

.bar-track {
  background: #E5E7EB;
  border-radius: 8px;
  height: 10px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.mcda-summary {
  margin-top: 24px;
  padding: 16px 20px;
  background: #E8F4FD;
  border-radius: 10px;
  border: 1px solid rgba(47,128,237,0.15);
}

.mcda-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

.mcda-summary-label { font-size: 0.9rem; font-weight: 700; color: var(--navy); }
.mcda-summary-value { font-size: 0.9rem; font-weight: 800; }

.methodology-note {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.7;
  margin-top: 12px;
  padding: 16px 20px;
  background: var(--light);
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* ── Pipeline Stats ────────────────────────────────────────── */
.pipeline-stat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}

.pipeline-stat .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pipeline-stat .info { flex: 1; }
.pipeline-stat .info .label { font-size: 0.72rem; color: var(--muted); }
.pipeline-stat .info .value { font-size: 1.1rem; font-weight: 700; }

/* ── Chart containers ──────────────────────────────────────── */
.chart-box {
  position: relative;
  height: 250px;
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-box-radar {
  height: 500px;
}

/* ── Flash Messages ────────────────────────────────────────── */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin: 16px 24px 0;
  font-size: 0.85rem;
}

.flash-success { background: #F0FDF4; color: var(--green); border: 1px solid #BBF7D0; }
.flash-error { background: #FEF2F2; color: var(--red); border: 1px solid #FECACA; }

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
  font-size: 0.9rem;
}

/* ── Forbidden Page ────────────────────────────────────────── */
.forbidden-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--cloud);
  padding: 24px;
}

.forbidden-card {
  background: var(--white);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  max-width: 420px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
}

.forbidden-card .icon { font-size: 2.5rem; margin-bottom: 16px; }
.forbidden-card h2 { font-size: 1.3rem; font-weight: 700; color: var(--navy); margin-bottom: 8px; }
.forbidden-card p { font-size: 0.85rem; color: var(--muted); line-height: 1.5; margin-bottom: 16px; }
.forbidden-card .email { font-size: 0.78rem; color: var(--muted); margin-top: 12px; }

/* ── Review Modal Overlay ─────────────────────────────────── */
.review-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.review-modal-overlay > .card {
  max-height: 90vh;
  overflow-y: auto;
}

/* ── Loading ───────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
}
