:root {
  color-scheme: dark;
  --bg: #071011;
  --bg-soft: #0d171a;
  --panel: #121d22;
  --panel-strong: #17252c;
  --line: rgba(255, 255, 255, .12);
  --text: #f3fbfa;
  --muted: #9dacb1;
  --teal: #22d8cf;
  --lime: #98e33f;
  --coral: #ff9b50;
  --violet: #a979ff;
  --danger: #ff6b74;
  --radius: 12px;
  --sidebar-width: 248px;
  --shadow: 0 20px 60px rgba(0, 0, 0, .35);
  --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.theme-light {
  color-scheme: light;
  --bg: #f5f8f7;
  --bg-soft: #ecf2f1;
  --panel: #ffffff;
  --panel-strong: #eef5f4;
  --line: rgba(13, 31, 34, .14);
  --text: #102022;
  --muted: #607174;
  --teal: #008f8a;
  --lime: #518d15;
  --coral: #c45f16;
  --violet: #7051d8;
  --danger: #c93f4b;
  --shadow: 0 14px 36px rgba(21, 38, 42, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(34, 216, 207, .055), transparent 27rem),
    linear-gradient(135deg, #050909 0%, #071011 62%, #0a0f13 100%);
  color: var(--text);
}
body.theme-light {
  background:
    radial-gradient(circle at 18% 0%, rgba(0, 143, 138, .08), transparent 25rem),
    linear-gradient(135deg, #f7faf9 0%, #eef4f2 62%, #f5f8f7 100%);
}
button, input, select, textarea { font: inherit; }
canvas { max-width: 100%; }
button, select, input, textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  color: var(--text);
}
button { cursor: pointer; padding: .85rem 1rem; font-weight: 750; background: linear-gradient(135deg, var(--teal), #6cf2a4); color: #031212; border: 0; transition: transform .18s var(--ease), background .18s var(--ease), border-color .18s var(--ease); }
button:hover { transform: translateY(-1px); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(34,216,207,.45); outline-offset: 3px; }
label { display: grid; gap: .45rem; color: var(--muted); font-size: .9rem; }
input, select, textarea { width: 100%; padding: .82rem .9rem; }
select option { color: var(--text); background: var(--panel); }
body:not(.theme-light) select option { background: #101b20; }
select option:checked { color: #031212; background: var(--teal); }
.skip-link { position: absolute; left: -999px; top: 1rem; }
.skip-link:focus { left: 1rem; z-index: 10; }
.muted { color: var(--muted); margin: 0; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(100%, 430px); display: grid; gap: 1rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: 24px; background: rgba(18,29,34,.82); box-shadow: var(--shadow); }
.brand-mark { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; color: var(--teal); border: 2px solid rgba(34,216,207,.92); box-shadow: inset 0 0 22px rgba(34,216,207,.12); font-weight: 900; }
.brand-mark svg { width: 32px; height: 32px; }
.brand-mark circle, .brand-mark path { fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark path { stroke: var(--lime); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); transition: grid-template-columns .22s var(--ease); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 1.45rem .9rem 1rem; border-right: 1px solid rgba(255,255,255,.1); background: #071012; backdrop-filter: blur(18px); display: grid; grid-template-rows: auto auto 1fr auto; gap: 1.8rem; align-content: start; }
body.theme-light .sidebar { background: #ffffff; border-right-color: rgba(16,32,34,.12); }
.sidebar::after { content: ""; position: absolute; inset: 0 0 auto auto; width: 1px; height: 100%; background: linear-gradient(180deg, transparent, rgba(34,216,207,.3), transparent); pointer-events: none; }
.sidebar-toggle { position: absolute; right: -17px; top: 1.72rem; z-index: 2; width: 34px; height: 34px; padding: 0; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-soft); color: var(--text); box-shadow: none; display: inline-grid; place-items: center; }
.sidebar-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.brand-row { display: flex; align-items: center; justify-content: flex-start; gap: .72rem; min-height: 48px; padding: 0 .28rem; }
.brand-row strong { display: block; font-size: 1.15rem; line-height: 1; letter-spacing: 0; color: var(--text); }
.sidebar nav { display: grid; gap: 1.35rem; align-content: start; align-self: start; }
.nav-group { display: grid; gap: .32rem; }
.nav-group-title { padding: 0 .45rem; color: var(--muted); font-size: .72rem; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; }
.bottom-nav { display: grid; gap: .5rem; }
.nav-button { display: flex; align-items: center; gap: .78rem; min-height: 44px; padding: .66rem .75rem; border-radius: 8px; border: 1px solid transparent; color: #c3cfd2; background: transparent; font-size: .9rem; font-weight: 560; }
body.theme-light .nav-button { color: #46585b; }
.nav-button:hover { color: var(--text); background: rgba(255,255,255,.045); transform: none; }
.nav-button.active { color: var(--teal); border-color: transparent; background: rgba(34,216,207,.14); }
body.theme-light .nav-button.active { background: rgba(0,143,138,.1); }
.nav-icon { width: 22px; height: 22px; display: inline-grid; place-items: center; flex: 0 0 22px; }
.nav-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.nav-label { white-space: normal; overflow: hidden; line-height: 1.2; }
.ghost-button { background: rgba(255,255,255,.05); color: var(--text); border: 1px solid var(--line); }
.sidebar-footer { display: grid; gap: .65rem; align-self: end; }
.sidebar-footer .ghost-button { min-height: 44px; border-radius: 8px; }
.danger-button { background: rgba(255,107,116,.12); color: #ffd9dc; border: 1px solid rgba(255,107,116,.35); }

.sidebar-collapsed { --sidebar-width: 76px; }
.sidebar-collapsed .brand-row { justify-content: center; }
.sidebar-collapsed .brand-row strong,
.sidebar-collapsed .nav-group-title,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .sidebar-footer .ghost-button { opacity: 0; width: 0; height: 0; min-height: 0; padding: 0; pointer-events: none; overflow: hidden; }
.sidebar-collapsed .nav-button { justify-content: center; padding-inline: .5rem; }

.main-panel { width: min(100% - 2.5rem, 1540px); padding: 1.65rem 0 6rem; margin: 0 auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.2rem; }
.topbar h1 { margin: 0 0 .7rem; font-size: 2.05rem; line-height: 1; letter-spacing: 0; }
.topbar .muted { display: flex; align-items: center; gap: .38rem; font-size: .78rem; color: var(--text); }
.topbar .muted span { color: var(--muted); font-size: .62rem; }
.topbar .muted i { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 2px rgba(34,216,207,.18); }
.topbar-actions { display: flex; align-items: end; gap: 1rem; }
.topbar-actions select { width: auto; min-width: 178px; padding: .66rem .82rem; border-radius: 8px; background: rgba(255,255,255,.045); font-size: .86rem; }
.top-metric-field { min-width: 180px; gap: .25rem; font-size: .68rem; }
.top-metric-field select {
  width: 100%;
  min-width: 0;
  padding: .5rem .1rem .64rem;
  border: 0;
  border-bottom: 2px solid rgba(255,255,255,.18);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: .82rem;
}
.top-metric-field select option { color: var(--text); background: #101b20; }
.top-metric-field select:focus { border-bottom-color: var(--teal); }
.top-presets { align-items: end; padding: 0; border: 0; border-radius: 0; background: transparent; }
.top-presets button { position: relative; min-height: 42px; padding: .5rem .2rem .72rem; border-radius: 0; background: transparent; border: 0; color: var(--muted); font-weight: 520; }
.top-presets button::after { content: ""; position: absolute; left: .08rem; right: .08rem; bottom: .08rem; height: 2px; border-radius: 999px; background: transparent; }
.top-presets button.active { background: transparent; color: var(--text); font-weight: 560; }
.top-presets button.active::after { background: var(--text); box-shadow: 0 0 14px rgba(255,255,255,.28); }
.date-range { display: flex; align-items: end; gap: .55rem; padding: 0 0 .08rem; border: 0; border-radius: 0; background: transparent; }
.date-range label { gap: .25rem; font-size: .68rem; }
.date-range input { width: 138px; padding: .5rem .1rem .64rem; border: 0; border-bottom: 2px solid rgba(255,255,255,.18); border-radius: 0; background: transparent; color: var(--text); font-size: .82rem; }
.date-range input:focus { border-bottom-color: var(--teal); }
.view { display: none; animation: rise .28s var(--ease); }
.active-view { display: block; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .85rem; margin-bottom: .85rem; }
.metric-grid.compact { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(260px, 1fr)); gap: .85rem; align-items: start; }
.entry-launcher { grid-template-columns: repeat(5, minmax(160px, 1fr)); }
.entry-card { min-height: 130px; padding: 1rem; display: grid; align-content: start; gap: .55rem; text-align: left; color: var(--text); }
.entry-card strong { font-size: 1.02rem; }
.entry-card span { color: var(--muted); font-size: .84rem; line-height: 1.45; font-weight: 500; }
.summary-stack { display: grid; gap: 1.25rem; margin-bottom: 1.35rem; }
.metric-toggle { display: inline-flex; flex-wrap: wrap; gap: 1rem; margin: 0 0 .85rem; }
.metric-toggle button { position: relative; padding: .45rem .05rem .72rem; border: 0; border-radius: 0; background: transparent; color: var(--muted); font-weight: 520; }
.metric-toggle button::after { content: ""; position: absolute; left: 0; right: 0; bottom: .08rem; height: 2px; border-radius: 999px; background: transparent; }
.metric-toggle button.active { color: var(--text); }
.metric-toggle button.active::after { background: var(--teal); box-shadow: 0 0 14px rgba(34,216,207,.35); }
.dashboard-metric-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.dashboard-metric-row.four { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .95rem; }
.combo-card { display: grid; gap: .85rem; align-items: stretch; }
.glp-card { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.activity-card { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.combo-cell { min-width: 0; padding: .15rem .2rem; }
.mini-metric { display: flex; align-items: center; gap: .78rem; min-height: 82px; }
.mini-metric > div { display: grid; gap: .28rem; min-width: 0; }
.mini-metric .label { color: var(--text); font-size: .85rem; }
.mini-metric strong { font-size: 1.55rem; line-height: 1.05; overflow-wrap: anywhere; }
.mini-metric small { color: var(--lime); font-size: .78rem; line-height: 1.3; }
.progress-track { display: block; height: 5px; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,.12); margin: -.2rem .1rem .1rem 48px; }
.progress-track i { display: block; height: 100%; border-radius: inherit; background: var(--teal); }
.progress-track.lime i { background: var(--lime); }
.workout-kpi-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; }
.workout-kpi { min-width: 0; display: grid; grid-template-columns: 24px 1fr; align-items: center; column-gap: .55rem; row-gap: .16rem; padding: .72rem; border: 1px solid rgba(255,255,255,.08); border-radius: 10px; background: rgba(255,255,255,.028); }
.workout-kpi span:nth-child(2) { color: var(--muted); font-size: .74rem; line-height: 1.25; }
.workout-kpi strong { grid-column: 2; font-size: 1.28rem; line-height: 1; }
.card, .panel { border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius); background: linear-gradient(160deg, rgba(255,255,255,.062), rgba(255,255,255,.02)); box-shadow: none; }
.card { min-height: 110px; padding: 1rem 1rem .9rem; display: grid; align-content: space-between; gap: .55rem; }
.card-head { display: flex; align-items: center; gap: .72rem; }
.card-icon { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px; border-radius: 10px; color: var(--accent); background: rgba(34,216,207,.12); }
.card-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.card .label { color: var(--text); font-size: .86rem; }
.card .value { font-size: 1.86rem; font-weight: 780; letter-spacing: 0; line-height: 1.04; }
.card .delta { color: var(--lime); font-size: .78rem; line-height: 1.35; }
.metric-card { position: relative; overflow: hidden; }
.panel { padding: 1rem; margin-bottom: 1rem; }
.wide { min-height: 260px; }
.section-head { display: grid; grid-template-columns: auto minmax(180px, 1fr); align-items: center; gap: 1rem; margin-bottom: .8rem; }
.section-head h2, .panel h2 { margin: 0 0 .8rem; font-size: 1.05rem; }
.section-head h2 { margin: 0; }
.chart-panel { padding: 1.05rem 1.25rem 1rem; }
.chart-metric-field { justify-self: end; width: min(100%, 190px); gap: .25rem; font-size: .68rem; }
.chart-metric-field select { width: 100%; padding: .5rem .1rem .64rem; border: 0; border-bottom: 2px solid rgba(255,255,255,.18); border-radius: 0; background: transparent; color: var(--text); font-size: .82rem; }
.chart-metric-field select:focus { border-bottom-color: var(--teal); }
.card-progress { margin: .2rem 0 .35rem; }
.two-column { display: grid; grid-template-columns: minmax(280px, 410px) 1fr; gap: .85rem; align-items: start; }
.injection-layout { display: grid; gap: .85rem; }
.form-panel { display: grid; gap: .9rem; }
.horizontal-form { gap: .85rem; }
.horizontal-form h2 { grid-column: 1 / -1; }
.injection-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: .85rem; align-items: end; }
.activity-form-grid { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); }
.activity-form-grid select[multiple] { min-height: 50px; padding-block: .35rem; }
.activity-form-grid select[multiple] option { color: var(--text); background: #101b20; padding: .25rem .35rem; }
.activity-form-grid select[multiple] option:checked { color: #031212; background: var(--teal); }
.injection-form-grid button { min-width: 190px; min-height: 50px; white-space: normal; }
.notes-field textarea { min-height: 50px; height: 50px; resize: vertical; }
.split-fields { display: grid; grid-template-columns: 1fr 120px; gap: .75rem; }
.check-row { display: flex; grid-template-columns: none; align-items: center; gap: .55rem; color: var(--text); }
.check-row input { width: auto; }
.inline-form { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.timeline { display: grid; gap: .65rem; }
.timeline-item { padding: .75rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.035); }
.filters { display: flex; justify-content: space-between; align-items: end; gap: 1rem; }
.segmented { display: flex; gap: 1rem; flex-wrap: wrap; }
.segmented button { position: relative; background: transparent; color: var(--muted); border: 0; border-radius: 0; padding: .65rem .1rem .78rem; font-weight: 520; }
.segmented button::after { content: ""; position: absolute; left: .05rem; right: .05rem; bottom: .08rem; height: 2px; border-radius: 999px; background: transparent; }
.segmented button.active { background: transparent; color: var(--text); font-weight: 560; }
.segmented button.active::after { background: var(--text); box-shadow: 0 0 14px rgba(255,255,255,.28); }

.calendar-mode .topbar-actions,
.entry-mode .topbar-actions { display: none; }
.calendar-head { display: grid; justify-items: center; gap: .7rem; margin-bottom: .8rem; }
.calendar-controls { display: flex; align-items: center; justify-content: center; gap: .5rem; }
.calendar-controls input { width: 180px; text-align: center; }
.icon-button { width: 46px; height: 46px; padding: 0; display: inline-grid; place-items: center; }
.icon-button svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.today-button { height: 46px; padding: 0 .95rem; display: inline-flex; align-items: center; justify-content: center; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: .9rem; margin: -.25rem 0 .85rem; color: var(--muted); font-size: .84rem; }
.calendar-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; margin-bottom: 1.15rem; }
.weekday { padding: .15rem .55rem .35rem; color: var(--muted); font-size: .78rem; font-weight: 560; text-align: center; }
.weekday-short { display: none; }
.day { min-height: 112px; border: 1px solid var(--line); border-radius: 12px; padding: .55rem; background: rgba(255,255,255,.035); }
.today-day { border-color: rgba(34,216,207,.82); box-shadow: 0 0 0 2px rgba(34,216,207,.18), inset 0 0 0 1px rgba(34,216,207,.18); background: rgba(34,216,207,.055); }
.today-day button strong { color: var(--teal); }
.empty-day { opacity: .28; background: transparent; border-style: dashed; }
.day button { width: 100%; height: 100%; padding: 0; background: transparent; color: var(--text); text-align: left; border: 0; display: grid; align-content: start; gap: .45rem; }
.calendar-events { display: flex; gap: .38rem; flex-wrap: wrap; }
.event-icon { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: 0 0 22px; background: transparent; }
.event-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.15; stroke-linecap: round; stroke-linejoin: round; }
.event-icon.misurazione { color: var(--teal); }
.event-icon.iniezione { color: var(--violet); }
.event-icon.allenamento { color: var(--lime); }
.event-icon.allenamento.basket { color: var(--coral); }
.event-icon.passi { color: var(--teal); }
.day-event-list { display: grid; gap: .55rem; margin-top: .85rem; }
.day-event { width: 100%; display: flex; align-items: stretch; gap: .62rem; padding: .45rem; margin: 0; border: 1px solid rgba(255,255,255,.08); border-radius: 10px; background: rgba(255,255,255,.035); color: var(--text); }
.day-event:hover { transform: none; border-color: rgba(34,216,207,.32); background: rgba(34,216,207,.055); }
.day-event-main { min-width: 0; flex: 1; display: flex; align-items: flex-start; gap: .62rem; padding: .32rem .35rem; background: transparent; color: var(--text); border: 0; text-align: left; }
.day-event-main:hover { transform: none; background: transparent; }
.day-head { grid-template-columns: 1fr auto; }
.day-actions { display: flex; flex-wrap: wrap; gap: .55rem; justify-content: flex-end; }
.day-actions button { display: inline-flex; align-items: center; gap: .42rem; padding: .62rem .78rem; }
.day-detail { padding: 1.35rem 1.45rem; margin-top: 1.1rem; }
.complete-inline { margin-left: auto; padding: .52rem .68rem; white-space: nowrap; }

.measurements-panel { overflow: hidden; }
.table-wrap { overflow: auto; max-height: 72vh; border: 1px solid var(--line); border-radius: 14px; margin-top: .9rem; }
.table-tools { display: flex; align-items: end; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-top: 1rem; }
.table-tools label { min-width: min(100%, 300px); }
.table-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.table-actions button { min-height: 40px; padding: .58rem .72rem; border-radius: 8px; font-size: .82rem; }
.select-cell { width: 42px; text-align: center; }
.select-cell input { width: auto; min-width: 0; }
.data-table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: .82rem; }
.data-table th, .data-table td { padding: .55rem; border-bottom: 1px solid rgba(255,255,255,.08); text-align: left; vertical-align: top; }
.data-table th { position: sticky; top: 0; z-index: 1; background: var(--panel-strong); color: var(--text); font-weight: 760; }
.data-table th[data-sort] { cursor: pointer; user-select: none; }
.data-table th[data-direction="asc"]::after { content: " ↑"; color: var(--teal); }
.data-table th[data-direction="desc"]::after { content: " ↓"; color: var(--teal); }
.data-table input { min-width: 104px; padding: .48rem .55rem; border-radius: 8px; font-size: .82rem; background: rgba(0,0,0,.16); }
.data-table input[type="datetime-local"] { min-width: 168px; }
.row-actions { position: sticky; right: 0; background: var(--panel-strong); display: flex; gap: .4rem; }
.row-actions button { padding: .52rem .62rem; border-radius: 8px; font-size: .78rem; }

.bottom-nav { position: fixed; left: .8rem; right: .8rem; bottom: .8rem; z-index: 5; grid-auto-flow: column; grid-auto-columns: minmax(76px, 1fr); padding: .45rem; border: 1px solid var(--line); border-radius: 20px; background: rgba(7,16,17,.88); backdrop-filter: blur(20px); box-shadow: var(--shadow); display: none; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.bottom-nav::-webkit-scrollbar { display: none; }
.bottom-nav .nav-button { justify-content: center; font-size: .76rem; padding: .55rem .2rem; flex-direction: column; gap: .18rem; min-width: 76px; scroll-snap-align: center; }
.bottom-nav .nav-label { white-space: nowrap; }

.entry-dialog { width: min(94vw, 520px); padding: 1rem; border: 1px solid rgba(255,255,255,.14); border-radius: 14px; color: var(--text); background: var(--panel); box-shadow: 0 18px 56px rgba(0,0,0,.42); }
.entry-dialog::backdrop { background: rgba(0,0,0,.62); backdrop-filter: blur(4px); }
.entry-dialog .form-panel { margin: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dialog-head h2 { margin: 0; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 900px) {
  body { overflow-x: hidden; }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .bottom-nav { display: grid; }
  .main-panel { width: auto; padding: .85rem .9rem 6.9rem; margin: 0; }
  .metric-grid, .metric-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-metric-row, .dashboard-metric-row.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .glp-card, .activity-card { grid-template-columns: 1fr; }
  .workout-kpi-strip { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr; }
  .entry-launcher { grid-template-columns: 1fr; }
  .injection-form-grid { grid-template-columns: 1fr; }
  .two-column { grid-template-columns: 1fr; }
  .topbar { display: grid; align-items: start; gap: .72rem; margin-bottom: 1rem; }
  .topbar h1 { font-size: 2rem; margin-bottom: .35rem; }
  .topbar .muted { flex-wrap: wrap; font-size: .76rem; }
  .topbar .muted span { font-size: .7rem; }
  .topbar-actions { width: 100%; align-items: stretch; flex-direction: column; gap: .75rem; }
  .top-presets { flex-wrap: nowrap; overflow-x: auto; gap: 1.15rem; padding-bottom: .15rem; scrollbar-width: none; }
  .top-presets::-webkit-scrollbar { display: none; }
  .top-presets button { flex: 0 0 auto; min-height: 34px; font-size: .9rem; }
  .top-metric-field { width: 100%; min-width: 0; }
  .date-range { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
  .date-range input { width: 100%; }
  .filters { display: grid; align-items: stretch; }
  .section-head { display: flex; }
  .panel { padding: .9rem; border-radius: 12px; margin-bottom: .9rem; }
  .form-panel { gap: .72rem; }
  input, select, textarea { padding: .68rem .75rem; border-radius: 10px; font-size: .95rem; }
  button { padding: .68rem .78rem; border-radius: 10px; }
  .injection-form-grid button { white-space: normal; }
  .calendar-head { gap: .55rem; }
  .calendar-controls { width: 100%; gap: .45rem; }
  .calendar-controls input { min-width: 0; flex: 1; }
  .calendar-grid { gap: .35rem; grid-template-columns: repeat(7, minmax(40px, 1fr)); }
  .weekday { padding-inline: .1rem; font-size: .72rem; }
  .weekday-full { display: none; }
  .weekday-short { display: inline; }
  .day { min-height: 86px; border-radius: 12px; padding: .42rem; }
  .event-icon { width: 18px; height: 18px; flex-basis: 18px; }
  .event-icon svg { width: 17px; height: 17px; }
  .chart-panel, .wide { min-height: 230px; }
  .chart-panel canvas, .wide canvas { min-height: 190px; }
  .table-tools { display: grid; align-items: stretch; gap: .7rem; }
  .table-tools label { min-width: 0; }
  .table-actions { gap: .45rem; }
  .table-actions button { min-height: 36px; padding: .5rem .62rem; font-size: .76rem; }
  .table-wrap { max-height: 58vh; border-radius: 12px; }
  .data-table { font-size: .74rem; }
  .data-table th, .data-table td { padding: .44rem; }
  .row-actions { position: static; background: transparent; }
  .row-actions button { padding: .45rem .55rem; font-size: .72rem; }
}

@media (max-width: 520px) {
  .metric-grid, .metric-grid.compact { grid-template-columns: 1fr 1fr; }
  .main-panel { padding-inline: .85rem; }
  .quick-grid { gap: .7rem; }
  .entry-card { min-height: 108px; padding: .82rem; }
  .entry-card span { font-size: .76rem; }
  .card { min-height: 96px; padding: .72rem; gap: .36rem; }
  .card-head { gap: .52rem; align-items: flex-start; }
  .card-icon { width: 26px; height: 26px; flex-basis: 26px; border-radius: 8px; }
  .card-icon svg { width: 16px; height: 16px; }
  .card .label { font-size: .76rem; line-height: 1.2; }
  .card .value { font-size: 1.28rem; }
  .card .delta { font-size: .68rem; }
  .summary-stack { gap: 1rem; }
  .metric-toggle { overflow-x: auto; flex-wrap: nowrap; gap: 1rem; padding-bottom: .2rem; }
  .metric-toggle button { flex: 0 0 auto; font-size: .92rem; }
  .combo-card { gap: .65rem; }
  .mini-metric { min-height: 58px; gap: .56rem; }
  .mini-metric strong { font-size: 1.18rem; }
  .mini-metric small { font-size: .68rem; }
  .progress-track { margin-left: 36px; }
  .workout-kpi-strip { gap: .45rem; }
  .workout-kpi { padding: .55rem; grid-template-columns: 20px 1fr; }
  .workout-kpi strong { font-size: 1.05rem; }
  .bottom-nav { left: .55rem; right: .55rem; bottom: calc(.55rem + env(safe-area-inset-bottom)); grid-auto-columns: 72px; border-radius: 18px; padding: .32rem; scroll-snap-type: x proximity; }
  .bottom-nav .nav-button { min-width: 72px; min-height: 58px; font-size: .67rem; padding: .46rem .18rem; }
  .bottom-nav .nav-icon svg { width: 22px; height: 22px; }
  .split-fields { grid-template-columns: 1fr; }
  .calendar-controls input { width: 100%; }
  .calendar-controls .icon-button { width: 40px; height: 40px; flex: 0 0 40px; }
  .today-button { height: 40px; padding-inline: .7rem; }
  .calendar-grid { gap: .28rem; grid-template-columns: repeat(7, minmax(34px, 1fr)); }
  .day { min-height: 72px; padding: .34rem; }
  .day button { gap: .28rem; }
  .day button strong { font-size: .95rem; }
}

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