:root {
    --bg: #f8f5ef;
    --panel: #fffdf9;
    --ink: #2f2b29;
    --muted: #7b736b;
    --sidebar: #262a36;
    --sidebar-border: #343949;
    --accent: #de9118;
    --accent-dark: #b16c05;
    --line: #e5ddd1;
    --danger: #b73b2d;
    --success: #2e7d32;
    --shadow: 0 18px 35px rgba(47, 43, 41, 0.08);
    --radius: 18px;
    --radius-sm: 12px;
    --heading: Georgia, "Times New Roman", serif;
    --body: "Segoe UI", Tahoma, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--body);
    color: var(--ink);
    background:
        radial-gradient(circle at top right, rgba(222, 145, 24, 0.08), transparent 24%),
        linear-gradient(180deg, #fbf9f4 0%, #f4efe7 100%);
}

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

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

.sidebar {
    background: linear-gradient(180deg, #2a2f3c 0%, #232734 100%);
    color: #fefaf2;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--sidebar-border);
    transition: transform 0.28s ease, box-shadow 0.28s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 24px 22px;
    border-bottom: 1px solid var(--sidebar-border);
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-weight: 700;
    background: linear-gradient(135deg, #f2a11a, #cc7f0d);
    color: #2b2318;
}

.mobile-menu-toggle,
.mobile-menu-close,
.mobile-overlay {
    display: none;
}

.mobile-menu-toggle {
    width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 14px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    box-shadow: none;
}

.mobile-menu-toggle span {
    width: 18px;
    height: 2px;
    background: #fff9f0;
    border-radius: 999px;
    display: block;
}

.mobile-menu-close {
    margin-left: auto;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 10px;
    font-size: 24px;
    line-height: 1;
    box-shadow: none;
}

.mobile-overlay {
    position: fixed;
    inset: 0;
    border: 0;
    background: rgba(17, 20, 28, 0.48);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
    z-index: 8;
}

.brand strong,
.topbar h1,
.card h2,
.stat-card h3,
.print-title {
    font-family: var(--heading);
}

.brand span,
.topbar p,
.muted,
small {
    color: rgba(255, 250, 242, 0.72);
}

.menu {
    padding: 14px;
    display: grid;
    gap: 8px;
}

.menu-item {
    padding: 13px 14px;
    border-radius: 12px;
    color: #f2ece2;
    transition: 0.2s ease;
}

.menu-item:hover,
.menu-item.active {
    background: linear-gradient(90deg, #e89618, #d6860e);
    color: #2b2318;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16);
}

.sidebar-footer {
    margin-top: auto;
    padding: 18px 22px;
    border-top: 1px solid var(--sidebar-border);
    display: grid;
    gap: 8px;
    color: rgba(255, 250, 242, 0.65);
    font-size: 13px;
}

.content {
    padding: 0 26px 26px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 24px 0 20px;
    border-bottom: 1px solid var(--line);
}

.topbar h1 {
    margin: 0 0 6px;
    font-size: 2.2rem;
}

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

.user-chip {
    min-width: 180px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
}

.user-chip small {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}

.grid {
    display: grid;
    gap: 20px;
}

.grid.stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 24px;
}

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

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

.card,
.stat-card,
.table-card,
.hero,
.print-card {
    background: rgba(255, 253, 249, 0.92);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card,
.table-card,
.hero,
.print-card {
    padding: 20px;
}

.stat-card {
    padding: 22px;
    min-height: 118px;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: auto -35px -35px auto;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(222, 145, 24, 0.18), transparent 70%);
}

.stat-card h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 500;
}

.stat-card strong {
    display: block;
    margin-top: 26px;
    font-size: 2.2rem;
    font-family: var(--heading);
}

.hero {
    margin-top: 20px;
    padding: 26px;
}

.hero h2,
.card h2,
.table-card h2 {
    margin-top: 0;
    font-size: 1.75rem;
}

.alert {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
}

.alert-success {
    background: rgba(46, 125, 50, 0.08);
    color: var(--success);
}

.alert-error {
    background: rgba(183, 59, 45, 0.08);
    color: var(--danger);
}

form {
    margin: 0;
}

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

.field {
    display: grid;
    gap: 8px;
    grid-column: span 12;
}

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

label {
    font-size: 14px;
    color: #4f473e;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border-radius: 12px;
    border: 1px solid #dacdbd;
    background: #fffdfa;
    color: var(--ink);
    padding: 12px 14px;
    font: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(222, 145, 24, 0.14);
}

textarea {
    min-height: 130px;
    resize: vertical;
}

.btn,
button {
    cursor: pointer;
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 700;
    background: linear-gradient(90deg, #d58710, #e49b1b);
    color: #fff9f0;
    box-shadow: 0 10px 22px rgba(213, 135, 16, 0.18);
}

.btn.secondary {
    background: #fff9f0;
    color: var(--ink);
    border: 1px solid var(--line);
    box-shadow: none;
}

.actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.table-card {
    margin-top: 20px;
}

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

th,
td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin: 24px 0 18px;
    flex-wrap: wrap;
}

.toolbar .search {
    min-width: min(100%, 320px);
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 28px 16px;
}

.cards-row {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.doc-card {
    padding: 22px;
    border-radius: var(--radius);
    background: rgba(255, 252, 246, 0.95);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    min-height: 136px;
    display: grid;
    place-items: center;
    text-align: center;
}

.doc-card span {
    color: var(--muted);
}

.preview-box {
    min-height: 320px;
    border: 1px dashed #ddcba9;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255,250,242,0.8), rgba(255,255,255,0.6));
    padding: 18px;
}

.preview-label {
    width: 62mm;
    min-height: 35mm;
    margin: 0 auto;
    background: white;
    color: black;
    border: 1px solid #000;
    padding: 5mm 4mm;
    font-size: 12px;
}

.print-layout {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px;
    background: white;
    color: black;
}

.print-header {
    display: flex;
    gap: 18px;
    align-items: center;
    padding-bottom: 18px;
    border-bottom: 2px solid #000;
    margin-bottom: 22px;
}

.print-header img {
    width: 84px;
    height: 84px;
    object-fit: contain;
}

.print-title {
    text-align: center;
    font-size: 1.8rem;
    margin: 16px 0 20px;
}

.print-body {
    line-height: 1.8;
    font-size: 1rem;
    text-align: justify;
    white-space: pre-line;
}

.print-footer {
    margin-top: 42px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.receipt-copy {
    border: 1px dashed #000;
    padding: 18px;
    margin-bottom: 16px;
}

.inline-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.badge {
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(222, 145, 24, 0.12);
    color: #935a07;
    font-size: 13px;
    font-weight: 600;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card {
    width: min(100%, 440px);
    background: rgba(255, 252, 248, 0.95);
    border: 1px solid var(--line);
    border-radius: 26px;
    box-shadow: var(--shadow);
    padding: 30px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.login-brand .brand-mark {
    width: 52px;
    height: 52px;
}

@media (max-width: 1100px) {
    .grid.stats,
    .cards-row,
    .grid.cols-2,
    .grid.cols-3 {
        grid-template-columns: 1fr 1fr;
    }
}

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

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(86vw, 320px);
        z-index: 10;
        box-shadow: 0 24px 40px rgba(0, 0, 0, 0.28);
        transform: translateX(-100%);
        border-right: 1px solid var(--sidebar-border);
    }

    body.menu-open {
        overflow: hidden;
    }

    body.menu-open .sidebar {
        transform: translateX(0);
    }

    body.menu-open .mobile-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-menu-toggle,
    .mobile-menu-close,
    .mobile-overlay {
        display: flex;
    }

    .content {
        padding: 0 16px 20px;
    }

    .topbar {
        align-items: flex-start;
        padding: 18px 0 16px;
        gap: 12px;
    }

    .topbar h1 {
        font-size: 1.85rem;
    }

    .topbar-right {
        margin-left: auto;
    }

    .user-chip {
        min-width: 0;
        padding: 10px 12px;
    }

    .brand {
        padding-right: 16px;
    }

    .menu {
        overflow-y: auto;
        padding-bottom: 24px;
    }

    .form-grid,
    .grid.stats,
    .cards-row,
    .grid.cols-2,
    .grid.cols-3 {
        grid-template-columns: 1fr;
    }

    .field,
    .span-2,
    .span-3,
    .span-4,
    .span-5,
    .span-6,
    .span-7,
    .span-8,
    .span-12 {
        grid-column: span 1;
    }
}

@media print {
    body {
        background: white;
    }

    .no-print {
        display: none !important;
    }

    .print-layout {
        padding: 0;
        max-width: none;
    }
}
