:root {
    --app-sand-50: #fbf4ea;
    --app-sand-100: #f3e4d1;
    --app-sand-200: #e6cfac;
    --app-sand-300: #d7b37e;
    --app-mocha-700: #5c3928;
    --app-mocha-800: #43281d;
    --app-mocha-900: #2a1913;
    --app-olive-500: #6f8550;
    --app-olive-600: #556a39;
    --app-coral-500: #c36b4a;
    --app-coral-600: #a85335;
    --app-cream: #fffaf2;
    --app-ink: #2a211d;
    --app-muted: #735b4e;
    --app-line: rgba(67, 40, 29, 0.14);
    --app-line-strong: rgba(67, 40, 29, 0.22);
    --app-surface: rgba(255, 250, 242, 0.9);
    --app-surface-strong: rgba(255, 248, 238, 0.97);
    --app-shadow: 0 24px 60px rgba(42, 25, 19, 0.12);
    --app-shadow-soft: 0 14px 32px rgba(42, 25, 19, 0.08);
    --pico-font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", "Trebuchet MS", sans-serif;
    --pico-form-element-background-color: rgba(255, 255, 255, 0.9);
    --pico-form-element-border-color: rgba(67, 40, 29, 0.18);
    --pico-form-element-active-border-color: rgba(168, 83, 53, 0.5);
    --pico-form-element-focus-color: rgba(168, 83, 53, 0.24);
    --pico-primary: var(--app-coral-500);
    --pico-primary-hover: var(--app-coral-600);
    --pico-primary-focus: rgba(168, 83, 53, 0.28);
    --pico-primary-inverse: #fff7f1;
    --pico-secondary: var(--app-olive-500);
    --pico-secondary-hover: var(--app-olive-600);
    --pico-secondary-focus: rgba(85, 106, 57, 0.22);
    --pico-del-color: #a53f3f;
    --pico-ins-color: var(--app-olive-600);
    --pico-mark-background-color: rgba(215, 179, 126, 0.25);
    --pico-mark-color: var(--app-mocha-800);
    --pico-card-background-color: var(--app-surface);
    --pico-card-border-color: var(--app-line);
    --pico-card-box-shadow: var(--app-shadow-soft);
    --pico-card-sectioning-background-color: rgba(255, 244, 233, 0.7);
    color-scheme: light;
}

html {
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(215, 179, 126, 0.35), transparent 28%),
        radial-gradient(circle at top right, rgba(111, 133, 80, 0.16), transparent 24%),
        linear-gradient(180deg, #fdf8f1 0%, #f5ede2 46%, #efe2d3 100%);
    color: var(--app-ink);
}

body {
    position: relative;
    min-height: 100vh;
    color: var(--app-ink);
}

body::before,
body::after {
    content: "";
    position: fixed;
    z-index: -1;
    border-radius: 999px;
    filter: blur(10px);
    pointer-events: none;
}

body::before {
    top: 4rem;
    left: -5rem;
    width: 16rem;
    height: 16rem;
    background: rgba(215, 179, 126, 0.24);
}

body::after {
    right: -6rem;
    bottom: 10rem;
    width: 18rem;
    height: 18rem;
    background: rgba(111, 133, 80, 0.15);
}

a {
    color: var(--app-coral-600);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
}

a:hover {
    color: var(--app-mocha-800);
}

h1,
h2,
h3,
h4,
summary,
.brand-mark {
    font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "New York", Georgia, serif;
    letter-spacing: -0.02em;
    color: var(--app-mocha-800);
}

h1 {
    margin-bottom: 0.4rem;
    font-size: clamp(2.1rem, 6vw, 3.35rem);
    line-height: 0.95;
}

h2 {
    margin-top: 2.5rem;
    font-size: clamp(1.35rem, 4vw, 1.95rem);
}

h3 {
    font-size: clamp(1.1rem, 3.5vw, 1.4rem);
}

p,
li,
dd,
dt,
td,
th,
label,
small {
    color: var(--app-ink);
}

small {
    color: var(--app-muted);
}

nav.app-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 0.9rem 1.2rem;
    border-bottom: 1px solid rgba(67, 40, 29, 0.08);
    background: rgba(255, 248, 240, 0.72);
    backdrop-filter: blur(16px);
}

.app-nav ul {
    align-items: center;
    gap: 0.35rem;
}

.app-nav a,
.app-nav button {
    border-radius: 999px;
}

.app-nav a {
    padding: 0.45rem 0.85rem;
    color: var(--app-muted);
    text-decoration: none;
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.app-nav a:hover,
.app-nav a[aria-current="page"] {
    background: rgba(255, 255, 255, 0.72);
    color: var(--app-mocha-800);
    transform: translateY(-1px);
}

.brand-mark {
    font-size: 1.2rem;
    font-weight: 700;
}

.user-chip {
    padding: 0.35rem 0.8rem;
    border: 1px solid var(--app-line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.64);
    color: var(--app-mocha-700);
    font-size: 0.92rem;
    white-space: nowrap;
}

.app-main {
    width: min(1180px, calc(100% - 2rem));
    margin: 1.25rem auto 3rem;
    padding: clamp(1.2rem, 3vw, 2.2rem);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(255, 252, 247, 0.96), rgba(255, 248, 239, 0.9)),
        rgba(255, 250, 242, 0.84);
    box-shadow: var(--app-shadow);
}

.app-main > *:first-child {
    margin-top: 0;
}

.app-main > p:first-of-type {
    max-width: 52rem;
    color: var(--app-muted);
}

.flash {
    margin-bottom: 1rem;
    padding: 0.95rem 1rem;
    border: 1px solid transparent;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.66);
    box-shadow: var(--app-shadow-soft);
}

.flash-success {
    color: #244c31;
    border-color: rgba(85, 106, 57, 0.22);
    background: rgba(213, 232, 204, 0.62);
}

.flash-error {
    color: #7a2e25;
    border-color: rgba(168, 83, 53, 0.2);
    background: rgba(250, 225, 216, 0.8);
}

.status-note {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 0.9rem;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
}

.status-good {
    background: rgba(213, 232, 204, 0.7);
    color: #244c31;
}

.status-warn {
    background: rgba(244, 221, 171, 0.72);
    color: #7a5a16;
}

.status-bad {
    background: rgba(250, 225, 216, 0.9);
    color: #7a2e25;
}

article,
details,
fieldset,
pre,
dl {
    border: 1px solid var(--app-line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.58);
    box-shadow: var(--app-shadow-soft);
}

article,
details,
fieldset,
pre,
dl {
    padding: 1rem 1.1rem;
}

fieldset {
    margin-bottom: 1rem;
}

details summary {
    cursor: pointer;
}

pre {
    white-space: pre-wrap;
    word-break: break-word;
}

table {
    display: block;
    width: 100%;
    overflow-x: auto;
    margin: 1rem 0 1.5rem;
    border: 1px solid var(--app-line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.62);
    box-shadow: var(--app-shadow-soft);
}

thead,
tbody,
tr {
    width: 100%;
}

thead tr {
    background: rgba(243, 228, 209, 0.52);
}

th,
td {
    border-color: rgba(67, 40, 29, 0.08);
    white-space: nowrap;
}

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

tr.is-below-par {
    color: #8f3125;
    background: rgba(237, 189, 173, 0.24);
}

form {
    margin-bottom: 1.25rem;
}

input,
select,
textarea {
    border-radius: 16px;
}

input:focus,
select:focus,
textarea:focus {
    box-shadow: 0 0 0 0.2rem rgba(168, 83, 53, 0.15);
}

button,
[role="button"],
input[type="submit"] {
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 10px 20px rgba(168, 83, 53, 0.16);
}

button.outline,
[role="button"].outline {
    background: rgba(255, 255, 255, 0.76);
}

mark {
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
}

hr {
    margin: 2rem 0;
    border-color: rgba(67, 40, 29, 0.12);
}

img.receipt-image {
    display: block;
    width: min(100%, 46rem);
    max-height: 38rem;
    object-fit: contain;
    border: 1px solid var(--app-line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--app-shadow-soft);
}

.page-actions,
.pager {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin: 1rem 0 1.5rem;
}

.pager {
    justify-content: center;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    align-items: end;
    padding: 1rem 1.05rem;
    border: 1px solid var(--app-line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.56);
    box-shadow: var(--app-shadow-soft);
}

.filter-form > * {
    margin-bottom: 0;
}

.inline-form {
    display: inline-flex;
    gap: 0.45rem;
    align-items: center;
    margin: 0;
}

.compact-button {
    margin: 0;
    padding: 0.35rem 0.7rem;
}

.remove-row-btn {
    min-width: 2rem;
    padding: 0.2rem 0.55rem;
    width: auto;
    justify-self: start;
    align-self: end;
    line-height: 1;
    font-size: 1rem;
    box-shadow: none;
}

.compact-input {
    width: auto;
    margin: 0;
    padding: 0.35rem 0.65rem;
}

.entry-row {
    display: grid;
    gap: 0.75rem;
    align-items: end;
    margin-bottom: 0.75rem;
    padding: 0.9rem;
    border: 1px solid rgba(67, 40, 29, 0.1);
    border-radius: 20px;
    background: rgba(255, 252, 247, 0.84);
}

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

.entry-flow-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: end;
    height: calc(1em * var(--pico-line-height) + (var(--pico-form-element-spacing-vertical) * 2) + (var(--pico-border-width) * 2));
    margin-bottom: var(--pico-spacing);
    color: var(--app-mocha-700);
}

.entry-flow-indicator svg {
    width: 1.5rem;
    height: 1.5rem;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.inventory-panel {
    margin-top: 0.8rem;
    padding: 1rem;
    border: 1px dashed rgba(67, 40, 29, 0.24);
    border-radius: 18px;
    background: rgba(255, 250, 244, 0.72);
}

.metric-value {
    display: inline-block;
    padding: 0.85rem 1rem;
    border: 1px solid var(--app-line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.72);
    font-size: clamp(1.35rem, 4vw, 1.9rem);
    font-weight: 800;
    box-shadow: var(--app-shadow-soft);
}

.fill-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
}

.fill-card {
    min-width: 9rem;
}

.fill-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.65rem;
}

.fill-buttons .compact-button {
    padding: 0.3rem 0.65rem;
}

.fill-counter {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.fill-counter .compact-button {
    padding-inline: 0.9rem;
}

.fill-count,
.fill-total {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--app-mocha-800);
}

.fill-count {
    min-width: 2.5rem;
}

.quick-adjust {
    white-space: nowrap;
}

.quick-adjust .inline-form + .inline-form {
    margin-left: 0.35rem;
}

.rename-form {
    flex-wrap: wrap;
}

.row-actions-cell {
    width: 1%;
    text-align: right;
}

.row-action-menu {
    position: relative;
    display: inline-block;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.row-action-menu[open] {
    z-index: 5;
}

.row-action-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid var(--app-line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--app-mocha-700);
    font-size: 1.1rem;
    line-height: 1;
    list-style: none;
    cursor: pointer;
    box-shadow: var(--app-shadow-soft);
}

.row-action-trigger::-webkit-details-marker {
    display: none;
}

.row-action-trigger:hover {
    color: var(--app-mocha-800);
    background: rgba(255, 250, 244, 0.98);
}

.row-action-panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 15rem;
    padding: 0.9rem;
    border: 1px solid var(--app-line);
    border-radius: 18px;
    background: rgba(255, 251, 246, 0.98);
    box-shadow: var(--app-shadow);
}

.row-action-panel .rename-form {
    display: grid;
    gap: 0.65rem;
    margin: 0;
}

.row-action-panel .rename-form label {
    margin: 0;
    font-size: 0.9rem;
    color: var(--app-muted);
}

.row-action-panel .rename-form input {
    margin: 0;
}

.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;
}

.auth-shell {
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.auth-shell::before {
    top: 10%;
    left: 10%;
    width: 22rem;
    height: 22rem;
    background: rgba(215, 179, 126, 0.24);
}

.auth-shell::after {
    right: 8%;
    bottom: 8%;
    width: 18rem;
    height: 18rem;
    background: rgba(111, 133, 80, 0.18);
}

.auth-card {
    width: min(100%, 30rem);
    margin: 8vh auto;
    padding: clamp(1.35rem, 4vw, 2rem);
    border: 1px solid rgba(255, 255, 255, 0.66);
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(255, 251, 246, 0.98), rgba(255, 246, 236, 0.92)),
        rgba(255, 250, 242, 0.9);
    box-shadow: var(--app-shadow);
}

.auth-card hgroup {
    margin-bottom: 1.5rem;
}

.auth-card h1 {
    margin-bottom: 0.35rem;
}

.auth-footer {
    margin-top: 1.25rem;
    text-align: center;
}

@media (min-width: 720px) {
    .entry-row {
        grid-template-columns: minmax(0, 1fr);
    }

    #entries .entry-row {
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) minmax(10rem, 0.65fr) auto;
    }

    .inventory-panel .entry-row {
        grid-template-columns: minmax(0, 1fr) minmax(10rem, 0.65fr) auto;
    }

    .inventory-panel .entry-row .remove-row-btn,
    #entries .entry-row .remove-row-btn {
        margin-bottom: 0.05rem;
    }
}

@media (max-width: 719px) {
    #entries .entry-flow-indicator {
        justify-content: flex-start;
        align-self: end;
        padding-left: 0.1rem;
    }

    #entries .entry-flow-indicator svg {
        width: 1.3rem;
        height: 1.3rem;
    }
}

@media (max-width: 900px) {
    nav.app-nav {
        position: static;
    }

    .app-main {
        width: min(100% - 1rem, 100%);
        margin-top: 0.75rem;
        padding: 1rem;
        border-radius: 24px;
    }

    .nav-brand {
        display: none !important;
    }
}

@media (max-width: 800px) {
    .nav-user {
        display: none !important;
    }

    nav.app-nav {
        justify-content: center;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 15px;
    }

    nav.app-nav {
        padding: 0.8rem;
    }

    .app-nav,
    .app-nav ul {
        gap: 0.45rem;
    }

    .app-nav ul {
        flex-wrap: wrap;
        justify-content: center;
    }

    .app-nav a {
        padding: 0.4rem 0.72rem;
        font-size: 0.92rem;
    }

    .nav-desktop-only {
        display: none !important;
    }

    table {
        border-radius: 18px;
    }

    th,
    td {
        padding-inline: 0.7rem;
    }
}

@media print {
    body::before,
    body::after,
    nav.app-nav,
    form,
    button,
    [role="button"] {
        display: none !important;
    }

    html,
    body,
    .app-main,
    article,
    details,
    fieldset,
    pre,
    table,
    dl {
        color: #000 !important;
        background: #fff !important;
        box-shadow: none !important;
    }

    .app-main {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
        border: 0;
    }
}
