:root {
    color-scheme: light;
    --canvas: #f4f4ef;
    --surface: #fff;
    --ink: #192a24;
    --muted: #52635a;
    --line: #dce3dc;
    --forest: #18332c;
    --forest-hover: #274c40;
    --gold: #e6cf9d;
    --danger: #9a3538;
    --radius: 18px;
    --sans: "Segoe UI", system-ui, sans-serif;
    --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html { scroll-padding-top: 24px; }

body {
    display: grid;
    grid-template-columns: 224px minmax(0, 1fr);
    min-height: 100vh;
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font: 1rem / 1.55 var(--sans);
}

[hidden] { display: none !important; }

:focus-visible {
    outline: 3px solid #9b712f;
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 5;
    padding: 10px 16px;
    transform: translateY(-150%);
    background: var(--surface);
    color: var(--ink);
}

.skip-link:focus { transform: none; }

.site-nav {
    position: sticky;
    top: 0;
    align-self: start;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: 100vh;
    padding: 28px 18px 20px;
    overflow-y: auto;
    background: #142922;
    color: #eff3ec;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 0 4px 34px;
    color: inherit;
    font: 1.26rem / 1.2 var(--serif);
    white-space: nowrap;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 39px;
    height: 39px;
    border: 1px solid #937e54;
    border-radius: 11px;
    background: #213b30;
    color: var(--gold);
    font-size: 1.35rem;
}

.site-nav ul {
    display: grid;
    gap: 5px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.site-nav li a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: #d9e2db;
    font-size: .9rem;
    font-weight: 600;
    text-decoration: none;
}

.site-nav li a:hover,
.site-nav li a[aria-current="location"] {
    background: #244138;
    border-color: #365447;
    color: #f2dfb4;
}

.storage-note {
    margin: auto 4px 0;
    padding-top: 16px;
    border-top: 1px solid #345043;
    color: #c5d1c8;
    font-size: .81rem;
}

main {
    width: min(100%, 1260px);
    min-width: 0;
    margin-inline: auto;
    padding: clamp(16px, 3.4vw, 46px);
}

.welcome {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 244px;
    isolation: isolate;
    overflow: hidden;
    margin-bottom: 22px;
    padding: clamp(22px, 4.2vw, 46px);
    border: 1px solid #2d493e;
    border-radius: 22px;
    background: #172f29;
    color: #fbf6e9;
}

.welcome::before {
    position: absolute;
    z-index: -1;
    inset: 0 0 0 38%;
    background: url("hero-coffee.webp") center 52% / cover no-repeat;
    content: "";
}

.welcome::after {
    position: absolute;
    z-index: -1;
    inset: 0;
    background: linear-gradient(90deg, #172f29 3%, #172f29 36%, #172f29a6 57%, #172f2900 100%);
    content: "";
}

.welcome-copy { max-width: 66%; }

.welcome h1,
.section-heading h2 {
    margin: 0;
    font-family: var(--serif);
    font-weight: 500;
    letter-spacing: -.035em;
    line-height: 1.13;
}

.welcome h1 { font-size: clamp(2rem, 4.3vw, 3.6rem); }
.welcome p { margin: 12px 0 21px; color: #d5e1d7; }

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 13px;
    margin-bottom: 24px;
}

.card {
    min-width: 0;
    padding: 17px clamp(13px, 2vw, 23px);
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
}

.card-highlight {
    border-color: #dccda7;
    background: #f4ebd5;
}

.card-title {
    margin: 0;
    color: var(--muted);
    font-size: .91rem;
    font-weight: 600;
}

.card h2 {
    margin: 7px 0 0;
    font-size: clamp(1.25rem, 2.15vw, 1.85rem);
    letter-spacing: -.04em;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.content-section {
    min-width: 0;
    padding: clamp(15px, 2.6vw, 32px);
    margin-bottom: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 5px 18px #18332c08;
}

.section-heading { margin-bottom: 23px; }
.section-heading h2 { font-size: clamp(1.65rem, 3vw, 2.3rem); }

h3 {
    margin: 24px 0 13px;
    font-size: 1.15rem;
    line-height: 1.3;
}

.section-heading + h3 { margin-top: 0; }
.inventory-heading h3 { margin-top: 31px; }

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

#revenue .transaction-form + .transaction-form { margin-top: 14px; }
#reports > .form-group { max-width: 300px; }

.form-group { display: grid; gap: 6px; min-width: 0; }

.form-group label {
    font-size: .89rem;
    font-weight: 650;
}

.form-group input,
.form-group select {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid #cbd8cf;
    border-radius: 9px;
    background-color: #fcfdfa;
    color: var(--ink);
    font: inherit;
}

.form-group input::placeholder { color: #68786e; }
.form-group input:focus,
.form-group select:focus { border-color: #527a63; }

.form-group select {
    appearance: none;
    padding-right: 38px;
    background-image: linear-gradient(45deg, transparent 50%, #405c4d 50%),
        linear-gradient(135deg, #405c4d 50%, transparent 50%);
    background-position: right 19px center, right 14px center;
    background-size: 5px 5px;
    background-repeat: no-repeat;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 8px 13px;
    border: 1px solid #cbd8cf;
    border-radius: 9px;
    background: #f8faf6;
    color: var(--forest);
    font: 650 .89rem / 1.2 var(--sans);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

button:hover:not(:disabled) { background: #e7efe7; }
button:disabled { opacity: .54; cursor: default; }

.submit-button,
.button-accent {
    border-color: var(--forest);
    background: var(--forest);
    color: #fff;
}

.submit-button:hover:not(:disabled),
.button-accent:hover:not(:disabled) { background: var(--forest-hover); }

.submit-button,
.form-alternative { grid-column: 1 / -1; justify-self: start; }

.submit-button { min-height: 46px; padding-inline: 20px; }

.button-gold {
    border-color: var(--gold);
    background: var(--gold);
    color: #2e281a;
}

.button-gold:hover { background: #f4dfb2; }

.delete-button {
    border-color: #ecd8d6;
    background: #fff7f6;
    color: var(--danger);
}

.delete-button:hover:not(:disabled) { background: #fbe6e5; }

.actions-bar,
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.actions-bar { margin-block: 12px; }
.row-actions { flex-wrap: nowrap; }

[role="status"],
#report-count {
    margin: 10px 0;
    color: var(--muted);
    font-size: .88rem;
}

[role="status"]:empty { display: none; }

#transaction-range-error,
#ingredient-edit-error { color: var(--danger); }

.table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

#revenue table { min-width: 628px; }
#ingredients table { min-width: 690px; }
#ingredients .table-container:last-child table { min-width: 500px; }

th,
td { padding: 11px 13px; border-bottom: 1px solid #e7ebe5; }

th {
    background: #edf2ec;
    color: #3c5246;
    font-size: .86rem;
    font-weight: 700;
}

td { font-size: .9rem; overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: #f8faf6; }
.inventory-empty { text-align: center; color: var(--muted); }
#ingredient-list td:nth-child(5) { font-weight: 650; }

.income,
.expense,
.stock-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 650;
    white-space: nowrap;
}

.income, .stock-normal { color: #234f39; background: #e2f0e4; }
.expense, .stock-empty { color: #882f32; background: #f7e4e3; }
.stock-low { color: #694918; background: #f6ecd4; }

.report-totals {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0 20px;
}

.report-totals p {
    min-width: 0;
    margin: 0;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--forest);
    color: #e5eee6;
    font-size: .9rem;
}

.report-totals strong {
    display: block;
    margin-top: 4px;
    color: #fff;
    font-size: clamp(1.25rem, 3vw, 1.8rem);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.report-totals .report-balance-card { background: #f4ebd5; color: #584526; }
.report-balance-card strong { color: var(--ink); }
#expenses :is(th, td):not(:first-child) { text-align: right; }

dialog {
    width: min(450px, calc(100% - 30px));
    max-height: calc(100% - 30px);
    padding: clamp(16px, 4vw, 26px);
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 16px 60px #14292250;
}

dialog::backdrop { background: #12262099; }

dialog h3 { margin-top: 0; }
dialog .form-group + .form-group { margin-top: 12px; }
dialog .actions-bar { margin-bottom: 0; }

footer {
    padding: 12px 2px 4px;
    color: var(--muted);
    font: 1rem var(--serif);
}

@media (max-width: 1100px) {
    .dashboard-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    body { display: block; }
    .site-nav {
        position: static;
        height: auto;
        min-height: 0;
        padding: 13px 14px 10px;
    }
    .brand { margin: 0 0 7px; }
    .brand-mark { width: 36px; height: 36px; }
    .site-nav ul { display: flex; flex-wrap: wrap; gap: 3px; }
    .site-nav li a { padding-inline: 8px; }
    .storage-note { margin: 6px 0 0; padding: 8px 3px 0; }
}

@media (max-width: 550px) {
    .welcome { min-height: 214px; }
    .welcome-copy { max-width: 90%; }
    .welcome::before { left: 20%; opacity: .65; }
    .welcome::after { background: linear-gradient(90deg, #172f29 6%, #172f29c9 54%, #172f292b 100%); }
    .dashboard-cards { gap: 8px; }
    .transaction-form, .report-totals { grid-template-columns: 1fr; }
    .submit-button, .form-alternative { justify-self: stretch; }
    button, .button { min-height: 44px; }
    #expenses :is(th, td) { padding-inline: 8px; }
}
