*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:      #0f1117;
    --surface: #1a1d27;
    --border:  #2e3148;
    --text:    #e8eaf0;
    --muted:   #7a7f9a;
    --accent:  #e84060;
    --green:   #7edd8a;
    --radius:  12px;
}

body { background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; min-height: 100vh; }

.topnav { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0.75rem 1.5rem; display: flex; align-items: center; justify-content: space-between; font-size: 0.95rem; font-weight: 600; }
.nav-right { display: flex; align-items: center; gap: 1rem; font-weight: 400; }
.nav-right a { color: var(--accent); text-decoration: none; font-size: 0.85rem; }

.container { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem 4rem; display: flex; flex-direction: column; gap: 1.25rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.card h2 { font-size: 1rem; margin-bottom: 1rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; margin-bottom: 0.75rem; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; color: var(--muted); }
input, textarea { background: #23263a; border: 1px solid var(--border); color: var(--text); padding: 0.45rem 0.6rem; border-radius: 6px; font-size: 0.88rem; width: 100%; outline: none; }
input:focus, textarea:focus { border-color: var(--accent); }

.filter-row { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.filter-row label { min-width: 140px; }

.btn-primary { background: var(--accent); color: #fff; border: none; padding: 0.5rem 1.25rem; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 0.9rem; margin-top: 0.5rem; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: #23263a; border: 1px solid var(--border); color: var(--muted); padding: 0.45rem 0.9rem; border-radius: 6px; cursor: pointer; font-size: 0.85rem; text-decoration: none; }
.btn-ghost:hover { color: var(--text); }
.btn-icon { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0.2rem; }
.btn-icon:hover { color: #e84040; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 1rem; }
.stat { text-align: center; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); font-size: 0.78rem; text-transform: uppercase; }
td { padding: 0.6rem 0.75rem; border-bottom: 1px solid #1e2135; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #1e2135; }

.muted { color: var(--muted); }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.5rem; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 1.25rem; }
.login-box h1 { text-align: center; }
.error { color: #e84040; font-size: 0.88rem; text-align: center; }

.bp-normal { color: var(--green); }
.bp-high   { color: #f7c948; }
.bp-vhigh  { color: #e84040; }

/* ── Detail page stat tiles ── */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 0; }
.stat-tile  { background: #13151f; border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem 1rem; text-align: center; }
.stat-tile .tile-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.5rem; }
.stat-tile .tile-value { font-size: 2rem; font-weight: 700; line-height: 1; color: var(--text); }
.stat-tile .tile-unit  { font-size: 0.75rem; color: var(--muted); margin-top: 0.3rem; }
.stat-tile .tile-badge { display: inline-block; margin-top: 0.5rem; padding: 0.2rem 0.6rem; border-radius: 99px; font-size: 0.7rem; font-weight: 600; }
.badge-normal   { background: rgba(126,221,138,0.15); color: #7edd8a; }
.badge-elevated { background: rgba(247,201,72,0.15);  color: #f7c948; }
.badge-high1    { background: rgba(247,150,50,0.15);  color: #f79632; }
.badge-high2    { background: rgba(232,64,64,0.15);   color: #e84040; }
.badge-neutral  { background: rgba(122,127,154,0.15); color: var(--muted); }

.section-title { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.75rem; font-weight: 600; }

/* ── Log forms ── */
.log-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; }

/* ── Training log ── */
.training-list { list-style: none; margin-top: 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.training-list li { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.75rem; background: #13151f; border: 1px solid var(--border); border-radius: 6px; font-size: 0.88rem; }

/* ── Garmin ── */
.garmin-badge { display: inline-block; background: rgba(108,142,247,0.15); color: #6c8ef7; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.06em; padding: 0.15rem 0.5rem; border-radius: 99px; text-transform: uppercase; vertical-align: middle; margin-left: 0.4rem; }
.garmin-empty { color: var(--muted); font-size: 0.88rem; margin-top: 0.75rem; }
.activity-name { color: var(--text); max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
