:root {
    --font-base: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --color-bg: #0f172a;
    --color-surface: #ffffff;
    --color-surface-alt: #f8fafc;
    --color-border: #e2e8f0;
    --color-accent: #2563eb;
    --color-accent-dark: #1d4ed8;
    --color-muted: #475569;
    --radius-md: 16px;
    --shadow-soft: 0 10px 35px rgba(15, 23, 42, 0.1);
}

* {
    box-sizing: border-box;
    font-family: var(--font-base);
}

body {
    margin: 0;
    background: radial-gradient(circle at top, #1e3a8a 0%, #0f172a 45%, #020617 100%);
    color: #0f172a;
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: rgba(2, 6, 23, 0.65);
    backdrop-filter: blur(18px);
    color: #e2e8f0;
    padding: 2rem clamp(1rem, 4vw, 3.5rem) 1.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.02);
}

header h1 {
    margin: 0 0 0.75rem;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: -0.02em;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.eyebrow {
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.3em;
    color: rgba(226, 232, 240, 0.7);
    margin: 0 0 0.2rem;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.5);
    color: #e2e8f0;
}

.user-chip .user-name {
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.3rem;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.5);
    color: #e2e8f0;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.nav-toggle__bar {
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 999px;
}

.nav-toggle:focus-visible,
.nav-toggle:hover {
    border-color: rgba(255, 255, 255, 0.7);
    transform: scale(1.05);
}

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

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

nav a {
    color: #e2e8f0;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    font-weight: 500;
}

nav a:hover,
nav a:focus-visible {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.08);
}

nav a.active {
    border-color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.3);
}

main {
    padding: clamp(1.5rem, 4vw, 3rem);
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

h2 {
    margin: 2.5rem 0 1rem;
    font-size: 1.25rem;
    color: #0f172a;
}

.card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: clamp(1.25rem, 3vw, 2rem);
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(15, 23, 42, 0.05);
    margin-bottom: 1.5rem;
}

form {
    background: var(--color-surface);
    padding: clamp(1.25rem, 3vw, 2rem);
    border-radius: var(--radius-md);
    max-width: 720px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(15, 23, 42, 0.05);
    display: grid;
    gap: 1rem;
}

.card form {
    background: transparent;
    box-shadow: none;
    border: 0;
    padding: 0;
    max-width: 100%;
}

.card form .btn {
    justify-self: flex-start;
}

label {
    font-weight: 600;
    color: var(--color-muted);
    font-size: 0.95rem;
}

input,
textarea,
select {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: var(--color-surface-alt);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
    resize: vertical;
}

.product-meta {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.item-builder {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(140px, 1fr));
    gap: 1rem;
    align-items: stretch;
    margin-bottom: 1.5rem;
}

.item-builder__field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.item-builder__actions {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.item-builder__actions .btn {
    width: 100%;
}

.product-suggestions {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    margin-top: 0.25rem;
    max-height: 220px;
    overflow-y: auto;
    padding: 0.35rem;
    position: relative;
    z-index: 1;
}

.product-suggestions .suggestion {
    width: 100%;
    border: none;
    background: transparent;
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    transition: background 0.2s ease;
}

.product-suggestions .suggestion:hover,
.product-suggestions .suggestion:focus-visible {
    background: rgba(37, 99, 235, 0.08);
}

.item-values span {
    display: inline-block;
    color: var(--color-muted);
}

.item-values strong {
    color: #0f172a;
}

.item-builder + .empty-state {
    margin-top: 0;
}

.table-shell {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    padding: 0.5rem;
    border: 1px solid rgba(15, 23, 42, 0.05);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    background: var(--color-surface-alt);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    color: var(--color-muted);
}

tbody tr:hover {
    background: rgba(37, 99, 235, 0.04);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.65rem 1.35rem;
    background: var(--color-accent);
    color: #fff;
    text-decoration: none;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover {
    background: var(--color-accent-dark);
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.25);
    transform: translateY(-1px);
}

.btn.secondary {
    background: transparent;
    color: var(--color-accent);
    border-color: rgba(37, 99, 235, 0.4);
}

.btn.danger {
    background: #dc2626;
}

.btn.danger:hover {
    background: #b91c1c;
    box-shadow: 0 10px 20px rgba(220, 38, 38, 0.3);
}

.actions {
    display: flex;
    gap: 0.5rem;
}

.receipt-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.receipt-actions .btn {
    flex: 1 1 180px;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.form-help {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin: 0.35rem 0 0.75rem;
}

.product-image-field {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.product-image-field img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-soft);
    background: var(--color-surface);
}

.product-image-field .remove-image {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: var(--color-muted);
}

.product-thumb {
    width: 90px;
    text-align: center;
}

.product-thumb img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-soft);
}

.product-thumb .no-image {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    color: var(--color-muted);
    border: 1px dashed var(--color-border);
    border-radius: 999px;
}

.flash {
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    border: 1px solid transparent;
    box-shadow: var(--shadow-soft);
}

.flash.success {
    background: #dcfce7;
    color: #166534;
    border-color: rgba(22, 101, 52, 0.25);
}

.flash.error {
    background: #fee2e2;
    color: #b91c1c;
    border-color: rgba(185, 28, 28, 0.25);
}

footer {
    color: rgba(226, 232, 240, 0.7);
    text-align: center;
    padding: 2rem 1rem 2.5rem;
    font-size: 0.85rem;
    margin-top: auto;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(15, 23, 42, 0.05);
}

.summary-card span {
    display: block;
    font-size: 0.85rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
}

.summary-card strong {
    font-size: 2rem;
    color: #0f172a;
}

.card.stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.section-heading p {
    margin: 0;
    color: var(--color-muted);
}

.empty-state {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    border: 1px dashed rgba(15, 23, 42, 0.2);
    color: var(--color-muted);
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.filter-form input[type="date"] {
    width: 200px;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.inline-form {
    display: inline-flex;
}

.pill {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.pill--success {
    background: #dcfce7;
    color: #166534;
}

.pill--danger {
    background: #fee2e2;
    color: #b91c1c;
}

@media (max-width: 768px) {
    nav {
        display: none;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        margin-top: 1rem;
    }

    nav.is-open {
        display: flex;
    }

    nav a {
        width: 100%;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .header-top {
        align-items: flex-start;
    }

    table {
        min-width: 100%;
        font-size: 0.95rem;
    }

    form {
        padding: 1.25rem;
    }

    .item-builder {
        grid-template-columns: 1fr;
    }

    .item-builder__actions {
        justify-content: flex-start;
    }
}
