:root {
    --brand: #0d6efd;
    --brand-soft: #eff5ff;
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --page-bg: #f4f7f6;
    --card-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    --radius: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: var(--page-bg);
    color: #1e293b;
}

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

/* Auth / Login */
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 45%, #e2e8f0 100%);
    padding: 24px;
}

.auth-card {
    width: min(460px, 100%);
    border: 0;
    border-radius: 24px;
    box-shadow: var(--card-shadow);
}

.auth-brand .brand-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, #0d6efd, #14b8a6);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.4rem;
}

/* Admin shell */
body.admin-layout {
    margin: 0;
    background: var(--page-bg);
    color: #1e293b;
}

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

.sidebar {
    width: 270px;
    min-width: 270px;
    background: var(--sidebar-bg);
    color: #fff;
    padding: 20px 16px;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1030;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.08);
}

.admin-main {
    flex: 1;
    margin-left: 270px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.admin-topbar {
    background: #fff;
    border-bottom: 1px solid #e8edf3;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
}

.topbar-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.topbar-subtitle {
    color: #64748b;
    font-size: 0.88rem;
    margin-top: 2px;
}

.topbar-right {
    flex-shrink: 0;
}

.btn-icon-only {
    width: 42px;
    height: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.profile-dropdown {
    margin-left: 4px;
}

.profile-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 6px 12px 6px 6px;
    box-shadow: none;
}

.profile-toggle:hover,
.profile-toggle:focus,
.profile-toggle.show {
    background: #fff;
    border-color: #cbd5e1;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.profile-toggle::after {
    margin-left: 4px;
}

.profile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb, #14b8a6);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.profile-meta {
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
    text-align: left;
}

.profile-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #0f172a;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-role {
    font-size: 0.72rem;
    color: #64748b;
    font-weight: 500;
}

.profile-menu {
    min-width: 220px;
    border: 1px solid #e8edf3;
    border-radius: 14px;
    padding: 8px;
    margin-top: 10px !important;
}

.profile-menu .dropdown-item {
    border-radius: 10px;
    padding: 10px 12px;
    font-weight: 500;
}

.profile-menu .dropdown-item:hover {
    background: #f1f5f9;
}

.profile-menu .dropdown-header {
    padding: 10px 12px 6px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding: 8px 10px;
}

.sidebar-brand .brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2563eb, #14b8a6);
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.sidebar-brand small,
.brand-text small {
    color: var(--sidebar-text);
    font-size: 0.76rem;
}

.sidebar-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
    padding: 14px 14px 8px;
    margin-top: 6px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 12px;
    color: var(--sidebar-text);
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 0.92rem;
    transition: all 0.2s ease;
}

.sidebar-nav a span {
    white-space: nowrap;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: #1e293b;
    color: #fff;
}

.sidebar-nav a.active {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.22);
}

.sidebar-nav a i {
    width: 18px;
    text-align: center;
    font-size: 0.95rem;
}

.main-content {
    padding: 24px;
    flex: 1;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.topbar h2 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
}

.topbar .muted {
    color: #64748b;
    font-size: 0.92rem;
}

.dashboard-welcome {
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid #e8edf3;
}

.content-card {
    background: #fff;
    border: 0;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    padding: 22px;
}

.page-card,
.report-card {
    background: #fff;
    border: 0;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
}

.page-card .card-header,
.report-card .card-header {
    background: #fff;
    border-bottom: 1px solid #eef2f7;
    padding: 18px 22px;
}

.page-card .card-body,
.report-card .card-body {
    padding: 22px;
}

.icon-box {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card {
    background: #fff;
    border: 0;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    padding: 22px;
    height: 100%;
}

.stat-card .label {
    color: #64748b;
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #0f172a;
}

.stat-card .icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
}

.icon-primary { background: #dbeafe; color: #1d4ed8; }
.icon-success { background: #dcfce7; color: #15803d; }
.icon-warning { background: #fef3c7; color: #b45309; }
.icon-info { background: #e0f2fe; color: #0369a1; }

.table-modern {
    margin-bottom: 0;
}

.table-modern thead th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    border-bottom-width: 1px;
    background: #f8fafc;
}

.table-modern tbody td {
    vertical-align: middle;
    padding: 14px 12px;
}

.badge-role {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 999px;
}

.alert-app {
    border: 0;
    border-radius: 14px;
    font-weight: 500;
}

.installer-page,
.installer {
    min-height: 100vh;
    padding: 34px 20px;
    background: linear-gradient(135deg, #f8fafc, #dbeafe);
}

.install-wrap {
    width: min(920px, 100%);
    margin: 0 auto;
}

.install-steps,
.steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 18px 0;
}

.install-step,
.step {
    padding: 12px;
    border-radius: 14px;
    background: #e2e8f0;
    text-align: center;
    font-weight: 700;
    font-size: 0.82rem;
}

.install-step.active,
.step.active {
    background: var(--brand);
    color: #fff;
}

.mobile-sidebar-btn {
    display: none;
}

@media (max-width: 991.98px) {
    .sidebar {
        left: -290px;
        transition: left 0.25s ease;
    }

    .sidebar.show {
        left: 0;
    }

    .admin-main {
        margin-left: 0;
    }

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

    .sidebar-backdrop.show {
        display: block;
    }

    .mobile-sidebar-btn {
        display: inline-flex;
    }

    .main-content {
        padding: 16px;
    }

    .admin-topbar {
        padding: 12px 16px;
    }

    .install-steps,
    .steps {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Legacy page compatibility */
.muted { color: #64748b; }

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

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

.card.panel,
.card.stat {
    background: #fff;
    border: 0;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    padding: 22px;
}

.card.stat b {
    font-size: 1.8rem;
}

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.input,
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 0.95rem;
}

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

.table th,
.table td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

.badge {
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 0.75rem;
    font-weight: 700;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 1060;
}

.modal-backdrop.show,
.modal-backdrop .modal.show {
    display: flex;
}

.modal-backdrop .modal {
    background: #fff;
    border-radius: 18px;
    box-shadow: var(--card-shadow);
    width: min(560px, 96vw);
    padding: 22px;
    display: block;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.modal-head .close {
    border: 0;
    background: #e2e8f0;
    border-radius: 10px;
    width: 34px;
    height: 34px;
    cursor: pointer;
}

.receipt,
.label-preview {
    font-family: monospace;
    background: #fff;
    padding: 15px;
}

.receipt { width: 300px; }
.label-preview {
    border: 1px dashed #64748b;
    width: 260px;
}

@media (max-width: 991.98px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

@media print {
    .sidebar,
    .admin-topbar,
    .topbar,
    .no-print,
    .btn,
    .mobile-sidebar-btn {
        display: none !important;
    }

    .admin-main {
        margin-left: 0;
    }

    .app-shell {
        display: block;
    }

    .main-content {
        padding: 0;
    }

    .content-card,
    .stat-card,
    .card.panel,
    .card.stat {
        box-shadow: none;
        border: 0;
    }
}
