/* Ubhyas design system. Same ink and type as Kratuvid; turmeric replaces the seal as the lead colour. */
:root {
  --bg: #F5F1E7;
  --card: #FFFDF8;
  --ink: #141B34;
  --ink-2: #1D2647;
  --soft: #545A72;
  --rule: #DAD3C2;
  --gold: #E8A917;
  --gold-deep: #8A6100;
  --gold-tint: #FBF0CF;
  --ok: #17693F;       --ok-tint: #DDF0E4;
  --warn: #8A5300;     --warn-tint: #FBE9C8;
  --bad: #B42A14;      --bad-tint: #FADFD8;
  --on-ink: #F3EDE0;
  --on-ink-soft: #A9AFC6;
  --heat-0: #EFEADD; --heat-1: #F6DE9C; --heat-2: #EEC252; --heat-3: #D79A0C; --heat-4: #8A6100;
  --display: "Gloock", Georgia, serif;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1rem/1.5 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold-deep); outline-offset: 2px; border-radius: 2px; }
.skip { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--ink); color: var(--on-ink); padding: .7rem 1rem; }
.skip:focus { left: .5rem; top: .5rem; }

h1 { font: 400 clamp(1.9rem, 3.4vw, 2.6rem)/1.1 var(--display); letter-spacing: -.01em; }
h2 { font: 400 1.4rem/1.2 var(--display); }
h3 { font-size: 1.02rem; font-weight: 600; }
small { font-size: .84em; font-weight: 400; color: var(--soft); }
.muted { color: var(--soft); }
.mono { font-family: var(--mono); }

/* Page layout helpers */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: .75rem 1.5rem; margin-bottom: 1.5rem; }
.page-head p { color: var(--soft); margin-top: .25rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.stack { display: grid; gap: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); margin-bottom: 1rem; }
.section { margin-top: 1.75rem; }
.section > h2 { margin-bottom: .75rem; }

.card { background: var(--card); border: 1px solid var(--rule); border-radius: 8px; padding: 1.15rem 1.25rem; }
.card > h2:first-child { margin-bottom: .75rem; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .75rem; }

/* Stat tile */
.stat { background: var(--card); border: 1px solid var(--rule); border-radius: 8px; padding: .95rem 1.1rem; }
.stat-label { font: 500 .72rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: .07em; color: var(--soft); }
.stat-value { margin-top: .3rem; font: 400 2rem/1.1 var(--display); }
.stat-note { margin-top: .2rem; font-size: .86rem; color: var(--soft); }
.stat-warn { border-left: 4px solid var(--warn); }
.stat-bad { border-left: 4px solid var(--bad); }
.stat-ok { border-left: 4px solid var(--ok); }
.stat-dark { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.stat-dark .stat-label, .stat-dark .stat-note { color: var(--on-ink-soft); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.75rem; padding: .5rem 1.1rem; background: var(--ink); color: var(--on-ink); border: 1.5px solid var(--ink); border-radius: 6px; font-weight: 600; text-decoration: none; cursor: pointer; transition: background .12s, color .12s; }
.btn:hover { background: var(--ink-2); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn-gold:hover { background: #D79A0C; border-color: #D79A0C; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--on-ink); }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-sm { min-height: 2.25rem; padding: .25rem .7rem; font-size: .9rem; }
.btn-wide { width: 100%; }
.link { background: none; border: 0; padding: .25rem 0; font-weight: 500; text-decoration: underline; cursor: pointer; }
.inline-form { display: inline; }

/* Badges: status always carries words */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 4px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-tint); color: var(--ok); }
.badge-warn { background: var(--warn-tint); color: var(--warn); }
.badge-bad { background: var(--bad-tint); color: var(--bad); }
.badge-muted { background: #EAE5D8; color: var(--soft); }
.badge-gold { background: var(--gold-tint); color: var(--gold-deep); }

/* Forms */
.form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.field-wide { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: .25rem; font-weight: 600; font-size: .92rem; }
.field input, .field select, .field textarea { width: 100%; min-height: 2.75rem; padding: .45rem .7rem; background: #fff; border: 1.5px solid var(--rule); border-radius: 6px; }
.field textarea { line-height: 1.45; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold-deep); box-shadow: 0 0 0 3px var(--gold-tint); }
.field.has-err input, .field.has-err select, .field.has-err textarea { border-color: var(--bad); }
.hint { margin-top: .25rem; font-size: .84rem; color: var(--soft); }
.err { margin-top: .25rem; font-size: .86rem; font-weight: 500; color: var(--bad); }
.check { display: flex; align-items: center; gap: .55rem; min-height: 2.75rem; font-weight: 500; cursor: pointer; }
.check input { width: 1.2rem; height: 1.2rem; accent-color: var(--ink); }

.choice { margin: 0; padding: 0; border: 0; }
.choice legend { padding: 0; margin-bottom: .1rem; font-weight: 600; font-size: .92rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { padding: .6rem .9rem; text-align: left; font: 500 .72rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--soft); border-bottom: 1.5px solid var(--ink); white-space: nowrap; }
.table td { padding: .7rem .9rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FBF7EC; }
.table a { font-weight: 600; }
.table .num, .table-tight .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table-tight td, .table-tight th { padding: .35rem .5rem; }

/* Messages */
.flash { margin-bottom: 1rem; padding: .65rem .9rem; background: var(--ok-tint); color: var(--ok); border-radius: 6px; font-weight: 500; }
.banner { margin-bottom: 1rem; padding: .65rem .9rem; border-radius: 6px; font-weight: 500; }
.banner-bad { background: var(--bad-tint); color: var(--bad); }
.banner-warn { background: var(--warn-tint); color: var(--warn); }
.empty { padding: 2.25rem 1.25rem; text-align: center; color: var(--soft); }
.empty-title { margin-bottom: .25rem; font: 400 1.25rem/1.25 var(--display); color: var(--ink); }
.empty .btn { margin-top: 1rem; }

/* Rows inside cards: renewal lists, at-risk lists */
.rows > li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 1rem; padding: .7rem 0; border-bottom: 1px solid var(--rule); }
.rows > li:last-child { border-bottom: 0; }
.rows .row-sub { font-size: .86rem; color: var(--soft); }

/* Line chart: one hue, 2px line, end marker, recessive grid */
.chart figcaption { margin-bottom: .5rem; font-weight: 600; }
.chart-plot { position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .axis { fill: var(--soft); font: 400 12px var(--mono); }
.chart .line { fill: none; stroke: var(--gold-deep); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--gold-deep); stroke: var(--card); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover, .chart .hit:focus { fill: rgba(138, 97, 0, .16); outline: none; }
.chart-tip { position: absolute; transform: translate(-50%, -100%); padding: .2rem .55rem; background: var(--ink); color: var(--on-ink); border-radius: 4px; font: 500 .78rem/1.4 var(--mono); white-space: nowrap; pointer-events: none; }
.chart-table { margin-top: .5rem; font-size: .9rem; }
.chart-table summary { min-height: 2rem; color: var(--soft); cursor: pointer; }
.chart-empty { padding: 2rem 0; text-align: center; color: var(--soft); }

/* The SVG scales with its card, so on a narrow card its text and marks must be drawn bigger to stay readable */
.chart { container-type: inline-size; }
.chart .line { vector-effect: non-scaling-stroke; }
@container (max-width: 460px) {
  .chart .axis { font-size: 24px; }
  .chart .dot { r: 10px; stroke-width: 4; }
  .chart .hit { r: 30px; }
}

/* Heatmap */
.heat { display: grid; gap: 2px; font: 400 .7rem/1 var(--mono); color: var(--soft); }
.heat-cell { aspect-ratio: 1; min-width: 0; border-radius: 3px; }
.heat-0 { background: var(--heat-0); } .heat-1 { background: var(--heat-1); } .heat-2 { background: var(--heat-2); } .heat-3 { background: var(--heat-3); } .heat-4 { background: var(--heat-4); }

/* Staff shell */
.shell { display: grid; grid-template-columns: 14.5rem minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.1rem .9rem; background: var(--ink); color: var(--on-ink); }
.side-brand { display: flex; align-items: center; gap: .55rem; padding: 0 .45rem; font: 400 1.35rem/1 var(--display); text-decoration: none; }
.side-gym { margin: .7rem .45rem 1.1rem; font-size: .84rem; color: var(--on-ink-soft); overflow-wrap: anywhere; }
.side nav { display: grid; gap: .15rem; }
.side nav a { display: flex; align-items: center; min-height: 2.6rem; padding: 0 .7rem; border-radius: 6px; font-weight: 500; text-decoration: none; color: var(--on-ink-soft); }
.side nav a:hover { background: rgba(243, 237, 224, .08); color: var(--on-ink); }
.side nav a[aria-current="page"] { background: var(--gold); color: var(--ink); font-weight: 600; }
.side-foot { margin-top: auto; padding: .7rem .45rem 0; border-top: 1px solid rgba(243, 237, 224, .18); font-size: .9rem; }
.side-foot small { display: block; color: var(--on-ink-soft); text-transform: capitalize; }
.side :focus-visible { outline-color: var(--gold); }
.main { padding: clamp(1.1rem, 3vw, 2.25rem); min-width: 0; max-width: 78rem; }

/* Member app: phone first */
.member { padding-bottom: 5rem; background: var(--bg); }
.m-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .55rem 1rem; background: var(--ink); color: var(--on-ink); }
.m-gym { font: 400 1.05rem/1.2 var(--display); }
.m-main { width: min(100%, 40rem); margin-inline: auto; padding: 1rem; }
.m-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom); background: var(--ink); }
.m-tabs a { display: flex; align-items: center; justify-content: center; min-height: 3.5rem; font-weight: 600; font-size: .92rem; text-decoration: none; color: var(--on-ink-soft); border-top: 3px solid transparent; }
.m-tabs a[aria-current="page"] { color: var(--gold); border-top-color: var(--gold); }
.m-tabs :focus-visible, .m-top :focus-visible { outline-color: var(--gold); outline-offset: -3px; }

/* Auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; background: var(--ink); }
.auth-card { width: min(100%, 26rem); padding: clamp(1.4rem, 4vw, 2.1rem); background: var(--card); border-radius: 10px; }
.auth-brand { display: flex; align-items: center; gap: .55rem; margin-bottom: 1.4rem; font: 400 1.4rem/1 var(--display); text-decoration: none; }
.auth-card h1 { margin-bottom: .35rem; }
.auth-sub { margin-bottom: 1.2rem; color: var(--soft); }
.auth-card form { margin-top: 1.1rem; }
.auth-foot { margin-top: 1.2rem; font-size: .92rem; color: var(--soft); }

@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side { position: static; height: auto; padding: .7rem .9rem; }
  .side-gym { margin: .35rem .45rem .55rem; }
  .side nav { display: flex; overflow-x: auto; scrollbar-width: none; gap: .25rem; }
  .side nav a { flex: none; }
  .side-foot { display: flex; justify-content: space-between; align-items: center; margin-top: .55rem; padding-top: .45rem; }
  .side-foot small { display: inline; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
