/* ============================================================================
   AIDE+ — design system (static prototype)
   A calm, trustworthy "veille" (daily vigil) language for residence staff.
   Petrol-teal brand on cool stone; Instrument Serif (the human voice) +
   Hanken Grotesk (operational data). Conventional triage semantics, refined.
   ============================================================================ */

/* ---- tokens ------------------------------------------------------------- */
:root {
  /* surfaces & ink — "Brand Palette" anatomy: light-neutral ground, navy ink */
  --stone:        #F3EDE0;   /* LIGHT NEUTRAL (cream) — page ground (~30%) */
  --stone-deep:   #E7DECB;
  --surface:      #FFFFFF;   /* document cards on cream */
  --ink:          #182B4A;   /* DARK NEUTRAL — navy, not pure black (~15%) */
  --ink-soft:     #45506B;   /* secondary text */
  --ink-faint:    #828BA1;   /* captions / meta */
  --line:         #E5DCC9;   /* warm hairlines on cream */
  --line-soft:    #EEE7D7;

  /* brand — HERO cobalt + accents (~30% hero, ~25% accents) */
  --primary:      #2B5AAD;   /* HERO */
  --primary-deep: #1E4488;
  --primary-tint: #DEE6F5;   /* light cobalt wash (from accent #BDCFEE) */
  --accent:       #D1C33A;   /* ACCENT — citron */
  --accent-soft:  #F3ECC8;

  /* triage semantics — functional safety colors. The palette has no green/red,
     but status is scanned fast on a safety tool: keep ok=green, alert=red;
     vigilance uses the palette's citron (yellow = caution). */
  --ok:        #2E7D57;  --ok-tint:    #E2EFE8;
  --watch:     #8F7A0C;  --watch-tint: #F3ECC6;  /* readable citron for text */
  --alert:     #C0392B;  --alert-tint: #F6E2DD;
  --quiet:     #828BA1;  --quiet-tint: #ECE5D8;  /* no-contact / unknown */

  /* type */
  --font-display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-ui: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* shape */
  --r-sm: 8px;  --r: 14px;  --r-lg: 20px;
  --shadow: 0 1px 2px rgba(21,48,44,.04), 0 6px 20px rgba(21,48,44,.06);
  --shadow-soft: 0 1px 2px rgba(21,48,44,.04);

  /* spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;

  --maxw: 1120px;
}

/* ---- reset / base ------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--stone);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--primary-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
:focus-visible { outline: 2.5px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.serif { font-family: var(--font-display); font-weight: 400; letter-spacing: 0; }

/* eyebrow / labels — encode the "veille" framing, not decoration */
.eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---- app shell ---------------------------------------------------------- */
.appbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.appbar__inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--s5);
  height: 64px; display: flex; align-items: center; gap: var(--s5);
}
.brand { display: flex; align-items: center; gap: var(--s3); }
.brand__mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.brand__name { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand__name b { color: var(--primary); }

/* per-institution context chip in the bar */
.institution {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: 999px;
  background: var(--stone); cursor: pointer;
}
.institution__logo {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  background: linear-gradient(135deg, #2B5AAD, #1E4488); color:#fff;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.institution__name { font-weight: 600; font-size: 14px; }
.institution__chev { color: var(--ink-faint); font-size: 12px; }

.spacer { flex: 1; }
.nav { display: flex; gap: var(--s2); }
.nav a {
  padding: var(--s2) var(--s3); border-radius: var(--r-sm); color: var(--ink-soft);
  font-size: 14px; font-weight: 500;
}
.nav a:hover { background: var(--stone); text-decoration: none; color: var(--ink); }
.nav a.is-active { background: var(--primary-tint); color: var(--primary-deep); }

.user { display: flex; align-items: center; gap: var(--s3); }
.avatar {
  width: 32px; height: 32px; border-radius: 999px; background: var(--primary-deep); color:#fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
}
.user__meta { font-size: 13px; line-height: 1.2; }
.user__role { color: var(--ink-faint); }

/* institution-led header (director/staff) — the residence leads; AIDE+ recedes
   to the footer. One logo object (the institution's), no competing AIDE+ box. */
.lead { display: flex; align-items: center; gap: var(--s3); }
.lead__logo {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, #2B6CB0, #1A4E8A); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.lead__name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }

/* switcher pill for the admin shell — text only (AIDE+ keeps the one boxed mark) */
.institution--text { padding-left: var(--s4); }

/* footer — quiet platform attribution */
.footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer__inner {
  max-width: var(--maxw); margin: 0 auto; padding: var(--s5);
  display: flex; align-items: center; gap: var(--s4); font-size: 13px; color: var(--ink-faint);
}
.powered { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink-soft); }
.powered b { color: var(--primary); font-weight: 700; }
@media (max-width: 560px) {
  .footer__inner { flex-direction: column; align-items: flex-start; gap: var(--s2); }
}

.page { max-width: var(--maxw); margin: 0 auto; padding: var(--s6) var(--s5) var(--s8); }

/* ---- hero (the thesis: is everyone OK today?) --------------------------- */
.hero { margin-bottom: var(--s6); }
.hero__date { display: flex; align-items: baseline; gap: var(--s3); margin-bottom: var(--s3); }
.hero__thesis {
  font-family: var(--font-display); font-weight: 400; letter-spacing: 0;
  font-size: clamp(28px, 4vw, 44px); line-height: 1.12; color: var(--ink);
  max-width: 22ch;
}
.hero__thesis em { font-style: normal; color: var(--alert); }
.hero__thesis .ok { color: var(--ok); }

/* signature: bande de veille — one dot per resident, colored by status */
.veille { margin-top: var(--s5); }
.veille__grid {
  display: flex; flex-wrap: wrap; gap: 7px; max-width: 760px;
}
.dot {
  width: 16px; height: 16px; border-radius: 5px; background: var(--quiet-tint);
  border: 1px solid rgba(21,48,44,.06);
  opacity: 0; transform: scale(.6);
  animation: pop .4s cubic-bezier(.2,.8,.3,1) forwards;
}
.dot--ok    { background: var(--ok); }
.dot--watch { background: var(--accent); }  /* bright citron from the palette */
.dot--alert { background: var(--alert); }
.dot--quiet { background: #D6CDBA; }   /* not yet contacted / no answer */
@keyframes pop { to { opacity: 1; transform: scale(1); } }
.veille__legend { display: flex; gap: var(--s5); margin-top: var(--s4); flex-wrap: wrap; }
.legend { display: inline-flex; align-items: center; gap: var(--s2); font-size: 13px; color: var(--ink-soft); }
.legend .swatch { width: 12px; height: 12px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  .dot { animation: none; opacity: 1; transform: none; }
}

/* ---- coverage tiles ----------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s4); margin-bottom: var(--s6); }
.tile {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r);
  padding: var(--s5); box-shadow: var(--shadow-soft);
}
.tile__label { font-size: 13px; color: var(--ink-soft); font-weight: 500; margin-bottom: var(--s3); }
.tile__value { font-size: 38px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.tile__sub { font-size: 13px; color: var(--ink-faint); margin-top: var(--s2); }
.tile--accent { background: var(--alert-tint); border-color: #EBC9C1; }
.tile--accent .tile__value { color: var(--alert); }
.tile--accent .tile__label { color: #8E3A2E; }

/* ---- section header ----------------------------------------------------- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: var(--s6) 0 var(--s4); }
.section-head h2 { font-size: 19px; }
.section-head__meta { font-size: 13px; color: var(--ink-faint); }

/* ---- card --------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r);
  box-shadow: var(--shadow-soft); overflow: hidden;
}
.card__head { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.card__body { padding: var(--s5); }

/* ---- triage table ------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
  text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-faint); padding: var(--s3) var(--s5); border-bottom: 1px solid var(--line-soft);
}
.table tbody td { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: #F6F8F7; }
.row-alert { box-shadow: inset 3px 0 0 var(--alert); }
.row-watch { box-shadow: inset 3px 0 0 var(--watch); }
.person { display: flex; flex-direction: column; }
.person__name { font-weight: 600; }
.person__phone { font-size: 13px; color: var(--ink-faint); }
.reason { color: var(--ink-soft); max-width: 46ch; }
.when { color: var(--ink-faint); font-size: 13px; white-space: nowrap; }

/* ---- status chip -------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 4px 10px 4px 8px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: currentColor; }
.chip--alert { background: var(--alert-tint); color: var(--alert); }
.chip--watch { background: var(--watch-tint); color: var(--watch); }
.chip--ok    { background: var(--ok-tint);    color: var(--ok); }
.chip--quiet { background: var(--quiet-tint);  color: var(--ink-soft); }

/* ---- buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer;
  font-size: 14px; font-weight: 600; padding: 9px 16px; border-radius: 10px;
  border: 1px solid transparent; transition: background .12s ease, border-color .12s ease;
}
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-deep); text-decoration: none; }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: var(--stone); text-decoration: none; }
.btn--quiet { background: transparent; color: var(--primary-deep); padding: 9px 10px; }
.btn--quiet:hover { background: var(--primary-tint); text-decoration: none; }
.btn--sm { padding: 6px 12px; font-size: 13px; }

/* ---- day picker / toolbar ---------------------------------------------- */
.toolbar { display: flex; align-items: center; gap: var(--s3); }
.daypick {
  display: inline-flex; align-items: center; gap: var(--s3);
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 4px;
}
.daypick button { border: 0; background: transparent; cursor: pointer; color: var(--ink-soft);
  width: 30px; height: 30px; border-radius: 7px; }
.daypick button:hover { background: var(--stone); }
.daypick__label { font-weight: 600; font-size: 14px; padding: 0 var(--s2); }

/* ---- forms (institution config) ---------------------------------------- */
.field { margin-bottom: var(--s5); }
.field__label { display: block; font-size: 14px; font-weight: 600; margin-bottom: var(--s2); }
.field__hint { font-size: 13px; color: var(--ink-faint); margin-top: var(--s2); }
.input, .textarea, .select {
  width: 100%; font-family: inherit; font-size: 15px; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); outline: none;
  box-shadow: 0 0 0 3px var(--primary-tint); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.55; }

.switch { display: inline-flex; align-items: center; gap: var(--s3); cursor: pointer; }
.switch__track { width: 42px; height: 24px; border-radius: 999px; background: var(--stone-deep); position: relative; transition: background .15s ease; }
.switch__track::after { content:""; position:absolute; top:2px; left:2px; width:20px; height:20px; border-radius:999px; background:#fff; box-shadow: var(--shadow-soft); transition: transform .15s ease; }
.switch.is-on .switch__track { background: var(--primary); }
.switch.is-on .switch__track::after { transform: translateX(18px); }

.voice-opt {
  display: flex; align-items: center; gap: var(--s4); padding: var(--s4);
  border: 1px solid var(--line); border-radius: var(--r); margin-bottom: var(--s3); cursor: pointer;
}
.voice-opt.is-sel { border-color: var(--primary); background: var(--primary-tint); }
.voice-opt__play { width: 36px; height: 36px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--primary-deep); }

.dropzone {
  border: 1.5px dashed var(--line); border-radius: var(--r); padding: var(--s6);
  text-align: center; color: var(--ink-soft); background: #F8FAF9;
}

/* uploaded KB doc rows */
.doc { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line-soft); }
.doc:last-child { border-bottom: 0; }
.doc__icon { width: 30px; height: 30px; border-radius: 8px; background: var(--primary-tint); color: var(--primary-deep); display: grid; place-items: center; font-size: 13px; font-weight: 700; }

/* ---- two-column config layout ------------------------------------------ */
.cols { display: grid; grid-template-columns: 220px 1fr; gap: var(--s6); align-items: start; }
.subnav { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 2px; }
.subnav a { padding: var(--s3) var(--s4); border-radius: 10px; color: var(--ink-soft); font-size: 14px; font-weight: 500; }
.subnav a:hover { background: var(--stone); text-decoration: none; color: var(--ink); }
.subnav a.is-active { background: var(--surface); color: var(--ink); border: 1px solid var(--line-soft); box-shadow: var(--shadow-soft); }

/* ---- empty / states ----------------------------------------------------- */
.empty { text-align: center; padding: var(--s7) var(--s5); color: var(--ink-soft); }
.empty__mark { font-family: var(--font-display); font-size: 40px; color: var(--ok); margin-bottom: var(--s3); }

/* ---- auth (login) ------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth__aside { background: var(--primary-deep); color: #E7EDF8; padding: var(--s8) var(--s7); display: flex; flex-direction: column; }
.auth__aside .brand__name { color: #fff; }
.auth__aside .brand__name b { color: #D1C33A; }
.auth__pitch { font-family: var(--font-display); font-size: clamp(28px,3.4vw,40px); line-height: 1.15; margin-top: auto; max-width: 18ch; }
.auth__sub { color: #B7C6E6; margin-top: var(--s4); max-width: 38ch; }
.auth__main { display: grid; place-items: center; padding: var(--s6); }
.auth__card { width: 100%; max-width: 380px; }
.auth__title { font-size: 24px; margin-bottom: var(--s2); }
.auth__lede { color: var(--ink-soft); margin-bottom: var(--s6); }
.auth .field:last-of-type { margin-bottom: var(--s5); }

/* ---- design-system sheet helpers --------------------------------------- */
.ds-section { margin: var(--s7) 0; }
.ds-grid { display: grid; gap: var(--s4); }
.swatch-card { border: 1px solid var(--line-soft); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.swatch-card__chip { height: 72px; }
.swatch-card__meta { padding: var(--s3) var(--s4); font-size: 13px; }
.swatch-card__meta b { display: block; }
.swatch-card__hex { color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* ---- responsive --------------------------------------------------------- */
@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .cols { grid-template-columns: 1fr; }
  .subnav { position: static; flex-direction: row; flex-wrap: wrap; }
  /* Auth: drop the two-column grid to a single centered, viewport-constrained
     column (the grid track let the 380px card overflow narrow phones). */
  .auth { display: block; }
  .auth__aside { display: none; }
  .auth__main { min-height: 100vh; padding: var(--s6) var(--s4); }
  .auth__card { margin-inline: auto; }
  .nav { display: none; }
}
@media (max-width: 560px) {
  .tiles { grid-template-columns: 1fr; }
  .page { padding: var(--s5) var(--s4) var(--s7); }
  .table thead { display: none; }
  .table tbody td { display: block; padding: var(--s2) var(--s5); border: 0; }
  .table tbody tr { display: block; padding: var(--s4) 0; border-bottom: 1px solid var(--line-soft); }
}
