:root {
    --bg: #f4f6f1;
    --surface: #fffdf8;
    --surface-strong: #ffffff;
    --ink: #1e2724;
    --muted: #66706b;
    --line: #d9ddd2;
    --primary: #1f4d5a;
    --primary-dark: #173a44;
    --accent: #c85a44;
    --success: #547d5b;
    --warning: #a87320;
    --danger: #a33d35;
    --shadow: 0 14px 34px rgba(31, 77, 90, 0.12);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

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

button {
    cursor: pointer;
}

button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 76px;
    padding: 14px 16px;
    background: rgba(255, 253, 248, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.topbar h1,
.section-head h2,
.progress-panel h2 {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.1;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.app-shell {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 16px;
}

.dashboard-main {
    display: grid;
    gap: 16px;
}

.panel,
.loading-panel,
.notice,
.insight-panel,
.metric {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel,
.loading-panel,
.notice,
.insight-panel {
    padding: 16px;
}

.loading-panel {
    display: grid;
    min-height: 180px;
    place-items: center;
    color: var(--muted);
}

.section-head {
    margin-bottom: 14px;
}

.section-head-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.field {
    display: grid;
    gap: 6px;
}

.field span {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    color: var(--ink);
    background: var(--surface-strong);
    border: 1px solid #cbd2c5;
    border-radius: var(--radius);
    outline: none;
}

.field textarea {
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 77, 90, 0.14);
}

.field input[aria-invalid="true"] {
    border-color: var(--danger);
}

.field small {
    color: var(--danger);
    font-weight: 700;
}

.field-wide {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.primary-button,
.secondary-button,
.ghost-button,
.small-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.primary-button {
    color: #ffffff;
    background: var(--primary);
}

.primary-button:hover {
    background: var(--primary-dark);
}

.secondary-button,
.ghost-button,
.small-button {
    color: var(--primary);
    background: #ffffff;
    border-color: #bfcbbf;
}

.secondary-button:hover,
.ghost-button:hover,
.small-button:hover {
    border-color: var(--primary);
}

.ghost-button[aria-pressed="true"] {
    color: #ffffff;
    background: var(--primary);
}

.danger-button {
    color: var(--danger);
}

.notice {
    margin-bottom: 16px;
    font-weight: 800;
}

.notice-success {
    color: #254f32;
    background: #edf6ed;
    border-color: #bfd8bf;
}

.notice-error {
    color: #7f2721;
    background: #fff0ed;
    border-color: #e8c1ba;
}

.profile-panel {
    margin-bottom: 16px;
}

.action-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 0;
}

.action-strip h2 {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.1;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.metric {
    min-height: 112px;
    padding: 14px;
}

.metric span,
.metric small {
    display: block;
    color: var(--muted);
}

.metric span {
    font-size: 0.84rem;
    font-weight: 800;
}

.metric strong {
    display: block;
    margin: 8px 0 2px;
    font-size: 1.38rem;
    line-height: 1.1;
}

.metric-good strong {
    color: var(--success);
}

.metric-watch strong {
    color: var(--warning);
}

.progress-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.progress-copy {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
}

.progress-copy strong {
    color: var(--primary);
    font-size: 1.6rem;
}

.progress-track {
    height: 12px;
    overflow: hidden;
    background: #e7ece4;
    border-radius: 999px;
}

.progress-track span {
    display: block;
    height: 100%;
    max-width: 100%;
    background: var(--success);
}

.insight-panel {
    color: #27322d;
    background: #eef4ef;
    border-color: #c6d7c9;
    box-shadow: none;
}

.insight-panel p {
    margin: 0;
    font-weight: 700;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-left: auto;
    gap: 10px 14px;
}

.legend {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 800;
}

.legend span {
    display: inline-block;
    width: 22px;
    height: 3px;
    background: var(--primary);
    border-radius: 999px;
}

.legend-real span {
    background: var(--accent);
}

.legend-projected span {
    background: repeating-linear-gradient(
        to right,
        var(--success) 0 7px,
        transparent 7px 12px
    );
}

.legend-average span {
    background: var(--primary);
}

.chart-panel canvas {
    display: block;
    width: 100%;
    height: 260px;
}

.entry-list {
    display: grid;
    gap: 10px;
}

.entry-row {
    display: grid;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.entry-row:first-child {
    border-top: 0;
    padding-top: 0;
}

.entry-main {
    min-width: 0;
}

.entry-main time,
.entry-main span {
    display: block;
    color: var(--muted);
}

.entry-main strong {
    display: block;
    margin: 2px 0;
    font-size: 1.2rem;
}

.entry-main p {
    margin: 8px 0 0;
    overflow-wrap: anywhere;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.small-button {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 0.9rem;
}

.empty-state {
    padding: 20px 0;
    color: var(--muted);
    text-align: center;
}

@media (min-width: 680px) {
    .topbar {
        padding-inline: 24px;
    }

    .app-shell {
        padding: 24px;
    }

    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metrics-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .entry-row {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .row-actions {
        justify-content: flex-end;
    }
}
