:root {
    --accent: #2563eb;
    --accent-dark: #1e40af;
    --ink: #1c2430;
    --muted: #64748b;
    --line: #e4e7ec;
    --bg: #f5f7fb;
    --sidebar-bg: #0e1626;
    --sidebar-ink: #cbd5e1;
}

html, body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    margin: 0;
}

h1, h2, h3 { font-weight: 700; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-dark);
    --bs-btn-hover-border-color: var(--accent-dark);
    --bs-btn-active-bg: var(--accent-dark);
    --bs-btn-disabled-bg: var(--accent);
    --bs-btn-disabled-border-color: var(--accent);
}
.text-accent { color: var(--accent) !important; }

/* ---- App shell layout ------------------------------------------------ */
.page { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; flex: 0 0 240px;
    background: var(--sidebar-bg);
    background-image: linear-gradient(180deg, #101b30, #0b1220);
}
main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.top-row.px-4 {
    height: 56px; background: #fff; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
}
.content { padding-top: 1.4rem; padding-bottom: 3rem; }
.company-icon { color: var(--muted); }
.company-switcher { min-width: 180px; }
.user-chip { color: var(--muted); font-size: .9rem; }
.top-link { color: var(--muted); font-size: 1.15rem; }
.top-link:hover { color: var(--accent); text-decoration: none; }

/* ---- Sidebar nav ----------------------------------------------------- */
.sidebar .navbar { background: transparent; height: 56px; }
.sidebar .navbar-brand { color: #fff; font-weight: 700; font-size: 1.15rem; }
.nav-scrollable { padding: .5rem 0; }
.sidebar .nav-link {
    color: var(--sidebar-ink); border-radius: 8px; margin: 2px 8px;
    padding: .5rem .75rem; font-size: .94rem; font-weight: 500;
}
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar .nav-link.active { background: var(--accent); color: #fff; }
.nav-section {
    color: #5b6b85; font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; padding: 1rem 1.25rem .25rem;
}
.navbar-toggler { display: none; }

@media (max-width: 820px) {
    .page { flex-direction: column; }
    .sidebar { width: 100%; flex-basis: auto; }
}

/* ---- Cards / tables -------------------------------------------------- */
.card { border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.stat-card { padding: 1.1rem 1.25rem; }
.stat-card .stat-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 700; }
.table thead th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--line); }
.table td { vertical-align: middle; }

.badge-status { font-weight: 600; padding: .35em .6em; border-radius: 6px; font-size: .74rem; }
.st-Draft { background: #eef0f4; color: #475467; }
.st-Sent { background: #e0edff; color: #1e40af; }
.st-PartiallyPaid { background: #fff3d6; color: #92600b; }
.st-Paid { background: #dcfce7; color: #166534; }
.st-Overdue { background: #fee2e2; color: #b42318; }
.st-Void { background: #f1f1f4; color: #98a2b3; text-decoration: line-through; }

/* ---- Login ----------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0e1626, #1e293b); padding: 1rem; }
.login-card { background: #fff; border-radius: 16px; padding: 2.2rem; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-brand { font-size: 1.5rem; font-weight: 700; }

/* ---- Invoice document (shared by editor preview, public page, print) - */
.inv-doc {
    --inv-accent: var(--accent);
    background: #fff; color: #1c2430; max-width: 820px; margin: 0 auto;
    padding: 44px 48px; font-size: 14px; line-height: 1.5;
    box-shadow: 0 1px 3px rgba(16,24,40,.08); border-radius: 8px;
}
.inv-doc table { width: 100%; border-collapse: collapse; }
.inv-doc .inv-logo { max-height: 64px; max-width: 220px; }
.inv-doc .inv-title { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.inv-doc .inv-company-name { font-size: 20px; font-weight: 700; }
.inv-doc .muted { color: #64748b; }
.inv-doc .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; }
.inv-doc .items th { text-align: left; padding: 9px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #64748b; }
.inv-doc .items td { padding: 10px 8px; border-bottom: 1px solid #eef0f4; }
.inv-doc .items .num { text-align: right; white-space: nowrap; }
.inv-doc .totals { width: 300px; margin-left: auto; margin-top: 14px; }
.inv-doc .totals td { padding: 4px 8px; }
.inv-doc .totals .grand td { font-weight: 800; font-size: 17px; border-top: 2px solid #1c2430; padding-top: 8px; }
.inv-doc .totals .due td { font-weight: 700; color: #b42318; }
.inv-doc .inv-notes { margin-top: 26px; padding-top: 16px; border-top: 1px solid #eef0f4; color: #475467; }
.inv-doc .header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.inv-doc .parties { display: flex; justify-content: space-between; gap: 24px; margin: 28px 0 8px; }

/* Classic: clean, accent used as thin rules only */
.tmpl-classic .inv-title { color: var(--inv-accent); }
.tmpl-classic .items thead tr { border-bottom: 2px solid var(--inv-accent); }
.tmpl-classic .totals .grand td { border-top-color: var(--inv-accent); }

/* Modern: full-width accent header band */
.tmpl-modern { padding-top: 0; overflow: hidden; }
.tmpl-modern .band { background: var(--inv-accent); color: #fff; margin: 0 -48px 28px; padding: 34px 48px; }
.tmpl-modern .band .inv-title { color: #fff; }
.tmpl-modern .band .muted, .tmpl-modern .band .lbl { color: rgba(255,255,255,.82); }
.tmpl-modern .items thead tr { background: #f6f8fc; }
.tmpl-modern .items th { border-bottom: 1px solid var(--line); }
.tmpl-modern .totals .grand td { color: var(--inv-accent); border-top-color: var(--inv-accent); }

/* Minimal: airy, monochrome, accent only on the grand total */
.tmpl-minimal { padding: 56px 52px; }
.tmpl-minimal .inv-title { font-weight: 600; letter-spacing: .12em; text-transform: uppercase; font-size: 20px; color: #1c2430; }
.tmpl-minimal .items th { border-bottom: 1px solid var(--line); }
.tmpl-minimal .items td { border-bottom: 1px solid #f3f4f7; }
.tmpl-minimal .totals .grand td { color: var(--inv-accent); border-top: 1px solid #1c2430; }

/* Bold: oversized accent block header */
.tmpl-bold .band { background: var(--inv-accent); color: #fff; margin: -44px -48px 30px; padding: 40px 48px; }
.tmpl-bold .band .inv-title { color: #fff; font-size: 40px; }
.tmpl-bold .band .inv-company-name, .tmpl-bold .band .muted, .tmpl-bold .band .lbl { color: rgba(255,255,255,.9); }
.tmpl-bold .items thead tr { border-bottom: 3px solid var(--inv-accent); }
.tmpl-bold .totals .grand td { background: var(--inv-accent); color: #fff; border-radius: 6px; }

/* ---- Public page + print -------------------------------------------- */
.public-wrap { background: var(--bg); min-height: 100vh; padding: 28px 16px; }
.public-actions { max-width: 820px; margin: 0 auto 16px; display: flex; justify-content: flex-end; gap: 8px; }

@media print {
    .no-print { display: none !important; }
    body, .public-wrap { background: #fff !important; padding: 0 !important; }
    .inv-doc { box-shadow: none; border-radius: 0; max-width: none; padding: 0; }
    .tmpl-modern .band, .tmpl-bold .band { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .tmpl-bold .totals .grand td, .tmpl-classic .items thead tr,
    .st-Paid, .st-Overdue, .badge-status { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
