/* ============================================================
   UMA DEWS — Desertion Early-Warning System
   "Institutional data desk" — refined, calm, serious.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --paper:      #f6f4ee;
  --surface:    #ffffff;
  --surface-2:  #fbfaf6;
  --ink:        #1a1e26;
  --ink-soft:   #3d4551;
  --muted:      #6a7280;
  --faint:      #9aa0a8;
  --line:       #e5e1d6;
  --line-soft:  #efece3;

  --brand:      #1b4a52;   /* deep teal-slate — primary action */
  --brand-deep: #123a41;
  --brand-tint: #e7efee;

  --p1:         #9e2b25;   /* priority 1 — brick */
  --p1-tint:    #f7e9e7;
  --p2:         #9a5a17;   /* priority 2 — ochre */
  --p2-tint:    #f6ecdd;
  --ok:         #3c6a50;   /* low / continued — sage */
  --ok-tint:    #e6efe8;

  --sidebar:    #171c24;
  --sidebar-2:  #1f2530;
  --sidebar-ink:#c9cdd4;
  --sidebar-faint:#7b828d;

  --shadow-sm: 0 1px 2px rgba(26,30,38,.05), 0 1px 3px rgba(26,30,38,.04);
  --shadow-md: 0 2px 8px rgba(26,30,38,.06), 0 8px 24px rgba(26,30,38,.05);

  --serif: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans:  'IBM Plex Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono:  'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  --radius: 10px;
  --radius-sm: 7px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; color: var(--ink); margin: 0; }

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

.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  padding: 26px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid #000;
}

.brand {
  display: flex; align-items: baseline; gap: 9px;
  padding: 0 8px 22px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--sidebar-2);
}
.brand .mark {
  font-family: var(--serif);
  font-size: 26px; font-weight: 600;
  color: #fff; line-height: 1;
}
.brand .sub {
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--sidebar-faint);
}

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-ink);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .14s ease, color .14s ease;
}
.nav a:hover { background: var(--sidebar-2); text-decoration: none; color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav a .ico { width: 15px; height: 15px; opacity: .8; flex: none; }
.nav a.active .ico { opacity: 1; }

.sidebar .foot {
  margin-top: auto;
  padding: 14px 12px 0;
  border-top: 1px solid var(--sidebar-2);
  font-size: 12px;
  color: var(--sidebar-faint);
  display: flex; flex-direction: column; gap: 6px;
}
.sidebar .foot a { color: var(--sidebar-ink); }

/* ---------- Main ---------- */

.main { padding: 34px 44px 60px; max-width: 1240px; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .brand { border: 0; padding: 0 12px 0 0; margin: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 24px 20px 48px; }
}

.page-head { margin-bottom: 26px; animation: rise .5s ease both; }
.page-head .eyebrow {
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 7px; font-weight: 500;
}
.page-head h1 { font-size: 30px; line-height: 1.12; }
.page-head .lede { color: var(--ink-soft); margin-top: 8px; max-width: 68ch; font-size: 14px; }
.page-head .rule { height: 2px; background: var(--ink); width: 44px; margin-top: 16px; }

/* ---------- Cards / panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 18px;
  animation: rise .5s ease both;
}
.panel.tight { padding: 14px 16px; }
.panel h2 { font-size: 17px; margin-bottom: 3px; }
.panel .panel-note { color: var(--muted); font-size: 12.5px; }

.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.toolbar label { font-size: 12px; font-weight: 500; color: var(--ink-soft); }

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

select, input[type=text], input[type=password], input[type=number], textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  transition: border-color .14s ease, box-shadow .14s ease;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
select { cursor: pointer; padding-right: 30px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236a7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}

.btn {
  font: inherit; font-weight: 500;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .14s ease, transform .06s ease, box-shadow .14s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); }
.btn-primary:disabled { opacity: .55; cursor: progress; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--muted); }

/* ---------- Chips / filters ---------- */

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-soft);
  transition: all .14s ease;
}
.chip:hover { border-color: var(--muted); text-decoration: none; }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }

.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px;
  border-radius: 5px;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  font-family: var(--sans);
}
.badge.p1 { background: var(--p1-tint); color: var(--p1); }
.badge.p2 { background: var(--p2-tint); color: var(--p2); }
.badge.low { background: var(--ok-tint); color: var(--ok); }
.badge.neutral { background: var(--line-soft); color: var(--muted); }

/* ---------- Per-course attendance (student detail, live from UMA) ---------- */

.course-attendance { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.course-attendance:last-child { border-bottom: none; }
.course-attendance-head { margin-bottom: 8px; }
.session-list { display: flex; flex-wrap: wrap; gap: 4px; }
.session-list .badge { cursor: default; font-weight: 500; letter-spacing: 0; text-transform: none; }

/* ---------- Stat cards ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 4px 0 20px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat .n { font-family: var(--serif); font-size: 30px; font-weight: 500; line-height: 1; color: var(--ink); }
.stat .n.p1 { color: var(--p1); }
.stat .k { font-size: 11.5px; color: var(--muted); margin-top: 8px; line-height: 1.35; }

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

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left;
  font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .1s ease; }
table.data tbody tr:hover { background: var(--surface-2); }
.code { font-family: var(--mono); font-size: 12.5px; font-weight: 500; color: var(--ink); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* risk meter */
.risk { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.risk .track { width: 74px; height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; flex: none; }
.risk .fill { height: 100%; border-radius: 3px; background: var(--brand); }
.risk .fill.p1 { background: var(--p1); }
.risk .fill.p2 { background: var(--p2); }
.risk .fill.low { background: var(--ok); }
.risk .pct { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink-soft); }

/* ---------- Notices ---------- */

.notice { border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13px; margin-bottom: 16px; border: 1px solid; }
.notice.good { background: var(--ok-tint); border-color: #cfe1d5; color: #2f5641; }
.notice.warn { background: #fbf3df; border-color: #ecdcb3; color: #7a5a1c; }
.notice.info { background: var(--brand-tint); border-color: #cfe0de; color: var(--brand-deep); }

/* ---------- Ingest strip ---------- */

.ingest { display: flex; align-items: center; gap: 12px; }
.ingest .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.ingest .dot.run  { background: var(--p2); box-shadow: 0 0 0 3px var(--p2-tint); animation: pulse 1.4s ease-in-out infinite; }
.ingest .dot.done { background: var(--ok); }
.ingest .dot.idle { background: var(--faint); }
.ingest .body { flex: 1; min-width: 0; }
.ingest .body b { font-weight: 600; }
.ingest .msg { color: var(--muted); font-size: 12.5px; }
.ingest .track { height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; margin-top: 8px; }
.ingest .track .fill { height: 100%; background: var(--brand); width: 0; transition: width .5s ease; }

/* ---------- Matrix (backtest) ---------- */

.matrix { border-collapse: separate; border-spacing: 4px; margin: 6px 0 4px; }
.matrix th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: 6px 10px; text-align: center; }
.matrix td { padding: 12px 16px; text-align: center; border-radius: var(--radius-sm); font-size: 13px; min-width: 116px; }
.matrix td .big { font-family: var(--serif); font-size: 22px; display: block; line-height: 1.1; }
.matrix td.hit { background: var(--ok-tint); color: #2f5641; }
.matrix td.miss { background: var(--p1-tint); color: var(--p1); }
.matrix td.clear { background: var(--surface-2); color: var(--ink-soft); }

.tag { display: inline-block; padding: 2px 9px; border-radius: 5px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.tag.left { background: var(--p1-tint); color: var(--p1); }
.tag.stay { background: var(--ok-tint); color: var(--ok); }
.mark-ok { color: var(--ok); font-weight: 700; }
.mark-no { color: var(--p1); font-weight: 700; }

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1100px 500px at 15% -10%, #eef1ef 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 110%, #ece8dd 0%, transparent 55%),
    var(--paper);
  padding: 24px;
}
.login-card {
  width: 360px; max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 34px 32px 30px;
  animation: rise .5s ease both;
}
.login-card .mark { font-family: var(--serif); font-size: 30px; font-weight: 600; color: var(--ink); line-height: 1; }
.login-card .sub { font-size: 10.5px; letter-spacing: .17em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.login-card h1 { font-size: 18px; margin: 24px 0 4px; }
.login-card p.hint { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; }
.login-card label { font-size: 12px; font-weight: 500; color: var(--ink-soft); display: block; margin-bottom: 6px; }
.login-card input { width: 100%; }
.login-card .btn { width: 100%; margin-top: 16px; padding: 10px; }
.login-card .err { color: var(--p1); font-size: 12.5px; margin-bottom: 12px; background: var(--p1-tint); padding: 8px 11px; border-radius: 6px; }

/* ---------- misc ---------- */

.stack > * + * { margin-top: 18px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mt0 { margin-top: 0; }
.empty { color: var(--muted); padding: 28px; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
code.kbd { font-family: var(--mono); font-size: 12px; background: var(--line-soft); padding: 1px 6px; border-radius: 4px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px var(--p2-tint); } 50% { box-shadow: 0 0 0 6px transparent; } }

.stagger > * { animation: rise .5s ease both; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .10s; }
.stagger > *:nth-child(4) { animation-delay: .14s; }
.stagger > *:nth-child(5) { animation-delay: .18s; }
