:root {
    --primary: #1e4fd6;
    --primary-dark: #163dad;
    --primary-soft: #e8effc;
    --success: #0f7a3a;
    --success-soft: #e8f6ee;
    --danger: #c62828;
    --danger-soft: #fdecec;
    --warning: #c45c12;
    --warning-soft: #fff3e8;
    --neutral: #5b6b7c;
    --bg: #eef2f7;
    --bg-accent: #e4ebf5;
    --card: #ffffff;
    --text: #152033;
    --text-muted: #6b7a8c;
    --border: #d7e0ea;
    --shadow-sm: 0 1px 2px rgba(21, 32, 51, 0.04), 0 1px 3px rgba(21, 32, 51, 0.06);
    --shadow-md: 0 4px 16px rgba(21, 32, 51, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    color: var(--primary-dark);
}

/* ---------- Auth ---------- */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(ellipse 80% 50% at 10% -10%, rgba(30, 79, 214, 0.14), transparent 55%),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(15, 122, 58, 0.08), transparent 50%),
        linear-gradient(165deg, #dce6f4 0%, var(--bg) 48%, #e8edf5 100%);
}

.auth-wrapper {
    width: min(440px, 100%);
}

.auth-card {
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.auth-brand-mark {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 8px 20px rgba(30, 79, 214, 0.28);
}

.auth-card .form-control {
    min-height: 44px;
}

/* ---------- App shell ---------- */
.app-shell {
    min-height: 100vh;
    background: var(--bg);
}

.app-topbar {
    height: var(--topbar-height);
    background: linear-gradient(90deg, #1a3fb8 0%, var(--primary) 55%, #2563eb 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(21, 32, 51, 0.12);
    z-index: 1030;
}

.app-topbar .navbar-brand {
    font-weight: 700;
    letter-spacing: -0.02em;
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
}

.app-brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
}

.app-topbar-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.84rem;
}

.app-topbar-meta .user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
}

.app-topbar-meta .role-badge {
    background: #fff;
    color: var(--primary-dark);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.28rem 0.55rem;
}

.app-body {
    display: flex;
    min-height: calc(100vh - var(--topbar-height));
}

.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--topbar-height));
    position: sticky;
    top: var(--topbar-height);
    overflow: hidden;
}

.app-sidebar-scroll {
    overflow-y: auto;
    flex: 1;
    padding: 0.4rem 0.45rem 0.6rem;
}

.app-sidebar .nav-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.45rem 0.65rem 0.2rem;
}

.app-sidebar .nav-section {
    margin-top: 0.15rem;
}

.app-sidebar .nav-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.45rem 0.65rem;
    margin: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-sidebar .nav-section-toggle:hover {
    background: #f3f6fb;
    color: var(--text);
}

.app-sidebar .nav-section-chevron {
    font-size: 0.75rem;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.app-sidebar .nav-section.is-open .nav-section-chevron {
    transform: rotate(180deg);
}

.app-sidebar .nav-section-body {
    display: none;
    padding-left: 0.15rem;
}

.app-sidebar .nav-section.is-open .nav-section-body {
    display: block;
}

.app-sidebar .nav-link-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.38rem 0.65rem;
    margin-bottom: 1px;
    border-radius: var(--radius-sm);
    color: #334155;
    text-decoration: none;
    border: 0;
    background: transparent;
    width: 100%;
    text-align: left;
    font-size: 0.92rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-sidebar .nav-link-item i {
    width: 1.15rem;
    text-align: center;
    font-size: 1.05rem;
    opacity: 0.85;
}

.app-sidebar .nav-link-item:hover {
    background: #f3f6fb;
    color: var(--text);
}

.app-sidebar .nav-link-item.active {
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--primary);
}

.app-sidebar .nav-link-item.text-danger {
    color: var(--danger);
}

.app-sidebar .nav-link-item.text-danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.app-content {
    min-width: 0;
    flex: 1;
    padding: 1.35rem 1.5rem 2rem;
}

.page-header h1,
.page-header .h3 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.page-header .text-muted {
    color: var(--text-muted) !important;
}

/* ---------- Cards / tables / forms ---------- */
.card {
    border-radius: var(--radius);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.card.border-0.shadow-sm {
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-sm) !important;
}

.card-header {
    background: transparent;
    border-bottom-color: var(--border);
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: #3d4b5c;
    margin-bottom: 0.35rem;
}

.form-control,
.form-select {
    border-color: var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
}

.form-control:focus,
.form-select:focus {
    border-color: #93b4f5;
    box-shadow: 0 0 0 0.2rem rgba(30, 79, 214, 0.15);
}

.form-control-lg,
.form-select-lg {
    min-height: 46px;
}

.btn {
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.95rem;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}

.btn-outline-secondary {
    border-color: var(--border);
    color: #445466;
}

.btn-outline-secondary:hover {
    background: #f1f5f9;
    border-color: #c5d0dc;
    color: var(--text);
}

.table {
    --bs-table-hover-bg: #f5f8fc;
}

.table thead th {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
    background: #f7f9fc !important;
    border-bottom-color: var(--border);
}

.table td {
    vertical-align: middle;
    border-color: #e9eef4;
}

.table tbody tr.js-row-link {
    cursor: pointer;
}

.table tbody tr.js-row-link:focus-visible {
    outline: 2px solid var(--primary, #1e4fd6);
    outline-offset: -2px;
}

.badge {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.alert {
    border-radius: var(--radius-sm);
    border: 0;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background: var(--success-soft);
    color: #0b5c2c;
}

.alert-danger {
    background: var(--danger-soft);
    color: #8f1f1f;
}

.alert-warning {
    background: var(--warning-soft);
    color: #8a3f0a;
}

/* ---------- Dashboard ---------- */
.dashboard-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
    height: 100%;
}

.dashboard-card-link:hover,
.dashboard-card-link:focus-visible {
    color: inherit;
}

.dashboard-card-link:focus-visible .dashboard-card,
.dashboard-card-link:focus-visible .quick-stat {
    outline: 2px solid var(--primary, #1e4fd6);
    outline-offset: 2px;
}

.dashboard-card-link .quick-stat {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-card-link:hover .quick-stat {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md) !important;
}

.dashboard-card {
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md) !important;
}

.dashboard-card .icon-pill {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-top: 0.25rem;
}

.quick-stat {
    border-left: 3px solid var(--primary);
}

/* ---------- POS ---------- */
.pos-product-panel {
    max-height: 520px;
    overflow: auto;
}

.pos-product-panel .product-row {
    border-left: 3px solid transparent;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.pos-product-panel .product-row:hover {
    background: var(--primary-soft);
    border-left-color: var(--primary);
}

.pos-product-panel .product-row.is-out-of-stock {
    opacity: 0.85;
}

.pos-product-panel .product-row-details {
    cursor: pointer;
    color: inherit;
}

.pos-product-panel .product-row-details:hover .fw-semibold {
    color: var(--primary);
}

.pos-product-panel .product-add-btn {
    min-width: 2.5rem;
}

.pos-cart-summary {
    background: linear-gradient(180deg, #f8fafc 0%, #eef3f9 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.pos-grand-total {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary-dark);
}

#checkout-btn:not(:disabled) {
    box-shadow: 0 6px 16px rgba(15, 122, 58, 0.25);
}

/* ---------- Nav pills / filters ---------- */
.nav-pills .nav-link {
    border-radius: 999px;
    color: var(--neutral);
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.4rem 0.9rem;
}

.nav-pills .nav-link.active {
    background: var(--primary);
}

/* ---------- Sidebar toggle (mobile) ---------- */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: var(--topbar-height) 0 0 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 1020;
}

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

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: var(--topbar-height);
        bottom: 0;
        z-index: 1025;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        max-height: none;
        box-shadow: var(--shadow-md);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .app-content {
        padding: 1rem;
    }
}

@media (min-width: 992px) {
    .btn-sidebar-toggle {
        display: none !important;
    }
}

.card-header h2,
.card-header .h6 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

/* ---------- Dashboard product search ---------- */
.product-search-wrap {
    position: relative;
}

.product-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1050;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-height: 360px;
    overflow-y: auto;
}

.product-search-option {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: 0;
    border-bottom: 1px solid #eef2f7;
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: var(--text);
}

.product-search-option:last-child {
    border-bottom: 0;
}

.product-search-option:hover,
.product-search-option.is-active {
    background: var(--primary-soft);
}

.product-search-option .meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.product-search-option .price {
    font-weight: 700;
    white-space: nowrap;
}

.product-search-main {
    min-width: 0;
    flex: 1;
}

.product-search-name {
    margin-bottom: 0.2rem;
}

.product-search-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    margin-bottom: 0.15rem;
    font-size: 0.82rem;
    color: var(--text);
}

.product-search-details .label {
    color: var(--text-muted);
    font-weight: 600;
    margin-right: 0.2rem;
}

.product-search-aside {
    flex-shrink: 0;
}

.product-search-empty,
.product-search-loading {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ---------- Product form sections ---------- */
.product-form-sections {
    display: grid;
    gap: 1rem;
}

.product-form-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.product-form-section-head {
    padding: 0.85rem 1.15rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.product-form-section-body {
    padding: 1.15rem;
}

.product-form-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 1rem;
    padding: 1rem 0 0.25rem;
}

.product-image-upload {
    display: grid;
    gap: 0.55rem;
}

.product-image-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: #f8fafc;
    overflow: hidden;
}

.product-image-preview img {
    display: block;
    max-width: 100%;
    max-height: 160px;
    object-fit: contain;
}

.product-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.product-image-placeholder i {
    font-size: 1.6rem;
}

.product-status-radios {
    display: flex;
    align-items: center;
    min-height: 38px;
    gap: 0.25rem;
}

.basic-editor {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #fff;
}

.basic-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.basic-editor-btn {
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 0.35rem;
    background: transparent;
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.basic-editor-btn:hover,
.basic-editor-btn:focus-visible {
    background: #e8eef8;
    color: var(--primary-dark);
}

.basic-editor-sep {
    width: 1px;
    height: 1.1rem;
    background: var(--border);
    margin: 0 0.25rem;
}

.basic-editor-content {
    min-height: 140px;
    padding: 0.75rem 0.9rem;
    outline: none;
    font-size: 0.95rem;
    line-height: 1.5;
}

.basic-editor-content:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    pointer-events: none;
}

.basic-editor-content ul,
.basic-editor-content ol {
    margin: 0.35rem 0 0.35rem 1.2rem;
    padding: 0;
}

.product-description-html p {
    margin-bottom: 0.5rem;
}

.product-description-html ul,
.product-description-html ol {
    margin: 0.35rem 0 0.35rem 1.2rem;
}
