:root {
    --brand: #0f4c5c;
    --brand-2: #1b7f8c;
    --accent: #e36414;
    --ink: #1f2933;
    --muted: #6b7785;
    --line: #e4e8ee;
    --bg: #f4f6f9;
    --sidebar-w: 252px;
}
[data-bs-theme="dark"] { --ink: #e6e9ee; --muted: #9aa5b1; --line: #2c333b; --bg: #14181d; }

body { background: var(--bg); color: var(--ink); font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: .92rem; }
h1, h2, h3, h4, h5 { letter-spacing: -.01em; }
.text-muted { color: var(--muted) !important; }

/* ---- shell ---- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: linear-gradient(180deg, #0b3a46, var(--brand)); color: #cfe3e8; flex-shrink: 0; position: fixed; inset: 0 auto 0 0; overflow-y: auto; z-index: 1040; transition: transform .2s; }
.sidebar .brand { padding: 1.1rem 1.25rem; font-weight: 700; font-size: 1.05rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; gap: .6rem; align-items: center; }
.sidebar .brand i { color: var(--accent); font-size: 1.3rem; }
.sidebar .nav-group { padding: .9rem 1.25rem .3rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: #7fa7b1; }
.sidebar .nav-link { color: #cfe3e8; padding: .48rem 1.25rem; display: flex; align-items: center; gap: .7rem; border-left: 3px solid transparent; font-size: .88rem; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .nav-link.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: var(--accent); }
.sidebar .nav-link i { width: 1.1rem; text-align: center; opacity: .9; }
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: .6rem 1.5rem; display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 1030; }
[data-bs-theme="dark"] .topbar { background: #1a1f25; }
.content { padding: 1.5rem; max-width: 1500px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; }
.page-head h1 { font-size: 1.35rem; margin: 0; font-weight: 650; }

/* ---- cards ---- */
.card { border: 1px solid var(--line); border-radius: .7rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: transparent; font-weight: 600; border-bottom: 1px solid var(--line); }
.stat { padding: 1rem 1.15rem; }
.stat .label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat .value { font-size: 1.55rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .78rem; color: var(--muted); }
.stat.accent { border-left: 4px solid var(--brand-2); }
.stat.warn { border-left: 4px solid var(--accent); }

/* ---- tables ---- */
.table > :not(caption) > * > * { padding: .6rem .8rem; }
.table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; border-bottom-width: 1px; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-hover tbody tr:hover { background: rgba(15,76,92,.04); }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: #0b3a46; border-color: #0b3a46; color: #fff; }
.form-label { font-weight: 550; font-size: .82rem; margin-bottom: .25rem; }
.form-text { font-size: .76rem; }

/* ---- phase tracker ---- */
.tracker { display: flex; gap: .5rem; }
.tracker .step { flex: 1; text-align: center; position: relative; }
.tracker .step .dot { width: 2.1rem; height: 2.1rem; border-radius: 50%; margin: 0 auto .35rem; display: grid; place-items: center; background: #e8edf2; color: var(--muted); font-weight: 700; border: 2px solid #e8edf2; }
.tracker .step.in_progress .dot, .tracker .step.submitted .dot { background: #fff; border-color: var(--brand-2); color: var(--brand-2); }
.tracker .step.approved .dot { background: #198754; border-color: #198754; color: #fff; }
.tracker .step.rejected .dot { background: #dc3545; border-color: #dc3545; color: #fff; }
.tracker .step .name { font-size: .72rem; line-height: 1.15; color: var(--muted); }
.tracker .step.in_progress .name, .tracker .step.approved .name, .tracker .step.submitted .name { color: var(--ink); font-weight: 600; }
.tracker .step:not(:last-child)::after { content: ""; position: absolute; top: 1.05rem; left: 60%; width: 80%; height: 2px; background: #e1e6ec; z-index: 0; }
.tracker .step .dot { position: relative; z-index: 1; }

/* ---- timeline ---- */
.timeline { list-style: none; padding-left: 1.2rem; margin: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1rem 1rem; }
.timeline li::before { content: ""; position: absolute; left: -1.62rem; top: .35rem; width: .75rem; height: .75rem; border-radius: 50%; background: var(--brand-2); border: 2px solid #fff; }
.timeline .when { font-size: .74rem; color: var(--muted); }

/* ---- pipeline ---- */
.pipeline { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: .8rem; overflow-x: auto; padding-bottom: .5rem; }
.pipeline .col { background: rgba(15,76,92,.05); border-radius: .7rem; padding: .6rem; }
.pipeline .col h6 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; justify-content: space-between; }
.pipeline .lead-card { background: #fff; border: 1px solid var(--line); border-radius: .55rem; padding: .6rem .7rem; margin-bottom: .5rem; }
[data-bs-theme="dark"] .pipeline .lead-card { background: #1a1f25; }

/* ---- invoice preview ---- */
.invoice-sheet { background: #fff; color: #1f2933; max-width: 860px; margin: 0 auto; padding: 2.2rem 2.5rem; border: 1px solid var(--line); border-radius: .6rem; }
.invoice-sheet h2 { color: var(--brand); }
.invoice-sheet .totals td { padding: .25rem .5rem; }

/* ---- portal ---- */
.portal-nav { background: var(--brand); }
.portal-nav .nav-link { color: #d6e7eb; }
.portal-nav .nav-link.active { color: #fff; font-weight: 600; border-bottom: 2px solid var(--accent); }
.portal-wrap { max-width: 1000px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }

/* ---- guest ---- */
.guest-bg { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 10% -10%, #1b7f8c33, transparent), linear-gradient(160deg, #0b3a46, #0f4c5c 60%, #12303a); padding: 1rem; }
.guest-card { width: 100%; max-width: 420px; background: #fff; border-radius: .9rem; padding: 2rem; box-shadow: 0 20px 50px rgba(0,0,0,.25); color: #1f2933; }

/* ---- misc ---- */
.progress { height: .5rem; }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; background: var(--brand-2); color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: .8rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.chart-box { position: relative; height: 260px; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: none; }
    .main { margin-left: 0; }
    .content { padding: 1rem; }
    .tracker .name { display: none; }
}
@media print {
    .sidebar, .topbar, .no-print, .alert { display: none !important; }
    .main { margin: 0; }
    body { background: #fff; }
    .invoice-sheet { border: 0; padding: 0; }
}
