/* ===== Theme tokens ===== */
:root {
  color-scheme: light;
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #eef1f4; --surface-3: #e3e8ed;
  --text: #121a22; --text-2: #4a5866; --text-3: #6b7885;
  --border: #d9e0e6; --border-strong: #b9c4ce;
  --accent: #0f7b6c; --accent-strong: #0a5f53; --accent-soft: #d8f0eb; --on-accent: #ffffff;
  --ok: #1d7a3e; --ok-soft: #dcf2e3; --warn: #8a5a00; --warn-soft: #fbedc9; --fail: #b42318; --fail-soft: #fde3e0;
  --info: #1f5fa8; --info-soft: #dde9f8;
  --deficit: #c2410c; --deficit-soft: #fde6d8; --maint: #1f5fa8; --maint-soft: #dde9f8; --surplus: #6d3fc0; --surplus-soft: #ebe1fb;
  --s1: #0f7b6c; --s2: #c2410c; --s3: #1f5fa8; --s4: #6d3fc0;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radius: 14px; --radius-sm: 9px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1217; --surface: #151c23; --surface-2: #1c252e; --surface-3: #26313c;
    --text: #e8edf2; --text-2: #b3bfcb; --text-3: #8a98a6;
    --border: #2a3541; --border-strong: #3c4a58;
    --accent: #3cc4ad; --accent-strong: #6bd8c5; --accent-soft: #123a35; --on-accent: #06221d;
    --ok: #5fd08a; --ok-soft: #133622; --warn: #f2c25b; --warn-soft: #3a2d0d; --fail: #ff8a7a; --fail-soft: #431915;
    --info: #7fb2f0; --info-soft: #14263d;
    --deficit: #fb8a4c; --deficit-soft: #3d2113; --maint: #7fb2f0; --maint-soft: #14263d; --surplus: #b594f5; --surplus-soft: #2a1d45;
    --s1: #3cc4ad; --s2: #fb8a4c; --s3: #7fb2f0; --s4: #b594f5;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1217; --surface: #151c23; --surface-2: #1c252e; --surface-3: #26313c;
  --text: #e8edf2; --text-2: #b3bfcb; --text-3: #8a98a6;
  --border: #2a3541; --border-strong: #3c4a58;
  --accent: #3cc4ad; --accent-strong: #6bd8c5; --accent-soft: #123a35; --on-accent: #06221d;
  --ok: #5fd08a; --ok-soft: #133622; --warn: #f2c25b; --warn-soft: #3a2d0d; --fail: #ff8a7a; --fail-soft: #431915;
  --info: #7fb2f0; --info-soft: #14263d;
  --deficit: #fb8a4c; --deficit-soft: #3d2113; --maint: #7fb2f0; --maint-soft: #14263d; --surplus: #b594f5; --surplus-soft: #2a1d45;
  --s1: #3cc4ad; --s2: #fb8a4c; --s3: #7fb2f0; --s4: #b594f5;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: .25rem 0; }
a { color: var(--accent); }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.icon { flex: none; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== Shell ===== */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.1rem; padding: 4px 10px 16px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 550; font-size: .95rem; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav-sep { height: 1px; background: var(--border); margin: 10px 6px; }
.main { min-width: 0; padding: 28px 32px 48px; max-width: 1200px; width: 100%; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: calc(14px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7rem; font-weight: 600; color: var(--text-3); text-decoration: none; padding: 4px 0; border: 0; background: none; font-family: inherit; cursor: pointer; }
  .tab.active { color: var(--accent); }
  .tab-plus { width: 46px; height: 46px; margin-top: -18px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; box-shadow: var(--shadow); }
  h1 { font-size: 1.4rem; }
}

/* ===== Page pieces ===== */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: 1fr 1fr; } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head h2 { font-size: 1rem; }
.empty { text-align: center; padding: 26px 12px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-title { font-weight: 650; color: var(--text); }
.loading { display: flex; gap: 10px; align-items: center; color: var(--text-2); padding: 24px 0; }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid; font-size: .92rem; }
.alert-fail { background: var(--fail-soft); color: var(--fail); border-color: color-mix(in srgb, var(--fail) 35%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }

.stat { padding: 2px 0; }
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 650; }
.stat-value { font-size: 1.55rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .85rem; color: var(--text-2); }
.stat-down .stat-sub { color: var(--ok); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 650; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge-accent { background: var(--accent-soft); color: var(--accent-strong); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-fail { background: var(--fail-soft); color: var(--fail); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-deficit { background: var(--deficit-soft); color: var(--deficit); }
.badge-maintenance { background: var(--maint-soft); color: var(--maint); }
.badge-surplus { background: var(--surplus-soft); color: var(--surplus); }

/* ===== Buttons & inputs ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 600 .93rem var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-danger { color: var(--fail); border-color: color-mix(in srgb, var(--fail) 45%, transparent); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.quick-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 650 .95rem var(--font); cursor: pointer; text-align: left; box-shadow: var(--shadow); text-decoration: none; }
.quick-btn:hover { border-color: var(--accent); }
.quick-btn .qi { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 11px; min-height: 42px; width: 100%; }
textarea { min-height: 76px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
@media (max-width: 860px) { input, select, textarea { font-size: 16px; } } /* stops iPhone zooming into fields */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: .85rem; font-weight: 650; color: var(--text-2); }
.field-hint { font-size: .8rem; color: var(--text-3); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .field-wide { grid-column: 1 / -1; }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: center; font-weight: 550; cursor: pointer; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; color: var(--text-2); font: 600 .88rem var(--font); padding: 6px 12px; border-radius: 8px; cursor: pointer; min-height: 34px; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.search { position: relative; }
.search .icon { position: absolute; left: 11px; top: 11px; color: var(--text-3); }
.search input { padding-left: 38px; }

/* ===== Tables & lists ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 700; background: var(--surface); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 650; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Dialog ===== */
.dialog { border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.dialog-wide { width: min(900px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(5,10,15,.55); }
.dialog-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 8px; }
.dialog-body { padding: 8px 18px 16px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); flex-wrap: wrap; }
@media (max-width: 640px) {
  .dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 92dvh; }
  .dialog-inner { max-height: 92dvh; }
}

/* ===== Toasts ===== */
.toasts { position: fixed; z-index: 100; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
@media (max-width: 860px) { .toasts { left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: none; } }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: .92rem; }
.toast-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .8rem; flex: none; }
.toast-ok .toast-icon { background: var(--ok-soft); color: var(--ok); }
.toast-fail { border-color: var(--fail); }
.toast-fail .toast-icon { background: var(--fail-soft); color: var(--fail); }
.toast-info .toast-icon { background: var(--info-soft); color: var(--info); }
.toast-text { flex: 1; }
.toast-x { border: 0; background: none; color: var(--text-3); font-size: 1.2rem; cursor: pointer; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Charts ===== */
.chart { position: relative; width: 100%; }
.chart svg { display: block; touch-action: pan-y; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--text-3); font-size: 11px; }
.chart .line { fill: none; stroke-width: 2.2; stroke-linejoin: round; }
.chart .series.s1 .line { stroke: var(--s1); } .chart .series.s1 .dot { fill: var(--s1); }
.chart .series.s2 .line { stroke: var(--s2); } .chart .series.s2 .dot { fill: var(--s2); }
.chart .series.s3 .line { stroke: var(--s3); } .chart .series.s3 .dot { fill: var(--s3); }
.chart .series.s4 .line { stroke: var(--s4); } .chart .series.s4 .dot { fill: var(--s4); }
.chart .series.faint .dot { fill: var(--text-3); opacity: .55; }
.chart .series.faint .line { stroke: var(--text-3); opacity: .4; stroke-width: 1.2; }
.chart .band { opacity: .5; }
.chart .band.deficit { fill: var(--deficit-soft); } .chart .band.maintenance { fill: var(--maint-soft); } .chart .band.surplus { fill: var(--surplus-soft); }
.chart .band-label { fill: var(--text-2); font-size: 10.5px; font-weight: 650; }
.chart .ref-band { fill: var(--ok-soft); opacity: .7; }
.chart .hline { stroke: var(--text-2); stroke-dasharray: 5 4; }
.chart .hline-label { fill: var(--text-2); font-size: 11px; font-weight: 650; }
.chart .crosshair { stroke: var(--border-strong); }
.chart .hover-dot { stroke: var(--surface); stroke-width: 2; }
.chart .hover-dot.s1 { fill: var(--s1); } .chart .hover-dot.s2 { fill: var(--s2); } .chart .hover-dot.s3 { fill: var(--s3); } .chart .hover-dot.s4 { fill: var(--s4); } .chart .hover-dot.faint { fill: var(--text-3); }
.chart-tip { position: absolute; top: 4px; right: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 3px 8px; font-size: .8rem; box-shadow: var(--shadow); }
.chart-empty { padding: 30px 0; text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82rem; color: var(--text-2); margin-top: 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; background: var(--s1); }
.legend-item.s2 i { background: var(--s2); } .legend-item.s3 i { background: var(--s3); } .legend-item.s4 i { background: var(--s4); }
.legend-item.faint i { background: var(--text-3); } .legend-item.hl i { background: none; border-top: 2px dashed var(--text-2); height: 0; }

.date-stepper { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.date-stepper input { width: auto; flex: 0 1 190px; min-width: 0; }

/* ===== Calendar ===== */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.wday { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 6px 2px; text-align: center; cursor: pointer; font: inherit; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 64px; }
.wday small { color: var(--text-3); font-size: .7rem; font-weight: 650; text-transform: uppercase; }
.wday b { font-size: 1.05rem; }
.wday.sel { border-color: var(--accent); background: var(--accent-soft); }
.wday.today b { color: var(--accent); }
.dots { display: flex; gap: 3px; height: 7px; }
.dot-i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.dot-onsite { background: var(--s3); } .dot-offsite { background: var(--s1); } .dot-refeed { background: var(--warn); } .dot-event { background: var(--s4); }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.month-h { text-align: center; font-size: .72rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; padding: 4px 0; }
.mday { min-height: 92px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 5px 6px; cursor: pointer; text-align: left; font: inherit; color: var(--text); display: flex; flex-direction: column; gap: 3px; overflow: hidden; position: relative; }
.mday.out { opacity: .45; }
.mday.sel { outline: 2px solid var(--accent); }
.mday .dn { font-weight: 700; font-size: .85rem; }
.mday.today .dn { color: var(--on-accent); background: var(--accent); border-radius: 999px; padding: 0 7px; align-self: flex-start; }
.mday .phase-bar { position: absolute; left: 0; right: 0; top: 0; height: 3px; }
.phase-bar.deficit { background: var(--deficit); } .phase-bar.maintenance { background: var(--maint); } .phase-bar.surplus { background: var(--surplus); }
.mtag { font-size: .7rem; line-height: 1.25; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mtag.off { background: var(--accent-soft); color: var(--accent-strong); }
.mtag.on { background: var(--info-soft); color: var(--info); }
.mtag.refeed { background: var(--warn-soft); color: var(--warn); }
.mtag.ev { background: var(--surplus-soft); color: var(--surplus); }
@media (max-width: 640px) {
  .mday { min-height: 56px; padding: 4px; }
  .mday .mtag { display: none; }
  .mday .dots { display: flex; }
}
@media (min-width: 641px) { .mday .dots { display: none; } }

/* ===== Meals ===== */
.meal { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.meal + .meal { margin-top: 12px; }
.meal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; background: var(--surface-2); flex-wrap: wrap; }
.meal-name { font-weight: 700; }
.macro-row { display: flex; gap: 12px; flex-wrap: wrap; font-size: .85rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.macro-row b { color: var(--text); }
.macro-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.macro-tile { background: var(--surface-2); border-radius: 12px; padding: 10px; }
.macro-tile .v { font-size: 1.3rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.macro-tile .l { font-size: .75rem; color: var(--text-3); font-weight: 650; text-transform: uppercase; }
.item-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 9px 12px; border-top: 1px solid var(--border); }
.item-name { font-weight: 600; }
.item-qty { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.item-sub { grid-column: 1 / -1; font-size: .8rem; color: var(--text-3); display: flex; gap: 10px; flex-wrap: wrap; }
.plan-chip { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.group-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .group-grid { grid-template-columns: 1fr; } }

/* ===== Training ===== */
.ex-card { border: 1px solid var(--border); border-radius: 14px; padding: 12px; background: var(--surface); }
.ex-card + .ex-card { margin-top: 12px; }
.set-grid { display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 8px; align-items: center; }
.set-grid .h { font-size: .72rem; color: var(--text-3); font-weight: 700; text-transform: uppercase; }
.set-grid input { text-align: center; font-size: 1.1rem; font-weight: 650; min-height: 48px; padding: 6px; }
.set-no { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.set-no.saved { background: var(--ok-soft); color: var(--ok); }
.prev { font-size: .82rem; color: var(--text-2); background: var(--surface-2); border-radius: 8px; padding: 6px 9px; }
.setup { font-size: .85rem; color: var(--text-2); }

/* ===== Media ===== */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
@media (max-width: 640px) { .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; } }
.thumb { position: relative; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; background: var(--surface-3); border: 2px solid transparent; padding: 0; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.sel { border-color: var(--accent); }
.thumb .tag { position: absolute; left: 4px; bottom: 4px; right: 4px; font-size: .68rem; background: rgba(0,0,0,.6); color: #fff; padding: 2px 5px; border-radius: 5px; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.thumb .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; filter: drop-shadow(0 1px 3px rgba(0,0,0,.6)); }
.viewer img, .viewer video { width: 100%; max-height: 70dvh; object-fit: contain; background: #000; border-radius: 10px; display: block; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.compare img { width: 100%; border-radius: 10px; background: #000; max-height: 72dvh; object-fit: contain; display: block; }
.meter { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter.warn > i { background: var(--warn); } .meter.full > i { background: var(--fail); }
.progress-list .list-item { font-size: .9rem; }

/* ===== Phases timeline ===== */
.timeline { position: relative; overflow-x: auto; padding-bottom: 6px; }
.tl-row { display: grid; grid-template-columns: 1fr; position: relative; height: 34px; margin-bottom: 6px; }
.tl-bar { position: absolute; top: 0; height: 30px; border-radius: 8px; display: flex; align-items: center; padding: 0 8px; font-size: .8rem; font-weight: 650; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border: 1px solid; cursor: pointer; }
.tl-bar.deficit { background: var(--deficit-soft); color: var(--deficit); border-color: var(--deficit); }
.tl-bar.maintenance { background: var(--maint-soft); color: var(--maint); border-color: var(--maint); }
.tl-bar.surplus { background: var(--surplus-soft); color: var(--surplus); border-color: var(--surplus); }
.tl-bar.open { border-right-style: dashed; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.tl-axis { position: relative; height: 18px; font-size: .72rem; color: var(--text-3); }
.tl-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }

/* ===== Auth ===== */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); }
.flag { color: var(--warn); }
.flag-list { margin: 4px 0 0; padding-left: 18px; font-size: .85rem; color: var(--warn); }
details summary { cursor: pointer; font-weight: 650; }
.kbd { font-family: ui-monospace, Consolas, monospace; font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
