:root {
    --primary: #4361ee;
    --primary-soft: #eaeefe;
    --ink: #1f2a44;
    --muted: #7a869a;
    --line: #e8ecf3;
    --bg: #f4f6fb;
    --sidebar-w: 260px;
    --topbar-h: 64px;
    --radius: 14px;
}

body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: #2f49c9; }
.material-symbols-outlined { font-size: 20px; vertical-align: middle; font-variation-settings: 'FILL' 0, 'wght' 400; }

/* ---------- Topbar ---------- */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--line); z-index: 1030; display: flex; align-items: center; padding: 0 20px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--ink); width: calc(var(--sidebar-w) - 20px); }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #4361ee, #7b8cff); color: #fff; display: grid; place-items: center; }
.icon-btn { border: 0; background: transparent; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); position: relative; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn .dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: #ef476f; border: 2px solid #fff; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 600; }
.topbar .search { position: relative; max-width: 320px; flex: 1; }
.topbar .search input { padding-left: 38px; background: var(--bg); border: 0; border-radius: 10px; height: 40px; }
.topbar .search .material-symbols-outlined { position: absolute; left: 11px; top: 10px; color: var(--muted); }
#navToggle { display: none; }

/* ---------- Sidebar ---------- */
.sidebar { position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--line); overflow-y: auto; padding: 18px 14px; z-index: 1020; transition: transform .2s; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: .08em; color: #a0a9b9; text-transform: uppercase; margin: 18px 10px 8px; }
.nav-group:first-child { margin-top: 4px; }
.sidebar a.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #55627a; font-weight: 500; margin-bottom: 2px; }
.sidebar a.nav-item:hover { background: var(--bg); color: var(--ink); }
.sidebar a.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.sidebar .nav-foot { margin: 24px 10px 0; padding: 14px; border-radius: 12px; background: var(--primary-soft); color: var(--ink); font-size: 12.5px; }

/* ---------- Content ---------- */
.content { margin-left: var(--sidebar-w); padding: calc(var(--topbar-h) + 26px) 28px 30px; min-height: 100vh; }
.content h3 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--muted); margin-bottom: 22px; }
.app-footer { margin-top: 36px; color: var(--muted); font-size: 12.5px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ---------- Cards / widgets ---------- */
.card { border: 0; border-radius: var(--radius); box-shadow: 0 1px 2px rgba(31, 42, 68, .04), 0 4px 16px rgba(31, 42, 68, .04); }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 0; }
.card-head h5 { margin: 0; font-size: 15px; font-weight: 600; }
.card-pad { padding: 18px 20px; }

.welcome { background: linear-gradient(120deg, #4361ee 0%, #6f86ff 60%, #8fa2ff 100%); color: #fff; border-radius: var(--radius); padding: 26px 28px; position: relative; overflow: hidden; margin-bottom: 22px; }
.welcome h4 { font-weight: 700; margin-bottom: 6px; }
.welcome p { opacity: .9; max-width: 460px; margin-bottom: 16px; }
.welcome .btn-light { color: var(--primary); font-weight: 600; border-radius: 10px; }
.welcome::after { content: ''; position: absolute; right: -40px; top: -60px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.welcome::before { content: ''; position: absolute; right: 120px; bottom: -90px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255, 255, 255, .08); }

.stat { display: flex; align-items: center; gap: 14px; padding: 18px 20px; }
.stat .ico { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat .ico .material-symbols-outlined { font-size: 24px; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat .sub { font-size: 12px; color: var(--muted); }
.ico.blue { background: #eaeefe; color: #4361ee; }
.ico.green { background: #e3f8ee; color: #1fa971; }
.ico.orange { background: #fff1e0; color: #f08c1a; }
.ico.pink { background: #fde8ef; color: #e5487a; }
.up { color: #1fa971; font-weight: 600; }
.down { color: #e5487a; font-weight: 600; }

/* mini bar chart */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bars .bar { width: 100%; max-width: 28px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, #7b8cff, #4361ee); min-height: 3px; }
.bars .bar.zero { background: var(--line); }
.bars .lbl { font-size: 10.5px; color: var(--muted); margin-top: 6px; }
.bars .val { font-size: 10.5px; color: var(--ink); margin-bottom: 3px; }

.meter { margin-bottom: 14px; }
.meter .top { display: flex; justify-content: space-between; margin-bottom: 6px; font-weight: 500; }
.meter .track { height: 8px; border-radius: 8px; background: var(--bg); overflow: hidden; }
.meter .fill { height: 100%; border-radius: 8px; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #f8f9fc; border-bottom: 1px solid var(--line); padding: 12px 16px; white-space: nowrap; }
.table > tbody td { padding: 13px 16px; border-color: var(--line); }
.table-hover > tbody > tr:hover > * { background: #fafbfe; }
.table-wrap { background: #fff; border-radius: var(--radius); box-shadow: 0 1px 2px rgba(31, 42, 68, .04), 0 4px 16px rgba(31, 42, 68, .04); overflow: hidden; }
.table-wrap .table-responsive { margin: 0; }
.table.bg-white { background: #fff !important; border-radius: var(--radius); overflow: hidden; }

/* ---------- Forms / buttons / badges ---------- */
.form-control, .form-select { border-radius: 10px; border-color: #dfe4ee; padding: .55rem .85rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(67, 97, 238, .15); }
.btn { border-radius: 10px; font-weight: 500; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #3652d6; border-color: #3652d6; }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }
.badge { font-weight: 500; padding: .45em .7em; border-radius: 8px; }
.card.card-body { padding: 22px; }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }
.page-link { color: var(--primary); }
.alert { border: 0; border-radius: 12px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #eef1ff, #f8f9ff); padding: 20px; }
.auth-card { width: 100%; max-width: 400px; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    #navToggle { display: grid; }
    .brand { width: auto; }
    .topbar .search { display: none; }
    .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open::after { content: ''; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(15, 23, 42, .35); z-index: 1010; }
    .content { margin-left: 0; padding: calc(var(--topbar-h) + 18px) 14px 24px; }
    .welcome { padding: 20px; }
}

/* ---------- Workflow timeline ---------- */
.timeline { max-width: 760px; position: relative; }
.timeline::before { content: ''; position: absolute; left: 31px; top: 24px; bottom: 56px; width: 2px; background: var(--line); }
.tl-node { position: relative; display: flex; align-items: center; gap: 16px; background: #fff; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(31, 42, 68, .04), 0 4px 16px rgba(31, 42, 68, .04); }
.tl-ico { width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; z-index: 1; }
.tl-trigger .tl-ico { background: #fff1e0; color: #f08c1a; }
.tl-body { flex: 1; min-width: 0; }
.tl-title { font-weight: 600; }
.tl-desc { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.tl-actions { display: flex; gap: 2px; flex: none; }
.tl-actions .icon-btn { width: 34px; height: 34px; }
.tl-add { padding-left: 16px; }
.tl-add .btn { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 575.98px) { .tl-node { flex-wrap: wrap; } .tl-actions { width: 100%; justify-content: flex-end; } .timeline::before { display: none; } }

/* ---------- Pipelines / kanban board ---------- */
.pipe-card { transition: transform .12s, box-shadow .12s; }
.pipe-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(31, 42, 68, .1); }
.stat-ico { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; flex: none; }

.board { display: flex; gap: 16px; align-items: flex-start; overflow-x: auto; padding-bottom: 18px; min-height: 62vh; -webkit-overflow-scrolling: touch; }
.lane { flex: 0 0 290px; background: #eaeef7; border-radius: var(--radius); padding: 10px; }
.lane-head { display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 10px; border-top: 3px solid var(--primary); padding: 6px 8px 6px 6px; font-weight: 600; box-shadow: 0 1px 2px rgba(31, 42, 68, .05); }
.lane-handle { cursor: grab; color: #a0a9b9; user-select: none; touch-action: none; }
.lane-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-head .icon-btn { width: 30px; height: 30px; }
.lane-sum { font-size: 12px; color: var(--muted); padding: 6px 4px 0; min-height: 22px; }
.lane-body { min-height: 72px; padding: 6px 0 8px; display: flex; flex-direction: column; gap: 10px; }
.lane-add { width: 100%; border: 1px dashed #c3cce0; background: transparent; color: var(--muted); border-radius: 10px; padding: 8px; font-size: 13px; }
.lane-add:hover { background: #fff; color: var(--primary); border-color: var(--primary); }
.lane-new { background: transparent; border: 2px dashed #cfd6e6; }

.kcard { background: #fff; border-radius: 12px; padding: 12px; box-shadow: 0 1px 2px rgba(31, 42, 68, .06), 0 2px 8px rgba(31, 42, 68, .05); cursor: grab; border: 1px solid transparent; }
.kcard:hover { border-color: #cfd8f7; }
.kcard-chosen { box-shadow: 0 10px 28px rgba(31, 42, 68, .2); }
.kcard-ghost { opacity: .45; background: var(--primary-soft); }
.kc-top { display: flex; gap: 10px; align-items: center; }
.kc-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 600; flex: none; }
.kc-main { min-width: 0; }
.kc-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kc-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kc-value { display: inline-block; margin-top: 8px; font-weight: 600; font-size: 12.5px; color: #1fa971; background: #e3f8ee; border-radius: 8px; padding: 2px 8px; }
.kc-note { margin-top: 8px; font-size: 12.5px; color: #55627a; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kc-meta { margin-top: 8px; font-size: 11.5px; color: #a0a9b9; }
.kc-eng { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 11.5px; color: #55627a; }
.kc-eng .material-symbols-outlined { font-size: 15px; vertical-align: -3px; color: #8a94a8; }
.kc-eng .badge { font-size: 10.5px; }
.add-results { max-height: 220px; overflow-y: auto; }
@media (max-width: 575.98px) { .lane { flex-basis: 82vw; } }

/* keep the page from scrolling sideways on phones */
.bars .col { min-width: 0; }
.bars .lbl { white-space: nowrap; }
html, body { overflow-x: hidden; max-width: 100%; }
@media (max-width: 575.98px) {
    .bars { gap: 3px; }
    .bars .lbl { font-size: 9px; }
    .bars .col:nth-child(even) .lbl { visibility: hidden; }
    .bars .val { font-size: 9px; }
}

/* ---------- Investor portal ---------- */
body.portal { background: var(--bg); }
.portal-wrap { max-width: 1100px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.portal-top { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1020; }
.portal-top > .portal-wrap:first-child { min-height: 58px; }
.portal-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--ink); min-width: 0; }
.portal-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 8px; }
.portal-nav::-webkit-scrollbar { display: none; }
.portal-nav a { white-space: nowrap; padding: 7px 12px; border-radius: 9px; color: #55627a; font-weight: 500; }
.portal-nav a:hover { background: var(--bg); color: var(--ink); }
.portal-nav a.active { background: var(--primary-soft); color: var(--primary); }
.portal-nav a:focus-visible, .portal-brand:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.portal-main { padding-top: 24px; padding-bottom: 24px; }
.portal-main h3 { font-size: 22px; font-weight: 700; }
.portal-foot { color: var(--muted); font-size: 12px; padding-top: 12px; padding-bottom: 28px; border-top: 1px solid var(--line); }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 20px; font-weight: 700; }
.ledger td, .ledger th { white-space: nowrap; }
@media print {
    .portal-top, .portal-foot .no-print, .no-print { display: none !important; }
    body.portal { background: #fff; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}
