:root {
    --color-bg: #07111f;
    --color-surface: rgba(255, 255, 255, .96);
    --color-surface-soft: rgba(8, 22, 38, .72);
    --color-text: #102033;
    --color-on-dark: #eef6ff;
    --color-muted: #63738a;
    --color-border: rgba(98, 120, 145, .22);
    --color-primary: #1b8d77;
    --color-primary-dark: #136352;
    --color-accent: #6adf9a;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 20px 50px rgba(4, 16, 30, .18);
}

* { box-sizing: border-box; }
body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    font-family: "Aptos", "Segoe UI", "Trebuchet MS", sans-serif;
    background: linear-gradient(220deg, #0092b996 0%, #51ffb78a 100%);
    color: var(--color-text);
}
main { flex: 1; }
a { color: var(--color-primary); }
.container { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; }
.narrow-page { max-width: 640px; }
.app-page { padding-bottom: 3rem; }
.text-center { text-align: center; }
.muted { color: var(--color-muted); }

.hero-shell {
    margin: 1rem 0 0 0;
    padding: 1.35rem;
    background: linear-gradient(135deg, rgb(255 224 224 / 96%), rgb(255 251 204 / 94%));
    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: calc(var(--radius) + 6px);
    box-shadow: var(--shadow);
}

.hero-shell h1,
.hero-shell .subtitle,
.hero-shell .muted,
.hero-shell .stat-label,
.hero-shell .stat-value {
    color: var(--color-text);
}

.navbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem max(1rem, calc((100vw - 1180px) / 2));
    background: rgba(7, 17, 31, .86);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    backdrop-filter: blur(14px);
}
.nav-brand {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    color: var(--color-on-dark);
    font-weight: 800;
    text-decoration: none;
}
.nav-links { display: flex; align-items: center; gap: .65rem; }
.nav-links a {
    color: var(--color-on-dark);
    text-decoration: none;
    padding: .45rem .6rem;
    border-radius: var(--radius-sm);
}
.nav-links a.active { background: rgba(106, 223, 154, .18); color: var(--color-accent); }
.nav-toggle { display: none; color: var(--color-text); }

a.btn.btn-secondary.btn-sm {
    color: var(--color-text);
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin: 2rem 0 1.25rem;
}
.page-header h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.6rem); }
.subtitle { margin: .25rem 0 0; color: var(--color-muted); }

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.panel { padding: 1.25rem; margin-bottom: 1.25rem; }
.panel h1, .panel h2 { margin-top: 0; }
.panel h2 { font-size: 1.15rem; }
.notice { padding: 1rem 1.25rem; margin-bottom: 1.25rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }

.tracker-layout { display: grid; gap: 0rem; }
.tracker-hero {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1.6fr) minmax(260px, .9fr);
    align-items: start;
}

.tracker-week-head {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
}

.week-strip-wrap {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: .65rem;
    margin-top: 1rem;
    align-items: center;
}

.week-strip {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: .45rem;
    padding-bottom: .15rem;
}

.week-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 999px;
    background: rgba(7, 17, 31, .08);
    color: var(--color-text);
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 800;
}

.week-nav.week-today {
    font-size: 0.75rem;
    width: auto;
    padding: 0.4rem 0.7rem;
    border: 1px solid rgba(27, 141, 119, 0.3);
    background: rgba(27, 141, 119, 0.1);
    color: var(--color-primary-dark);
    font-weight: 700;
    transition: all 0.2s ease;
}

.week-nav.week-today:hover {
    background: rgba(27, 141, 119, 0.2);
    border-color: var(--color-primary);
}

.day-chip {
    display: grid;
    gap: .15rem;
    padding: .75rem;
    border-radius: 14px;
    border: 1px solid var(--color-border);
    background: rgba(255, 255, 255, .9);
    color: var(--color-text);
    text-decoration: none;
    text-align: center;
    width: 80px;
    position: relative;
    overflow: hidden;
}

.day-chip::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0;
    background: linear-gradient(to right, #fff3cd 0%, #e7d4b5 50%, #fff3cd 100%);
    opacity: 0;
    transition: height 0.2s ease;
}

.day-chip::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    background: #d8f3dc;
    opacity: 0;
    transition: width 0.2s ease;
}

.day-chip.has-morning::before {
    height: 4px;
    opacity: 1;
}

.day-chip.has-evening::after {
    width: 4px;
    height: 100%;
    opacity: 1;
}

.day-chip.has-both::before {
    height: 3px;
}

.day-chip.has-both::after {
    width: 3px;
}

.day-chip span {
    font-size: .76rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--color-muted);
}

.day-chip strong {
    font-size: 1.05rem;
    line-height: 1;
}

.day-chip-month {
    font-size: 0.65rem;
    color: var(--color-muted);
    line-height: 1;
    display: block;
}

.day-chip.today { border-color: rgba(27, 141, 119, .35); }
.day-chip.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.day-chip.active span { color: rgba(255, 255, 255, .85); }

.tracker-summary-shell {
    display: grid;
    gap: 1rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .9rem;
}

@media (max-width: 1024px) {
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-card {
        padding: 0.8rem;
    }
    .stat-value {
        margin-top: 0.25rem;
        font-size: 1.2rem;
    }
    .field-note-inline {
        font-size: 0.75rem;
    }
}

.stat-card {
    padding: 1rem;
    border-radius: var(--radius);
    background: rgba(7, 17, 31, .9);
    color: var(--color-on-dark);
}

.stat-card .stat-label,
.stat-card .stat-value {
    color: var(--color-on-dark);
}

.stat-label {
    display: block;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(238, 246, 255, .72);
}

.stat-value {
    display: block;
    margin-top: .35rem;
    font-size: 1.45rem;
    font-weight: 800;
}

.tracker-status {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .6rem .85rem;
    border-radius: 999px;
    background: rgba(16, 32, 51, .08);
    color: var(--color-text);
    font-weight: 700;
}

.tracker-status[data-state="pending"] { background: #fff2cc; color: #8a5b00; }
.tracker-status[data-state="saved"] { background: #dbf7e7; color: #136352; }
.tracker-status[data-state="error"] { background: #fde2e1; color: #9f1d20; }

.autosave-banner {
    margin-top: 1rem;
    padding: .9rem 1rem;
    border-radius: var(--radius-sm);
    background: rgba(106, 223, 154, .14);
    border: 1px solid rgba(106, 223, 154, .28);
    color: #0f3f35;
}

.autosave-banner strong {
    display: block;
    margin-bottom: .15rem;
    color: #0f3f35;
}

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

.field-group {
    display: grid;
    gap: .35rem;
}

.field-group.field-disabled { opacity: .55; }

.field-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
    margin-left: .35rem;
    padding: .1rem .45rem;
    border-radius: 999px;
    background: rgba(27, 141, 119, .12);
    color: var(--color-primary-dark);
    font-size: .82rem;
    font-weight: 800;
}

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

.field-grid.three-up { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-grid .span-2 { grid-column: span 2; }
.field-grid .span-3 { grid-column: span 3; }

.tab-bar {
    display: inline-flex;
    gap: .45rem;
    padding: .3rem;
    border-radius: 999px;
    background: rgba(7, 17, 31, .05);
    margin-bottom: 1rem;
}

.tab-button {
    border: 0;
    border-radius: 999px;
    padding: .55rem .95rem;
    background: transparent;
    color: var(--color-muted);
    font-weight: 800;
}

.tab-button.active {
    background: var(--color-surface);
    color: var(--color-primary-dark);
    box-shadow: 0 4px 12px rgba(4, 16, 30, .08);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.form-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
}

.metric-strip {
    display: grid;
    gap: .8rem;
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric-box {
    padding: .9rem;
    border-radius: var(--radius-sm);
    background: #f4f8fb;
    border: 1px solid var(--color-border);
}

.metric-box span {
    display: block;
    font-size: .78rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.metric-box strong {
    display: block;
    margin-top: .25rem;
    font-size: 1.05rem;
}

.pill-row {
    display: flex;
    gap: .45rem;
    flex-wrap: wrap;
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .35rem .6rem;
    border-radius: 999px;
    background: #edf4f2;
    color: var(--color-primary-dark);
    font-size: .8rem;
    font-weight: 800;
}

.pill.dark {
    background: rgba(255, 255, 255, .12);
    color: var(--color-text);
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .5rem;
}

.section-heading h2,
.section-heading h3 { margin: 0; }

.range-toolbar {
    display: flex;
    gap: .75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.range-toolbar .field-group { min-width: 160px; }

.trend-table tbody tr:nth-child(odd) { background: rgba(7, 17, 31, .02); }

.trend-bars {
    display: grid;
    gap: .85rem;
}

.trend-row {
    display: grid;
    grid-template-columns: 100px 1fr 72px;
    gap: .75rem;
    align-items: center;
}

.trend-track {
    position: relative;
    height: .8rem;
    border-radius: 999px;
    overflow: hidden;
    background: #e6edf5;
}

.trend-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
}

.trend-meta {
    text-align: right;
    font-weight: 700;
}

.insight-list {
    display: grid;
    gap: .7rem;
}

.insight-item {
    padding: .85rem 1rem;
    border-radius: var(--radius-sm);
    background: #f4f8fb;
    border: 1px solid var(--color-border);
}

.insight-item strong { display: block; margin-bottom: .2rem; }

.btn, button, input[type="submit"] {
    border: 0;
    border-radius: var(--radius-sm);
    padding: .62rem .9rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.btn-sm { padding: .42rem .65rem; font-size: .88rem; }
.btn-primary, button[type="submit"], input[type="submit"] { background: var(--color-primary); color: #fff; }
.btn-primary:hover, button[type="submit"]:hover { background: var(--color-primary-dark); }
.btn-secondary { background: #eef2f6; color: var(--color-text); }
.btn-danger { background: #b42318; color: #fff; }
.btn:disabled, button:disabled { opacity: .6; cursor: wait; }

.form-block {
    width: min(420px, calc(100% - 2rem));
    margin: 2rem auto;
    padding: 1.5rem;
    display: grid;
    gap: .85rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.form-block h1 { margin: 0 0 .5rem; }
.form-message { max-width: 420px; margin: 1rem auto; }
.stack { display: grid; gap: .75rem; }
.inline-form { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.input-row { display: flex; gap: .5rem; align-items: stretch; }
.input-row input { flex: 1; min-width: 0; }
.input-row .btn { flex-shrink: 0; }

.time-input-group {
    display: flex;
    gap: .3rem;
    align-items: center;
}

.time-input-h, .time-input-m {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: .65rem .5rem;
    font: inherit;
    background: #fff;
    color: var(--color-text);
    text-align: center;
    font-weight: 600;
}

.time-input-m {
    flex: 0 0 50px;
}

.time-input-h {
    flex: 0 0 50px;
}

.time-input-sep {
    color: var(--color-muted);
    font-weight: 800;
    line-height: 1;
}
.honeypot {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

label { display: block; font-weight: 700; margin-bottom: .35rem; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: .65rem .75rem;
    font: inherit;
    background: #fff;
    color: var(--color-text);
}
.checkbox-label { display: inline-flex; align-items: center; gap: .45rem; font-weight: 500; margin: 0; }
.checkbox-label input { width: auto; }
.form-note { color: var(--color-muted); font-size: .92rem; }
.error-message { background: #fde2e1; color: #9f1d20; border-radius: var(--radius-sm); padding: .65rem .8rem; }
.success-message { background: #d8f3dc; color: #1b6b3a; border-radius: var(--radius-sm); padding: .65rem .8rem; }

.key-value-list { display: grid; gap: .75rem; margin: 0; }
.key-value-list div { display: grid; grid-template-columns: minmax(120px, 35%) 1fr; gap: .75rem; }
.key-value-list dt { color: var(--color-muted); font-size: .85rem; font-weight: 700; }
.key-value-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th, .data-table td {
    padding: .65rem .75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}
.data-table th { background: var(--color-bg); font-weight: 700; }
.hide-mobile { display: table-cell; }
.action-row { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }

.status-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: .18rem .55rem;
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
}
.badge-active { background: #d8f3dc; color: #1b6b3a; }
.badge-inactive { background: #fde2e1; color: #9f1d20; }
.badge-admin { background: #fff3cd; color: #856404; }
.badge-global { background: #cff4fc; color: #055160; }
.badge-soft { background: #edf4f2; color: var(--color-primary-dark); }

.tracker-mini-card {
    padding: .95rem 1rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .6);
    border: 1px solid var(--color-border);
}

.tracker-mini-card strong { display: block; margin-bottom: .2rem; }

.tracker-note {
    min-height: 8rem;
    resize: vertical;
}

.report-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1.2fr .8fr;
    align-items: start;
}

@media (max-width: 1024px) {
    .report-grid { grid-template-columns: 1fr; }
}

.chart-card { padding: 1rem 1.1rem; }

.site-footer {
    margin-top: 2.5rem;
    padding: 1rem max(1rem, calc((100vw - 1180px) / 2));
    background: rgba(7, 17, 31, .9);
    border-top: 1px solid rgba(255, 255, 255, .08);
    backdrop-filter: blur(14px);
}
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.footer-account { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.footer-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    flex: 0 0 auto;
    border-radius: 50%;
    background: rgba(106, 223, 154, .15);
    color: var(--color-accent);
    font-weight: 800;
}
.footer-label {
    display: block;
    margin-bottom: .1rem;
    color: rgba(238, 246, 255, .68);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
}
.footer-user { display: block; overflow: hidden; color: var(--color-on-dark); text-overflow: ellipsis; white-space: nowrap; }
.footer-links { display: flex; align-items: center; justify-content: flex-end; gap: .35rem; flex-wrap: wrap; }
.footer-links a {
    color: var(--color-on-dark);
    text-decoration: none;
    padding: .45rem .65rem;
    border-radius: var(--radius-sm);
    font-size: .92rem;
    font-weight: 700;
}
.footer-links a:hover, .footer-links a.active { background: rgba(106, 223, 154, .15); color: var(--color-accent); }
.footer-links .footer-logout { color: #ff9ea1; }
.footer-links .footer-logout:hover { background: rgba(180, 35, 24, .26); color: #fff; }

@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
    .inline-form { align-items: stretch; }
    .tracker-hero,
    .report-grid,
    .summary-grid,
    .section-grid,
    .field-grid,
    .field-grid.three-up,
    .metric-strip { grid-template-columns: 1fr; }
    .field-grid .span-2 { grid-column: auto; }
    .field-grid .span-3 { grid-column: auto; }
    .tracker-week-head,
    .form-footer-row { flex-direction: column; align-items: stretch; }
    .week-strip-wrap { grid-template-columns: auto 1fr auto auto; }
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .nav-toggle { display: inline-flex; background: #eef2f6; }
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        right: 1rem;
        left: 1rem;
        flex-direction: column;
        align-items: stretch;
        padding: .75rem;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
    }
    .nav-links.open { display: flex; }
    .page-header { display: block; }
    .key-value-list div { grid-template-columns: 1fr; gap: .15rem; }
    .input-row { flex-direction: column; }
    .site-footer { padding-block: .85rem; }
    .footer-inner { align-items: stretch; flex-direction: column; }
    .footer-links { justify-content: stretch; }
    .footer-links a { flex: 1; text-align: center; }
    .trend-row { grid-template-columns: 1fr; }
    .trend-meta { text-align: left; }
    .summary-grid { grid-template-columns: 1fr; }
    .stat-card { padding: 0.7rem; }
    .stat-label { font-size: 0.7rem; }
    .stat-value { font-size: 1.1rem; margin-top: 0.2rem; }
    .week-strip { grid-template-columns: repeat(7, minmax(20px, 1fr)); }
    .day-chip {
        gap: .15rem;
        padding: .75rem .25rem;
        width: 40px;
    }
    .week-nav {
        width: 1.4rem;
        height: 2.4rem;
    }
    .nav-links a {
        color: var(--color-text);
    }
    .range-toolbar {
        flex-direction: column;
    }
    .range-toolbar .field-group {
        min-width: 100%;
    }
    .table-wrap {
        overflow-x: auto;
        font-size: 0.8rem;
    }
    .data-table th, .data-table td {
        padding: 0.4rem 0.35rem;
        font-size: 0.8rem;
    }
    .data-table th {
        white-space: nowrap;
    }
    .field-note-inline {
        font-size: 0.7rem;
        margin-top: -0.3rem;
        margin-bottom: 0.3rem;
    }
    .trend-bars {
        gap: 0.6rem;
    }
    .hide-mobile {
        display: none !important;
    }
}
