/* ------------------------------------------------------------------
 * Design system
 * ------------------------------------------------------------------ */

:root {
    --bg: #07090d;
    --bg-elevated: #0c0f14;
    --surface: #11151c;
    --surface-2: #171c24;
    --surface-3: #202632;
    --border: #2a303b;
    --border-strong: #3a4351;

    --text: #f5f7fb;
    --text-muted: #a4adba;
    --text-dim: #6f7a89;

    --accent: #18c7a7;
    --accent-hover: #5be2ca;
    --accent-bg: #092b26;
    --accent-border: #146f63;
    --focus: #7dd3fc;

    --energy: #f6c453;
    --purple: #a78bfa;
    --ok: #42d36b;
    --warn: #f59f3a;
    --danger: #ff5f6d;

    --disclaimer-bg: #20160a;
    --disclaimer-border: #6c4818;
    --disclaimer-text: #f4d4a1;

    --radius: 8px;
    --radius-sm: 6px;
    --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.28);

    --bottom-nav-h: 72px;
    --side-nav-w: 252px;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
}

html,
body {
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
                 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    margin: 0;
    overflow-x: hidden;
}

::selection {
    background: rgba(24, 199, 167, 0.32);
}

a {
    color: var(--accent-hover);
    text-decoration: none;
}

a:hover {
    color: var(--text);
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

/* ------------------------------------------------------------------
 * Reusable primitives
 * ------------------------------------------------------------------ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    min-width: 0;
    padding: 1rem;
}

.card-quiet {
    background: var(--bg-elevated);
    box-shadow: none;
}

.panel-title {
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 760;
    line-height: 1.2;
}

.eyebrow,
.stat-label {
    color: var(--text-dim);
    font-size: 0.68rem;
    font-weight: 780;
    letter-spacing: 0.08em;
    line-height: 1.15;
    text-transform: uppercase;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 108px;
    padding: 0.85rem;
}

.stat-value {
    color: var(--text);
    font-size: 1.55rem;
    font-variant-numeric: tabular-nums;
    font-weight: 780;
    line-height: 1.05;
    margin-top: 0.45rem;
}

.stat-sub {
    color: var(--text-dim);
    font-size: 0.78rem;
    line-height: 1.35;
    margin-top: 0.35rem;
}

.pill {
    align-items: center;
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    border-radius: 999px;
    color: var(--accent-hover);
    display: inline-flex;
    font-size: 0.68rem;
    font-weight: 800;
    gap: 0.35rem;
    letter-spacing: 0.07em;
    line-height: 1;
    padding: 0.33rem 0.58rem;
    text-transform: uppercase;
    white-space: nowrap;
}

.btn {
    align-items: center;
    background: var(--text);
    border: 1px solid var(--text);
    border-radius: var(--radius);
    color: #090c11;
    cursor: pointer;
    display: inline-flex;
    font-weight: 780;
    gap: 0.45rem;
    justify-content: center;
    min-height: 44px;
    padding: 0.72rem 1rem;
    transition: background 0.14s ease, border-color 0.14s ease,
                color 0.14s ease, transform 0.14s ease;
}

.btn:hover {
    background: #ffffff;
    border-color: #ffffff;
    color: #07090d;
    text-decoration: none;
    transform: translateY(-1px);
}

.btn-ghost {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}

.btn-ghost:hover {
    background: var(--surface-3);
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-soft {
    background: var(--accent-bg);
    border-color: var(--accent-border);
    color: var(--accent-hover);
}

.btn-soft:hover {
    background: #0d3a33;
    border-color: #1d8b7d;
    color: var(--text);
}

.progress-track {
    background: #080a0f;
    border: 1px solid var(--border);
    border-radius: 999px;
    height: 0.62rem;
    overflow: hidden;
}

.progress-fill {
    background: var(--accent);
    border-radius: inherit;
    height: 100%;
    min-width: 0.3rem;
}

.progress-fill.is-warn {
    background: var(--warn);
}

.progress-fill.is-energy {
    background: var(--energy);
}

.metric-row {
    align-items: center;
    display: flex;
    gap: 0.8rem;
    justify-content: space-between;
}

@media (max-width: 640px) {
    .coach-card .metric-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .coach-card .text-right {
        text-align: left !important;
    }

    .dose-window-labels {
        align-items: flex-start !important;
        flex-direction: column;
        gap: 0.2rem;
    }
}

.metric-number {
    color: var(--text);
    font-size: clamp(2rem, 8vw, 3.7rem);
    font-variant-numeric: tabular-nums;
    font-weight: 820;
    letter-spacing: 0;
    line-height: 0.95;
}

.metric-unit {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 650;
}

.value-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 768px) {
    .value-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ------------------------------------------------------------------
 * Forms
 * ------------------------------------------------------------------ */

.input,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
    background: #090c12;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    min-height: 46px;
    padding: 0.72rem 0.82rem;
    width: 100%;
}

textarea {
    min-height: 112px;
    resize: vertical;
}

.input:focus,
input:focus,
select:focus,
textarea:focus {
    border-color: var(--focus);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.15);
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--accent);
}

label {
    color: var(--text-muted);
    display: block;
    font-size: 0.84rem;
    font-weight: 650;
    margin-bottom: 0.35rem;
}

/* ------------------------------------------------------------------
 * App shell
 * ------------------------------------------------------------------ */

.appbar {
    align-items: center;
    background: rgba(12, 15, 20, 0.96);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    min-height: 62px;
    max-width: 100vw;
    min-width: 0;
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 30;
}

@media (max-width: 767px) {
    .appbar-actions {
        display: none !important;
    }
}

.appbar-title {
    color: var(--text);
    font-size: 1rem;
    font-weight: 820;
}

.appbar-title:hover {
    color: var(--text);
}

.appbar-actions a,
.appbar-actions button {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.appbar-actions a:hover,
.appbar-actions button:hover {
    color: var(--text);
}

.app-shell {
    min-height: 100vh;
}

.app-content {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

@media (min-width: 768px) {
    .app-shell {
        display: flex;
    }
}

.sidenav {
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: none;
    flex-direction: column;
    gap: 0.25rem;
    height: 100vh;
    overflow-y: auto;
    padding: 1.1rem 0.75rem;
    position: sticky;
    top: 0;
    width: var(--side-nav-w);
}

@media (min-width: 768px) {
    .sidenav {
        display: flex;
    }
}

.sidenav-brand {
    align-items: center;
    color: var(--text);
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.35rem 0.45rem 0.85rem;
}

.sidenav-brand:hover {
    color: var(--text);
}

.brand-mark {
    align-items: center;
    background: var(--text);
    border-radius: var(--radius);
    color: #090c11;
    display: inline-flex;
    font-size: 0.82rem;
    font-weight: 860;
    height: 2.45rem;
    justify-content: center;
    width: 2.45rem;
}

.brand-name {
    display: block;
    font-weight: 840;
    line-height: 1.1;
}

.brand-sub {
    color: var(--text-dim);
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-top: 0.18rem;
    text-transform: uppercase;
}

.sidenav-section {
    color: var(--text-dim);
    font-size: 0.68rem;
    font-weight: 760;
    letter-spacing: 0.08em;
    padding: 0.55rem 0.7rem 0.4rem;
    text-transform: uppercase;
}

.sidenav a.nav-link {
    align-items: center;
    border-radius: var(--radius);
    color: var(--text-muted);
    display: flex;
    font-size: 0.93rem;
    font-weight: 720;
    gap: 0.72rem;
    margin-bottom: 0.12rem;
    padding: 0.72rem 0.72rem;
}

.sidenav a.nav-link:hover {
    background: var(--surface-2);
    color: var(--text);
}

.sidenav a.nav-link.active {
    background: var(--surface-2);
    box-shadow: inset 3px 0 0 var(--accent);
    color: var(--text);
}

.sidenav .icon,
.bottomnav .icon {
    align-items: center;
    background: #090c12;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: inline-flex;
    font-size: 0.72rem;
    font-weight: 860;
    height: 1.35rem;
    justify-content: center;
    line-height: 1;
    width: 1.35rem;
}

.sidenav a.nav-link.active .icon,
.bottomnav a.active .icon {
    background: var(--accent-bg);
    border-color: var(--accent-border);
}

.bottomnav {
    background: rgba(12, 15, 20, 0.98);
    border-top: 1px solid var(--border);
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: var(--bottom-nav-h);
    left: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
    position: fixed;
    right: 0;
    width: 100%;
    max-width: 100vw;
    z-index: 40;
}

@media (min-width: 768px) {
    .bottomnav {
        display: none;
    }
}

.bottomnav a {
    align-items: center;
    color: var(--text-dim);
    display: flex;
    flex-direction: column;
    font-size: 0.68rem;
    font-weight: 740;
    gap: 0.18rem;
    justify-content: center;
    min-width: 0;
}

.bottomnav a:hover,
.bottomnav a.active {
    color: var(--text);
}

.bottomnav a.active .icon {
    color: var(--accent-hover);
}

.main {
    margin: 0 auto;
    max-width: 1120px;
    overflow-x: hidden;
    padding: 1rem;
    padding-bottom: calc(var(--bottom-nav-h) + 1.5rem);
    width: 100%;
}

@media (min-width: 768px) {
    .appbar {
        min-height: 66px;
        padding: 0.9rem 1.35rem;
    }

    .main {
        padding: 1.35rem;
        padding-bottom: 2rem;
    }
}

/* ------------------------------------------------------------------
 * Dashboard
 * ------------------------------------------------------------------ */

.dashboard-shell {
    display: grid;
    gap: 1rem;
    min-width: 0;
}

.dashboard-hero {
    display: grid;
    gap: 1rem;
    min-width: 0;
}

@media (min-width: 920px) {
    .dashboard-hero {
        grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    }
}

.hero-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 250px;
}

.hero-title {
    font-size: clamp(1.65rem, 5vw, 3rem);
    font-weight: 840;
    letter-spacing: 0;
    line-height: 0.98;
    margin: 0.45rem 0 0;
}

.hero-copy {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.55;
    max-width: 44rem;
    overflow-wrap: anywhere;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: auto;
}

.quick-actions .btn {
    flex: 0 1 auto;
}

.coach-card {
    display: grid;
    gap: 1rem;
}

.coach-card .metric-number {
    font-size: clamp(2.4rem, 8vw, 4rem);
}

.stat-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
}

@media (min-width: 920px) {
    .stat-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.week-strip {
    display: grid;
    gap: 0.45rem;
    grid-template-columns: repeat(7, minmax(4.75rem, 1fr));
    overflow-x: auto;
    padding-bottom: 0.15rem;
}

.mf-day {
    background: #090c12;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: 88px;
    padding: 0.52rem 0.42rem;
}

.mf-day.is-today {
    border-color: var(--text);
}

.mf-day.is-planned {
    border-color: var(--accent-border);
}

.mf-day.is-complete {
    background: #10231f;
    border-color: var(--accent);
}

.mf-day-label {
    color: var(--text-dim);
    display: block;
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.mf-day-num {
    color: var(--text);
    display: block;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    font-weight: 820;
    margin-top: 0.2rem;
}

.mf-day-bar {
    background: var(--surface-3);
    border-radius: 999px;
    height: 0.36rem;
    margin-top: 0.75rem;
    overflow: hidden;
}

.mf-day.is-planned .mf-day-bar,
.mf-day.is-complete .mf-day-bar {
    background: var(--accent);
}

.mf-day-status {
    color: var(--text-dim);
    display: block;
    font-size: 0.66rem;
    font-weight: 760;
    margin-top: 0.5rem;
    min-height: 0.9rem;
}

.mf-day.is-complete .mf-day-status {
    color: var(--accent-hover);
}

.dashboard-grid {
    display: grid;
    gap: 1rem;
    min-width: 0;
}

@media (min-width: 920px) {
    .dashboard-grid {
        grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    }
}

.serum-card {
    min-height: 260px;
}

.serum-readout {
    align-items: end;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.serum-readout .metric-number {
    font-size: clamp(2.6rem, 11vw, 5rem);
}

.mini-stack {
    display: grid;
    gap: 0.75rem;
}

.mini-panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem;
}

.summary-list {
    display: grid;
    gap: 0.65rem;
    margin-top: 0.85rem;
}

.summary-item {
    align-items: baseline;
    display: flex;
    gap: 0.8rem;
    justify-content: space-between;
}

.summary-item strong {
    color: var(--text);
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.summary-item span {
    color: var(--text-dim);
    font-size: 0.76rem;
    font-weight: 720;
}

.empty-panel {
    align-items: center;
    background: #090c12;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    color: var(--text-dim);
    display: flex;
    justify-content: center;
    min-height: 130px;
    padding: 1rem;
    text-align: center;
}

.disclaimer {
    background: var(--disclaimer-bg);
    border: 1px solid var(--disclaimer-border);
    border-radius: var(--radius);
    color: var(--disclaimer-text);
    font-size: 0.82rem;
    line-height: 1.5;
    padding: 0.8rem 0.95rem;
}
