:root {
    --bg: #F0F2F5;
    --surface: #FFFFFF;
    --navy: #1A1A2E;
    --navy-hover: #15213E;
    --blue: #2F6FED;
    --blue-soft: rgba(47, 111, 237, 0.12);
    --orange: #D9822B;
    --teal: #0C8599;
    --green: #1E8449;
    --red: #C0392B;
    --ink: #1A1A2E;
    --ink-2: #6B7280;
    --ink-3: #9AA1AD;
    --line: rgba(26, 26, 46, 0.09);
    --r-lg: 18px;
    --r-md: 14px;
    --r-sm: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.tnum {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

body {
    display: flex;
    min-height: 100vh;
    background-color: #f0f2f5;
}

.sidebar{
    width: 200px;
    background-color: #1a1a2e;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    height: 100vh;
    position: sticky;
    top: 0;
}

.sidebar > a,
.nav-item > a {
    color: #ffffff;
    text-decoration: none;
    padding: 12px 20px;
    font-size: 14px;
    display: block;
}

.sidebar > a:hover,
.nav-item > a:hover {
    background-color: #15213e;
}

.sidebar > a.active,
.nav-item > a.active,
.nav-item ul li a.active {
    background-color: var(--navy-hover);
    position: relative;
}

.sidebar > a.active::before,
.nav-item > a.active::before,
.nav-item ul li a.active::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--blue);
}

.sidebar a:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: -2px;
}

#logout {
    margin-top: auto;
    font-size: 10px;
    text-align: center;
}
#company-logo {
    font-size: 19px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#company-logo img,
.brand img {
    height: 28px;
    width: 28px;
}

.main{
    flex: 1;
    height: 100vh;
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 24px;
    padding: 30px 32px;
    background-color: #f0f2f5;
    overflow-y: auto;
}

body:has(#sidebar) {
    font-family: 'Plus Jakarta Sans', sans-serif;
}

body:has(#sidebar) h1,
body:has(#sidebar) h2,
body:has(#sidebar) h3,
body:has(#sidebar) h4,
body:has(#sidebar) h5,
body:has(#sidebar) h6 {
    font-weight: 700;
    letter-spacing: -0.01em;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--r-lg);
    padding: 18px 22px;
    margin-bottom: 6px;
    box-shadow: 0 1px 3px rgba(26, 26, 46, 0.06);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    position: sticky;
    top: 20px;
    z-index: 5;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .dashboard-header {
        background-color: var(--surface);
        border-color: var(--line);
    }
}

.dashboard-header h2 {
    font-size: 19px;
    margin-bottom: 2px;
}

.dashboard-greet {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
}

.dashboard-greet h5 {
    font-size: 13px;
}

.dashboard-greet p {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink-2);
    margin: 0;
}

.who {
    display: flex;
    align-items: center;
    gap: 11px;
}

.who .nm {
    font-size: 13px;
    font-weight: 600;
    text-align: right;
}

.who .nm small {
    display: block;
    margin-top: 2px;
    color: var(--ink-3);
    font-weight: 500;
    font-size: 11px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #1a1a2e;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0;
}

.chart-wrapper {
    position: relative;
    height: 250px;
    min-height: 150px;
    width: 100%;
}

/* ===== LOADER ===== */
.loader {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    transform: rotateZ(45deg);
    perspective: 1000px;
    color: var(--blue);
}

.loader::before,
.loader::after {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: inherit;
    height: inherit;
    border-radius: 50%;
    transform: rotateX(70deg);
    animation: pv-loader-spin 1s linear infinite;
}

.loader::after {
    color: var(--navy);
    transform: rotateY(70deg);
    animation-delay: 0.4s;
}

@keyframes pv-loader-spin {
    0%, 100% { box-shadow: 0.2em 0px 0 0px currentcolor; }
    12% { box-shadow: 0.2em 0.2em 0 0 currentcolor; }
    25% { box-shadow: 0 0.2em 0 0px currentcolor; }
    37% { box-shadow: -0.2em 0.2em 0 0 currentcolor; }
    50% { box-shadow: -0.2em 0 0 0 currentcolor; }
    62% { box-shadow: -0.2em -0.2em 0 0 currentcolor; }
    75% { box-shadow: 0px -0.2em 0 0 currentcolor; }
    87% { box-shadow: 0.2em -0.2em 0 0 currentcolor; }
}

#pageLoader {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(240, 242, 245, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.2s ease;
}

#pageLoader.pv-hide {
    opacity: 0;
    pointer-events: none;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    #pageLoader {
        background: rgba(240, 242, 245, 0.92);
    }
}

@media (prefers-reduced-motion: reduce) {
    .loader::before,
    .loader::after {
        animation: none;
    }

    #pageLoader {
        transition: none;
    }
}

.section-label {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--ink-2);
    margin-bottom: 20px;
}

.card-body {
    display:flex;
    flex-direction: column;
    height: 100%;
    text-align: center;
    align-items: center;
    justify-content: center;
}

/* KPI CARDS */
.kpi-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 16px;
}

.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    min-width: 0;
}

.charts-row > div {
    min-width: 0;
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 22px;
    box-shadow: 0 1px 3px rgba(26, 26, 46, 0.05);
}

.kpi-card {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background-color: var(--surface);
    box-shadow: 0 1px 3px rgba(26, 26, 46, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 30px -18px rgba(26, 26, 46, 0.35);
}

.kpi-card .card-body {
    padding: 22px;
}

.kpi-card .card-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--ink-2);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.kpi-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background-color: var(--ink-3);
}

.kpi-blue .kpi-dot {
    background-color: var(--blue);
}

.kpi-orange .kpi-dot {
    background-color: var(--orange);
}

.kpi-teal-positive .kpi-dot {
    background-color: var(--teal);
}

.kpi-profit-positive .kpi-dot {
    background-color: var(--green);
}

.kpi-profit-negative .kpi-dot {
    background-color: var(--red);
}

.kpi-card h3 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}

.kpi-hero h3 {
    font-size: 2.25rem;
}

.kpi-blue {
    background-color: var(--surface);
    border-color: var(--line);
}

.kpi-blue h3 {
    color: var(--blue);
}

.kpi-orange {
    background-color: var(--surface);
    border-color: var(--line);
}

.kpi-orange h3 {
    color: var(--orange);
}

/* used for Estimated Profit (Today) when positive, kept distinct from the
   green Monthly Net Profit hero so two profit cards don't both read green */
.kpi-teal-positive {
    background-color: var(--surface);
    border-color: var(--line);
}

.kpi-teal-positive h3 {
    color: var(--teal);
}

.kpi-profit-positive {
    background-color: #e6f7ec;
    border-color: #b7e4c7;
}

.kpi-profit-positive h3 {
    color: var(--green);
}

.kpi-profit-negative {
    background-color: #fdecea;
    border-color: #f5b7b1;
}

.kpi-profit-negative h3 {
    color: var(--red);
}

@media (prefers-reduced-motion: reduce) {
    .kpi-card,
    .kpi-card:hover {
        transform: none;
        transition: none;
    }
}

@media (max-width: 900px) {
    .main {
        padding: 22px 18px;
    }

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

    .charts-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .kpi-row {
        grid-template-columns: 1fr;
    }
}

.nav-item {
    display:block;
    margin: 0;
    padding: 0;
}

.nav-item ul li a {
    font-size: 12px;
    padding: 8px 20px 8px 32px;
    color: #aaaaaa;
}

.nav-item ul li a:hover {
    background-color: #15213e;
    color: #ffffff;
}

.nav-item ul {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-item ul.open {
    max-height: 200px;
}

.form {
    flex: 1;
    padding: 40px;
    background-color: #f0f2f5;
    overflow-y: auto;
    width: 100%;
}
.form form {
    max-width: 600px;
    margin: 0 auto;
    background-color: white;
    padding: 32px;
    border-radius: 8px;
}

.content {
    flex: 1;
    display: flex;
    padding: 30px;
    background-color: #f0f2f5;
    overflow-y: auto;
    flex-direction: column;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.form-header {
    max-width: 600px;
    margin: 0 auto 20px;
}

/* ===== INVOICE PAGE ===== */
.invoice-paper {
    background: #ffffff;
    border-radius: 8px;
    padding: 48px;
    max-width: 720px;
    margin: 0 auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    font-size: 0.95rem;
    line-height: 1.6;
    overflow: hidden;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin: -48px -48px 32px;
    padding: 32px 48px 24px;
    background: #f8f9fa;
    border-bottom: 2px solid #1a1a2e;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.invoice-brand h3 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
}

.invoice-contact {
    margin-top: 6px;
    color: #6c757d;
    font-size: 0.8rem;
}

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

.invoice-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: #1a1a2e;
    margin-bottom: 12px;
}

.invoice-number {
    font-weight: 700;
    margin-bottom: 4px;
}

.invoice-date {
    color: #6c757d;
    margin-bottom: 10px;
}

.invoice-status {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #ffffff;
    background: #198754;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.invoice-billto {
    margin-bottom: 28px;
}

.invoice-billto .label {
    color: #6c757d;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.invoice-billto-name {
    font-size: 1.05rem;
    font-weight: 600;
}

.invoice-items {
    margin-bottom: 24px;
}

.invoice-items thead th {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    padding: 12px 14px;
}

.invoice-items tbody td {
    padding: 12px 14px;
}

.invoice-items th:first-child,
.invoice-items td:first-child {
    width: 40px;
}

.invoice-item-desc {
    display: block;
    color: #6c757d;
    font-size: 0.8rem;
}

.invoice-totals {
    margin-left: auto;
    max-width: 280px;
    margin-bottom: 32px;
}

.invoice-totals .row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

.invoice-totals .row:not(.grand-total) {
    color: #6c757d;
}

.invoice-totals .grand-total {
    border-top: 2px solid #1a1a2e;
    padding-top: 12px;
    font-size: 1.15rem;
    font-weight: 700;
}

.invoice-payment {
    margin-bottom: 32px;
    color: #495057;
}

.invoice-footer {
    border-top: 1px solid #dee2e6;
    padding-top: 20px;
    text-align: center;
    color: #6c757d;
    font-size: 0.8rem;
    line-height: 1.8;
}

/* ===== SIDEBAR UPGRADE CTA ===== */
#sidebar-upgrade-cta {
    margin: 8px 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(47,111,237,0.18) 0%, rgba(12,133,153,0.12) 100%);
    border: 1px solid rgba(47,111,237,0.35);
    border-radius: 12px;
}

#sidebar-upgrade-cta .upgrade-plan-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.45);
    text-transform: uppercase;
    margin: 0 0 5px;
}

#sidebar-upgrade-cta .upgrade-tagline {
    font-size: 11.5px;
    font-weight: 600;
    color: rgba(255,255,255,0.88);
    line-height: 1.4;
    margin: 0 0 10px;
}

#sidebar-upgrade-cta .upgrade-wa-btn {
    display: block;
    text-align: center;
    padding: 7px 10px;
    background: var(--blue);
    color: #fff !important;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 0.2px;
    transition: background 0.15s;
}

#sidebar-upgrade-cta .upgrade-wa-btn:hover {
    background: #1a5cd8;
}

/* ===== PRINT ===== */
@media print {
    .sidebar,
    .content-header,
    #modal,
    .no-print {
        display: none !important;
    }

    body,
    .content {
        display: block;
        padding: 0;
        background: #ffffff;
    }

    .invoice-paper {
        box-shadow: none;
        max-width: 100%;
        padding: 0;
    }

    .invoice-header {
        margin: 0 0 32px;
        padding: 0 0 24px;
        background: none;
    }
}
