/* ============================================================
   Caid & Moon Capital — Dark Luxury Fintech Dashboard
   ============================================================ */

:root {
    /* Palette */
    --bg-main:        #0B0D10;
    --bg-card:        #12161C;
    --bg-surface:     #181D24;
    --border:         #262C35;
    --text-primary:   #F5F5F5;
    --text-secondary: #8B95A5;
    --text-muted:     #5C6672;
    --green:          #34D39A;
    --green-soft:     rgba(52, 211, 154, 0.12);
    --gold:           #C9A55C;
    --gold-soft:      rgba(201, 165, 92, 0.14);

    /* Layout */
    --sidebar-w:      256px;
    --radius:         16px;
    --radius-sm:      10px;
    --shadow-card:    0 8px 30px rgba(0, 0, 0, 0.35);
    --shadow-hover:   0 12px 36px rgba(0, 0, 0, 0.5);

    --transition:     0.25s cubic-bezier(0.22, 0.61, 0.36, 1);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

ul {
    list-style: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

/* ---------- App shell ---------- */

.app {
    display: flex;
    min-height: 100vh;
}

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left var(--transition);
}

.content {
    padding: 28px 32px 12px;
    flex: 1;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition), width var(--transition);
    padding: 22px 16px 20px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px 26px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(145deg, var(--gold), #a8863e);
    color: #0B0D10;
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: 800;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(201, 165, 92, 0.25);
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-title {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    white-space: nowrap;
}

.brand-sub {
    font-size: 10px;
    letter-spacing: 0.32em;
    color: var(--gold);
    font-weight: 500;
    white-space: nowrap;
}

.drawer-close {
    display: none;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 6px;
}

.drawer-close:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
}

/* Navigation */

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0 12px;
    margin-bottom: 12px;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    transition: background var(--transition), color var(--transition);
    position: relative;
}

.nav-link:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--gold-soft);
    color: var(--gold);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    border-radius: 0 3px 3px 0;
    background: var(--gold);
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    opacity: 0.85;
}

/* Footer / profile */

.sidebar-footer {
    padding-top: 18px;
    border-top: 1px solid var(--border);
    margin-top: 18px;
}

.profile {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.profile:hover {
    background: var(--bg-surface);
}

.profile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--gold), #a8863e);
    color: #0B0D10;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.profile-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.profile-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-role {
    font-size: 11px;
    color: var(--text-secondary);
}

.profile-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-soft);
}

/* ============================================================
   Topbar / Header
   ============================================================ */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 28px 32px 20px;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.menu-toggle {
    display: none;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 8px;
    transition: background var(--transition), color var(--transition);
}

.menu-toggle:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.greeting-title {
    font-size: clamp(20px, 3vw, 28px);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.2;
}

.greeting-sub {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-top: 3px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.filter-segmented {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}

.filter-btn {
    padding: 7px 14px;
    border-radius: 7px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}

.filter-btn:hover {
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: inset 0 0 0 1px var(--border);
}

.notif-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition);
}

.notif-btn:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
}

.notif-dot {
    position: absolute;
    top: 9px;
    right: 10px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold);
}

/* ============================================================
   Cards (shared)
   ============================================================ */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 24px;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.card:hover {
    border-color: #313a46;
}

.card-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.card-sub {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.card-badge {
    font-size: 11px;
    font-weight: 500;
    color: var(--gold);
    background: var(--gold-soft);
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
    margin-top: 4px;
}

/* ============================================================
   KPI Cards
   ============================================================ */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.kpi-card {
    padding: 22px 22px 18px;
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.kpi-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-indicator {
    font-size: 12px;
    font-weight: 600;
}

.kpi-indicator.positive {
    color: var(--green);
    background: var(--green-soft);
    padding: 3px 8px;
    border-radius: 20px;
}

.kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    color: var(--text-secondary);
}

.kpi-value {
    font-size: clamp(24px, 3vw, 30px);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-top: 6px;
    color: var(--text-primary);
    line-height: 1.1;
}

.kpi-footer {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.kpi-subtext {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================================
   Charts
   ============================================================ */

.charts-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.chart-body {
    position: relative;
    height: 300px;
}

.chart-body canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ============================================================
   Bottom grid — activity + capital
   ============================================================ */

.bottom-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 20px;
    align-items: stretch;
}

.activity-card,
.capital-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.text-link {
    color: var(--gold);
    font-size: 12.5px;
    font-weight: 500;
    margin-top: 4px;
}

.text-link:hover {
    text-decoration: underline;
}

/* Table */

.table-wrap {
    overflow-x: auto;
    flex: 1;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table th {
    text-align: left;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0 12px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: var(--bg-surface);
}

.ta-right {
    text-align: right !important;
}

.muted {
    color: var(--text-secondary);
}

.amount.green {
    color: var(--green);
    font-weight: 600;
}

.cell-business {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.business-avatar {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--gold);
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.status-chip {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

.status-chip.completed {
    color: var(--green);
    background: var(--green-soft);
}

.status-chip.pending {
    color: var(--gold);
    background: var(--gold-soft);
}

/* Capital overview content */

.capital-stats {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
}

.capital-stat {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.capital-stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.capital-stat-label {
    font-size: 12.5px;
    color: var(--text-secondary);
    font-weight: 500;
}

.capital-stat-value {
    font-size: 15.5px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.capital-stat-value.green {
    color: var(--green);
}

.progress {
    width: 100%;
    height: 7px;
    background: var(--bg-surface);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 10px;
    transition: width 0.8s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.progress-bar.invested {
    background: linear-gradient(90deg, var(--gold), #d9b877);
}

.progress-bar.available {
    background: linear-gradient(90deg, var(--green), #5be0b0);
}

.progress-caption {
    font-size: 11px;
    color: var(--text-muted);
}

/* ============================================================
   Capital by Account — donut + legend
   ============================================================ */

.capital-account-section {
    margin-top: 20px;
}

.capital-account-card {
    padding: 26px;
    overflow: hidden;
    background:
        radial-gradient(1200px 500px at 15% -10%, rgba(201, 165, 92, 0.05), transparent 60%),
        var(--bg-card);
}

.capital-account-body {
    display: flex;
    align-items: center;
    gap: 36px;
}

.donut-wrap {
    position: relative;
    width: 280px;
    height: 280px;
    flex-shrink: 0;
}

.donut-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    text-align: center;
}

.donut-center-value {
    font-size: clamp(22px, 2.5vw, 27px);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.1;
}

.donut-center-label {
    margin-top: 3px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    color: var(--text-secondary);
}

.capital-account-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), transform var(--transition);
}

.legend-item:hover {
    border-color: #313a46;
    transform: translateX(3px);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.02);
}

.legend-item[data-index="0"] .legend-dot {
    background: var(--gold);
}

.legend-item[data-index="1"] .legend-dot {
    background: var(--green);
}

.legend-item[data-index="2"] .legend-dot {
    background: #7BA7D9;
}

.legend-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 0;
}

.legend-value {
    margin-left: auto;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.legend-pct {
    min-width: 52px;
    text-align: right;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .capital-account-body {
        flex-direction: column;
        align-items: center;
        gap: 28px;
    }

    .capital-account-legend {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .donut-wrap {
        width: 230px;
        height: 230px;
    }
}

/* ============================================================
   Capital page — overview layout
   ============================================================ */

.capital-overview-section {
    margin-top: 20px;
}

.capital-overview-section .capital-card {
    padding: 26px;
}

.capital-overview-section .capital-stats {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
}

.capital-overview-section .capital-stat {
    flex: 1 1 200px;
    min-width: 180px;
    padding: 18px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

@media (max-width: 1100px) {
    .capital-overview-section .capital-stats {
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    .capital-overview-section .capital-stat {
        min-width: 0;
    }
}

/* ============================================================
   Footer
   ============================================================ */

.footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 32px 28px;
    font-size: 12px;
    color: var(--text-muted);
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
}

.footer-divider {
    opacity: 0.6;
}

/* ============================================================
   Drawer overlay (mobile)
   ============================================================ */

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 6, 8, 0.6);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
    z-index: 90;
}

.drawer-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1100px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .charts-grid,
    .bottom-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        width: min(var(--sidebar-w), 82vw);
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .drawer-close {
        display: flex;
    }

    .main {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .topbar {
        padding: 20px 20px 16px;
    }

    .content {
        padding: 20px 20px 8px;
    }
}

@media (max-width: 640px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .topbar-right {
        justify-content: space-between;
    }

    .filter-segmented {
        width: 100%;
    }

    .filter-btn {
        flex: 1;
        text-align: center;
        font-size: 12px;
        padding: 8px 6px;
    }

    .card {
        padding: 20px;
    }

    .chart-body {
        height: 260px;
    }

    .footer {
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }

    .footer-divider {
        display: none;
    }
}

/* ============================================================
   Scrollbar (subtle)
   ============================================================ */

::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #34404d;
}





/* ============================================================
   Businesses page
   ============================================================ */

/* Page heading / actions */
.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.page-title {
    font-size: clamp(22px, 3vw, 30px);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.2;
}

.page-sub {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Generic buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    transition: background var(--transition), border-color var(--transition),
                color var(--transition), transform var(--transition), box-shadow var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(145deg, var(--gold), #a8863e);
    color: #0B0D10;
    border: 1px solid transparent;
    box-shadow: 0 4px 16px rgba(201, 165, 92, 0.22);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(201, 165, 92, 0.32);
}

.btn-ghost {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    color: var(--text-primary);
    border-color: var(--gold);
    background: var(--bg-surface);
}

.btn-back {
    padding: 8px 14px;
    font-size: 12.5px;
}


/* Toolbar (search + filters) */
.businesses-card {
    padding: 22px;
}

.business-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.toolbar-search {
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 12px;
    color: var(--text-muted);
    min-width: 240px;
    flex: 1;
    max-width: 340px;
    transition: border-color var(--transition);
}

.toolbar-search:focus-within {
    border-color: var(--gold);
    color: var(--gold);
}

.toolbar-search svg {
    flex-shrink: 0;
}

.toolbar-input {
    flex: 1;
    width: 100%;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13.5px;
    padding: 10px 0;
    font-family: inherit;
}

.toolbar-input::placeholder {
    color: var(--text-muted);
}

.toolbar-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-field {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 10px;
    color: var(--text-muted);
    transition: border-color var(--transition);
}

.filter-field:focus-within {
    border-color: var(--gold);
    color: var(--gold);
}

.filter-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
}

.toolbar-select {
    background: none;
    border: none;
    outline: none;
    color: var(--text-secondary);
    font-size: 12.5px;
    font-family: inherit;
    padding: 10px 2px;
    cursor: pointer;
    max-width: 150px;
}

.toolbar-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Businesses table */
.businesses-table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.businesses-table {
    min-width: 860px;
}

.business-name {
    font-weight: 600;
    color: var(--text-primary);
}

.business-logo {
    width: 36px;
    height: 36px;
    font-size: 12.5px;
    background: linear-gradient(145deg, var(--gold-soft), transparent);
    border-color: rgba(201, 165, 92, 0.35);
    color: var(--gold);
}

.business-row {
    transition: background var(--transition), transform var(--transition);
    cursor: default;
}

.business-row:hover {
    background: var(--bg-surface);
}

.roi-cell {
    color: var(--gold);
    font-weight: 700;
}

.status-chip .status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    margin-right: 6px;
    box-shadow: 0 0 0 3px var(--green-soft);
}

.status-chip.inactive {
    color: var(--text-secondary);
    background: var(--bg-surface);
}

.status-chip.inactive .status-dot {
    background: var(--text-muted);
    box-shadow: 0 0 0 3px rgba(92, 102, 114, 0.18);
}

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--gold);
    font-weight: 600;
    font-size: 12.5px;
    white-space: nowrap;
    transition: color var(--transition), gap var(--transition);
}

.btn-link:hover {
    color: #e0bf7a;
    gap: 9px;
}

.empty-state {
    padding: 28px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13.5px;
}


/* ============================================================
   Business detail page
   ============================================================ */

.detail-heading {
    align-items: flex-end;
}

.detail-title-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.detail-avatar {
    gap: 14px;
}

.detail-avatar .business-logo {
    width: 46px;
    height: 46px;
    font-size: 15px;
}

.detail-name {
    margin: 0;
}

.detail-description {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 720px;
    margin: -10px 0 22px;
    line-height: 1.6;
}

.detail-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 22px;
}

.detail-metric {
    padding: 20px 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-metric:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.detail-metric-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    font-weight: 600;
}

.detail-metric-value {
    font-size: clamp(22px, 3vw, 27px);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.15;
    margin-top: 4px;
}

.detail-metric-value.green {
    color: var(--green);
}

.detail-metric-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.detail-chart-card {
    margin-bottom: 22px;
}

.detail-transactions-card {
    margin-bottom: 22px;
}

.transactions-table {
    min-width: 620px;
}

.type-chip {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

.type-chip.income {
    color: var(--green);
    background: var(--green-soft);
}

.type-chip.expense {
    color: var(--gold);
    background: var(--gold-soft);
}

.amount.red {
    color: #e56a5c;
    font-weight: 600;
}


/* ============================================================
   Add Business modal
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 6, 8, 0.7);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 200;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    padding: 24px;
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.modal-sub {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-top: 3px;
}

.modal-close {
    color: var(--text-muted);
    padding: 6px;
    border-radius: 8px;
    transition: background var(--transition), color var(--transition);
}

.modal-close:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-span-2 {
    grid-column: span 2;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}

.form-input:focus {
    border-color: var(--gold);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input option {
    background: var(--bg-card);
    color: var(--text-primary);
}

select.form-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238B95A5' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
}

.form-textarea {
    resize: vertical;
    min-height: 76px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 4px;
}

/* ============================================================
   Cash Flow page
   ============================================================ */

/* Summary cards */
.cashflow-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 22px;
}

.cashflow-stat {
    padding: 20px 22px 18px;
    display: flex;
    flex-direction: column;
}

.cashflow-stat:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.cashflow-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    color: var(--text-secondary);
}

.cashflow-stat-value {
    font-size: clamp(22px, 3vw, 28px);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.15;
    margin-top: 8px;
}

.cashflow-stat-value.cashflow-in {
    color: var(--green);
}

.cashflow-stat-value.cashflow-out {
    color: #e56a5c;
}

.cashflow-stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* Cash flow log card */
.cashflow-card {
    padding: 22px;
}

.cashflow-toolbar {
    margin-bottom: 18px;
}

.cashflow-table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.cashflow-table {
    min-width: 900px;
}

.cashflow-table .business-avatar {
    font-size: 11px;
}

@media (max-width: 1100px) {
    .cashflow-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .cashflow-summary {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   Businesses responsive
   ============================================================ */

@media (max-width: 1100px) {
    .detail-metrics {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .toolbar-search {
        max-width: none;
    }

    .toolbar-filters {
        width: 100%;
    }

    .filter-field {
        flex: 1;
        min-width: 0;
    }

    .toolbar-select {
        max-width: none;
        width: 100%;
    }

    .detail-metrics {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-span-2 {
        grid-column: span 1;
    }
}

/* ============================================================
   Reports page
   ============================================================ */

.reports-heading {
    align-items: flex-end;
}

.reports-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Date filter */
.report-date-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: fit-content;
    max-width: 100%;
}

.report-date-btn {
    padding: 7px 16px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}

.report-date-btn:hover {
    color: var(--text-primary);
}

.report-date-btn.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: inset 0 0 0 1px var(--border);
}

.report-custom-range {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 4px;
}

.report-date-input {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    color: var(--text-primary);
    font-size: 12.5px;
    font-family: inherit;
    outline: none;
    color-scheme: dark;
}

.report-date-input:focus {
    border-color: var(--gold);
}

.report-range-sep {
    font-size: 12px;
    color: var(--text-muted);
}

/* Profit & Loss card */
.report-chart-card {
    margin-bottom: 20px;
    padding: 26px;
}

.reports-chart-body {
    height: 320px;
}


/* Business Performance table */
.reports-table-card {
    margin-bottom: 20px;
    padding: 26px;
}

.reports-table {
    min-width: 720px;
}

.reports-table .business-name {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.best-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gold);
    background: var(--gold-soft);
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.reports-table .report-best-row {
    background: linear-gradient(90deg, rgba(201, 165, 92, 0.08), rgba(201, 165, 92, 0.02));
}

.reports-table .report-best-row td {
    border-top: 1px solid rgba(201, 165, 92, 0.35);
    border-bottom: 1px solid rgba(201, 165, 92, 0.25);
}

.best-avatar {
    border-color: var(--gold);
    color: var(--gold);
    background: var(--gold-soft);
}

.roi-cell {
    font-weight: 600;
    color: var(--green);
}

/* Bottom grid — Cash Flow + Capital */
.reports-bottom-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 20px;
    align-items: stretch;
    margin-bottom: 4px;
}

.report-cashflow-card,
.report-capital-card {
    padding: 26px;
    display: flex;
    flex-direction: column;
}

.report-cashflow-stats {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 22px;
}

.report-cashflow-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.report-cashflow-stat .cashflow-stat-label {
    font-size: 12px;
    letter-spacing: 0.08em;
}

.report-cashflow-stat .cashflow-stat-value {
    font-size: 17px;
    font-weight: 700;
    padding-top: 0;
    margin-top: 0;
    border: none;
}

.cashflow-stat-value.net-flow {
    color: var(--green);
}

.reports-trend-chart {
    position: relative;
    height: 180px;
    flex: 1;
}

.reports-trend-chart canvas {
    width: 100% !important;
    height: 100% !important;
}


/* Capital Summary */
.report-capital-rows {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.report-capital-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.report-capital-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.report-capital-value {
    font-size: 15.5px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.report-capital-divider {
    margin: -2px 0 -2px;
}

.report-capital-subheading {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    color: var(--text-secondary);
}

.report-account-breakdown {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.report-account-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.report-account-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 0;
}

.report-account-pct {
    margin-left: auto;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: right;
}

.report-account-value {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    min-width: 88px;
    text-align: right;
}

.report-account-item .legend-dot {
    box-shadow: none;
}

.report-account-item .dot-0 {
    background: var(--gold);
}

.report-account-item .dot-1 {
    background: var(--green);
}

.report-account-item .dot-2 {
    background: #7BA7D9;
}

/* Reports responsive */
@media (max-width: 1100px) {
    .reports-bottom-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .reports-actions {
        width: 100%;
    }

    .reports-actions .btn {
        flex: 1;
    }

    .report-date-filter {
        width: 100%;
    }

    .report-custom-range {
        flex-wrap: wrap;
    }

    .reports-chart-body {
        height: 260px;
    }
}


/* Ensure the custom range stays hidden when the [hidden] attribute is set,
   even though .report-custom-range otherwise uses display: flex. */
.report-custom-range[hidden] {
    display: none;
}

/* ============================================================
   Toasts / flash messages
   ============================================================ */
.toasts {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-hover);
    color: var(--text-primary);
    font-size: 13px;
    animation: toast-in 0.25s ease;
}

.toast-success {
    border-left: 3px solid var(--green);
}
.toast-success .toast-icon {
    color: var(--green);
}
.toast-error {
    border-left: 3px solid #e56a5c;
}
.toast-error .toast-icon {
    color: #e56a5c;
}

.toast-icon {
    display: inline-flex;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    line-height: 1.4;
}

.toast-close {
    color: var(--text-muted);
    padding: 2px;
    border-radius: 6px;
    transition: background var(--transition), color var(--transition);
}
.toast-close:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Form validation feedback */
.form-error {
    margin-top: -6px;
    font-size: 11.5px;
    color: #e56a5c;
}
.form-input.invalid {
    border-color: #e56a5c;
}

