:root {
    --bg: #f6faf7;
    --surface: #ffffff;
    --surface-soft: #eef8f2;
    --text: #173126;
    --muted: #627368;
    --line: #d8e6dd;
    --accent: #0f9f6e;
    --accent-dark: #087456;
    --danger: #c2413b;
    --danger-soft: #fff0ee;
    --shadow: 0 18px 50px rgba(23, 49, 38, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
    font: inherit;
}

a {
    color: inherit;
}

.app-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.topbar h1,
.login-panel h1 {
    margin: 0;
    font-size: clamp(2rem, 6vw, 3.7rem);
    line-height: 0.95;
    letter-spacing: 0;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent-dark);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.entry-layout {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(280px, 0.9fr);
    gap: 16px;
    align-items: stretch;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

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

.panel,
.metric-card,
.history-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel {
    padding: 18px;
}

.metric-card {
    min-height: 132px;
    padding: 15px;
}

.metric-card p,
.metric-card span {
    margin: 0;
    color: var(--muted);
}

.metric-card p {
    font-size: 0.83rem;
    font-weight: 800;
}

.metric-card strong {
    display: block;
    margin: 14px 0 10px;
    font-size: clamp(1.55rem, 4vw, 2.35rem);
    line-height: 1;
}

.metric-card span {
    font-size: 0.9rem;
}

.section-heading {
    margin-bottom: 16px;
}

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

.split-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
}

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

.field,
.login-form label {
    display: grid;
    gap: 7px;
}

.field span,
.login-form span {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 750;
}

.field input,
.login-form input {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdfb;
    color: var(--text);
    padding: 12px;
    outline: none;
}

.field input:focus,
.login-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 159, 110, 0.15);
}

.farmer-preview {
    grid-column: 1 / -1;
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--accent-dark);
    font-weight: 800;
}

.primary-button,
.ghost-button,
.delete-form button {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 850;
}

.primary-button {
    grid-column: 1 / -1;
    background: var(--accent);
    color: white;
    padding: 12px 16px;
}

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

.ghost-button {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    padding: 10px 14px;
}

.secondary-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
    color: var(--accent-dark);
    font-size: 0.9rem;
    font-weight: 800;
    text-decoration: none;
}

.today-panel {
    background: #fafffc;
}

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

.today-grid div {
    min-height: 86px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface);
}

.today-grid strong {
    display: block;
    margin-bottom: 6px;
    font-size: 1.65rem;
    line-height: 1;
}

.today-grid span {
    color: var(--muted);
    font-weight: 750;
}

.flash {
    margin-bottom: 16px;
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 800;
}

.flash.success {
    border: 1px solid rgba(15, 159, 110, 0.25);
    background: #ecfbf4;
    color: var(--accent-dark);
}

.flash.error {
    border: 1px solid rgba(194, 65, 59, 0.25);
    background: var(--danger-soft);
    color: var(--danger);
}

.progress-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.progress-row:last-child {
    border-bottom: 0;
}

.progress-row strong,
.progress-row span {
    display: block;
}

.progress-row span {
    color: var(--muted);
    margin-top: 3px;
}

.progress-track {
    grid-column: 1 / -1;
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8f0eb;
}

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

.stat-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.stat-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.stat-list div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.stat-list dt {
    color: var(--muted);
    font-weight: 750;
}

.stat-list dd {
    margin: 0;
    text-align: right;
    font-weight: 900;
}

.chart-panel,
.history-panel {
    margin-top: 16px;
}

.bar-chart {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
    min-height: 210px;
    align-items: end;
}

.bar-item {
    display: grid;
    gap: 7px;
    justify-items: center;
    min-width: 0;
}

.bar-shell {
    display: flex;
    align-items: end;
    width: 100%;
    height: 142px;
    overflow: hidden;
    border-radius: 8px;
    background: #eaf3ee;
}

.bar-fill {
    width: 100%;
    min-height: 4px;
    border-radius: 8px 8px 0 0;
    background: var(--accent);
}

.bar-item strong {
    font-size: 0.95rem;
}

.bar-item span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

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

.history-row {
    display: grid;
    grid-template-columns: minmax(170px, 0.8fr) minmax(240px, 1.5fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    box-shadow: none;
}

.history-date strong,
.history-date span {
    display: block;
}

.history-date span {
    margin-top: 5px;
    color: var(--muted);
    font-size: 0.9rem;
}

.history-values {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.history-values span {
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text);
    padding: 7px 10px;
    font-size: 0.88rem;
}

.delete-form button {
    background: var(--danger-soft);
    color: var(--danger);
    padding: 8px 10px;
}

.empty-state {
    margin: 0;
    color: var(--muted);
    font-weight: 700;
}

.login-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-shell {
    width: min(420px, 100%);
}

.login-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 24px;
}

.login-copy {
    margin: 14px 0 18px;
    color: var(--muted);
    line-height: 1.5;
}

.login-form {
    display: grid;
    gap: 14px;
}

@media (max-width: 980px) {
    .metrics-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .app-shell {
        width: min(100% - 20px, 560px);
        padding-top: 16px;
    }

    .topbar {
        align-items: start;
    }

    .entry-layout,
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .metric-card {
        min-height: 108px;
    }

    .history-row {
        grid-template-columns: 1fr;
    }

    .delete-form button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .panel {
        padding: 14px;
    }

    .entry-form,
    .today-grid {
        grid-template-columns: 1fr;
    }

    .bar-chart {
        gap: 6px;
    }

    .bar-shell {
        height: 120px;
    }

    .split-heading {
        display: grid;
    }
}
