/* ==========================================================================
   Mercato design system
   Slate navigation, deep-indigo primary actions, white cards on a soft grey
   canvas and plain-language labels. Change the palette here, in the :root tokens.
   ========================================================================== */
:root {
    --brand: #4338ca;            /* primary: deep indigo */
    --brand-dark: #3730a3;
    --brand-soft: #eef0ff;
    --nav-bg: #111827;
    --nav-hover: #1f2937;
    --nav-text: #c9ced6;
    --ink: #1f2328;
    --muted: #6b7280;
    --line: #e4e7ec;
    --canvas: #f4f5f8;
    --card: #ffffff;
    --warn: #b45309;
    --danger: #c0392b;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
    --sidebar-w: 248px;

    /* Re-skin Bootstrap's primary colour to the brand green. */
    --bs-primary: var(--brand);
    --bs-primary-rgb: 67, 56, 202;
    --bs-link-color: #4338ca;
    --bs-link-color-rgb: 67, 56, 202;
    --bs-link-hover-color: #312e81;
    --bs-body-font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --bs-body-color: var(--ink);
    --bs-border-color: var(--line);
    --bs-border-radius: 8px;
}

html, body { height: 100%; }
body { background: var(--canvas); font-size: .925rem; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }

.btn-primary {
    --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark);
    --bs-btn-disabled-bg: #a5b4fc; --bs-btn-disabled-border-color: #a5b4fc;
    font-weight: 600;
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-dark); --bs-btn-border-color: #c7d2fe;
    --bs-btn-hover-bg: var(--brand-soft); --bs-btn-hover-color: var(--brand-dark); --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand-soft); --bs-btn-active-color: var(--brand-dark); --bs-btn-active-border-color: var(--brand);
}
.btn { border-radius: 8px; }
.btn-success { font-weight: 600; }
.form-control, .form-select { border-radius: 8px; border-color: #d0d5dd; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(67, 56, 202, .18); }
.form-label { font-weight: 600; font-size: .82rem; color: #344054; margin-bottom: .3rem; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.nav-pills .nav-link.active { background: var(--brand); }
.nav-pills .nav-link { color: #344054; border-radius: 8px; }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); }
.badge { font-weight: 600; }
.text-brand { color: var(--brand) !important; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar { background: var(--nav-bg) !important; color: #fff; width: var(--sidebar-w); flex-shrink: 0; display: flex; flex-direction: column; }
/* z-index: sticky makes the sidebar its own stacking layer; keep it (and its menus) above page content. */
@media (min-width: 992px) { .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1030; } }
.sidebar::-webkit-scrollbar { width: 6px; } .sidebar::-webkit-scrollbar-thumb { background: #3a404b; border-radius: 3px; }

.brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.25rem .9rem; color: #fff; font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; color: #fff; }
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff; font-weight: 800; }

.new-btn { margin: 0 1rem 1rem; width: calc(100% - 2rem); border-radius: 999px; padding: .55rem 1rem; font-weight: 700; background: var(--brand); border: 0; color: #fff; }
.new-btn:hover, .new-btn:focus, .new-btn.show { background: var(--brand-dark); color: #fff; }
.new-menu { width: min(760px, 92vw); padding: 1.25rem 1.5rem; border: 0; border-radius: 12px; box-shadow: var(--shadow-lg); }
/* Float the menu beside the sidebar; inside it, the sidebar's scroll area would clip it. */
@media (min-width: 992px) {
    .new-menu.show { position: fixed !important; inset: 64px auto auto calc(var(--sidebar-w) - 12px) !important; transform: none !important; z-index: 1060; }
}
.new-menu h6 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .5rem; }
.new-menu a { display: block; padding: .3rem 0; color: var(--ink); }
.new-menu a:hover { color: var(--brand-dark); text-decoration: none; }

.nav-list { list-style: none; padding: 0 .6rem 1.5rem; margin: 0; }
.nav-list a, .nav-group-toggle {
    display: flex; align-items: center; gap: .75rem; width: 100%; padding: .55rem .75rem; border-radius: 8px;
    color: var(--nav-text); font-weight: 500; background: none; border: 0; text-align: start;
}
.nav-list a:hover, .nav-group-toggle:hover { background: var(--nav-hover); color: #fff; text-decoration: none; }
.nav-list a.active { background: rgba(129, 140, 248, .18); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.nav-list .bi { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .9; }
.nav-list .nav-pos { background: var(--brand); color: #fff; font-weight: 700; margin: .25rem 0 .5rem; }
.nav-list .nav-pos:hover { background: var(--brand-dark); }
.nav-group-toggle .chev { margin-left: auto; transition: transform .2s; font-size: .75rem; }
.nav-group-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.nav-sub { list-style: none; padding: .15rem 0 .4rem; margin: 0; }
.nav-sub a { padding: .4rem .75rem .4rem 2.7rem; font-size: .88rem; font-weight: 400; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.5rem; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1020; }
.global-search { position: relative; flex: 0 1 420px; }
.global-search .bi { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.global-search input { padding-left: 2.2rem; background: var(--canvas); border-color: transparent; border-radius: 999px; }
.global-search input:focus { background: #fff; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; color: #475467; font-size: 1.15rem; }
.icon-btn:hover { background: var(--canvas); color: var(--ink); }
.icon-btn .count { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .65rem; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #dbeafe; color: #1e3a8a; font-weight: 700; display: inline-grid; place-items: center; font-size: .8rem; }
.conn-badge { background: #fde68a; color: #78350f; border-radius: 999px; padding: .2rem .7rem; font-size: .75rem; font-weight: 600; }
.notif-menu { width: 360px; max-height: 70vh; overflow-y: auto; padding: 0; border: 0; box-shadow: var(--shadow-lg); border-radius: 12px; }
.notif-menu .item { display: block; padding: .75rem 1rem; border-bottom: 1px solid var(--line); color: var(--ink); }
.notif-menu .item:hover { background: var(--canvas); text-decoration: none; }

.content { padding: 1.5rem; max-width: 1400px; width: 100%; }
@media (max-width: 575.98px) { .content { padding: 1rem; } .topbar { padding: .5rem .75rem; } }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.45rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); font-size: .88rem; }
.page-head .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Surfaces ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 600; padding: .8rem 1rem; border-radius: var(--radius) var(--radius) 0 0 !important; }
.toolbar { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.toolbar > .form-control, .toolbar > input[type=search] { flex: 1 1 240px; }
.empty { background: #fff; border: 1px dashed #cbd5e1; border-radius: var(--radius); padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.empty .bi { display: block; font-size: 2rem; margin-bottom: .5rem; color: #98a2b3; }

.table { --bs-table-hover-bg: #f7f8ff; margin-bottom: 0; }
.table > thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; border-bottom-width: 1px; white-space: nowrap; }
.table > :not(caption) > * > * { padding: .65rem .85rem; }
.table-sm > :not(caption) > * > * { padding: .45rem .7rem; }
.table-responsive.card { overflow: auto; }

.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; height: 100%; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-sub { color: var(--muted); font-size: .78rem; }
.stat-warn { border-color: #f6c26b; background: #fffbeb; }
a.stat:hover { text-decoration: none; border-color: var(--brand); }

/* ---------- Home: QuickBooks-style workflow ---------- */
.flow-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem 1.25rem; box-shadow: var(--shadow); height: 100%; }
.flow-card h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 .9rem; font-weight: 700; }
.flow { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.flow-step { display: flex; flex-direction: column; align-items: center; gap: .35rem; width: 96px; padding: .6rem .3rem; border-radius: 12px; color: var(--ink); text-align: center; font-size: .8rem; font-weight: 600; line-height: 1.15; }
.flow-step:hover { background: var(--brand-soft); text-decoration: none; color: var(--brand-dark); }
.flow-step .ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35rem; background: var(--brand-soft); color: var(--brand-dark); }
.flow-step.blue .ico { background: #dcf5f1; color: #0f766e; }
.flow-step.amber .ico { background: #fff1d6; color: #b45309; }
.flow-step.violet .ico { background: #fde7ef; color: #be185d; }
.flow-arrow { color: #c0c6cf; font-size: 1.1rem; }

.bars { display: flex; align-items: flex-end; gap: 5px; height: 190px; }
.bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bar-fill { background: linear-gradient(180deg, #6366f1, var(--brand)); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar:hover .bar-fill { background: var(--brand-dark); }
.bar-label { text-align: center; font-size: .65rem; color: var(--muted); margin-top: 3px; }

/* ---------- Report center ---------- */
.report-group h2 { font-size: 1rem; font-weight: 700; margin-bottom: .6rem; }
.report-link { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border-radius: 8px; color: var(--ink); }
.report-link:hover { background: var(--brand-soft); text-decoration: none; color: var(--brand-dark); }
.report-link .bi { color: var(--brand); }
.report-sheet { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; }
.report-sheet .rtitle { text-align: center; margin-bottom: 1.5rem; }
.report-sheet .rtitle h2 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.report-sheet .rtitle div { color: var(--muted); font-size: .85rem; }
.report-table td.num, .report-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.report-table .section td { font-weight: 700; padding-top: 1rem; border-bottom: 0; }
.report-table .total td { font-weight: 700; border-top: 2px solid var(--ink); }
.report-table .indent { padding-left: 1.75rem !important; }

.perm-group { break-inside: avoid; margin-bottom: 1rem; }
@media (min-width: 768px) { .perm-grid { columns: 2; } }
@media (min-width: 1200px) { .perm-grid { columns: 3; } }

.logo-preview { width: 96px; height: 96px; border: 1px dashed #cbd5e1; border-radius: 12px; display: grid; place-items: center; background: #fff; overflow: hidden; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview span { display: flex; flex-direction: column; align-items: center; color: #98a2b3; font-size: 1.6rem; }
.logo-preview small { font-size: .7rem; }
.product-photo { width: 120px; height: 120px; border: 1px dashed #cbd5e1; border-radius: 12px; display: grid; place-items: center; background: #fff; overflow: hidden; flex-shrink: 0; }
.product-photo img { width: 100%; height: 100%; object-fit: cover; }
.product-photo span { display: flex; flex-direction: column; align-items: center; color: #98a2b3; font-size: 1.8rem; }
.product-photo small { font-size: .7rem; }
.product-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--canvas); flex-shrink: 0; }
.product-thumb.empty { display: grid; place-items: center; color: #98a2b3; font-size: 1.1rem; }
.wallet-logo { width: 56px; height: 56px; flex-shrink: 0; border-radius: 12px; border: 1px solid var(--line); display: grid; place-items: center; background: #fff; overflow: hidden; font-size: 1.5rem; color: var(--brand); }
.wallet-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; object-fit: contain; background: #fff; padding: 2px; }

/* MVC renders the summary even with no errors; don't show an empty red alert. */
.validation-summary-valid { display: none; }
.line-results { z-index: 30; max-height: 320px; overflow-y: auto; }

/* Tables collapse into labelled cards on phones */
@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack tr { display: block; padding: .5rem .75rem; border-bottom: 1px solid var(--line); }
    .table-stack td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .2rem 0 !important; text-align: end !important; }
    .table-stack td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: start; }
    .table-stack td .form-control { max-width: 60%; }
    .page-head .actions { margin-left: 0; }
}

/* ---------- Sign-in ---------- */
.auth-body { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: #fff; }
@media (min-width: 992px) { .auth-body { grid-template-columns: 1.1fr 1fr; } }
.auth-hero { display: none; background: radial-gradient(circle at 20% 20%, #6366f1 0, var(--brand) 40%, #1e1b4b 100%); color: #fff; padding: 4rem; flex-direction: column; justify-content: space-between; }
@media (min-width: 992px) { .auth-hero { display: flex; } }
.auth-hero h2 { font-size: 2.2rem; font-weight: 800; line-height: 1.15; max-width: 460px; }
.auth-hero ul { list-style: none; padding: 0; margin: 2rem 0 0; }
.auth-hero li { margin: .6rem 0; font-size: 1.05rem; opacity: .95; }
.auth-hero li .bi { margin-right: .6rem; }
.auth-pane { display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { color: var(--ink); padding: 0 0 2rem; }

/* ---------- Print ---------- */
.receipt-print { max-width: 380px; }
@media print {
    .sidebar, .topbar, .no-print, .page-head .actions { display: none !important; }
    .content { padding: 0; max-width: none; }
    body { background: #fff; }
    .report-sheet, .card { box-shadow: none; border: 0; }
}
