/* ============================================================
   EARNINGS HUB — mock design system
   Surface: pre-dawn blue-black. Sessions: dawn amber (BMO),
   dusk violet (AMC). Polarity: teal up / red down (validated).
   Type: Martian Mono (data/labels) + Archivo (UI prose).
   ============================================================ */

:root {
  /* surfaces */
  --bg:        #10141D;
  --panel:     #171D29;
  --raised:    #1D2432;
  --overlay:   #232B3C;
  --line:      #2A3245;
  --line-soft: #222938;

  /* ink */
  --ink:       #E8EAF0;
  --ink-2:     #9AA3B7;
  --ink-3:     #5E6880;

  /* sessions */
  --bmo:       #C4862D;   /* dawn amber  — before market open */
  --bmo-soft:  #C4862D22;
  --bmo-text:  #E2A24C;
  --amc:       #8B7BF0;   /* dusk violet — after market close */
  --amc-soft:  #8B7BF022;
  --amc-text:  #A99CF5;

  /* polarity (signed gap) */
  --up:        #1FA294;
  --dn:        #E5484D;

  /* status */
  --ok:        #4C9E5E;   /* confirmed */
  --ok-bright: #67C77E;   /* confirmed ✓ on chips — needs to pop at small size */
  --ok-soft:   #4C9E5E26;
  --warn:      #C4862D;
  --danger:    #E5484D;
  --danger-soft:#E5484D1F;

  --thead-bg:  #1A2130;
  --thead-ink: #C89858;

  --mono: "Martian Mono", ui-monospace, monospace;
  --sans: "Archivo", system-ui, sans-serif;

  --r-s: 4px;
  --r-m: 8px;
  --r-l: 12px;
}

/* light theme: same accents (validated on white), light surfaces, darker text tints */
:root[data-theme="light"] {
  --bg:        #E7EBF2;
  --panel:     #FBFCFE;
  --raised:    #EBEEF4;
  --overlay:   #DDE3EC;
  --line:      #B7C1D0;
  --line-soft: #CFD7E2;

  --ink:       #1B2130;
  --ink-2:     #465064;
  --ink-3:     #7A869C;

  --bmo-soft:  #C4862D1F;
  --bmo-text:  #96661C;
  --amc-soft:  #8B7BF024;
  --amc-text:  #6656D6;

  --ok:        #35824A;
  --ok-bright: #2E7A44;   /* darker on light surfaces */
  --ok-soft:   #35824A22;
  --danger-soft:#E5484D14;

  --thead-bg:  #EEF1F6;
  --thead-ink: #96661C;
}
:root[data-theme="light"] .tooltip { box-shadow: 0 6px 24px #1B213026; }
:root[data-theme="light"] .btn.primary { color: #FFFFFF; }
:root[data-theme="light"] .pf { color: #FFFFFF; }
/* light surfaces need a hint of elevation to not wash out */
:root[data-theme="light"] .day,
:root[data-theme="light"] .panel,
:root[data-theme="light"] .tbl-wrap,
:root[data-theme="light"] .tile { box-shadow: 0 1px 3px #1B213018; }

* { box-sizing: border-box; touch-action: manipulation; }  /* kills iOS double-tap zoom; pinch & pan unaffected */
[hidden] { display: none !important; }

/* smooth cross-fade between page navigations (Chromium, Safari 18+);
   moot in the real app — the SPA never reloads the shell */
@view-transition { navigation: auto; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}

::selection { background: #8B7BF055; }

a { color: var(--amc-text); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--bmo-text);
  outline-offset: 2px;
  border-radius: var(--r-s);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 20px;
  height: 54px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--ink);
  white-space: nowrap;
}
.brand .tick { color: var(--bmo-text); }

.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-2);
  padding: 6px 12px;
  border-radius: var(--r-m);
}
.nav a:hover { color: var(--ink); background: var(--raised); text-decoration: none; }
.nav a.active { color: var(--ink); background: var(--raised); }

.sync-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-2);
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  white-space: nowrap;
}
.sync-chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
}

.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--overlay);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-2);
}

/* ---------- page scaffold ---------- */

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px;
  transition: margin-right 0.22s ease;
}
/* drawer docks: content yields instead of being overlaid */
body.drawer-open .page { margin-right: 396px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.month-nav h1 {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.06em;
  margin: 0 10px;
  min-width: 150px;
  text-align: center;
}

.icon-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-2);
  border-radius: var(--r-m);
  width: 30px; height: 30px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.icon-btn:hover { color: var(--ink); background: var(--raised); }

.spacer { flex: 1; }

/* filter chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  background: none;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: var(--sans);
}
.chip:hover { color: var(--ink); }
.chip.on {
  color: var(--ink);
  border-color: var(--ink-3);
  background: var(--raised);
}

/* buttons */
.btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--r-m);
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--ink);
  padding: 8px 14px;
  cursor: pointer;
}
.btn:hover { background: var(--overlay); }
.btn.primary {
  background: var(--bmo);
  border-color: var(--bmo);
  color: #14100A;
}
.btn.primary:hover { background: var(--bmo-text); border-color: var(--bmo-text); }
.btn.ghost { background: none; }
.btn.danger-ghost { background: none; color: var(--dn); border-color: #E5484D55; }
.btn.small { font-size: 12px; padding: 5px 10px; }

/* ---------- calendar grid (signature) ---------- */

.cal-head {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.cal-head div {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  text-transform: uppercase;
  padding-left: 10px;
}

.cal {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.day {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-l);
  min-height: 128px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.day.today { border-color: var(--bmo); }
.day.other .day-num { opacity: 0.55; }

.day-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  padding: 7px 10px 4px;
}
.day.today .day-num { color: var(--bmo-text); }

/* the session split: dawn on top, dusk below — two explicit areas */
.sess {
  flex: 1;
  padding: 2px 6px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sess.bmo { background: linear-gradient(180deg, #C4862D14, #C4862D04); }
.sess.amc {
  background: linear-gradient(180deg, #8B7BF012, #8B7BF004);
  border-top: 1px solid var(--line-soft);
}
.sess-tag {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  padding-left: 4px;
  opacity: 0.75;
}
.sess.bmo .sess-tag { color: var(--bmo-text); }
.sess.amc .sess-tag { color: var(--amc-text); }

/* entry chip */
.entry {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--raised);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--ink-3);
  border-radius: var(--r-s);
  padding: 4px 7px;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  color: var(--ink);
  width: 100%;
  text-align: left;
}
.entry:hover { background: var(--overlay); }
.entry.s-bmo { border-left-color: var(--bmo); }
.entry.s-amc { border-left-color: var(--amc); }

.entry .t { font-weight: 700; letter-spacing: 0.02em; }
.entry .g { color: var(--ink-2); font-size: 10px; margin-left: auto; }
.entry .flag { font-size: 13px; font-weight: 700; line-height: 1; }
.entry .flag.ok { color: var(--ok-bright); }
.entry .flag.warn { color: var(--dn); }

.entry.unconfirmed { border-style: dashed; border-left-style: solid; }

/* traded: in play — filled with its session tint, diamond marker */
.entry.traded { border-left-style: solid; }
.entry.traded.s-bmo { background: var(--bmo-soft); border-color: #C4862D55; }
.entry.traded.s-amc { background: var(--amc-soft); border-color: #8B7BF055; }
.entry.traded:hover { filter: brightness(1.15); }
.entry .dia { font-size: 9px; line-height: 1; }
.entry.s-bmo .dia { color: var(--bmo-text); }
.entry.s-amc .dia { color: var(--amc-text); }

/* deleted: struck & dimmed (soft delete — restorable via the Deleted filter) */
.entry.deleted { opacity: 0.4; border-style: solid; }
.entry.deleted .t { text-decoration: line-through; text-decoration-thickness: 1px; }

/* lead info on prep-date placements: T-X and →report-day side by side */
.entry .lead {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-left: auto;
}
.entry .tx { font-size: 9px; color: var(--ink-2); }
.entry .rd { font-size: 9px; color: var(--ink-3); }
.entry .lead + .g { margin-left: 0; }
.entry[draggable="true"] { cursor: grab; }
.day.dragover { border-color: var(--amc); border-style: dashed; }

/* portfolio sub-filter, shown only while Traded is active */
.pf-sub {
  border-left: 1px solid var(--line);
  padding-left: 12px;
  margin-left: 4px;
}

.more-chip {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--ink-2);
  background: none;
  border: 1px dashed var(--line);
  border-radius: var(--r-s);
  padding: 3px 7px;
  cursor: pointer;
  width: 100%;
}
.more-chip:hover { color: var(--ink); background: var(--raised); }

.pf {
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 700;
  color: var(--bg);
  background: var(--ink-2);
  border-radius: 3px;
  padding: 1px 3px;
  line-height: 1.2;
}

/* ---------- week & day views ---------- */

.cal.week .day { min-height: 380px; }
.cal.week .entry { padding: 6px 8px; }

.day-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.sess-col {
  border: 1px solid var(--line-soft);
  border-radius: var(--r-l);
  padding: 14px 14px 16px;
  min-height: 340px;
}
.sess-col.bmo { background: linear-gradient(180deg, #C4862D12, var(--panel) 70%); }
.sess-col.amc { background: linear-gradient(180deg, #8B7BF010, var(--panel) 70%); }
.sess-col h3 {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 12px;
}
.sess-col.bmo h3 { color: var(--bmo-text); }
.sess-col.amc h3 { color: var(--amc-text); }
.sess-col .entry { margin-bottom: 8px; }
.sess-col .empty { color: var(--ink-3); font-size: 13px; margin: 4px 0; }

/* big chips (day view): company name on a second line */
.entry.big { flex-wrap: wrap; padding: 8px 10px; font-size: 12px; }
.entry.big .co {
  width: 100%;
  order: 10;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--ink-2);
  margin-top: 2px;
}

@media (max-width: 700px) {
  .day-view { grid-template-columns: 1fr; }
  .sess-col { min-height: 0; }
  /* on phones the day view replaces the agenda (not both) */
  body.view-day .agenda { display: none; }
}

/* ---------- drawer ---------- */

.drawer {
  position: fixed;
  top: 54px;
  right: 0;
  bottom: 0;
  width: 380px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  transform: translateX(102%);
  transition: transform 0.22s ease;
  z-index: 50;
  overflow-y: auto;
  padding: 20px;
}
.drawer.open { transform: none; }

.drawer-close {
  position: absolute;
  top: 14px; right: 14px;
  background: none; border: none;
  color: var(--ink-3);
  font-size: 18px;
  cursor: pointer;
}
.drawer-close:hover { color: var(--ink); }

.d-ticker {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  margin: 2px 0 0;
}
.d-company { color: var(--ink-2); font-size: 13.5px; margin: 2px 0 6px; }

.ir-link {
  display: inline-block;
  font-size: 12.5px;
  margin-bottom: 12px;
}

/* audit trail box */
.audit {
  background: var(--raised);
  border-radius: var(--r-m);
  padding: 10px 12px;
  margin-bottom: 14px;
}
.audit .k {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.audit ul { list-style: none; margin: 0; padding: 0; }
.audit li {
  font-size: 11.5px;
  color: var(--ink-2);
  padding: 4px 0;
  border-bottom: 1px solid var(--line-soft);
  line-height: 1.5;
}
.audit li:last-child { border-bottom: none; }
.audit .ts { font-family: var(--mono); font-size: 10px; color: var(--ink-3); margin-right: 8px; }
.audit .who { font-weight: 600; color: var(--ink); margin-right: 6px; }

.sess-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 4px 9px;
  border-radius: 99px;
}
.sess-badge.bmo { background: var(--bmo-soft); color: var(--bmo-text); }
.sess-badge.amc { background: var(--amc-soft); color: var(--amc-text); }

.d-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}
.fact {
  background: var(--raised);
  border-radius: var(--r-m);
  padding: 10px 12px;
}
.fact .k {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.fact .v { font-family: var(--mono); font-size: 13.5px; }
.fact .v small { color: var(--ink-2); font-size: 11px; }

.d-actions { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.d-actions .row { display: flex; gap: 8px; }
.d-actions .row .btn { flex: 1; }

.pf-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--raised);
  border-radius: var(--r-m);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--ink-2);
}
.pf-toggle .btn.small.on {
  background: var(--overlay);
  border-color: var(--ink-3);
  color: var(--ink);
}

.provenance {
  font-size: 11.5px;
  color: var(--ink-3);
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
  margin-top: 16px;
  line-height: 1.6;
}

/* conflict banner */
.conflict {
  background: var(--danger-soft);
  border: 1px solid #E5484D66;
  border-radius: var(--r-m);
  padding: 12px 14px;
  margin: 14px 0;
  font-size: 13px;
}
.conflict b { color: var(--dn); font-weight: 600; }
.conflict p { margin: 0 0 10px; color: var(--ink); }
.conflict .row { display: flex; gap: 8px; }

/* ---------- modal (manual entry) ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #00000080;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 22px 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px #00000080;
}
.modal h2 { margin: 0 0 4px; font-size: 16px; }
.modal .sub { font-size: 12.5px; color: var(--ink-3); margin: 0 0 16px; }
.modal label {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 12px;
}
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-width: 0; }
.modal label, .modal .field { min-width: 0; }
.field {
  display: block;
  width: 100%;
  margin-top: 5px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  padding: 8px 10px;
}
.field.mono { font-family: var(--mono); font-size: 13px; }
.field.notes {
  resize: vertical;
  min-height: 64px;
  font-size: 13px;
  line-height: 1.5;
  background: var(--panel);
}
.seg { display: flex; gap: 6px; margin-top: 5px; }
.seg .btn.on { background: var(--overlay); border-color: var(--ink-3); }

/* ---------- tables ---------- */

.tbl-wrap {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-l);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
th {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--thead-ink);
  background: var(--thead-bg);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 9px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--raised); }
td.mono, .mono { font-family: var(--mono); font-size: 12px; }
td.num { font-family: var(--mono); font-size: 12px; text-align: right; }
th.num { text-align: right; }
.pos { color: var(--up); }
.neg { color: var(--dn); }

.region {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  border: 1px solid var(--line);
  color: var(--ink-2);
  border-radius: 4px;
  padding: 2px 6px;
}

/* ---------- stat tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.tile {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-l);
  padding: 16px 18px;
}
.tile .k {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.tile .v {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.1;
}
.tile .v small { font-size: 13px; color: var(--ink-2); font-weight: 400; }
.tile .sub { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; }

/* ---------- chart panel ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-l);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.panel h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 2px;
}
.panel .sub { font-size: 12px; color: var(--ink-3); margin-bottom: 14px; }

.legend {
  display: flex;
  gap: 16px;
  font-size: 11.5px;
  color: var(--ink-2);
  margin-top: 10px;
}
.legend .sw {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -1px;
}

.tooltip {
  position: fixed;
  background: var(--overlay);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  padding: 8px 11px;
  font-family: var(--mono);
  font-size: 11px;
  pointer-events: none;
  z-index: 90;
  display: none;
  line-height: 1.7;
  box-shadow: 0 6px 24px #0008;
}

/* ---------- agenda (mobile calendar) ---------- */

.agenda { display: none; }
.agenda-day { margin-bottom: 4px; }
.agenda-date {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  padding: 14px 2px 6px;
  text-transform: uppercase;
}
.agenda .entry { padding: 10px 12px; font-size: 13px; border-radius: var(--r-m); margin-bottom: 6px; }
.agenda .entry .g { font-size: 11.5px; }

/* ---------- landing page ---------- */

.hero { padding: 56px 0 30px; }
.hero .eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--bmo-text);
  text-transform: uppercase;
  margin-bottom: 14px;
}
.hero h1 {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(26px, 4.5vw, 42px);
  letter-spacing: 0.02em;
  margin: 0 0 12px;
  line-height: 1.15;
}
.hero h1 .dawn { color: var(--bmo-text); }
.hero h1 .dusk { color: var(--amc-text); }
.hero p { color: var(--ink-2); max-width: 62ch; margin: 0; }

.mock-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 28px 0;
}
.mock-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-l);
  padding: 20px 22px;
  color: var(--ink);
}
.mock-card:hover { border-color: var(--ink-3); text-decoration: none; background: var(--raised); }
.mock-card .n {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.14em;
  margin-bottom: 8px;
}
.mock-card h3 { margin: 0 0 6px; font-size: 16px; }
.mock-card p { margin: 0; font-size: 13px; color: var(--ink-2); }

.swatches { display: flex; gap: 8px; margin: 18px 0 6px; flex-wrap: wrap; }
.swatch {
  width: 92px;
  border-radius: var(--r-m);
  overflow: hidden;
  border: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-2);
}
.swatch .c { height: 44px; }
.swatch .l { padding: 5px 7px; background: var(--panel); }

/* ---------- responsive: 2 breakpoints ----------
   ≤1024px  tablet portrait      grid stays, denser; drawer overlays
   ≤700px   phone                agenda list, bottom tab bar, bottom-sheet drawer
--------------------------------------------------- */

@media (max-width: 1024px) {
  .page { padding: 16px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .day { min-height: 108px; }
  .entry { font-size: 10px; padding: 4px 5px; gap: 4px; }
  .entry .g { font-size: 9.5px; }
  /* not enough room to push content — drawer overlays with a shadow */
  body.drawer-open .page { margin-right: auto; }
  .drawer { box-shadow: -14px 0 44px #00000059; }
}

@media (max-width: 700px) {
  html, body { overflow-x: hidden; }
  .cal, .cal-head { display: none; }
  .agenda { display: block; }

  /* topbar slims down; nav becomes a bottom tab bar */
  .topbar { gap: 10px; padding: 0 14px; }
  .topbar .brand { flex: 1; }
  .sync-chip { display: none; }
  .nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 60;
    background: var(--panel);
    border-top: 1px solid var(--line);
    padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
    gap: 4px;
  }
  .nav a {
    flex: 1;
    text-align: center;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    padding: 7px 2px 8px;
  }
  .nav a::before {
    display: block;
    font-size: 15px;
    line-height: 1.3;
    font-family: var(--sans);
  }
  .nav a:nth-child(1)::before { content: "▦"; }
  .nav a:nth-child(2)::before { content: "◆"; }
  .nav a:nth-child(3)::before { content: "∿"; }
  .nav a:nth-child(4)::before { content: "⛁"; }
  .nav a.active { background: none; color: var(--bmo-text); }
  body { padding-bottom: 70px; }

  .page { padding: 14px; }
  .toolbar { gap: 8px; margin-bottom: 12px; }
  .month-nav h1 { font-size: 14px; min-width: 0; }
  /* filter chips: one swipeable row, no visible scrollbar */
  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .chips::-webkit-scrollbar { display: none; }
  .chip { white-space: nowrap; flex-shrink: 0; }

  /* agenda readability */
  .agenda .entry { padding: 12px 14px; font-size: 14.5px; border-left-width: 4px; }
  .agenda .entry .g { font-size: 12px; }
  .agenda-date {
    font-size: 11.5px;
    padding: 16px 2px 8px;
    position: sticky;
    top: 54px;
    background: var(--bg);
    z-index: 5;
  }

  /* drawer takes the whole screen on phones */
  .drawer {
    width: 100%;
    top: 0;
    height: 100dvh;
    border-left: none;
    border-radius: 0;
    transform: translateY(103%);
    z-index: 80;              /* above the bottom tab bar */
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .drawer-close {
    top: 10px;
    right: 10px;
    font-size: 22px;
    padding: 10px;            /* ~44px tap target */
  }

  /* new-entry modal becomes a full-screen card */
  .modal-backdrop { padding: 0; align-items: stretch; justify-content: stretch; }
  .modal {
    max-width: none;
    width: 100%;
    height: 100dvh;
    border: none;
    border-radius: 0;
    overflow-y: auto;
    /* room to scroll fields above the on-screen keyboard */
    padding: 24px 20px 45dvh;
  }
  .modal .row2 { grid-template-columns: 1fr; gap: 0; }  /* date & session stack */
  .drawer.open { transform: none; }
  body.drawer-open .page { margin-right: auto; }

  .tiles { gap: 10px; }
  .tile { padding: 16px; min-height: 96px; }
  .tile .v { font-size: 24px; }
  .tile .sub { margin-top: 8px; }

  /* iOS Safari zooms focused inputs under 16px — never go below it on phones */
  input, select, textarea, .field { font-size: 16px !important; }

  /* tables become labeled cards */
  .tbl-wrap { background: none; border: none; overflow: visible; box-shadow: none !important; }
  .tbl-wrap table, .tbl-wrap tbody, .tbl-wrap tr, .tbl-wrap td { display: block; width: 100%; }
  .tbl-wrap thead { display: none; }
  .tbl-wrap tr {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-l);
    margin-bottom: 10px;
    padding: 12px 16px;
  }
  .tbl-wrap tr:hover td { background: none; }
  .tbl-wrap td {
    border: none;
    padding: 4px 0;
    white-space: normal;
    display: flex;
    justify-content: flex-start;
    align-items: baseline;
    gap: 6px;
    font-size: 14px;
  }
  .tbl-wrap td.num, .tbl-wrap td.mono { font-size: 13px; }
  .tbl-wrap td[data-label]::before {
    content: attr(data-label);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-3);
    flex-shrink: 0;
    margin-right: auto;   /* label left, value(s) grouped right */
  }
  .tbl-wrap td .btn { width: 100%; }

  /* charts keep their height and scroll sideways instead of squashing */
  .panel svg { min-width: 680px; height: 220px; }

  /* .compact tables opt out of card mode: stay a real table, tightened,
     with secondary columns (session, EPS, rev) hidden to fit the width */
  .tbl-wrap.compact {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    overflow-x: auto;
    border-radius: var(--r-l);
  }
  .tbl-wrap.compact table { display: table; width: 100%; }
  .tbl-wrap.compact thead { display: table-header-group; }
  .tbl-wrap.compact tbody { display: table-row-group; }
  .tbl-wrap.compact tr {
    display: table-row;
    background: none;
    border: none;
    border-radius: 0;
    margin: 0;
    padding: 0;
  }
  .tbl-wrap.compact th, .tbl-wrap.compact td {
    display: table-cell;
    width: auto;
    padding: 7px 8px;
    font-size: 11px;
    white-space: nowrap;
  }
  .tbl-wrap.compact th { font-size: 8.5px; }
  .tbl-wrap.compact td::before { content: none !important; }
  .tbl-wrap.compact th:nth-child(2), .tbl-wrap.compact td:nth-child(2),
  .tbl-wrap.compact th:nth-child(3), .tbl-wrap.compact td:nth-child(3),
  .tbl-wrap.compact th:nth-child(7), .tbl-wrap.compact td:nth-child(7),
  .tbl-wrap.compact th:nth-child(8), .tbl-wrap.compact td:nth-child(8) { display: none; }
}
