:root {
    --sidebar-bg: #0d332f;
    --sidebar-bg-hover: #134540;
    --sidebar-active: #1a5e57;
    --sidebar-text: #cfe4e1;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 240px;
    --topbar-h: 60px;
    --teal-primary: #0d332f;
    --teal-dark: #082823;
    --brand-accent: #3b82f6;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background: #f3f5f7;
    color: #1f2937;
}

/* ============================ */
/* SIDEBAR                       */
/* ============================ */
.app-body { min-height: 100vh; }

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    color: #fff;
    font-size: 1.05rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-brand .brand-icon {
    color: var(--brand-accent);
    font-size: 1.35rem;
    margin-right: 0.55rem;
}

.sidebar-brand .brand-text { letter-spacing: 0.2px; }
.sidebar-brand .brand-text strong { color: #fff; font-weight: 700; }

.sidebar-nav {
    padding: 0.75rem 0.5rem;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    color: var(--sidebar-text);
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    margin-bottom: 2px;
    font-size: 0.92rem;
    text-decoration: none;
    transition: background 0.15s;
}

.sidebar-nav .nav-link i { width: 22px; font-size: 1rem; margin-right: 0.6rem; }
.sidebar-nav .nav-link:hover { background: var(--sidebar-bg-hover); color: #fff; }
.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    font-weight: 600;
}
.sidebar-nav .nav-link.disabled { opacity: 0.55; pointer-events: none; }

/* ============================ */
/* TOP BAR                       */
/* ============================ */
.main-shell {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-h);
    background: var(--teal-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar-logo { display: flex; align-items: center; }
.topbar-logo i { font-size: 1.6rem; color: #fff; }
.topbar-logo .text-muted { color: rgba(255,255,255,0.85) !important; font-weight: 600; }

.topbar-right { display: flex; align-items: center; }
.topbar-right .company-name { color: #fff; font-weight: 500; }
.topbar-right .btn-outline-dark {
    background: transparent;
    color: #fff;
    border-color: rgba(255,255,255,0.4);
}
.topbar-right .btn-outline-dark:hover { background: rgba(255,255,255,0.1); color: #fff; }

.page-content { padding: 1.5rem 2rem 3rem; }

/* ============================ */
/* CARDS / PANELS                */
/* ============================ */
.panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.panel-header h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-teal {
    background: var(--teal-primary);
    color: #fff;
    border: none;
    font-weight: 500;
    padding: 0.4rem 1.1rem;
    border-radius: 6px;
}
.btn-teal:hover { background: var(--teal-dark); color: #fff; }

.btn-teal-outline {
    background: #fff;
    color: var(--teal-primary);
    border: 1px solid var(--teal-primary);
    font-weight: 500;
    padding: 0.4rem 1rem;
    border-radius: 6px;
}
.btn-teal-outline:hover { background: var(--teal-primary); color: #fff; }

/* ============================ */
/* DASHBOARD                     */
/* ============================ */
.insight-banner {
    background: linear-gradient(135deg, #6d4ed8 0%, #a368f0 100%);
    border-radius: 12px;
    padding: 1.25rem 1.75rem;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.insight-banner h3 {
    margin: 0;
    font-weight: 400;
    font-size: 1.5rem;
}
.insight-banner h3 .accent { color: #ffb36b; font-weight: 700; }
.insight-banner .subtitle { font-size: 0.85rem; opacity: 0.8; margin-top: 0.2rem; }

.insight-banner .form-label {
    color: rgba(255,255,255,0.9);
    font-size: 0.8rem;
    margin-bottom: 0.15rem;
}
.insight-banner .form-control { min-width: 140px; }

.stat-card {
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    color: #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    min-height: 100px;
}
.stat-card .label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    opacity: 0.95;
    margin-bottom: 0.35rem;
}
.stat-card .value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
}
.stat-card.orange { background: linear-gradient(135deg, #ff8258 0%, #ff6f61 100%); }
.stat-card.cyan   { background: linear-gradient(135deg, #3db7c9 0%, #4ea0c0 100%); }
.stat-card.green  { background: linear-gradient(135deg, #34c774 0%, #22a368 100%); }
.stat-card.purple { background: linear-gradient(135deg, #8a62d8 0%, #a368f0 100%); }

.fbr-card {
    background: #fff;
    border-radius: 10px;
    padding: 0.9rem 1rem;
    border-left: 4px solid transparent;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    min-width: 0;
}
.fbr-card .caption {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #6b7280;
    text-transform: uppercase;
    margin-bottom: 0.15rem;
}
.fbr-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
}
.fbr-card .bar { height: 5px; background: #e5e7eb; border-radius: 999px; margin-top: 0.45rem; overflow: hidden; }
.fbr-card .bar > span { display: block; height: 100%; border-radius: 999px; }
.fbr-card.yellow  { border-left-color: #f4c542; }
.fbr-card.yellow .bar > span { background: #f4c542; }
.fbr-card.purple  { border-left-color: #7e3fbf; }
.fbr-card.purple .bar > span { background: #7e3fbf; }
.fbr-card.red     { border-left-color: #e53e3e; }
.fbr-card.red .bar > span { background: #e53e3e; }

/* ============================ */
/* TABLE                         */
/* ============================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.data-table thead th {
    background: #0e2f2b;
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid #1a423e;
    text-align: left;
    vertical-align: middle;
}
.data-table tbody td {
    border: 1px solid #e5e7eb;
    padding: 0.7rem 0.85rem;
    font-size: 0.88rem;
    color: #1f2937;
    vertical-align: middle;
}
.data-table tbody tr:hover { background: #f9fafb; }
.data-table .action-btn {
    background: none;
    border: none;
    padding: 2px 6px;
    color: #3b82f6;
}
.data-table .action-btn.delete { color: #e53e3e; }
.data-table .action-cell { white-space: nowrap; }
.data-table .action-cell .action-btn { padding: 2px 4px; }
.data-table td.mono { font-family: 'Courier New', monospace; }

.data-table tfoot td {
    background: #f9fafb;
    border-top: 2px solid #e5e7eb;
    padding: 0.6rem 0.85rem;
}

.party-preview {
    min-height: 1.1rem;
    font-size: 0.8rem;
}
.party-preview:not(:empty) {
    background: #f9fafb;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
}
.invoice-line .line-children {
    border-top: 1px dashed #e5e7eb;
    padding-top: 1rem;
}

.pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.pill-green { background: #dcfce7; color: #166534; }
.pill-gray  { background: #e5e7eb; color: #374151; }

.record-header {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px 10px 0 0;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
}
.record-header h4 { margin: 0; font-size: 1.1rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }

.filters-bar {
    background: #fff;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
    padding: 1rem 1.25rem;
}

/* ============================ */
/* MODAL                         */
/* ============================ */
.modal-header.teal {
    background: var(--teal-primary);
    color: #fff;
    border-bottom: none;
}
.modal-header.teal .btn-close { filter: brightness(0) invert(1); }
.modal-header.teal .modal-title {
    display: flex; align-items: center; gap: 0.5rem; font-weight: 500;
}
.modal-header.teal .modal-title i { color: #c27cf4; }

.form-label-sm {
    font-size: 0.8rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

/* ============================ */
/* AUTH                          */
/* ============================ */
.auth-body { background: #f3f5f7; min-height: 100vh; margin: 0; }

.auth-split { display: flex; min-height: 70vh; }
.auth-hero {
    flex: 1;
    background-image: linear-gradient(135deg, rgba(30,64,175,0.2), rgba(30,64,175,0.1)),
        url('https://images.unsplash.com/photo-1464822759023-fed622ff2c3b?w=1600&auto=format&fit=crop&q=70');
    background-size: cover;
    background-position: center;
    min-height: 500px;
    position: relative;
}
.auth-hero-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-hero-title {
    font-size: 2.5rem;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
    font-weight: 300;
}

.auth-panel {
    flex: 0 0 450px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: #fff;
}
.auth-form-wrap { width: 100%; max-width: 340px; }
.auth-logo { display: flex; align-items: center; gap: 0.5rem; font-size: 1.25rem; }
.auth-logo i { font-size: 1.5rem; }

.auth-tiles { background: #f3f5f7; padding: 1.25rem 3rem; }
.auth-tiles .tile {
    background: #f3f5f7;
    padding: 1rem 1.25rem;
    border: 1px solid transparent;
    font-size: 0.92rem;
}
.auth-tiles .tile-text { color: #4b5563; font-size: 0.85rem; }

/* ============================ */
/* UTIL                          */
/* ============================ */
.alert-thin { padding: 0.55rem 1rem; font-size: 0.88rem; margin-bottom: 1rem; }

@@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
    .sidebar.open { transform: translateX(0); }
    .main-shell { margin-left: 0; }
}
