:root {
  /* Same token system + palette as the ARMC app fleet (timeclock-admin). */
  --mono: ui-monospace, Consolas, "DejaVu Sans Mono", "Liberation Mono", "Courier New", monospace;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #16202c;
  --muted: #4a535d;
  --line: #c4ccd6;
  --accent: #234f8e;
  --ready: #1d6b3f;
  --error: #b3261e;
  /* Carried over from the old .ods: week banding + the steel-blue e1RM accent. */
  --wk-a: #dde8cb;      /* pale green week band */
  --wk-b: #dee6ef;      /* pale blue week band */
  --gr-a: #eeeeee;      /* e1RMs gray band A */
  --gr-b: #dddddd;      /* e1RMs gray band B */
  --steel: #5983b0;     /* e1RM / PR column highlight */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--mono);
  background: var(--bg);
  color: var(--ink);
}
button, input, select, textarea { font-family: inherit; }

/* Top bar / nav */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: var(--accent);
  color: #fff;
  padding: env(safe-area-inset-top, 0px) 1.25rem 0;
  height: calc(48px + env(safe-area-inset-top, 0px));
}
.brand { font-weight: 700; color: #fff; text-decoration: none; letter-spacing: .05em; white-space: nowrap; }
.mainnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.mainnav a {
  color: #dce6f4; text-decoration: none; padding: .35rem .6rem;
  border-radius: 4px; font-size: .9rem; white-space: nowrap;
}
.mainnav a:hover { background: rgba(255,255,255,.15); color: #fff; }
.mainnav a.active { background: rgba(255,255,255,.22); color: #fff; }

.content { max-width: none; margin: 0; padding: 1rem 2rem; }
h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
.lede { color: var(--muted); margin-top: 0; }
code { background: #eceff3; padding: .1rem .3rem; border-radius: 3px; font-size: .85em; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 1rem 1.25rem; margin: 1rem 0;
}
.panel h2 { font-size: 1.05rem; margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; }
.badge { background: var(--accent); color: #fff; font-size: .8rem; border-radius: 10px; padding: .05rem .55rem; }

table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: .72rem; letter-spacing: .03em; }
tbody tr:hover { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-style: italic; }
.error { color: var(--error); font-size: .85rem; }
.note { color: var(--muted); font-size: .8rem; margin: 0 0 .5rem; }
.table-wrap { overflow-x: auto; }

/* Filter bar + buttons */
.filterbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.filterbar label { color: var(--muted); font-size: .85rem; }
.filterbar input, .filterbar select {
  padding: .3rem .4rem; border: 1px solid var(--line); border-radius: 4px; font-size: .9rem;
}
.btn {
  text-decoration: none; color: var(--accent); border: 1px solid var(--line);
  border-radius: 4px; padding: .3rem .55rem; font-size: .85rem; background: var(--panel);
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary {
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  border-radius: 6px; padding: .5rem 1.1rem; font-weight: 700; font-size: .9rem; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-danger { color: var(--error); }
.btn-danger:hover { border-color: var(--error); }

/* ---- The Log grid (mirrors the .ods look: banded weeks, dotted set rules) ---- */
table.loggrid { width: auto; font-size: .78rem; }
table.loggrid th, table.loggrid td {
  padding: .18rem .45rem; border-bottom: none; white-space: nowrap;
}
/* header row: all labels centered, bold perimeter box */
table.loggrid thead th {
  text-align: center;
  border-top: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
}
table.loggrid thead th:first-child { border-left: 3px solid var(--ink); }
table.loggrid thead th:last-child { border-right: 3px solid var(--ink); }
table.loggrid th { font-size: .66rem; }
/* dark right edge of the table, mirroring the cycle column's left edge */
table.loggrid td.actions { border-right: 3px solid var(--ink); }
/* merged cycle/week/date cells: value printed once, centered in the run */
table.loggrid td.grp { vertical-align: middle; text-align: center; }
/* boundary weights on merged cells (dotted day / solid week / thick cycle) */
table.loggrid td.b-day   { border-bottom: 1px dotted #6a7684; }
table.loggrid td.b-week  { border-bottom: 1.5px solid var(--ink); }
table.loggrid td.b-cycle { border-bottom: 3px solid var(--ink); }
/* border hierarchy on the label columns:
   cycle | week | date  =  thick | solid | dotted verticals, and week cells
   always open/close with the solid inter-week rule (never dotted). */
table.loggrid td.wk-cell {
  border-right: 1px dotted #6a7684;
  border-bottom: 1.5px solid var(--ink);
}
table.loggrid td.wk-cell.b-cycle { border-bottom: 3px solid var(--ink); }
table.loggrid td.cy-cell {
  border-left: 3px solid var(--ink);
  border-right: 1.5px solid var(--ink);
  border-bottom: 3px solid var(--ink);
}
/* scope-aware hover highlight (driven by static/js/log.js) */
table.loggrid td.hl { filter: brightness(.94); }
table.loggrid td.grp { cursor: default; }
/* Fixed-width set strings ('  5×  95'): pre keeps the pad spaces so the ×
   sits in the same column of every cell; centering aligns the whole block. */
table.loggrid td.setcell {
  text-align: center; white-space: pre;
  font-variant-numeric: tabular-nums; min-width: 3.6rem;
}
table.loggrid td.lift { font-weight: 400; }
/* Column coloration: grey base, warm-ups blue, working sets yellow->orange->red,
   extra volume green (the spreadsheet's real scheme, column-wise). */
table.loggrid td { background: #ececec; }
table.loggrid td.c-warm, table.loggrid th.c-warm { background: var(--wk-b); }
table.loggrid td.c-y,    table.loggrid th.c-y    { background: #f7e9a8; }
table.loggrid td.c-o,    table.loggrid th.c-o    { background: #f8d3a0; }
table.loggrid td.c-r,    table.loggrid th.c-r    { background: #f3b7b0; }
table.loggrid td.c-vol,  table.loggrid th.c-vol  { background: var(--wk-a); }
/* :not(.grp) — merged label cells control their own borders; without this a
   row rule (higher specificity) overrides a week cell's solid rule to dotted
   whenever the cell's first row is also a date boundary. */
table.loggrid tr.new-day td:not(.grp) { border-bottom: 1px dotted #6a7684; }
table.loggrid tr.new-week td:not(.grp) { border-bottom: 1.5px solid var(--ink); }
table.loggrid tr.new-cycle td:not(.grp) { border-bottom: 3px solid var(--ink); }
table.loggrid td.topset { font-weight: 400; }
table.loggrid td.e1rm, table.loggrid th.e1rm {
  color: #06101c; font-weight: 700;
  border-left: 1.5px solid var(--ink);
  border-right: 1.5px solid var(--ink);
}
table.loggrid td.e1rm { text-align: right; }
table.loggrid th.e1rm { background: #ececec; text-align: center; }
/* td.e1rm gets its Symmetric-Strength rating color inline; unrated stays grey */
table.loggrid th.num { text-align: center; }
table.loggrid td.dt-cell { white-space: pre; }
table.loggrid .actions .btn { font-size: .68rem; padding: 0 .28rem; line-height: 1.3; }
.wk-ord { display: block; font-size: .6rem; color: var(--muted); }
/* inline row editing */
.ie-set {
  width: 3.6rem; font-size: .72rem; text-align: center; padding: .08rem .15rem;
  border: 1px solid var(--accent); border-radius: 3px; background: #fff;
}
.ie-lift {
  width: 10rem; font-size: .74rem; padding: .08rem .25rem;
  border: 1px solid var(--accent); border-radius: 3px; background: #fff;
}
.ie-bar { display: inline-flex; gap: .2rem; }
table.loggrid td.actions { white-space: nowrap; }
table.loggrid .actions form { display: inline; }
.dl-chip {
  display: block; width: fit-content; margin: .15rem auto 0;
  background: var(--ink); color: #fff; font-size: .62rem;
  border-radius: 3px; padding: 0 .3rem; letter-spacing: .05em;
}

/* ---- Big 4 analytics table (gray week bands, steel PR block) ---- */
table.e1grid { width: auto; font-size: .78rem; }
table.e1grid th, table.e1grid td { padding: .18rem .5rem; white-space: nowrap; border-bottom: none; }
table.e1grid th { text-align: center; }
table.e1grid td { text-align: right; font-variant-numeric: tabular-nums; }
table.e1grid td.dt { text-align: left; }
/* merged week/cycle cells (value once, centered; border = bottom boundary) */
table.e1grid td.wkgrp, table.e1grid td.cygrp {
  vertical-align: middle; text-align: center;
}
table.e1grid td.b-wk  { border-bottom: 1px solid #6a7684; }
table.e1grid td.b-cyc { border-bottom: 1.5px solid var(--ink); }
table.e1grid tr.gr-a td { background: var(--gr-a); }
table.e1grid tr.gr-b td { background: var(--gr-b); }
table.e1grid tr.new-week td:not(.wkgrp):not(.cygrp) { border-bottom: 1px solid #6a7684; }
table.e1grid tr.new-cycle td:not(.wkgrp):not(.cygrp) { border-bottom: 1.5px solid var(--ink); }
table.e1grid .grpsep { border-left: 3px double #333; }
table.e1grid td.pr, table.e1grid th.pr { background: var(--steel); color: #06101c; }
table.e1grid tr:hover td { filter: brightness(.95); }

/* ---- Rep-max matrices + %1RM grid (tiny like the sheet's 6pt) ---- */
table.matrix { width: auto; font-size: .68rem; }
table.matrix th, table.matrix td {
  padding: .12rem .3rem; text-align: right; font-variant-numeric: tabular-nums;
  border-bottom: 1px dotted var(--line); white-space: nowrap;
}
table.matrix th.rowhead, table.matrix td.rowhead { font-weight: 700; text-align: left; }
table.matrix td .sub { display: block; color: var(--muted); font-size: .58rem; }
table.matrix td.hit { background: #eaf0f9; }

/* ---- Standards (the sheet's rating rainbow, verbatim hexes) ---- */
table.stds { width: auto; }
table.stds td, table.stds th { text-align: center; white-space: nowrap; }
table.stds td.bwcol { font-weight: 700; background: var(--gr-b); }
/* current-BW row: one black box around the whole row */
table.stds tr.curbw td { border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
table.stds tr.curbw td:first-child { border-left: 2px solid var(--ink); }
table.stds tr.curbw td:last-child { border-right: 2px solid var(--ink); }
/* current all-time PR cell (black box) */
table.stds td.hit { box-shadow: inset 0 0 0 3px var(--ink); font-weight: 700; }
/* best e1RM achieved while in that weight category (white box) */
table.stds td.best { outline: 3px solid #fff; outline-offset: -4px; }

/* ---- Charts ---- */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; max-width: 100%; height: auto; }
.legend { display: flex; gap: 1.25rem; flex-wrap: wrap; margin: 0 0 .5rem; font-size: .82rem; }
.legend .key { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); }
.legend .swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-tip {
  position: absolute; pointer-events: none; display: none; z-index: 10;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15); padding: .4rem .6rem; font-size: .75rem;
  min-width: 9rem;
}
.chart-tip .tip-date { font-weight: 700; margin-bottom: .2rem; }
.chart-tip .tip-row { display: flex; align-items: center; gap: .4rem; }
.chart-tip .tip-row .val { margin-left: auto; font-variant-numeric: tabular-nums; }
.chart-tip .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, max-content)); gap: .75rem; align-items: end; }
.fld { display: flex; flex-direction: column; gap: .2rem; font-size: .82rem; color: var(--muted); }
.fld input, .fld select {
  padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px; font-size: .9rem;
  color: var(--ink);
}
.fld input.wide { min-width: 26rem; }
.checkline { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--ink); }

/* ---- Audit page ---- */
.audit-json details { margin: .1rem 0; }
.audit-json summary { cursor: pointer; color: var(--accent); font-size: .78rem; }
.audit-json pre {
  margin: .2rem 0; padding: .4rem .6rem; background: #eceff3; border-radius: 4px;
  font-size: .72rem; max-width: 60rem; overflow-x: auto; white-space: pre-wrap;
}

/* Footer */
.footer {
  max-width: none; margin: .4rem 0 0;
  padding: .3rem 1.5rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem;
}

/* ---- Mobile (PWA) ---- */
.log-cards { display: none; }
.mc-day {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 1rem 0 .25rem; padding-bottom: .15rem;
  border-bottom: 1.5px solid var(--ink);
  font-size: .78rem; color: var(--muted); white-space: pre;
}
.mc-entry {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: .5rem .6rem; margin: .4rem 0;
}
.mc-head { display: flex; align-items: center; gap: .5rem; }
.mc-lift { font-size: .85rem; }
.mc-e1rm {
  margin-left: auto; font-weight: 700; font-size: .8rem;
  padding: .05rem .5rem; border-radius: 4px; border: 1px solid var(--ink);
  color: #06101c;
}
.mc-sets { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .45rem; }
.mc-set {
  padding: .05rem .4rem; border-radius: 4px; font-size: .78rem;
  background: #ececec; font-variant-numeric: tabular-nums;
}
.mc-set.c-warm { background: var(--wk-b); }
.mc-set.c-y    { background: #f7e9a8; }
.mc-set.c-o    { background: #f8d3a0; }
.mc-set.c-r    { background: #f3b7b0; border: 1px solid #b3736c; }
.mc-set.c-vol  { background: var(--wk-a); }
.m-add {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem; margin-bottom: .5rem;
  display: flex; flex-direction: column; gap: .45rem;
}
.m-add input {
  padding: .55rem .6rem; border: 1px solid var(--line); border-radius: 6px;
  font-size: 16px;   /* 16px+ stops iOS zoom-on-focus */
}

@media (max-width: 760px) {
  .content { padding: .6rem .6rem 3rem; }
  h1 { font-size: 1.15rem; }
  .lede { font-size: .82rem; }
  .topbar { gap: .6rem; overflow-x: auto; }
  .mainnav { flex-wrap: nowrap; }
  .panel { padding: .6rem; overflow-x: auto; }
  .footer { padding: .3rem .6rem; }
  /* Log: cards instead of the wide grid; inline row-add is desktop-only */
  .log-desktop, #addEntry { display: none; }
  .log-cards { display: block; }
}

@media print {
  .topbar, .filterbar, .footer, form, .actions { display: none; }
  body { background: #fff; }
}

/* ---- Auth pages ---- */
.auth-box { max-width: 22rem; margin: 3rem auto; }
.auth-box .fld input { width: 100%; }

/* Version chip in the footer */
.footer .version {
  background: var(--accent); color: #fff; border-radius: 4px;
  padding: .05rem .4rem; font-size: .72rem; margin-left: .3rem;
}

/* Mobile editor: per-slot boxes, zone-colored like the grid columns */
.m-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; }
.m-slot { display: flex; flex-direction: column; gap: .1rem; border-radius: 6px; padding: .2rem .25rem .25rem; }
.m-slot > span { font-size: .6rem; color: var(--muted); text-align: center; }
.m-slot input {
  width: 100%; text-align: center; font-size: 16px; padding: .3rem .1rem;
  border: 1px solid var(--line); border-radius: 4px; background: #fff;
}
.m-slot.c-warm { background: var(--wk-b); }
.m-slot.c-y    { background: #f7e9a8; }
.m-slot.c-o    { background: #f8d3a0; }
.m-slot.c-r    { background: #f3b7b0; }
.m-slot.c-vol  { background: var(--wk-a); }
.mc-actions { display: inline-flex; gap: .25rem; }
.mc-actions .btn { font-size: .7rem; padding: .02rem .35rem; line-height: 1.4; }
