/* Britech MIS - shared stylesheet
   One file for every page. Change colors and spacing in :root below. */

:root {
  --ink: #0f2742;
  --ink-soft: #1a3a60;
  --ink-line: #254a75;
  --brand: #1c5ca8;
  --brand-strong: #144682;
  --brand-tint: #e8f0fa;
  --gold: #d9a421;

  --bg: #f3f5f8;
  --surface: #ffffff;
  --line: #dde3ea;
  --line-soft: #eaeef3;
  --text: #18232f;
  --muted: #5b6978;

  --ok: #17703f;      --ok-bg: #e1f3e8;
  --warn: #7a4f00;    --warn-bg: #fdf0cf;
  --danger: #a32a2a;  --danger-bg: #fbe6e6;
  --info: #1c5ca8;    --info-bg: #e4eefb;
  --neutral: #4d5a68; --neutral-bg: #eceff3;

  --radius: 8px;
  --sidebar: 256px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--brand); }
a:hover { color: var(--brand-strong); }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -9999px; top: 8px;
  background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 6px; z-index: 100;
}
.skip-link:focus { left: 8px; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- App shell ---------- */

.app { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar);
  background: var(--ink);
  color: #c9d6e6;
  display: flex; flex-direction: column;
  z-index: 40;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--ink-line);
  text-decoration: none; color: #fff;
}
.brand:hover { color: #fff; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 8px; flex: none;
  background: #fff; color: var(--ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 1.15rem;
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-name { font-weight: 650; font-size: 1.05rem; line-height: 1.2; }
.brand-sub { font-size: 0.78rem; color: #9db2cc; line-height: 1.3; }

.nav { padding: 14px 12px 24px; flex: 1; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-label { padding: 0 10px 6px; font-size: 0.8rem; color: #8ea6c3; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: 6px;
  color: #c9d6e6; text-decoration: none; font-weight: 500;
  border-left: 3px solid transparent;
}
.nav a:hover { background: var(--ink-soft); color: #fff; }
.nav a.active { background: var(--ink-soft); color: #fff; border-left-color: var(--gold); }

.main { margin-left: var(--sidebar); min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  height: 60px; padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-school { flex: 1; min-width: 0; color: var(--muted); font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  display: none;
  width: 40px; height: 40px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; color: var(--ink); cursor: pointer; place-items: center;
}

.user-menu { position: relative; }
.user-menu summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 8px;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--bg); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 650; font-size: 0.85rem;
}
.user-text { line-height: 1.2; text-align: left; }
.user-name { font-weight: 600; font-size: 0.92rem; }
.user-role { font-size: 0.8rem; color: var(--muted); }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 210px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 39, 66, .14);
}
.menu a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 6px;
  color: var(--text); text-decoration: none;
}
.menu a:hover { background: var(--bg); }

.scrim { display: none; }

.page { padding: 28px; max-width: 1320px; }

/* ---------- Page pieces ---------- */

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 14px; margin-bottom: 22px;
}
.page-head p { color: var(--muted); margin-top: 6px; max-width: 70ch; }
.page-head .head-rule { display: block; width: 44px; height: 3px; background: var(--gold); border-radius: 2px; margin-bottom: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.card + .card { margin-top: 18px; }
.card-narrow { max-width: 720px; }
.card-flush { padding: 0; overflow: hidden; }

.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 18px; border: 1px solid transparent;
  display: flex; gap: 10px; align-items: flex-start;
}
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: #b9e0c8; }
.alert-error   { background: var(--danger-bg); color: var(--danger); border-color: #f0c2c2; }
.alert-warn    { background: var(--warn-bg); color: var(--warn); border-color: #f0dc9c; }
.alert-info    { background: var(--info-bg); color: var(--info); border-color: #bcd3f0; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; min-height: 40px;
  font: inherit; font-weight: 600; font-size: 0.92rem; line-height: 1.2;
  border-radius: 7px; border: 1px solid transparent;
  text-decoration: none; cursor: pointer;
  background: var(--brand); color: #fff;
}
.btn:hover { background: var(--brand-strong); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: #c4ceda; }
.btn-secondary:hover { background: var(--bg); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #e3b4b4; }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn-ok { background: var(--surface); color: var(--ok); border-color: #a9d6bb; }
.btn-ok:hover { background: var(--ok-bg); color: var(--ok); }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 0.86rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Forms ---------- */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.85rem; }
.value { padding: 9px 0; border-bottom: 1px solid var(--line-soft); }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="search"], input[type="file"], select, textarea {
  width: 100%; min-height: 42px;
  padding: 9px 12px;
  font: inherit; color: var(--text);
  background: #fff; border: 1px solid #b9c4d1; border-radius: 7px;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(28, 92, 168, .25); border-color: var(--brand); }
input[type="file"] { padding: 8px; }

.form-actions { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line-soft); }

.logo-preview {
  display: inline-block; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
}
.logo-preview img { display: block; max-width: 180px; max-height: 180px; }

/* ---------- Tables ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.toolbar .search { position: relative; flex: 1 1 280px; max-width: 420px; }
.toolbar .search .icon { position: absolute; left: 12px; top: 11px; color: var(--muted); width: 18px; height: 18px; }
.toolbar .search input { padding-left: 38px; }
.toolbar-meta { color: var(--muted); font-size: 0.9rem; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th {
  text-align: left; white-space: nowrap;
  padding: 11px 14px;
  background: #f7f9fb; color: var(--muted); font-weight: 600; font-size: 0.86rem;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table tbody tr:hover { background: #fafbfd; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .nowrap { white-space: nowrap; }
.table .title-cell { min-width: 200px; max-width: 380px; }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }

.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form select, .inline-form input[type="date"] { width: auto; min-width: 130px; min-height: 36px; padding: 6px 10px; }
.stack-form { display: grid; gap: 8px; min-width: 250px; max-width: 320px; }
.stack-form > * { min-width: 0; }
.stack-form label { font-size: 0.84rem; font-weight: 600; }
.link-note { margin-bottom: 8px; font-size: 0.88rem; }

/* ---------- Badges ---------- */

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.82rem; font-weight: 600; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral);
}
.badge-processing { background: var(--info-bg); color: var(--info); }
.badge-submitted  { background: var(--warn-bg); color: var(--warn); }
.badge-revision   { background: var(--danger-bg); color: var(--danger); }
.badge-approved, .badge-active { background: var(--ok-bg); color: var(--ok); }
.badge-inactive   { background: var(--neutral-bg); color: var(--neutral); }

/* ---------- Dashboard ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.tile { display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.tile-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--brand-tint); color: var(--brand); display: grid; place-items: center; }
.tile p { color: var(--muted); }
.tile .btn-row { margin-top: auto; padding-top: 4px; }

.section-title { margin: 34px 0 14px; }
.section-title:first-of-type { margin-top: 0; }

.roadmap { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.roadmap li { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.roadmap li:last-child { border-bottom: 0; }
.roadmap .icon { color: var(--muted); }
.roadmap .r-text { flex: 1; min-width: 0; }
.roadmap .r-name { font-weight: 600; }
.roadmap .r-desc { color: var(--muted); font-size: 0.88rem; }

/* ---------- Monitoring stats ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; border-top: 3px solid var(--line); }
.stat-value { font-size: 1.9rem; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }
.stat.s-processing { border-top-color: var(--info); }
.stat.s-submitted  { border-top-color: #d6a21f; }
.stat.s-revision   { border-top-color: var(--danger); }
.stat.s-approved   { border-top-color: var(--ok); }

.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 20px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.filters .field { min-width: 200px; }

/* ---------- Sign-in and password pages ---------- */

.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 12px; padding: 32px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 26px; text-align: center; }
.auth-logo { display: block; max-width: 160px; max-height: 96px; object-fit: contain; }
.auth-brand .brand-name { color: var(--text); }
.auth-brand .brand-sub { color: var(--muted); }
.auth-brand .brand-mark { width: 56px; height: 56px; font-size: 1.5rem; background: var(--ink); color: #fff; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: 22px; }
.auth-card .field + .field { margin-top: 16px; }
.auth-card .btn { width: 100%; margin-top: 22px; }
.auth-foot { margin-top: 20px; color: var(--muted); font-size: 0.85rem; text-align: center; }

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(8, 20, 36, .5); z-index: 35; }
  .main { margin-left: 0; }
  .icon-btn { display: grid; }
  .topbar { padding: 0 16px; }
  .page { padding: 20px 16px; }
  .user-text { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
