:root {
    --bg: #050505;
    --paper: #141416;
    --panel: #08090d;
    --panel-soft: #111827;
    --accent: #971b2f;
    --accent-dark: #6f1322;
    --ink: #f4edf0;
    --muted: #b8a8b0;
    --line: #2a2d3a;
    --success: #1e2a22;
    --font-heading: Georgia, "Times New Roman", serif;
    --font-body: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    --shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
    --space-section: 1.5rem;
    --space-card: 1.5rem;
}

* {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
}

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(151, 27, 47, 0.34), transparent 22%),
        radial-gradient(circle at top right, rgba(23, 42, 79, 0.22), transparent 24%),
        radial-gradient(circle at bottom right, rgba(111, 19, 34, 0.28), transparent 26%),
        linear-gradient(180deg, #030304 0%, #0e0910 56%, #14070d 100%);
}

body,
.page-shell,
.main-content,
.hero,
.section-head,
.card,
.stat-card,
.summary-shell,
.sheet-sections,
.workspace-grid,
.table-card,
.stock-table-card {
    min-width: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.85rem 0.9rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #191919;
    font: inherit;
    color: var(--ink);
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
    font-weight: 600;
}

button {
    font: inherit;
    border: 0;
    cursor: pointer;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

.page-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

body.auth-page .page-shell {
    grid-template-columns: 1fr;
}

body.auth-page .sidebar {
    display: none;
}

body.auth-page .main-content {
    padding: 0;
}

.sidebar {
    background:
        linear-gradient(180deg, rgba(5, 7, 12, 0.98) 0%, rgba(16, 8, 14, 0.98) 52%, rgba(26, 9, 14, 0.98) 100%);
    color: #f7eded;
    padding: 2rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

body.sidebar-collapsed .page-shell {
    grid-template-columns: 1fr;
}

body.sidebar-collapsed .sidebar {
    display: none;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand strong,
h1,
h2 {
    font-family: var(--font-heading);
}

.brand-mark {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #0f2345 0%, var(--accent) 100%);
    color: #fff;
    font-weight: 700;
}

.brand small,
.nav-links a,
.sidebar-footer p {
    color: rgba(238, 244, 250, 0.8);
}


.nav-links {
    display: grid;
    gap: 0.65rem;
}

.nav-links a {
    padding: 0.85rem 1rem;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.55), rgba(151, 27, 47, 0.12));
    border: 1px solid rgba(151, 27, 47, 0.3);
}

.sidebar-footer {
    margin-top: auto;
}

.main-content {
    padding: 2rem;
}

.shell-toolbar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 1rem;
}

.sidebar-toggle {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 14px;
    border: 1px solid rgba(151, 27, 47, 0.3);
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.78), rgba(151, 27, 47, 0.18));
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.sidebar-toggle:hover {
    transform: translateY(-1px);
    border-color: rgba(151, 27, 47, 0.55);
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.9), rgba(151, 27, 47, 0.24));
}

.sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: #f4edf0;
}

.main-content > * + * {
    margin-top: var(--space-section);
}

.hero,
.section-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: end;
    margin-bottom: 1.5rem;
}

.hero {
    padding: 2rem;
    border-radius: 28px;
    background:
        radial-gradient(circle at top right, rgba(18, 41, 78, 0.28), transparent 28%),
        linear-gradient(135deg, rgba(7, 8, 12, 0.98), rgba(25, 10, 15, 0.96) 58%, rgba(72, 12, 27, 0.92));
    color: #fff4f5;
    box-shadow: var(--shadow);
    border: 1px solid rgba(151, 27, 47, 0.32);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.76rem;
    color: var(--accent);
    margin-bottom: 0.4rem;
}

.lead {
    color: var(--muted);
    max-width: 70ch;
}

.hero .lead {
    color: rgba(247, 251, 255, 0.82);
}

.card,
.auth-card,
.stat-card {
    background: var(--paper);
    border-radius: 24px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(151, 27, 47, 0.18);
}

.card,
.stat-card {
    padding: 1.5rem;
}

.auth-scene {
    position: relative;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2.5rem;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(5, 7, 12, 0.42), rgba(61, 10, 24, 0.24)),
        url("/static/css/images/pizzashopbg.png");
    background-size: cover;
    background-position: center;
}

.auth-scene::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top left, rgba(17, 36, 68, 0.18), transparent 24%),
        linear-gradient(180deg, rgba(7, 8, 12, 0.22), rgba(35, 8, 14, 0.18));
    pointer-events: none;
}

.auth-card {
    max-width: 760px;
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    gap: 1.5rem;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(7, 8, 12, 0.46), rgba(32, 13, 20, 0.34));
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.auth-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(5, 7, 12, 0.26), rgba(90, 12, 29, 0.12));
    pointer-events: none;
}

.auth-card > * {
    position: relative;
    z-index: 1;
}

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

.form-grid h2,
.form-grid .errorlist,
.form-grid .helptext,
.form-grid textarea {
    grid-column: 1 / -1;
}

.sheet-layout {
    display: grid;
    gap: var(--space-card);
}

.summary-shell {
    display: grid;
    gap: var(--space-card);
}

.sheet-sections {
    display: grid;
    gap: var(--space-card);
}

.workspace-dashboard {
    display: grid;
    gap: var(--space-card);
}

.workspace-hero {
    margin-bottom: 0;
    padding: 2.2rem 2.3rem;
    border-radius: 30px;
    background:
        radial-gradient(circle at top right, rgba(151, 27, 47, 0.32), transparent 28%),
        radial-gradient(circle at top left, rgba(17, 36, 68, 0.26), transparent 24%),
        linear-gradient(135deg, rgba(7, 8, 12, 0.99), rgba(19, 14, 27, 0.97), rgba(52, 10, 20, 0.95));
    color: #fff4f5;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.32);
    border: 1px solid rgba(151, 27, 47, 0.26);
}

.workspace-hero .lead {
    color: rgba(247, 251, 255, 0.82);
    max-width: 58rem;
    margin-bottom: 0;
}

.workspace-section {
    display: grid;
    gap: 1rem;
}

.workspace-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-card);
}

.workspace-panel {
    display: block;
    background: linear-gradient(180deg, #17181d 0%, #1b1218 100%);
    border: 1px solid rgba(38, 59, 99, 0.26);
    border-radius: 24px;
    box-shadow: 0 16px 35px rgba(0, 0, 0, 0.24);
    padding: 1.4rem 1.45rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.workspace-panel:hover {
    transform: translateY(-3px);
    box-shadow: 0 22px 40px rgba(0, 0, 0, 0.32);
    border-color: rgba(151, 27, 47, 0.55);
}

.workspace-panel strong {
    display: block;
    margin: 0.55rem 0 0.55rem;
    font-family: var(--font-heading);
    font-size: 1.28rem;
    line-height: 1.2;
    color: #f4d7db;
}

.workspace-panel p {
    margin: 0;
    color: #c3a8ad;
    line-height: 1.6;
    font-size: 0.98rem;
}

.workspace-kicker {
    display: inline-flex;
    align-items: center;
    padding: 0.32rem 0.72rem;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(17, 36, 68, 0.32), rgba(151, 27, 47, 0.2));
    color: #f0c7ce;
    font-size: 0.82rem;
    font-weight: 700;
}

.workspace-section .section-head {
    margin-bottom: 0;
    align-items: center;
}

.workspace-section .section-head h2 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.1;
    color: #f3eaea;
}

.workspace-section .eyebrow {
    margin-bottom: 0.45rem;
}

.workspace-panel-stock {
    background: linear-gradient(180deg, #151922 0%, #1b1015 100%);
}

.workspace-panel-accounting {
    background: linear-gradient(180deg, #17151a 0%, #221017 100%);
}

.workspace-panel-report {
    background: linear-gradient(180deg, #131924 0%, #170d12 100%);
}

.workspace-grid .workspace-panel:only-child {
    max-width: 420px;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-card);
    margin-top: 1rem;
}

.summary-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 1.1rem 1.2rem;
    display: grid;
    gap: 0.35rem;
}

.summary-card span {
    color: var(--muted);
    font-size: 0.9rem;
}

.summary-card strong {
    font-size: 1.15rem;
    font-family: var(--font-heading);
    color: var(--ink);
}

.workspace-link {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.workspace-link:hover {
    transform: translateY(-2px);
}

.hero-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.toolbar-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    align-items: end;
}

.toolbar-submit {
    display: flex;
    align-items: end;
}

.stock-table-shell {
    display: grid;
    gap: var(--space-card);
}

.stock-order-cards {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    align-items: start;
    gap: var(--space-card);
    margin-bottom: 0.5rem;
}

.stock-table {
    min-width: 980px;
}

.stock-table-card {
    max-width: 100%;
    max-height: 68vh;
    overflow: auto;
    position: relative;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #101114;
}

.stock-table th {
    position: sticky;
    top: 0;
    background: var(--paper);
    z-index: 1;
    box-shadow: inset 0 -1px 0 var(--line);
}

.stock-table thead th {
    white-space: nowrap;
}

.stock-order-cards .summary-card {
    padding: 1rem 1.1rem;
    gap: 0.75rem;
    min-height: auto;
}

.stock-order-cards .summary-card label {
    margin-bottom: 0;
}

.stock-order-cards .summary-input,
.stock-order-cards .calc-pill.summary-static {
    width: 100%;
    max-width: 160px;
    min-height: 56px;
}

.stock-order-cards .summary-input {
    font-size: 1.1rem;
    font-weight: 700;
}

.number-input {
    width: 100%;
    min-width: 72px;
    max-width: 110px;
    text-align: center;
}

.summary-input {
    max-width: 150px;
}

.center-text {
    text-align: center;
}

.item-cell {
    min-width: 180px;
    font-weight: 600;
}

.calc-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(17, 36, 68, 0.18), rgba(151, 27, 47, 0.16));
    color: #f1cdd2;
    font-weight: 600;
}

.summary-static {
    width: 100%;
}

.success-pill {
    background: #1d2c22;
    color: #bde0c4;
}

.info-pill {
    background: #2a1519;
    color: #f0b8c1;
}

.warn-pill {
    background: #341417;
    color: #ffb1bc;
}

.sheet-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.account-summary-card {
    padding: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-card);
    margin: 1.5rem 0;
}

.stat-card span {
    color: var(--muted);
    display: block;
    margin-bottom: 0.45rem;
}

.stat-card strong {
    font-size: 2rem;
    color: var(--ink);
}

.list-grid {
    display: grid;
    gap: var(--space-card);
}

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

.item-grid {
    display: grid;
    grid-template-columns: 70px 2fr 1.2fr 1.2fr 1.2fr 110px 130px 1.4fr 70px;
    gap: 0.75rem;
    align-items: start;
    margin-bottom: 0.8rem;
}

.item-grid-header {
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.delete-cell {
    display: grid;
    place-items: center;
    min-height: 48px;
}

.primary-button,
.ghost-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.9rem 1.3rem;
    border-radius: 999px;
    transition: transform 0.2s ease, background 0.2s ease;
}

.primary-button {
    background: var(--accent);
    color: #fff;
}

.primary-button:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
}

.ghost-button {
    background: linear-gradient(135deg, rgba(17, 36, 68, 0.2), rgba(151, 27, 47, 0.16));
    color: #f0cfd3;
}

.messages {
    margin-bottom: 1rem;
}

.message {
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: var(--success);
    color: #d4ebda;
}

.table-card {
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.auth-switch,
.inline-errors,
.errorlist {
    color: #9a2f2f;
}

.helptext {
    display: block;
    margin-top: 0.35rem;
    color: var(--muted);
}

#account-summary-form .form-grid input,
#account-summary-form .form-grid select {
    max-width: 240px;
    padding: 0.7rem 0.8rem;
}

#account-summary-form .line-row,
#account-summary-form .custom-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px;
    gap: 0.75rem;
    align-items: center;
    width: 100%;
}

#account-summary-form .input-list,
#account-summary-form .custom-rows {
    display: grid;
    gap: 0.7rem;
}

#account-summary-form .line-row > span {
    display: block;
    min-width: 0;
}

#account-summary-form .line-row > input,
#account-summary-form .custom-row > input {
    width: 120px !important;
    max-width: 120px !important;
    min-width: 120px;
    justify-self: end;
    padding: 0.45rem 0.65rem;
}

#account-summary-form .custom-row {
    grid-template-columns: minmax(0, 1fr) 120px auto;
}

#account-summary-form .custom-row > input:first-child {
    width: 100% !important;
    max-width: none !important;
    min-width: 0;
    justify-self: stretch;
}

#account-summary-form .custom-row > input:last-of-type {
    width: 120px !important;
    max-width: 120px !important;
}

@media (max-width: 1024px) {
    .page-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        gap: 1rem;
        padding: 1.25rem 1rem;
    }

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

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

    .main-content {
        padding: 1.25rem;
    }

    .nav-links {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    .stock-table-card {
        max-height: none;
    }

    #account-summary-form .line-row,
    #account-summary-form .custom-row {
        grid-template-columns: 1fr;
    }

    #account-summary-form .line-row input,
    #account-summary-form .custom-row input {
        width: 100%;
        justify-self: stretch;
    }
}

@media (max-width: 720px) {
    body {
        overflow-x: hidden;
    }

    .main-content {
        padding: 1rem;
    }

    .sidebar {
        padding: 1rem;
    }

    .hero,
    .section-head {
        flex-direction: column;
        align-items: stretch;
    }

    .hero,
    .card,
    .stat-card,
    .auth-card {
        padding: 1rem;
        border-radius: 18px;
    }

    .workspace-hero {
        padding: 1.5rem;
    }

    .workspace-section .section-head h2 {
        font-size: 1.7rem;
    }

    .summary-cards,
    .stats-grid,
    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .stock-order-cards {
        grid-template-columns: 1fr;
    }

    .toolbar-form,
    .hero-actions,
    .sheet-actions,
    .role-form-inline {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .toolbar-submit,
    .toolbar-submit .primary-button,
    .hero-actions > *,
    .sheet-actions > *,
    .role-form-inline > * {
        width: 100%;
    }

    .nav-links {
        grid-template-columns: 1fr;
    }

    .stock-table {
        min-width: 820px;
    }

    th,
    td {
        padding: 0.75rem 0.6rem;
    }

    .item-cell {
        min-width: 140px;
    }

    .number-input,
    .summary-input {
        max-width: none;
    }

    .sheet-actions {
        justify-content: stretch;
    }
}
