:root {
    --bg: #f3f5f1;
    --bg-2: #edf1ec;
    --panel: #ffffff;
    --panel-soft: #f7f8f5;
    --ink: #14221f;
    --muted: #61706a;
    --line: #dde5de;
    --primary: #0f5a52;
    --primary-dark: #0b4a43;
    --accent: #b7772a;
    --danger: #c24d24;
    --success: #dff1e8;
    --shadow: 0 10px 28px rgba(20, 34, 31, .06);
    --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    color: var(--ink);
    background: linear-gradient(180deg, #f8faf7 0%, var(--bg) 100%);
}

a { color: var(--primary); text-decoration: none; font-weight: 700; }
a:hover { color: var(--primary-dark); }
button, input, textarea, select { -webkit-tap-highlight-color: transparent; }
input, textarea, select { font-size: 16px; }

.app-shell {
    display: grid;
    grid-template-columns: 256px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: #f6f7f4;
    border-right: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
}
.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: #fff;
    font-size: 24px;
    font-weight: 900;
    box-shadow: none;
}
.brand strong {
    display: block;
    font-size: 18px;
    line-height: 1.05;
    letter-spacing: -.03em;
}
.brand small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-weight: 600;
}

.nav-links {
    display: grid;
    gap: 4px;
}
.nav-links a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 11px 14px;
    border-radius: 12px;
    color: #23332f;
    font-weight: 800;
    border: 1px solid transparent;
}
.nav-links a.active {
    background: #e8efea;
    border-color: #d3ddd7;
    color: var(--primary-dark);
}
.nav-links a:hover {
    background: #eef3ef;
    color: var(--primary-dark);
}

.sidebar-note {
    margin-top: auto;
    padding: 14px 15px;
    border-radius: 14px;
    background: #eef3ef;
    border: 1px solid #d8e1db;
    display: grid;
    gap: 6px;
    color: #24332f;
    font-size: 13px;
}
.sidebar-note span { color: var(--muted); line-height: 1.45; }

.main-content {
    width: 100%;
    max-width: 1380px;
    padding: 26px;
}

.page-head { margin-bottom: 18px; }
.page-head h1,
.hero-card h1 {
    margin: 4px 0 10px;
    font-size: clamp(32px, 4vw, 52px);
    line-height: 1.02;
    letter-spacing: -.05em;
}
.page-head p,
.hero-card p {
    max-width: 820px;
    margin: 0;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.55;
}
.split-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}
.eyebrow {
    display: inline-block;
    color: var(--primary);
    font-weight: 900;
    letter-spacing: .10em;
    text-transform: uppercase;
    font-size: 12px;
}
.head-actions,
.hero-actions,
.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.flash,
.alert {
    padding: 14px 16px;
    margin-bottom: 16px;
    border-radius: 14px;
    font-weight: 800;
}
.flash { background: var(--success); border: 1px solid #c8e5d7; color: #1a5d44; }
.alert { background: #fff2ef; border: 1px solid #ffd9d1; color: #7f2f1d; }
.alert ul { margin: 8px 0 0; padding-left: 18px; }

.hero-card {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr);
    gap: 20px;
    padding: 28px;
    border-radius: 22px;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.hero-panel {
    align-self: stretch;
    border-radius: 18px;
    padding: 20px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    color: var(--ink);
}
.hero-panel strong { display: block; margin-bottom: 8px; }
.hero-panel ul { margin: 0; padding-left: 18px; line-height: 1.75; color: var(--muted); }
.mini-progress,
.progress-line {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e7ece8;
}
.mini-progress { margin-bottom: 14px; }
.mini-progress span,
.progress-line span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mt { margin-top: 18px; }
.mt-sm { margin-top: 12px; display: block; }

.card,
.metric-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card { padding: 20px; }
.metric-card { padding: 18px; display: grid; gap: 8px; }
.card h2,
.metric-card strong {
    margin-top: 0;
    letter-spacing: -.03em;
}
.card p { color: var(--muted); line-height: 1.6; }
.card-icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: #e8efea;
    color: var(--primary-dark);
    font-weight: 900;
}
.big-card { min-height: 230px; }
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}
.card-head h2 { margin: 0; }
.pill {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 999px;
    background: #eef3ef;
    border: 1px solid #d8e1db;
    color: #3f5751;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}
.muted-card { background: var(--panel-soft); }
.inner-warning {
    box-shadow: none;
    border: 1px dashed #cbd8d0;
    margin-top: 16px;
    padding: 14px;
    border-radius: 14px;
}
.large-copy { font-size: 19px; }
.hint,
.section-copy { color: var(--muted); font-size: 14px; }

.metric-card span {
    color: var(--muted);
    font-weight: 800;
    font-size: 13px;
}
.metric-card strong {
    font-size: clamp(26px, 3.4vw, 36px);
    line-height: 1;
}
.metric-card small {
    color: var(--muted);
    font-weight: 700;
}
.progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin: 14px 0 10px;
    color: var(--muted);
}

.form-grid,
.fields { display: grid; gap: 14px; }
.fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
label {
    display: grid;
    gap: 7px;
    color: #29403a;
    font-weight: 900;
}
label small { color: var(--muted); font-weight: 700; }
input,
textarea,
select {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #cfd9d2;
    border-radius: 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
}
input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 90, 82, .10);
}
textarea { resize: vertical; }
.method-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.method-option {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-soft);
    cursor: pointer;
}
.method-option input,
.check-item input { width: 18px; margin-top: 2px; accent-color: var(--primary); }
.method-option small { display: block; margin-top: 3px; line-height: 1.4; }
.checklist-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.check-item {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--panel-soft);
}
.warning-check { background: #fff8ed; border-color: #efdbb9; }
.sticky-actions {
    position: sticky;
    bottom: 14px;
    width: fit-content;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255,255,255,.94);
    box-shadow: var(--shadow);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 11px 16px;
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
    transition: transform .12s ease, background .12s ease, color .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 20px rgba(15, 90, 82, .16);
}
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost {
    background: #eef3ef;
    border: 1px solid #d8e1db;
    color: #29403a;
}
.btn.danger {
    background: #c95a2f;
    color: #fff;
    box-shadow: 0 8px 20px rgba(201, 90, 47, .16);
}
.btn.light {
    background: #fff;
    color: var(--ink);
    border: 1px solid rgba(255,255,255,.22);
}
.btn.small { min-height: 38px; padding: 8px 12px; border-radius: 10px; font-size: 14px; }

.today-rings {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.today-rings div {
    padding: 18px;
    border-radius: 14px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    text-align: center;
}
.today-rings strong { display: block; font-size: 30px; line-height: 1.05; }
.today-rings span { color: var(--muted); font-weight: 800; }
.clean-list,
.timeline-list {
    margin: 0;
    padding-left: 18px;
    line-height: 1.8;
    color: var(--muted);
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); }
th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.success-band,
.crisis-hero {
    margin-bottom: 18px;
    padding: 18px 20px;
    border-radius: 18px;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    color: #fff;
    background: var(--primary);
    box-shadow: 0 10px 24px rgba(15, 90, 82, .16);
}
.success-band span { display: block; color: rgba(255,255,255,.82); margin-top: 4px; }
.crisis-hero { align-items: stretch; background: #173c36; }
.crisis-hero h2 { margin-top: 0; font-size: 34px; }
.crisis-hero ol { margin: 0; line-height: 1.9; color: rgba(255,255,255,.86); }
.timer-card {
    min-width: 210px;
    padding: 20px;
    border-radius: 18px;
    background: rgba(255,255,255,.10);
    text-align: center;
    display: grid;
    place-items: center;
}
.timer-card strong { font-size: 74px; line-height: .9; }
.timer-card span { font-weight: 900; }
.timer-card p { color: rgba(255,255,255,.75); }
.event-list { display: grid; gap: 10px; }
.event-list article {
    padding: 14px;
    border-radius: 14px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    display: grid;
    gap: 4px;
}
.event-list small,
.event-list span { color: var(--muted); }

.pwa-install-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow);
}
.pwa-install-card[hidden] { display: none !important; }
.pwa-install-card strong { display: block; letter-spacing: -.02em; }
.pwa-install-card span { display: block; color: var(--muted); font-size: 14px; line-height: 1.35; }
.pwa-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 999px;
    background: #eef3ef;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.mobile-tabbar { display: none; }
.compact-fields { display: grid; gap: 12px; }

@media all and (display-mode: standalone) {
    .sidebar { padding-top: calc(18px + env(safe-area-inset-top)); }
}

@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: relative;
        height: auto;
        padding: 14px;
        gap: 14px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        background: #f6f7f4;
        z-index: 20;
    }
    .brand-mark { width: 40px; height: 40px; font-size: 20px; }
    .brand strong { font-size: 18px; }
    .nav-links {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        overflow-x: auto;
        scrollbar-width: none;
        padding-bottom: 2px;
    }
    .nav-links::-webkit-scrollbar { display: none; }
    .nav-links a { min-width: 124px; justify-content: center; text-align: center; }
    .sidebar-note { display: none; }
    .hero-card { grid-template-columns: 1fr; }
    .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .main-content { padding: 20px; }
}

@media (max-width: 760px) {
    .app-shell { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
    .sidebar {
        position: sticky;
        top: 0;
        padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
        background: rgba(246,247,244,.96);
        backdrop-filter: blur(10px);
    }
    .brand { gap: 10px; }
    .brand-mark { width: 38px; height: 38px; font-size: 19px; }
    .brand strong { font-size: 18px; }
    .brand small { display: none; }
    .nav-links { display: none; }
    .main-content {
        max-width: 100%;
        padding: 14px 14px 20px;
    }
    .page-head { margin-bottom: 14px; }
    .page-head h1,
    .hero-card h1 { font-size: 38px; }
    .page-head p,
    .hero-card p { font-size: 16px; }
    .split-head,
    .success-band,
    .crisis-hero { flex-direction: column; align-items: stretch; }
    .hero-card { padding: 18px; gap: 14px; }
    .hero-panel { padding: 16px; }
    .card,
    .metric-card { border-radius: 16px; }
    .card { padding: 16px; }
    .metric-card { padding: 16px; }
    .grid.two,
    .grid.three,
    .grid.four,
    .fields.two,
    .fields.three,
    .fields.four,
    .method-grid,
    .checklist-grid,
    .compact-fields { grid-template-columns: 1fr; }
    .today-rings { grid-template-columns: 1fr; }
    .today-rings div {
        text-align: left;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .pwa-install-card {
        position: sticky;
        top: calc(64px + env(safe-area-inset-top));
        z-index: 18;
        align-items: flex-start;
        padding: 12px;
    }
    .pwa-install-card .btn { width: auto; white-space: nowrap; }
    .mobile-tabbar {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: calc(10px + env(safe-area-inset-bottom));
        z-index: 40;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        padding: 8px;
        border: 1px solid var(--line);
        border-radius: 18px;
        background: rgba(255,255,255,.96);
        box-shadow: 0 12px 28px rgba(20,34,31,.12);
    }
    .mobile-tabbar a {
        display: grid;
        justify-items: center;
        gap: 3px;
        padding: 8px 4px;
        border-radius: 12px;
        color: #40534d;
        font-size: 11px;
        font-weight: 900;
    }
    .mobile-tabbar a span { font-size: 18px; line-height: 1; }
    .mobile-tabbar a.active {
        background: #eef3ef;
        color: var(--primary-dark);
    }
    .form-actions { position: sticky; bottom: calc(82px + env(safe-area-inset-bottom)); z-index: 12; }
    .form-actions .btn,
    .btn { width: 100%; }
    .sticky-actions { width: 100%; bottom: calc(86px + env(safe-area-inset-bottom)); }
    table { min-width: 640px; }
}

@media (min-width: 761px) {
    .mobile-tabbar { display: none !important; }
}
