:root {
    --primary: #2563eb;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --sidebar: #111827;
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #172033;
    --muted: #667085;
    --border: #e5e7eb;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.10), transparent 32rem),
        var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

body.dark-mode {
    --bg: #0b1120;
    --card: #121a2c;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #23304a;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

a { text-decoration: none; }

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    background: linear-gradient(180deg, #111827 0%, #0b1220 100%);
    color: #f9fafb;
    display: flex;
    flex-direction: column;
    padding: 18px;
    z-index: 1040;
    transition: transform 0.22s ease;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 22px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 12px;
}

.brand-title { font-weight: 800; line-height: 1.05; }
.brand-subtitle { color: #9ca3af; font-size: 12px; margin-top: 3px; }

.sidebar-nav { display: grid; gap: 6px; }

.sidebar .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #cbd5e1;
    border-radius: 10px;
    padding: 10px 12px;
    font-weight: 600;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.10);
    transform: translateX(2px);
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #9ca3af;
    font-size: 13px;
    padding: 14px 10px 4px;
}

.sidebar-footer a { color: #dbeafe; font-weight: 700; }

.status-dot, .notify-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--success);
    display: inline-flex;
}

.main-wrap {
    width: 100%;
    min-width: 0;
    margin-left: 280px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 28px;
    background: rgba(245, 247, 251, 0.78);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(229, 231, 235, 0.7);
}

.dark-mode .topbar { background: rgba(11, 17, 32, 0.82); border-color: var(--border); }

.top-search {
    flex: 1;
    max-width: 560px;
    position: relative;
}

.top-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.top-search input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px 12px 42px;
    background: var(--card);
    color: var(--text);
    outline: none;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.icon-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.notify-dot {
    position: absolute;
    right: 10px;
    top: 9px;
    width: 7px;
    height: 7px;
}

.notification-menu {
    width: min(360px, calc(100vw - 24px));
    border-radius: 16px;
    border: 1px solid var(--border);
}

.notification-item {
    white-space: normal;
    display: grid;
    gap: 3px;
}

.notification-item small {
    color: var(--muted);
}

.user-chip {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    border-radius: 14px;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px 5px 5px;
}

.user-chip img, .avatar-fallback {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    object-fit: cover;
}

.avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dbeafe;
    color: var(--primary);
    font-weight: 800;
}

.user-chip small { display: block; color: var(--muted); font-size: 11px; text-align: left; }

.content {
    padding: 28px;
    max-width: 1600px;
    margin: 0 auto;
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.eyebrow {
    color: var(--primary);
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.page-heading h1 {
    margin: 3px 0 0;
    font-size: 28px;
    font-weight: 800;
}

.page-heading p { margin: 6px 0 0; color: var(--muted); }

.erp-card {
    background: var(--card);
    border: 1px solid rgba(229, 231, 235, 0.76);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.dark-mode .erp-card { border-color: var(--border); }

.metric-card {
    padding: 18px;
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    content: "";
    position: absolute;
    right: -24px;
    top: -24px;
    width: 90px;
    height: 90px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.10);
}

.metric-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    background: #dbeafe;
    font-size: 20px;
}

.metric-label { margin-top: 16px; color: var(--muted); font-weight: 700; font-size: 13px; }
.metric-value { font-size: 25px; font-weight: 800; margin-top: 3px; }

.chart-card { padding: 20px; min-height: 340px; }
.chart-card canvas { max-height: 280px; }
.map-panel { min-height: 420px; overflow: hidden; }
#areaMap, #dashboardMap { min-height: 380px; border-radius: 16px; }

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    vertical-align: middle;
}

.table thead th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom-color: var(--border);
}

.table tbody td { border-color: var(--border); }

.badge-soft {
    border-radius: 999px;
    padding: 0.42rem 0.62rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.badge-soft.primary { background: #dbeafe; color: #1d4ed8; }
.badge-soft.success { background: #dcfce7; color: #15803d; }
.badge-soft.danger { background: #fee2e2; color: #b91c1c; }
.badge-soft.warning { background: #fef3c7; color: #b45309; }
.badge-soft.secondary { background: #eef2f7; color: #475569; }

.filter-bar, .form-panel {
    padding: 18px;
    margin-bottom: 20px;
}

.btn {
    border-radius: 12px;
    font-weight: 700;
}

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

.form-control, .form-select {
    border-radius: 12px;
    border-color: var(--border);
    min-height: 42px;
    background-color: var(--card);
    color: var(--text);
}

.form-label { font-weight: 700; color: var(--text); }
.text-muted { color: var(--muted) !important; }

.receipt-thumb {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--border);
}

.skeleton {
    min-height: 18px;
    border-radius: 10px;
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.20), rgba(148, 163, 184, 0.08), rgba(148, 163, 184, 0.20));
    background-size: 220% 100%;
    animation: shimmer 1.3s infinite;
}

@keyframes shimmer { to { background-position: -220% 0; } }

.empty-state {
    text-align: center;
    padding: 42px 20px;
    color: var(--muted);
}

.empty-state i {
    font-size: 42px;
    color: #cbd5e1;
    display: block;
    margin-bottom: 12px;
}

.timeline {
    position: relative;
    display: grid;
    gap: 14px;
}

.timeline-item {
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 12px;
}

.timeline-dot {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dbeafe;
    color: var(--primary);
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        linear-gradient(145deg, rgba(37, 99, 235, 0.14), rgba(22, 163, 74, 0.08)),
        var(--bg);
}

.login-wrap { width: 100%; max-width: 440px; text-align: center; }
.login-logo { width: 64px; height: 64px; border-radius: 18px; object-fit: contain; margin-bottom: 16px; }
.login-title { font-size: 30px; font-weight: 800; margin: 0; }
.login-subtitle { color: var(--muted); margin: 8px 0 22px; }
.login-card { padding: 26px; text-align: left; }
.login-footer { margin-top: 18px; color: var(--muted); font-size: 13px; }

.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); width: 272px; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.42);
        z-index: 1035;
    }
    .main-wrap { margin-left: 0; }
    .topbar { padding: 12px 16px; }
    .content { padding: 18px; }
    .page-heading { flex-direction: column; }
    .top-search { max-width: none; }
}

@media (max-width: 575.98px) {
    .brand-logo { width: 32px; height: 32px; }
    .top-search { display: none; }
    .content { padding: 14px; }
    .page-heading h1 { font-size: 23px; }
    .chart-card { padding: 16px; min-height: 300px; }
    .table-responsive { border-radius: 16px; }
}
