:root {
    --sidebar-bg: #0f172a;
    --sidebar-fg: #cbd5e1;
    --accent: #2563eb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f1f5f9;
    color: #0f172a;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
    color: var(--accent);
}

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

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    transition: width .22s ease, padding .22s ease, transform .22s ease;
}

.sidebar-toggle {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-toggle svg {
    width: 19px;
    height: 19px;
}

.sidebar-backdrop {
    display: none;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    margin-bottom: 24px;
    padding: 0 8px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
}

.sidebar .nav-link {
    color: var(--sidebar-fg);
    border-radius: 8px;
    padding: 9px 12px;
    margin-bottom: 3px;
    font-size: .92rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar .nav-link:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
}

.sidebar .nav-link.active {
    background: var(--accent);
    color: #fff;
}

.sidebar .nav {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    flex-wrap: nowrap;
    align-items: stretch;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, .45) transparent;
}

.sidebar .nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar .nav::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, .45);
    border-radius: 3px;
}

.sidebar .nav > .nav-link,
.sidebar .menu-tree-group {
    width: 100%;
}

.menu-tree-group {
    margin-bottom: 2px;
}

.menu-tree-group > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.menu-tree-group > summary::-webkit-details-marker {
    display: none;
}

.sidebar .tree-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    font: inherit;
}

.sidebar .tree-toggle.active-parent {
    background: rgba(37, 99, 235, .22);
    color: #fff;
}

.sidebar .tree-toggle:focus-visible {
    outline: 2px solid rgba(96, 165, 250, .9);
    outline-offset: 1px;
}

.tree-label {
    flex: 1;
    min-width: 0;
}

.tree-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-left: auto;
}

.tree-chevron {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    transition: transform .18s ease;
}

.menu-tree-group[open] .tree-chevron {
    transform: rotate(0deg);
}

.menu-tree-group:not([open]) .tree-chevron {
    transform: rotate(-90deg);
}

.tree-subnav {
    margin-left: 8px;
    padding: 2px 0 4px 10px;
    border-left: 1px solid rgba(203, 213, 225, .16);
}

.tree-subnav .nav-link {
    padding: 7px 10px 7px 14px;
    margin-bottom: 1px;
    font-size: .88rem;
}

.sidebar-user-link {
    margin-top: 10px;
    font-size: .88rem;
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px 8px 4px;
    border-top: 1px solid rgba(255, 255, 255, .1);
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 20px 28px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.content {
    padding: 24px 28px 40px;
}

.card {
    border: 0;
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}

.stat-card .stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.2;
}

.table > :not(caption) > * > * {
    padding: .65rem .75rem;
}

.thumb {
    width: 46px;
    height: 46px;
    object-fit: cover;
    border-radius: 8px;
    background: #e2e8f0;
}

.thumb-lg {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 10px;
    background: #e2e8f0;
}

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a, #1e3a8a);
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 390px;
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}

.auth-card .brand-mark {
    width: 46px;
    height: 46px;
    font-size: 1.3rem;
}

.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: #64748b;
}

.photo-tile {
    position: relative;
}

.photo-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

@media (max-width: 860px) {
    .app-shell {
        flex-direction: row;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 1045;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        padding: 20px 14px;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform .22s ease;
    }

    body.sidebar-open {
        overflow: hidden;
    }

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

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .55);
        z-index: 1040;
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .brand {
        margin-bottom: 24px;
    }

    .sidebar .nav {
        flex-direction: column !important;
        flex-wrap: nowrap;
        overflow: visible;
    }

    .menu-tree-group {
        flex: none;
    }

    .tree-subnav {
        margin-left: 8px;
        padding-left: 10px;
    }

    .sidebar-user-link {
        margin-top: 10px;
    }

    .sidebar-footer {
        margin-top: auto;
        margin-left: 0;
        border-top: 1px solid rgba(255, 255, 255, .1);
        padding: 14px 8px 4px;
    }

    .sidebar-footer .small,
    .sidebar-footer .fw-semibold {
        display: block;
    }

    .main {
        width: 100%;
    }

    .topbar,
    .content {
        padding-left: 16px;
        padding-right: 16px;
    }
}

@media (min-width: 861px) {
    .app-shell.sidebar-collapsed .sidebar {
        width: 0;
        padding-left: 0;
        padding-right: 0;
        overflow: hidden;
    }

    .app-shell.sidebar-collapsed .sidebar > * {
        opacity: 0;
        pointer-events: none;
    }
}

/* ---- Nota / invoice ---- */
.print-body {
    background: #e2e8f0;
    margin: 0;
}

.print-toolbar {
    max-width: 820px;
    margin: 18px auto 0;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.invoice-paper {
    max-width: 820px;
    margin: 18px auto 40px;
    background: #fff;
    padding: 38px 42px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
    border-radius: 8px;
    color: #0f172a;
    font-size: .9rem;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 16px;
}

.invoice-company {
    font-size: 1.35rem;
    font-weight: 800;
}

.invoice-company-meta {
    color: #475569;
    font-size: .82rem;
    margin-top: 4px;
}

.invoice-title {
    text-align: right;
}

.invoice-word {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: .18em;
}

.invoice-number {
    color: #475569;
}

.paid-stamp {
    margin-top: 8px;
    display: inline-block;
    border: 2px solid #16a34a;
    color: #16a34a;
    padding: 2px 10px;
    border-radius: 6px;
    font-weight: 800;
    letter-spacing: .12em;
    transform: rotate(-6deg);
}

.paid-stamp.cancelled {
    border-color: #64748b;
    color: #64748b;
}

.invoice-meta {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin: 20px 0;
}

.invoice-label {
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .08em;
    color: #64748b;
    font-weight: 700;
    margin-bottom: 4px;
}

.invoice-customer {
    font-weight: 700;
}

.invoice-dates table th {
    text-align: left;
    font-weight: 400;
    color: #64748b;
    padding: 2px 16px 2px 0;
}

.invoice-dates table td {
    text-align: right;
    padding: 2px 0;
}

.invoice-table {
    width: 100%;
    margin: 10px 0 0;
    font-size: .88rem;
}

.invoice-table th {
    background: #f1f5f9;
    border-bottom: 1px solid #cbd5e1;
    padding: 8px;
}

.invoice-table td {
    border-bottom: 1px solid #e2e8f0;
    padding: 8px;
    vertical-align: top;
}

.invoice-item-meta {
    color: #64748b;
    font-size: .75rem;
}

.invoice-bottom {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    margin-top: 18px;
}

.invoice-terbilang {
    flex: 1;
    font-size: .82rem;
}

.invoice-totals table {
    width: 260px;
}

.invoice-totals th {
    text-align: left;
    font-weight: 400;
    color: #475569;
    padding: 3px 12px 3px 0;
}

.invoice-totals td {
    text-align: right;
    padding: 3px 0;
}

.invoice-grand th,
.invoice-grand td {
    border-top: 1px solid #0f172a;
    padding-top: 8px;
    font-weight: 800;
}

.invoice-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 48px;
    gap: 24px;
}

.invoice-signatures > div {
    width: 200px;
    text-align: center;
}

.invoice-sign-space {
    height: 60px;
}

.invoice-sign-name {
    border-top: 1px solid #94a3b8;
    padding-top: 6px;
    font-size: .82rem;
}

.invoice-footer {
    margin-top: 28px;
    border-top: 1px solid #e2e8f0;
    padding-top: 10px;
    text-align: center;
    color: #64748b;
    font-size: .78rem;
}

@media (max-width: 640px) {
    .invoice-paper {
        padding: 22px 18px;
        margin: 12px;
    }

    .invoice-header,
    .invoice-meta,
    .invoice-bottom {
        flex-direction: column;
    }

    .invoice-title,
    .invoice-dates table td {
        text-align: left;
    }

    .invoice-totals table {
        width: 100%;
    }
}

@media print {
    @page {
        size: A4;
        margin: 12mm;
    }

    body.print-body {
        background: #fff;
    }

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

    .invoice-paper {
        box-shadow: none;
        margin: 0;
        padding: 0;
        max-width: none;
        border-radius: 0;
    }

    .invoice-table th {
        background: #f1f5f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
