:root {
    --bg: #f3f1eb;
    --surface: #ffffff;
    --surface-muted: #f8f7f3;
    --surface-soft: #f0eee7;
    --line: #ddd8cc;
    --line-strong: #c9c2b4;
    --text: #1f2722;
    --muted: #5f695f;
    --brand: #315d46;
    --brand-strong: #244435;
    --accent: #a96c38;
    --danger: #a4473b;
    --success: #2f6b44;
    --shadow: 0 10px 30px rgba(26, 34, 28, 0.06);
    --radius: 18px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Jost", "Segoe UI", sans-serif;
    background:
        linear-gradient(to bottom, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.7)),
        linear-gradient(to right, rgba(49, 93, 70, 0.04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(49, 93, 70, 0.04) 1px, transparent 1px),
        var(--bg);
    background-size: auto, 28px 28px, 28px 28px, auto;
}

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

button {
    cursor: pointer;
}

.page-shell {
    width: min(1360px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.5rem 0 3rem;
}

.hero {
    display: grid;
    gap: 1.5rem;
    padding: 1.75rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 5px solid var(--brand);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.hero__copy h1 {
    margin: 0.35rem 0 0.75rem;
    max-width: 14ch;
    font-size: clamp(2.1rem, 4vw, 3.75rem);
    line-height: 0.95;
    letter-spacing: -0.04em;
    font-weight: 700;
}

.eyebrow,
.section-kicker {
    margin: 0;
    color: var(--brand);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.hero__lead,
.section-copy,
.subpanel__header p,
.note-banner,
.status-copy,
.storage-note,
.list-meta,
.report-meta,
.empty-state,
.field span,
.mini-field span,
.stat-card__hint,
.task-note,
.task-status,
.calc-meta {
    color: var(--muted);
}

.hero__lead {
    max-width: 72ch;
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
}

.hero__controls,
.hero__status {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
}

.hero__buttons,
.task-actions,
.calc-actions,
.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.status-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.status-copy,
.storage-note {
    margin: 0.2rem 0 0;
    font-size: 0.95rem;
}

.storage-note {
    max-width: 40rem;
    padding: 0.9rem 1rem;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

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

.stat-card {
    padding: 1.1rem 1.15rem;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

.stat-card__label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--brand);
}

.stat-card__value {
    display: block;
    margin: 0.35rem 0 0.15rem;
    font-size: clamp(1.8rem, 3vw, 2.3rem);
    line-height: 1;
    font-weight: 700;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1.25rem;
    margin-top: 1.25rem;
}

.panel {
    grid-column: span 6;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel--wide {
    grid-column: span 12;
}

.section-heading {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-heading h2,
.subpanel__header h3,
.task-main h3,
.calc-head h3,
.report-card h3 {
    margin: 0.25rem 0 0;
}

.section-heading h2,
.report-title,
.report-card h3 {
    font-size: clamp(1.45rem, 2vw, 1.85rem);
    line-height: 1.05;
    letter-spacing: -0.03em;
    font-weight: 700;
}

.section-copy {
    max-width: 52ch;
    margin: 0;
    line-height: 1.6;
}

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

.subpanel {
    padding: 1.05rem;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

.subpanel__header {
    margin-bottom: 1rem;
}

.subpanel__header p {
    margin: 0.25rem 0 0;
    line-height: 1.55;
}

.stack-form,
.inline-form {
    display: grid;
    gap: 0.9rem;
}

.inline-form {
    grid-template-columns: 1.3fr 1fr auto;
    align-items: end;
}

.field,
.mini-field {
    display: grid;
    gap: 0.38rem;
}

.field span,
.mini-field span {
    font-size: 0.88rem;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    padding: 0.82rem 0.9rem;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(49, 93, 70, 0.1);
}

textarea {
    resize: vertical;
}

.button {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0.82rem 1.15rem;
    background: var(--brand);
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.button:hover {
    background: var(--brand-strong);
}

.button:active {
    transform: translateY(1px);
}

.button--secondary {
    background: var(--accent);
}

.button--secondary:hover {
    background: #8f5d31;
}

.button--ghost {
    background: #fff;
    color: var(--text);
    border-color: var(--line-strong);
}

.button--ghost:hover {
    background: var(--surface-soft);
}

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

.button--danger:hover {
    background: #8f3d32;
}

.button--small {
    padding: 0.65rem 0.95rem;
    font-size: 0.92rem;
}

.day-selector {
    margin: 0;
    padding: 0;
    border: 0;
}

.day-selector legend {
    margin-bottom: 0.5rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--muted);
}

.day-selector__grid,
.weekly-targets,
.report-stats {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.5rem;
}

.day-selector__grid label {
    position: relative;
}

.day-selector__grid input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.day-selector__grid span {
    display: grid;
    place-items: center;
    min-height: 46px;
    padding: 0.75rem 0.5rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 0.86rem;
    font-weight: 600;
}

.day-selector__grid input:checked + span {
    background: rgba(49, 93, 70, 0.08);
    border-color: rgba(49, 93, 70, 0.35);
    color: var(--brand-strong);
}

.weekly-targets {
    align-items: start;
}

.mini-field input {
    text-align: center;
    padding-inline: 0.55rem;
}

.list-block,
.task-list,
.calc-list,
.report-view {
    display: grid;
    gap: 0.85rem;
    margin-top: 1rem;
}

.list-card,
.task-card,
.calc-card,
.report-card {
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.list-card__top,
.task-main,
.calc-head,
.report-card__head,
.report-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.75rem;
}

.list-card__top strong,
.task-main h3,
.calc-head h3 {
    font-size: 1rem;
    font-weight: 600;
}

.tag-row,
.report-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.8rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.34rem 0.62rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(49, 93, 70, 0.1);
    color: var(--brand-strong);
}

.badge--manual {
    background: rgba(169, 108, 56, 0.14);
    color: #7b4e27;
}

.badge--done {
    background: rgba(47, 107, 68, 0.12);
    color: var(--success);
}

.badge--pending {
    background: rgba(164, 71, 59, 0.12);
    color: var(--danger);
}

.list-meta,
.task-note,
.task-status,
.calc-meta,
.report-meta {
    margin: 0.55rem 0 0;
    line-height: 1.55;
}

.note-banner {
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    background: rgba(49, 93, 70, 0.06);
    border: 1px solid rgba(49, 93, 70, 0.12);
    border-radius: 12px;
    line-height: 1.55;
}

.task-card.is-done {
    border-color: rgba(47, 107, 68, 0.2);
    background: #fcfdfb;
}

.task-controls,
.calc-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
    margin-top: 1rem;
}

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

.calc-highlight {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.52rem 0.72rem;
    background: rgba(169, 108, 56, 0.12);
    color: #7b4e27;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 600;
}

.report-view {
    gap: 1rem;
}

.report-header {
    align-items: center;
}

.report-title {
    margin: 0;
}

.report-stats {
    margin-top: 1rem;
}

.report-stat {
    padding: 1rem;
    border-radius: 14px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
}

.report-stat strong {
    display: block;
    margin-top: 0.15rem;
    font-size: 1.45rem;
    font-weight: 700;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    padding: 0.85rem 0.9rem;
    text-align: left;
    border-bottom: 1px solid #ebe7de;
    font-size: 0.95rem;
}

th {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-muted);
}

tbody tr:last-child td {
    border-bottom: 0;
}

.empty-state {
    padding: 1rem;
    border: 1px dashed var(--line-strong);
    border-radius: 12px;
    background: var(--surface-muted);
    line-height: 1.55;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 1180px) {
    .stats-grid,
    .triple-grid,
    .calc-grid,
    .report-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .inline-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 920px) {
    .panel,
    .panel--wide {
        grid-column: span 12;
    }

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

    .task-controls {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .page-shell {
        width: min(100% - 1rem, 100%);
        padding-bottom: 1.5rem;
    }

    .hero,
    .panel {
        padding: 1rem;
        border-radius: 14px;
    }

    .stats-grid,
    .triple-grid,
    .weekly-targets,
    .day-selector__grid,
    .calc-grid,
    .report-stats {
        grid-template-columns: 1fr;
    }

    .hero__controls,
    .hero__status,
    .task-main,
    .calc-head,
    .report-header {
        align-items: stretch;
    }

    .hero__buttons,
    .task-actions,
    .calc-actions,
    .report-actions {
        width: 100%;
        flex-direction: column;
    }

    .button,
    .button--ghost,
    .button--secondary,
    .button--danger {
        width: 100%;
        justify-content: center;
    }

    .storage-note {
        border-radius: 12px;
    }
}

@media print {
    body {
        background: #fff;
    }

    #database,
    #tasks,
    #production,
    #print-report,
    #load-demo,
    #clear-data,
    .storage-note {
        display: none !important;
    }

    .page-shell {
        width: 100%;
        padding: 0;
    }

    .hero,
    .panel,
    .subpanel,
    .report-card {
        box-shadow: none;
        border: 1px solid #ddd;
        background: #fff;
    }

    .content-grid {
        display: block;
        margin-top: 1rem;
    }

    #report {
        margin-top: 1rem;
    }
}
