:root {
    --app-ink: #17231d;
    --app-muted: #66756d;
    --app-primary: #147d55;
    --app-primary-dark: #0d5b3d;
    --app-primary-soft: #e7f5ee;
    --app-bg: #f4f7f5;
    --app-panel: #ffffff;
    --app-border: #dfe7e2;
    --app-danger: #c2413b;
    --app-shadow: 0 12px 34px rgba(23, 35, 29, .07);
}

html, body { font-family: Inter, sans-serif; color: var(--app-ink); background: var(--app-bg); }
body { font-size: 14px; }
.wrapper { background: var(--app-bg); }
.left-sidebar { background: #10251c !important; box-shadow: 8px 0 28px rgba(6, 25, 17, .12); }
.app-brand { height: 82px; background: #0b1d16 !important; border-bottom: 1px solid rgba(255,255,255,.07); }
.app-brand a { display: flex; align-items: center; gap: 12px; width: 100%; padding: 18px 20px; }
.brand-mark { display: grid; flex: 0 0 46px; place-items: center; width: 46px; height: 46px; padding: 4px; border-radius: 13px; background: #fff; overflow: hidden; }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.2; color: white; }
.brand-copy strong { font-size: 15px; letter-spacing: -.01em; }
.brand-copy small { margin-top: 3px; color: #94b5a6; font-size: 11px; }
.nav-section-label { padding: 24px 28px 8px; color: #6f9583; font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.sidebar .sidebar-inner {
    margin-top: 4px !important;
    padding-top: 0;
}
.sidebar .nav > li > a { margin: 3px 14px; padding: 12px 14px; border-radius: 10px; color: #bad0c5; }
.sidebar .nav > li > a i { color: #86aa99; font-size: 20px; }
.sidebar .nav > li.active > a, .sidebar .nav > li > a:hover { color: #fff; background: rgba(116, 214, 164, .14); }
.sidebar .nav > li.active > a i { color: #7ee0ab; }
.sidebar .sub-menu > li > a, .sidebar .sub-menu a { color: #9ebbac; }
.sidebar .sub-menu > li > a:hover { color: #fff; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-footer a { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; color: #a9c4b7; }
.sidebar-footer a:hover { color: #fff; background: rgba(255,255,255,.06); }

.main-header {
    height: 76px;
    background: rgba(255,255,255,.94);
    border-bottom: 1px solid var(--app-border);
    backdrop-filter: blur(12px);
}
.main-header .navbar {
    display: flex;
    align-items: center;
    height: 76px;
    min-height: 76px;
    padding: 0 28px;
}
.main-header .sidebar-toggle {
    align-self: center;
    margin: 0;
}
.header-context { display: flex; flex-direction: column; margin-left: 18px; line-height: 1.3; }
.header-context .eyebrow { color: var(--app-muted); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.header-context strong { color: var(--app-ink); font-size: 16px; }
.main-header .navbar-right {
    display: flex;
    align-items: center;
    height: 76px;
    margin-left: auto;
}
.main-header .navbar-nav,
.main-header .user-menu {
    display: flex;
    align-items: center;
    height: 76px;
    margin: 0;
}
.main-header .user-menu .nav-link,
.main-header .user-menu .dropdown-toggle {
    display: flex !important;
    align-items: center !important;
    gap: 10px;
    width: auto !important;
    height: 76px !important;
    min-height: 76px;
    margin: 0;
    padding: 0 12px !important;
    color: var(--app-ink) !important;
    line-height: 1.2;
    white-space: nowrap;
}
.user-avatar {
    display: inline-flex !important;
    flex: 0 0 36px;
    align-items: center;
    justify-content: center;
    width: 36px !important;
    height: 36px !important;
    margin: 0 !important;
    border-radius: 12px;
    color: #fff;
    background: var(--app-primary);
    font-weight: 700;
    line-height: 36px;
}
.user-avatar-lg { width: 46px; height: 46px; flex: 0 0 46px; }
.dropdown-header { display: flex; align-items: center; gap: 12px; }
.dropdown-header div:last-child { display: flex; flex-direction: column; }
.dropdown-header small { color: var(--app-muted); }

.content-wrapper {
    min-height: calc(100vh - 132px);
    padding: 30px;
    background: var(--app-bg);
}
.content-wrapper > .container-fluid, .content-wrapper > .container { max-width: 1500px; padding: 0 !important; margin: 0 auto; }
.content-wrapper .p-5 { padding: 0 !important; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading h1 { margin: 0 0 6px; color: var(--app-ink); font-size: 26px; font-weight: 700; letter-spacing: -.035em; }
.page-heading p { margin: 0; color: var(--app-muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.card { border: 1px solid var(--app-border); border-radius: 16px; background: var(--app-panel); box-shadow: var(--app-shadow); }
.card-header { min-height: 68px; padding: 20px 24px; border-bottom: 1px solid var(--app-border); background: transparent; }
.card-header h2, .card-header h4, .card-header h5 { margin: 0; color: var(--app-ink); font-size: 17px; font-weight: 700; letter-spacing: -.02em; text-transform: none; }
.card-body { padding: 24px; }
.card-footer { border-top: 1px solid var(--app-border); }

.btn { min-height: 40px; padding: 9px 16px; border-radius: 10px; font-weight: 600; box-shadow: none; }
.btn-primary { border-color: var(--app-primary); background: var(--app-primary); }
.btn-primary:hover, .btn-primary:focus { border-color: var(--app-primary-dark); background: var(--app-primary-dark); }
.btn-outline-primary { color: var(--app-primary); border-color: #9dcbb6; }
.btn-outline-primary:hover { border-color: var(--app-primary); background: var(--app-primary); }
.btn-warning { color: #76580a; border-color: #f3d686; background: #fff8df; }
.btn-danger { border-color: #da5f58; background: #da5f58; }

label { margin-bottom: 7px; color: #32443b; font-weight: 600; }
.form-control, select.form-control, .dropdown__selected { min-height: 43px; border: 1px solid #ccd8d1; border-radius: 9px; color: var(--app-ink); background: #fff; }
.form-control:focus { border-color: var(--app-primary); box-shadow: 0 0 0 3px rgba(20,125,85,.12); }
.form-control::placeholder { color: #9aa8a0; }
.select2-container--default .select2-selection--single { height: 43px; border-color: #ccd8d1; border-radius: 9px; }

.table-responsive { width: 100%; }
.table { margin-bottom: 0; color: #33443c; }
.table thead th { padding: 13px 16px; border-top: 0; border-bottom: 1px solid var(--app-border); color: #718078; background: #f8faf9; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.table tbody td { padding: 15px 16px; border-top: 1px solid #edf1ef; vertical-align: middle; }
.table tbody tr:hover { background: #f8fbf9; }
.table .dropdown-menu { min-width: 150px; }
.empty-state { padding: 48px 20px !important; color: var(--app-muted); text-align: center; }

/* Invoice entry has more fields than the standard grid can comfortably hold
   beside the fixed sidebar. Reflow it before controls begin to overlap. */
.invoice-card { width: 100%; min-width: 0; }
.invoice-create-page .card-header,
.invoice-create-page .card-body { min-width: 0; }
.invoice-create-page .form-row > [class*="col-"] { min-width: 0; margin-bottom: 14px; }
.invoice-create-page .form-control { width: 100%; }
.invoice-items-table { margin-top: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.invoice-items-table .table { min-width: 720px; }

.app-alert { max-width: 1500px; margin: 0 auto 20px; border: 0; border-radius: 12px; box-shadow: var(--app-shadow); }
.alert-success { color: #155b3e; background: #e5f5ed; }
.alert-danger { color: #8c2f2b; background: #fdebea; }
.alert ul { margin: 8px 0 0; }
.badge-soft-success { padding: 6px 9px; border-radius: 999px; color: #126044; background: var(--app-primary-soft); font-size: 11px; font-weight: 700; }

.stat-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { padding: 20px; border: 1px solid var(--app-border); border-radius: 15px; background: #fff; box-shadow: var(--app-shadow); }
.stat-card span { color: var(--app-muted); font-size: 12px; font-weight: 600; }
.stat-card strong { display: block; margin-top: 8px; color: var(--app-ink); font-size: 25px; letter-spacing: -.04em; }
.gallery-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; }
.gallery-card { position: relative; overflow: hidden; aspect-ratio: 4 / 3; border-radius: 14px; background: #dce5e0; box-shadow: var(--app-shadow); }
.gallery-card img { width: 100%; height: 100%; object-fit: cover; }
.gallery-card form { position: absolute; top: 10px; right: 10px; }
.gallery-card .btn { min-height: 36px; padding: 6px 10px; }

.copyright { padding: 18px 28px; color: var(--app-muted); background: #fff; border-top: 1px solid var(--app-border); }

/* Keep dialogs above Sleek's fixed sidebar (z-index: 1060). */
.modal { z-index: 2000 !important; }
.modal-backdrop { z-index: 1990 !important; }
.modal-dialog { margin-top: 28px; margin-bottom: 28px; }
.modal-content { border: 0; border-radius: 16px; box-shadow: 0 24px 70px rgba(9, 25, 17, .28); }
.modal-header { align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--app-border); }
.modal-body { padding: 24px; }

@media (max-width: 1199px) {
    .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .invoice-create-page .invoice-summary-form > [class*="col-"],
    .invoice-create-page .invoice-item-form > [class*="col-"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
    .invoice-create-page .form-row > .form-group.text-right {
        display: flex;
        align-items: flex-end;
        justify-content: flex-start;
        gap: 10px;
        padding-top: 0 !important;
    }
}
@media (max-width: 767px) {
    .content-wrapper { padding: 20px 14px; }
    .main-header .navbar { padding: 0 14px; }
    .header-context { display: none; }
    .page-heading { flex-direction: column; }
    .page-actions, .page-actions .btn { width: 100%; }
    .stat-grid, .gallery-grid { grid-template-columns: 1fr; }
    .card-header, .card-body { padding: 18px; }
    .invoice-create-page .invoice-summary-form > [class*="col-"],
    .invoice-create-page .invoice-item-form > [class*="col-"] {
        flex-basis: 100%;
        max-width: 100%;
    }
    .invoice-create-page .form-row > .form-group.text-right .btn { flex: 1 1 0; }
}

.auth-page { min-height: 100vh; margin: 0; background: #eaf0ec; }
.auth-shell { display: grid; grid-template-columns: minmax(360px, .9fr) minmax(420px, 1.1fr); width: min(1120px, calc(100% - 40px)); min-height: 680px; margin: 40px auto; overflow: hidden; border-radius: 24px; background: #fff; box-shadow: 0 30px 80px rgba(16,37,28,.18); }
.auth-brand-panel { display: flex; flex-direction: column; justify-content: space-between; padding: 48px; color: #d6e8df; background: radial-gradient(circle at 20% 10%, rgba(101,211,154,.28), transparent 36%), #10251c; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand > span:last-child { display: flex; flex-direction: column; }
.auth-brand strong { color: #fff; font-size: 16px; }
.auth-brand small { color: #91b3a3; }
.auth-kicker { color: #7ee0ab; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.auth-brand-panel h1 { max-width: 480px; margin: 14px 0 18px; color: #fff; font-size: clamp(34px, 4vw, 52px); font-weight: 700; line-height: 1.07; letter-spacing: -.05em; }
.auth-brand-panel p { max-width: 440px; margin: 0; color: #a9c3b7; font-size: 15px; line-height: 1.75; }
.auth-form-panel { display: grid; place-items: center; padding: 48px; }
.auth-form-wrap { width: min(420px, 100%); }
.auth-form-wrap h2 { margin: 0 0 8px; color: var(--app-ink); font-size: 30px; font-weight: 700; letter-spacing: -.04em; }
.auth-form-wrap > p { margin-bottom: 32px; color: var(--app-muted); }
.auth-form-wrap .form-group { margin-bottom: 20px; }
.auth-form-wrap .form-control { min-height: 48px; }
.auth-form-wrap .btn { min-height: 48px; margin-top: 8px; }
.auth-back { display: inline-block; margin-top: 24px; color: var(--app-muted); font-weight: 600; }
.auth-back:hover { color: var(--app-primary); }
@media (max-width: 800px) {
    .auth-shell { grid-template-columns: 1fr; margin: 20px auto; }
    .auth-brand-panel { min-height: 300px; padding: 32px; }
    .auth-brand-panel h1 { font-size: 34px; }
    .auth-form-panel { padding: 38px 28px; }
}
