/* BuildFlow theme — layered on Bootstrap 5.3 */
:root {
  --bf-brand: #1f3a5f;
  --bf-brand-2: #e07a1f;
  --bf-sidebar-w: 248px;
  --bs-body-font-size: 1rem;
  --bs-primary: #1f4e8c;
  --bs-primary-rgb: 31, 78, 140;
  --bs-link-color: #1f4e8c;
  --bs-link-color-rgb: 31, 78, 140;
  --bs-border-radius: .55rem;
  --bf-surface: #ffffff;
  --bf-bg: #f3f5f8;
  --bf-muted-bg: #eef1f5;
}
[data-bs-theme="dark"] {
  --bs-primary: #6ea8fe;
  --bs-primary-rgb: 110, 168, 254;
  --bs-link-color: #8bb9fe;
  --bs-link-color-rgb: 139, 185, 254;
  --bs-body-bg: #11161d;
  --bs-body-color: #e3e7ec;
  --bs-secondary-color: #aab3bf;
  --bs-tertiary-bg: #1a212b;
  --bs-border-color: #2c3542;
  --bf-surface: #171e27;
  --bf-bg: #0f141a;
  --bf-muted-bg: #1d2530;
}
.btn-primary { --bs-btn-bg: #1f4e8c; --bs-btn-border-color: #1f4e8c; --bs-btn-hover-bg: #183f72; --bs-btn-hover-border-color: #183f72; --bs-btn-active-bg: #153763; }
[data-bs-theme="dark"] .btn-primary { --bs-btn-bg: #3d7bd4; --bs-btn-border-color: #3d7bd4; --bs-btn-hover-bg: #5a91de; --bs-btn-hover-border-color: #5a91de; --bs-btn-color: #fff; }
.btn-outline-primary { --bs-btn-color: var(--bs-primary); --bs-btn-border-color: var(--bs-primary); --bs-btn-hover-bg: var(--bs-primary); --bs-btn-hover-border-color: var(--bs-primary); }
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-hover-color: #0b1220; }

body { background: var(--bf-bg); font-size: 1rem; }
.skip-link { position: absolute; left: .5rem; top: .5rem; z-index: 2000; background: var(--bf-surface); padding: .5rem 1rem; border-radius: .4rem; }
:focus-visible { outline: 3px solid #f0a030 !important; outline-offset: 2px; }

.app-topbar { background: var(--bf-surface); z-index: 1030; min-height: 56px; }
.app-topbar .navbar-brand { color: var(--bs-body-color); }
.btn-icon { border: 0; background: transparent; color: var(--bs-body-color); padding: .35rem .5rem; border-radius: .5rem; }
.btn-icon:hover { background: var(--bf-muted-bg); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--bf-brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 600; }

.app-shell { display: flex; min-height: calc(100vh - 56px); }
.app-sidebar { background: var(--bf-surface); border-right: 1px solid var(--bs-border-color); }
@media (min-width: 992px) {
  .app-sidebar { width: var(--bf-sidebar-w); flex: 0 0 var(--bf-sidebar-w); position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
  .app-sidebar .offcanvas-body { display: flex; }
}
.nav-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bs-secondary-color); padding: .9rem .75rem .25rem; font-weight: 600; }
.app-sidebar .nav-link { color: var(--bs-body-color); border-radius: .5rem; display: flex; align-items: center; gap: .65rem; padding: .5rem .75rem; }
.app-sidebar .nav-link .bi { font-size: 1.05rem; opacity: .8; }
.app-sidebar .nav-link:hover { background: var(--bf-muted-bg); }
.app-sidebar .nav-link.active { background: rgba(var(--bs-primary-rgb), .12); color: var(--bs-primary); font-weight: 600; }
.app-sidebar .nav-link.active .bi { opacity: 1; }

.app-main { flex: 1; min-width: 0; padding: 1.5rem; padding-bottom: 5.5rem; }
@media (min-width: 992px) { .app-main { padding: 1.75rem 2rem 3rem; } }
.app-main:focus { outline: none; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.5rem; margin: 0; font-weight: 650; }
.page-head .subtitle { color: var(--bs-secondary-color); font-size: .95rem; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.card { border-color: var(--bs-border-color); background: var(--bf-surface); box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-header { background: transparent; font-weight: 600; }
.card-title-sm { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); font-weight: 600; }

.stat { padding: 1rem 1.1rem; }
.stat .label { font-size: .8rem; color: var(--bs-secondary-color); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat .value { font-size: 1.55rem; font-weight: 650; line-height: 1.2; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: .85rem; color: var(--bs-secondary-color); }

.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .65rem .75rem; vertical-align: middle; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); font-weight: 600; white-space: nowrap; border-bottom-width: 1px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn, .table .actions form { margin-left: .2rem; }
.table-total td, .table-total th { font-weight: 650; border-top: 2px solid var(--bs-border-color); }
.row-muted td { color: var(--bs-secondary-color); }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--bs-secondary-color); }
.empty-state .bi { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .6; }

.form-label { font-weight: 550; }
.form-text { font-size: .85rem; }
.form-section-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); font-weight: 650; margin: 1.25rem 0 .75rem; }

.status-flag { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; font-weight: 600; }
.status-flag::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: currentColor; }
.flag-red { color: #c0392b; }
.flag-yellow { color: #a86b00; }
.flag-green { color: #1e8449; }
.flag-none { color: var(--bs-secondary-color); }
[data-bs-theme="dark"] .flag-red { color: #ff8a80; }
[data-bs-theme="dark"] .flag-yellow { color: #ffd166; }
[data-bs-theme="dark"] .flag-green { color: #7bd88f; }

.meter { height: .55rem; border-radius: 1rem; background: var(--bf-muted-bg); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--bs-primary); }
.meter.warn > span { background: #d99100; }
.meter.over > span { background: #c0392b; }

.text-pos { color: #1e8449; }
.text-neg { color: #c0392b; }
[data-bs-theme="dark"] .text-pos { color: #7bd88f; }
[data-bs-theme="dark"] .text-neg { color: #ff8a80; }

.quickbar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--bf-surface); display: flex; z-index: 1020; padding-bottom: env(safe-area-inset-bottom); }
.quickbar a { flex: 1; text-align: center; padding: .5rem 0 .45rem; color: var(--bs-secondary-color); text-decoration: none; display: flex; flex-direction: column; align-items: center; font-size: .75rem; gap: .1rem; }
.quickbar a.active, .quickbar a:hover { color: var(--bs-primary); }

.employee-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .5rem; }
.employee-pick label { display: flex; align-items: center; gap: .6rem; border: 1px solid var(--bs-border-color); border-radius: .55rem; padding: .7rem .8rem; cursor: pointer; background: var(--bf-surface); min-height: 52px; }
.employee-pick input:checked + span { font-weight: 650; }
.employee-pick label:has(input:checked) { border-color: var(--bs-primary); background: rgba(var(--bs-primary-rgb), .08); }
.employee-pick .form-check-input { width: 1.3rem; height: 1.3rem; margin: 0; flex: 0 0 auto; }

.btn-check + .btn { min-height: 44px; }
.line-editor input, .line-editor select { min-width: 5rem; }
.line-editor td { padding: .35rem .3rem !important; }
.line-editor .desc { min-width: 14rem; }
.receipt-thumb { max-width: 100%; max-height: 260px; border-radius: .5rem; border: 1px solid var(--bs-border-color); }

/* Login / setup */
.minimal-body { background: var(--bf-bg); }
.minimal-main { max-width: 460px; margin: 0 auto; padding: 3rem 1rem; }

/* Printable documents (quotes, invoices, pay stubs, statements) */
.print-body { background: #e9ecef; color: #212529; }
.print-toolbar { max-width: 860px; margin: 1rem auto; display: flex; gap: .5rem; justify-content: space-between; padding: 0 1rem; }
.doc-page { max-width: 860px; margin: 0 auto 2rem; background: #fff; padding: 2.5rem; box-shadow: 0 2px 10px rgba(0,0,0,.08); border-radius: .4rem; }
.doc-page-alert { max-width: 860px; }
.doc-page h1 { font-size: 1.6rem; }
.doc-brand { color: var(--bf-brand); font-weight: 700; font-size: 1.3rem; }
.doc-meta td { padding: .1rem .5rem .1rem 0 !important; border: 0 !important; }
.doc-table th { background: #f1f3f5; }
.doc-totals td { border: 0 !important; padding: .2rem .75rem !important; }
.doc-totals .grand td { font-size: 1.15rem; font-weight: 700; border-top: 2px solid #212529 !important; }
.page-break { break-after: page; }
@media print {
  .print-body { background: #fff; }
  .doc-page { box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .app-sidebar, .app-topbar, .quickbar, .d-print-none { display: none !important; }
  .app-main { padding: 0; }
  a { text-decoration: none; color: inherit; }
}

@media (max-width: 575.98px) {
  .app-main { padding: 1rem .85rem 5.5rem; }
  .page-head h1 { font-size: 1.3rem; }
  .stat { padding: .85rem; }
  .stat .value { font-size: 1.2rem; }
  .table-responsive-stack thead { display: none; }
  .table-responsive-stack tr { display: block; border-bottom: 1px solid var(--bs-border-color); padding: .5rem 0; }
  .table-responsive-stack td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .2rem .5rem !important; text-align: right; }
  .table-responsive-stack td::before { content: attr(data-label); font-weight: 600; color: var(--bs-secondary-color); text-align: left; }
  .table-responsive-stack td.actions { justify-content: flex-end; }
  .table-responsive-stack td.actions::before { content: none; }
  .doc-page { padding: 1.25rem; }
}
.table-section > th, .table-section > td { background: var(--bf-muted-bg) !important; color: var(--bs-body-color); font-weight: 650; }

/* User manual */
.manual { max-width: 860px; line-height: 1.6; }
.manual h2 { font-size: 1.35rem; margin: 2rem 0 .75rem; padding-top: .75rem; border-top: 1px solid var(--bs-border-color); scroll-margin-top: 72px; }
.manual h2:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.manual h3 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; scroll-margin-top: 72px; }
.manual-table { margin: .75rem 0 1rem; }
.manual-table th { background: var(--bf-muted-bg); }
.manual-note { border-left: 4px solid var(--bs-primary); background: rgba(var(--bs-primary-rgb), .07); padding: .6rem 1rem; border-radius: .35rem; margin: 1rem 0; }
.manual-code { background: var(--bf-muted-bg); padding: .75rem 1rem; border-radius: .4rem; }
.manual-toc { max-height: calc(100vh - 90px); overflow-y: auto; }
@media print { .manual-toc, .page-head .actions, nav[aria-label="Settings sections"] { display: none !important; } .manual { max-width: none; } }
