:root {
    --bg: #eef3f2;
    --panel: #ffffff;
    --soft: #f3f6f5;
    --ink: #1d2528;
    --muted: #627074;
    --line: rgba(29, 37, 40, 0.11);
    --accent: #14796f;
    --accent-strong: #0c5e58;
    --accent-soft: rgba(20, 121, 111, 0.11);
    --warn: #b86b19;
    --good: #1f8f5f;
    --shadow: 0 16px 36px rgba(29, 37, 40, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    min-height: 100vh;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #e6f0ef 0%, #f7f8f6 46%, #eef2f0 100%);
    color: var(--ink);
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

.page, .auth-page {
    width: min(760px, calc(100% - 24px));
    margin: 0 auto;
    padding: 20px 0 100px;
}
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
}
.auth-card, .hero-card, .soft-panel, .nav-card, .list-item, .modal-card {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.auth-card, .hero-card, .soft-panel, .modal-card {
    border-radius: 8px;
    padding: 22px;
}
.hero-card.compact { padding: 20px; }
.lead, .muted { color: var(--muted); line-height: 1.6; }
.eyebrow {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
h1, h2, h3 {
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    letter-spacing: 0;
}
h1 { margin-top: 14px; font-size: clamp(34px, 5vw, 48px); line-height: 1; }
h2 { font-size: clamp(28px, 4vw, 38px); line-height: 1.05; }
h3 { font-size: 24px; }
.hero-kicker { color: var(--accent-strong); font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; }

.topbar, .section-head, .inline-actions, .stack, .list, .grid-two, .header-actions {
    display: grid;
    gap: 14px;
}
.topbar {
    grid-template-columns: 1fr auto;
    align-items: start;
    margin-bottom: 18px;
}
.section-head {
    grid-template-columns: 1fr auto;
    align-items: center;
    margin-bottom: 12px;
}
.header-actions {
    justify-items: end;
}
.list-section { margin-top: 20px; }
.list { gap: 12px; }
.grid-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 20px;
}

.button {
    border: none;
    cursor: pointer;
    border-radius: 8px;
    padding: 13px 18px;
    font-weight: 700;
}
.button.primary { background: var(--accent); color: white; }
.button.secondary { background: var(--accent-soft); color: var(--accent-strong); }
.button.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.button.danger { background: rgba(180, 51, 51, 0.12); color: #9c2b2b; }
.button.small { padding: 10px 14px; font-size: 14px; }
.text-link {
    border: none;
    background: transparent;
    color: var(--accent-strong);
    cursor: pointer;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.field { display: grid; gap: 8px; }
.field span { color: var(--muted); font-size: 14px; }
.field input {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 14px 16px;
    background: white;
}
.field textarea,
.field select {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 14px 16px;
    background: white;
    resize: vertical;
}
.checkbox-field {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    color: var(--ink);
}
.checkbox-field input {
    margin-top: 3px;
}

.nav-card {
    display: block;
    border-radius: 8px;
    padding: 18px;
    transition: transform 0.18s ease, border-color 0.18s ease;
}
.nav-card strong {
    display: block;
    font-size: 18px;
}
.nav-card span {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    line-height: 1.5;
}
.link-card {
    display: block;
}
.nav-card:hover, .list-item:hover, .link-card:hover {
    transform: translateY(-1px);
    border-color: rgba(15, 118, 110, 0.24);
}

.list-item {
    border-radius: 8px;
    padding: 16px;
}
.list-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}
.list-row.tail {
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}
.list-title { font-weight: 700; font-size: 18px; }
.list-sub { margin-top: 6px; color: var(--muted); line-height: 1.5; }
.chevron {
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
}
.chip {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--muted);
    font-size: 13px;
}
.chip.good { background: rgba(31, 143, 95, 0.12); color: var(--good); }
.chip.warn { background: rgba(217, 119, 6, 0.12); color: var(--warn); }
.chip.danger { background: rgba(180, 51, 51, 0.12); color: #9c2b2b; }

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    width: min(760px, calc(100% - 24px));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    padding: 8px;
    border-radius: 8px;
    background: rgba(255, 250, 242, 0.92);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}
.bottom-nav.six {
    grid-template-columns: repeat(6, 1fr);
}
.bottom-nav.four {
    grid-template-columns: repeat(4, 1fr);
}
.bottom-nav a {
    display: grid;
    place-items: center;
    min-height: 44px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}
.bottom-nav a.active {
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 700;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(18, 35, 29, 0.46);
}
.modal.open { display: flex; }
.mono { white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; line-height: 1.6; }
.preview-panel {
    margin-top: 14px;
    display: grid;
    gap: 12px;
}
.preview-image {
    width: 100%;
    max-height: 260px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #f0ece5;
}
.preview-meta {
    display: grid;
    gap: 4px;
}
.medicine-line {
    color: var(--muted);
    line-height: 1.45;
}
.detail-fold {
    margin-top: 16px;
}
.detail-fold summary {
    cursor: pointer;
    color: var(--accent-strong);
    font-weight: 700;
}
.nested-fold {
    box-shadow: none;
    border: none;
    padding: 0;
    margin-top: 10px;
    background: transparent;
}
.fold-content {
    margin-top: 14px;
}
.ocr-source {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}
.entry-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 20px 0 12px;
}
.manual-start {
    margin-top: 16px;
    border-top: 1px solid var(--line);
    padding-top: 16px;
}
.manual-start summary {
    cursor: pointer;
    color: var(--accent-strong);
    font-weight: 700;
}
.manual-start form {
    margin-top: 14px;
}
.compact-actions {
    display: flex;
    flex-wrap: wrap;
}
.editor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.field-span-2 {
    grid-column: span 2;
}
.editor-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    box-shadow: var(--shadow);
}
.editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}
.validation-card {
    display: grid;
    gap: 4px;
}
.confidence-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.top-gap {
    margin-top: 12px;
}
.timeline {
    display: grid;
    gap: 10px;
}
.timeline-item {
    padding: 14px 16px;
    border-radius: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--muted);
}
.empty-state {
    color: var(--muted);
}
.align-start {
    align-items: flex-start;
}
.compact-stack {
    gap: 8px;
}
.step-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}
.step-pill {
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--soft);
    color: var(--muted);
    font-size: 14px;
    border: 1px solid var(--line);
}
.step-pill.active {
    background: var(--accent-soft);
    color: var(--accent-strong);
    border-color: rgba(15, 118, 110, 0.24);
}
.mvp-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 18px 0;
}
.mvp-strip span {
    padding: 8px 10px;
    border-radius: 8px;
    background: #edf3f8;
    color: #385262;
    border: 1px solid rgba(56, 82, 98, 0.12);
    font-size: 13px;
}
.route-focus {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(240px, 0.7fr);
    gap: 16px;
    margin-top: 20px;
}
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.stat-item {
    min-height: 74px;
    padding: 12px;
    border-radius: 8px;
    background: #edf3f8;
    border: 1px solid rgba(56, 82, 98, 0.12);
}
.stat-item strong,
.stat-item span {
    display: block;
}
.stat-item strong {
    font-size: 24px;
    line-height: 1;
}
.stat-item span {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 760px) {
    .topbar, .section-head, .grid-two, .route-focus { grid-template-columns: 1fr; }
    .header-actions {
        justify-items: start;
    }
    .bottom-nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .bottom-nav.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .bottom-nav.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .editor-grid {
        grid-template-columns: 1fr;
    }
    .field-span-2 {
        grid-column: auto;
    }
    .entry-actions {
        grid-template-columns: 1fr;
    }
}
