/* ===========================================================================
   Beis Rivkah Schedule Builder

   Thesis: the principal asks one question all day — is there room? So the week
   is the hero, drawn as a week. The 5×7 capacity grid is the signature, and it
   holds the ONLY colour in the product. Everything else is ink on paper plus a
   single primary. If something is green, amber or rose, it is telling you about
   capacity. Nothing decorative is ever allowed those hues.

   Display / numerals : Bricolage Grotesque
   UI / data          : Public Sans (tabular figures)
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,600;12..96,700;12..96,800&family=Public+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* paper & ink */
  --canvas: #eaecf6;
  --paper: #ffffff;
  --paper-2: #f5f6fb;
  --paper-3: #edeff8;
  --line: #e0e3f0;
  --line-2: #cdd2e6;

  --ink: #171531;
  --ink-2: #5c5f7e;
  --ink-3: #8f93b0;

  /* the one primary */
  --brand: #4f3fd4;
  --brand-2: #6354e6;
  --brand-soft: #eceafc;
  --brand-line: #d6d1f8;

  /* capacity health — reserved, never decorative */
  --h4: #06603f;  --h4-bg: #c3ecd9;  --h4-line: #7fd6b1;   /* roomy   ≥25% */
  --h3: #14875f;  --h3-bg: #edfaf4;  --h3-line: #cdefdf;   /* healthy 15–25% */
  --h2: #9a5b06;  --h2-bg: #fdf1dd;  --h2-line: #f2d5a4;   /* tight   5–15% */
  --h1: #c2143f;  --h1-bg: #fdeaf0;  --h1-line: #f6bfd0;   /* broken  <5% */

  --info: #1f6fb2; --info-bg: #e8f1fa; --info-line: #c2ddf3;

  /* shape — generous, borrowed from the references */
  --r-panel: 24px;
  --r-card: 20px;
  --r-cell: 15px;
  --r-ctl: 12px;
  --r-pill: 999px;

  /* shadows carry a violet cast, not neutral black */
  --sh-sm: 0 1px 2px rgba(35, 30, 90, .05), 0 2px 6px -2px rgba(35, 30, 90, .06);
  --sh: 0 2px 6px rgba(35, 30, 90, .05), 0 12px 28px -12px rgba(35, 30, 90, .16);
  --sh-lift: 0 4px 10px rgba(35, 30, 90, .07), 0 20px 40px -16px rgba(35, 30, 90, .24);
  --sh-brand: 0 4px 14px -4px rgba(79, 63, 212, .5);

  --display: 'Bricolage Grotesque', 'Public Sans', system-ui, sans-serif;
  --sans: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 14.5px/1.55 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .num-display { font-family: var(--display); }

:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ===== shell — panels float on the canvas ================================ */

.shell { display: flex; gap: 18px; padding: 18px; min-height: 100vh; align-items: flex-start; }

.sidebar {
  width: 232px; flex: none;
  background: var(--paper);
  border-radius: var(--r-panel);
  box-shadow: var(--sh);
  padding: 20px 14px 16px;
  position: sticky; top: 18px;
  max-height: calc(100vh - 36px);
  display: flex; flex-direction: column;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 22px; }
.brand .mark {
  width: 36px; height: 36px; border-radius: 12px; flex: none;
  background: var(--brand); color: #fff;
  font-family: var(--display); font-size: 14px; font-weight: 800; letter-spacing: -.03em;
  display: grid; place-items: center; box-shadow: var(--sh-brand);
}
.brand .name {
  font-family: var(--display); font-size: 15.5px; font-weight: 700;
  letter-spacing: -.025em; line-height: 1.15;
}
.brand .name small {
  display: block; font-family: var(--sans); font-size: 11.5px;
  font-weight: 500; color: var(--ink-3); letter-spacing: 0;
}

.navwrap { overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
.navgroup > .lbl {
  font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-3); padding: 14px 10px 7px;
}
.navitem {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 12px; margin-bottom: 2px;
  border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-2);
  border-radius: var(--r-ctl); text-align: left;
  transition: background .13s, color .13s;
}
.navitem .ico { width: 18px; height: 18px; flex: none; opacity: .7; }
.navitem:hover { background: var(--paper-2); color: var(--ink); }
.navitem[aria-current="page"] {
  background: var(--brand); color: #fff; box-shadow: var(--sh-brand);
}
.navitem[aria-current="page"] .ico { opacity: 1; }
.navitem .tag { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--ink-3); }
.navitem[aria-current="page"] .tag { color: rgba(255, 255, 255, .72); }

/* pipeline rail */
.rail { padding-top: 14px; }
.rail .card-mini { background: var(--paper-2); border-radius: 16px; padding: 13px 14px; }
.rail h4 {
  margin: 0 0 10px; font-family: var(--sans); font-size: 10px; font-weight: 800;
  letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3);
}
.step { display: flex; align-items: center; gap: 9px; padding: 3.5px 0; font-size: 12.5px; color: var(--ink-3); }
.step .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--line-2); }
.step.done .dot { background: var(--h3); }
.step.blocked .dot { background: var(--h1); }
.step.done, .step.blocked { color: var(--ink); font-weight: 600; }
.step .note { margin-left: auto; font-size: 11px; color: var(--ink-3); font-weight: 500; }

/* ===== main ============================================================== */

.main { flex: 1; min-width: 0; max-width: 1320px; padding-bottom: 40px; }

.pagehead { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; padding: 6px 4px 20px; }
.pagehead h1 {
  margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -.038em; line-height: 1.05;
}
.pagehead p { margin: 7px 0 0; color: var(--ink-2); font-size: 14.5px; max-width: 60ch; }
.pagehead .actions { margin-left: auto; display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }

/* ===== THE WEEK — signature ============================================== */

.weekwrap { margin-bottom: 20px; }
.weekgrid {
  background: var(--paper); border-radius: var(--r-panel);
  box-shadow: var(--sh); padding: 20px; overflow-x: auto;
}
.weekgrid .whead {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.weekgrid .whead h2 {
  margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.025em;
}
.weekgrid .whead .sub { color: var(--ink-3); font-size: 13px; }
.weekgrid .whead .spacer { flex: 1; }

.wtable { display: grid; grid-template-columns: 74px repeat(5, minmax(122px, 1fr)); gap: 8px; min-width: 700px; }
.wtable .colhead {
  font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-3); text-align: center; padding-bottom: 2px;
}
.wtable .rowhead {
  font-size: 11px; font-weight: 700; color: var(--ink-3);
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 4px; text-align: right; line-height: 1.2;
}

.cell {
  border: 1.5px solid transparent; border-radius: var(--r-cell);
  padding: 11px 12px 10px; text-align: left; cursor: pointer;
  font: inherit; color: inherit; min-height: 74px;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: transform .12s ease, box-shadow .14s ease;
}
.cell:hover { transform: translateY(-2px); box-shadow: var(--sh-lift); }
.cell .pctn {
  font-family: var(--display); font-size: 21px; font-weight: 700;
  letter-spacing: -.035em; line-height: 1;
}
.cell .meta { font-size: 11.5px; font-weight: 500; opacity: .82; margin-top: 6px; }
.cell .tick { font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; opacity: .7; }

/* The capacity reading stays the headline; the classes sit under it so you can
   check the grid against the school's own sheet without leaving the page. */
.cell .chead { display: block; }
.cell .clist {
  list-style: none; margin: 10px 0 0; padding: 9px 0 0;
  border-top: 1px solid currentColor; border-color: color-mix(in srgb, currentColor 22%, transparent);
  display: grid; gap: 3px; width: 100%;
}
.cell .clist li {
  display: flex; align-items: baseline; gap: 5px;
  font-size: 11.5px; line-height: 1.25; min-width: 0;
}
.cell .clist .cs {
  font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.cell .clist .cs b {
  font-size: 9px; font-weight: 800; margin-left: 3px; padding: 0 3px;
  border-radius: 4px; vertical-align: 1px;
  background: color-mix(in srgb, currentColor 16%, transparent);
}
.cell .clist .ct { font-size: 10.5px; opacity: .62; white-space: nowrap; margin-left: auto; }
.cell .clist li.fixed { opacity: .55; font-style: italic; }

.cell.h4 { background: var(--h4-bg); border-color: var(--h4-line); color: var(--h4); }
.cell.h3 { background: var(--h3-bg); border-color: var(--h3-line); color: var(--h3); }
.cell.h2 { background: var(--h2-bg); border-color: var(--h2-line); color: var(--h2); }
.cell.h1 { background: var(--h1-bg); border-color: var(--h1-line); color: var(--h1); }
.cell.fixed {
  background: var(--paper-2); border-color: var(--line); color: var(--ink-3); cursor: default;
  min-height: 0; justify-content: flex-start; gap: 0;
}
.cell.fixed .chead { display: flex; align-items: baseline; gap: 8px; }
.cell.fixed .chead .meta { margin-top: 0; margin-left: auto; }
.cell.fixed:hover { transform: none; box-shadow: none; }
.cell.blank {
  background: none; border: 1.5px dashed var(--line); cursor: default;
  min-height: 74px;
}
/* Five classes to a cell need the room; below that the grid scrolls sideways. */
.wtable { grid-template-columns: 74px repeat(5, minmax(158px, 1fr)); }
.cell.blank:hover { transform: none; box-shadow: none; }
/* Seats not entered yet. Deliberately colourless: this session has no verdict,
   and a green or red cell would be claiming one. */
.cell.pending {
  background: repeating-linear-gradient(135deg, var(--paper-2) 0 8px, transparent 8px 16px);
  border-color: var(--line); color: var(--ink-3); border-style: dashed;
}
.cell.pending .pctn { opacity: .5; }
.cell[aria-pressed="true"] {
  box-shadow: 0 0 0 3px var(--brand), var(--sh-lift);
  border-color: transparent;
}

.wlegend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 15px; font-size: 12px; color: var(--ink-3); }
.wlegend span { display: flex; align-items: center; gap: 6px; }
.wlegend i { width: 11px; height: 11px; border-radius: 4px; display: block; border: 1.5px solid; }
.wlegend i.h4 { background: var(--h4-bg); border-color: var(--h4-line); }
.wlegend i.h3 { background: var(--h3-bg); border-color: var(--h3-line); }
.wlegend i.h2 { background: var(--h2-bg); border-color: var(--h2-line); }
.wlegend i.h1 { background: var(--h1-bg); border-color: var(--h1-line); }
.wlegend i.pending {
  background: repeating-linear-gradient(135deg, var(--paper-2) 0 4px, transparent 4px 8px);
  border-color: var(--line); border-style: dashed;
}

/* ===== cards ============================================================= */

.card {
  background: var(--paper); border-radius: var(--r-card);
  box-shadow: var(--sh-sm); margin-bottom: 18px; overflow: hidden;
}
.card > header {
  padding: 18px 22px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card > header + .body, .card > header + .body.flush { border-top: 1px solid var(--line); }
.card > header h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.025em; }
.card > header .sub { color: var(--ink-3); font-size: 13px; }
.spacer { flex: 1; }
.card .body { padding: 20px 22px; }
.card .body.flush { padding: 0; }

/* ===== stat tiles — WallQ's label / number / icon-chip ==================== */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--paper); border-radius: var(--r-card);
  padding: 17px 18px; box-shadow: var(--sh-sm);
}
.stat .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.stat .k { font-size: 10.5px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; color: var(--ink-3); }
.stat .chip {
  width: 30px; height: 30px; border-radius: 10px; flex: none;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand);
}
.stat .chip svg { width: 15px; height: 15px; }
.stat .v {
  font-family: var(--display); font-size: 32px; font-weight: 700;
  letter-spacing: -.045em; line-height: 1.05; margin-top: 10px;
}
.stat .n { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; font-weight: 500; }

.stat.hero { background: var(--brand); color: #fff; box-shadow: var(--sh-brand); }
.stat.hero .k { color: rgba(255, 255, 255, .7); }
.stat.hero .n { color: rgba(255, 255, 255, .78); }
.stat.hero .chip { background: rgba(255, 255, 255, .18); color: #fff; }

/* ===== banner ============================================================ */

.banner {
  display: flex; gap: 15px; align-items: flex-start;
  padding: 18px 20px; border-radius: var(--r-card); margin-bottom: 20px;
  border: 1.5px solid; font-size: 14.5px;
}
.banner .icon {
  width: 34px; height: 34px; border-radius: 11px; flex: none;
  display: grid; place-items: center; font-size: 16px; font-weight: 800;
  background: rgba(255, 255, 255, .7);
}
.banner h3 { margin: 0 0 3px; font-size: 16px; font-weight: 700; letter-spacing: -.025em; }
.banner p { margin: 0; opacity: .88; }
.banner.h3c { background: var(--h3-bg); border-color: var(--h3-line); color: var(--h3); }
.banner.h2c { background: var(--h2-bg); border-color: var(--h2-line); color: var(--h2); }
.banner.h1c { background: var(--h1-bg); border-color: var(--h1-line); color: var(--h1); }

/* ===== controls — pill buttons, Internia ================================= */

button.btn, .btn {
  appearance: none; font: inherit; font-size: 13.5px; font-weight: 700;
  padding: 10px 19px; border-radius: var(--r-pill); cursor: pointer;
  border: 1.5px solid var(--line-2); background: var(--paper); color: var(--ink);
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  transition: background .13s, border-color .13s, transform .09s, box-shadow .13s;
}
button.btn:hover { background: var(--paper-2); border-color: var(--ink-3); }
button.btn:active { transform: translateY(1px); }
button.btn.primary {
  background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: var(--sh-brand);
}
button.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
button.btn.danger { color: var(--h1); border-color: transparent; background: transparent; padding: 8px 14px; }
button.btn.danger:hover { background: var(--h1-bg); }
button.btn.sm { padding: 7px 14px; font-size: 12.5px; }
button.btn:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; transform: none; }

input, select, textarea {
  font: inherit; font-size: 14px; padding: 9px 13px; color: var(--ink);
  background: var(--paper); border: 1.5px solid var(--line-2);
  border-radius: var(--r-ctl); max-width: 100%;
  transition: border-color .13s, box-shadow .13s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3.5px var(--brand-soft);
}
input.num { width: 66px; text-align: center; font-weight: 700; padding: 8px 6px; }
input.ghost { border-color: transparent; background: transparent; width: 100%; font-weight: 600; }
input.ghost:hover { border-color: var(--line); background: var(--paper-2); }

label.field {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 11px; color: var(--ink-3); font-weight: 800;
  letter-spacing: .07em; text-transform: uppercase;
}
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; align-items: end; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type="search"] { min-width: 230px; border-radius: var(--r-pill); padding-left: 17px; }

/* ===== tables — airy, Internia row rhythm ================================ */

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
th {
  text-align: left; font-size: 10px; font-weight: 800; letter-spacing: .13em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 13px 22px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 15px 22px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--paper-2); }
td.num, th.num { text-align: right; }
.scroll-x { overflow-x: auto; }

/* ===== pills ============================================================= */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 800; padding: 4px 11px; border-radius: var(--r-pill);
  background: var(--paper-3); color: var(--ink-2); white-space: nowrap;
  border: 1.5px solid transparent; letter-spacing: .015em;
}
.pill.h4, .pill.ok { background: var(--h4-bg); color: var(--h4); border-color: var(--h4-line); }
.pill.h3       { background: var(--h3-bg); color: var(--h3); border-color: var(--h3-line); }
.pill.h2, .pill.warn { background: var(--h2-bg); color: var(--h2); border-color: var(--h2-line); }
.pill.h1, .pill.err  { background: var(--h1-bg); color: var(--h1); border-color: var(--h1-line); }
.pill.info  { background: var(--info-bg);  color: var(--info);  border-color: var(--info-line); }
.pill.brand { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-line); }
.pill.dupbadge { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-line); }

/* ===== slack bar ========================================================= */

.slack { display: flex; align-items: center; gap: 11px; min-width: 180px; }
.slack .track { flex: 1; height: 9px; border-radius: var(--r-pill); background: var(--paper-3); position: relative; overflow: hidden; }
.slack .fill { position: absolute; inset: 0 auto 0 0; border-radius: var(--r-pill); }
.slack .fill.h4 { background: var(--h4); } .slack .fill.h3 { background: var(--h3); }
.slack .fill.h2 { background: var(--h2); } .slack .fill.h1 { background: var(--h1); }
.slack .track::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 62%;
  width: 2px; background: var(--line-2);
}
.slack .lbl { font-size: 13px; font-weight: 700; width: 44px; text-align: right; color: var(--ink-2); }

.issue { font-size: 12.5px; margin-top: 5px; display: flex; gap: 6px; align-items: flex-start; line-height: 1.45; font-weight: 500; }
.issue.error { color: var(--h1); }
.issue.warn  { color: var(--h2); }
.issue.info  { color: var(--ink-3); }

/* ===== weekly-grid matrix ================================================ */

.matrix th.slot { position: sticky; left: 0; background: var(--paper); z-index: 2; }
.matrix td.slot { position: sticky; left: 0; background: var(--paper); font-weight: 700; z-index: 1; }
.matrix tbody tr:hover td.slot { background: var(--paper-2); }
.matrix select { font-size: 12.5px; padding: 6px 9px; border-radius: 9px; }
.matrix td, .matrix th { padding: 10px 16px; }
.daybreak td {
  background: var(--paper-3); font-size: 10px; font-weight: 800;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); padding: 9px 22px;
}

/* ===== class rows ======================================================== */

.slotblock { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.slotblock:last-child { border-bottom: 0; }
.slotblock > .head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.slotblock > .head strong { font-family: var(--display); font-size: 16px; font-weight: 700; letter-spacing: -.025em; }

.rows { display: flex; flex-direction: column; gap: 9px; }
.rowcard {
  display: flex; align-items: center; gap: 14px;
  background: var(--paper); border: 1.5px solid var(--line);
  border-radius: 16px; padding: 13px 16px;
  transition: transform .11s ease, box-shadow .14s ease, border-color .13s;
}
.rowcard:hover { transform: translateY(-2px); box-shadow: var(--sh-lift); border-color: transparent; }
.rowcard .who { min-width: 0; flex: 1 1 200px; }
.rowcard .who .t { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; letter-spacing: -.012em; }
.rowcard .who .s { font-size: 13px; color: var(--ink-3); margin-top: 2px; font-weight: 500; }
.rowcard .caps { display: flex; align-items: center; gap: 9px; }
.rowcard .caps label { font-size: 10px; font-weight: 800; color: var(--ink-3); letter-spacing: .1em; text-transform: uppercase; }
/* A class still waiting for its seat count — the one thing left to do on this row. */
.rowcard .caps.unset input { border-color: var(--h2-line); background: var(--h2-bg); }
.rowcard .caps.unset label { color: var(--h2); }

.avatar {
  width: 38px; height: 38px; border-radius: 13px; flex: none;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 800;
  background: var(--brand-soft); color: var(--brand); letter-spacing: -.02em;
}
.avatar.dim { background: var(--paper-3); color: var(--ink-3); }

/* ===== misc ============================================================== */

.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -.02em; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 3px; }
.empty { padding: 44px 20px; text-align: center; color: var(--ink-3); font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 24px; border-radius: var(--r-pill);
  font-size: 13.5px; font-weight: 700; box-shadow: var(--sh-lift);
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-5px); }
.toast.err { background: var(--h1); }

textarea.paste {
  width: 100%; font-family: var(--mono); font-size: 12.5px; padding: 14px;
  line-height: 1.65; resize: vertical; border-radius: var(--r-ctl);
}

/* ===== responsive ======================================================== */

@media (max-width: 940px) {
  .shell { flex-direction: column; padding: 12px; gap: 12px; }
  .sidebar { width: 100%; position: static; max-height: none; padding: 14px; }
  .brand { padding-bottom: 12px; }
  .navwrap { display: flex; gap: 7px; overflow-x: auto; }
  .navgroup { display: flex; align-items: center; gap: 7px; }
  .navgroup > .lbl { padding: 0 4px 0 10px; font-size: 9.5px; white-space: nowrap; }
  .navitem { width: auto; margin: 0; padding: 9px 14px; white-space: nowrap; }
  .navitem .ico { display: none; }
  .rail { display: none; }
  .main { max-width: none; }
  .pagehead h1 { font-size: 25px; }
}

/* Mobile: selection blocks stay one per row (product requirement) */
@media (max-width: 720px) {
  .formgrid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .rowcard { flex-wrap: wrap; }
  .rowcard .who { flex-basis: 100%; }
  th, td { padding: 12px 14px; }
  .slack { min-width: 120px; }
  .weekgrid { padding: 14px; }
}

/* ===== sign in =========================================================== */

.loginwrap { flex: 1; display: grid; place-items: center; min-height: 88vh; padding: 20px; }
.logincard {
  background: var(--paper); border-radius: var(--r-panel); box-shadow: var(--sh);
  padding: 32px; width: 100%; max-width: 384px;
}
.logincard h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.035em; }
.logincard p { margin: 6px 0 20px; font-size: 14px; }
.logincard input { width: 100%; padding: 12px 15px; }

/* ===== undo / redo ======================================================= */

.timectl { display: flex; gap: 6px; align-items: center; margin-right: 4px; }
.timectl .btn { padding: 7px 12px; }

.histpanel {
  background: var(--paper); border-radius: var(--r-card);
  box-shadow: var(--sh); margin-bottom: 18px; overflow: hidden;
}
.histpanel > header {
  padding: 18px 22px; display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; border-bottom: 1px solid var(--line);
}
.histpanel > header h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.025em; }
.histpanel > header .sub { color: var(--ink-3); font-size: 13px; }

.timeline { list-style: none; margin: 0; padding: 10px 0; }
.timeline .tl button {
  display: flex; align-items: center; gap: 13px; width: 100%;
  padding: 9px 22px; border: 0; background: none; cursor: pointer;
  font: inherit; text-align: left; color: var(--ink-2);
  position: relative;
}
.timeline .tl button:hover { background: var(--paper-2); }
/* the spine */
.timeline .tl button::before {
  content: ''; position: absolute; left: 27.5px; top: 0; bottom: 0;
  width: 2px; background: var(--line);
}
.timeline .tl:first-child button::before { top: 50%; }
.timeline .tl:last-child button::before { bottom: 50%; }
.timeline .node {
  width: 11px; height: 11px; border-radius: 50%; flex: none; z-index: 1;
  background: var(--paper); border: 2.5px solid var(--line-2);
}
.timeline .tl.here .node { border-color: var(--brand); background: var(--brand); }
.timeline .tl.here { color: var(--ink); }
.timeline .tl.here button { font-weight: 700; }
.timeline .tl.ahead button { opacity: .45; }
.timeline .tl.ahead .node { border-style: dashed; }
.timeline .what { flex: 1; min-width: 0; }
.timeline .when { font-size: 12px; color: var(--ink-3); font-weight: 500; }

/* a newly added row announces itself instead of vanishing into 180 others */
@keyframes rowflash {
  0%   { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
  100% { background: transparent;       box-shadow: inset 3px 0 0 transparent; }
}
tr.rowflash td { animation: rowflash 2.4s ease-out forwards; }

/* ===== account actions in the sidebar ==================================== */

.account { display: flex; flex-direction: column; gap: 2px; padding: 12px 4px 2px; }
.linkbtn {
  border: 0; background: none; cursor: pointer; font: inherit;
  font-size: 12.5px; font-weight: 600; color: var(--ink-3);
  text-align: left; padding: 6px 10px; border-radius: var(--r-sm);
}
.linkbtn:hover { background: var(--paper-2); color: var(--ink); }

/* checkbox group for "open to" */
.check {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  padding: 8px 14px; border: 1.5px solid var(--line-2); border-radius: var(--r-pill);
  transition: border-color .13s, background .13s, color .13s;
}
.check:hover { border-color: var(--ink-3); }
.check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.check input { accent-color: var(--brand); width: 15px; height: 15px; margin: 0; }

/* ---- the distribution -----------------------------------------------------
   The shape of the class, not its average. An average hides the girl who had a
   bad week, and she is the reason the solver works the way it does. */
.dist { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; height: 160px; align-items: end; }
.dist .bar { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.dist .bar .fill {
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  border-radius: 7px 7px 3px 3px; min-height: 3px;
  transition: height .35s cubic-bezier(.4, 0, .2, 1);
}
.dist .bar .n {
  text-align: center; font-size: 11px; font-weight: 700; color: var(--ink-2); padding-bottom: 4px;
}
.dist .bar .lbl {
  text-align: center; font-size: 10.5px; font-weight: 700; color: var(--ink-3);
  padding-top: 6px; border-top: 1px solid var(--line); margin-top: 5px;
}
/* The low bands carry the capacity hues, because a girl down there is the same
   kind of problem a session with no slack is. */
.dist .bar:nth-child(-n+3) .fill { background: linear-gradient(180deg, var(--h1-line), var(--h1)); }
.dist .bar:nth-child(4) .fill,
.dist .bar:nth-child(5) .fill { background: linear-gradient(180deg, var(--h2-line), var(--h2)); }
