/* Pearl Tech V2 — design tokens on top of Bootstrap 5.3 */
:root {
  --pt-brand: #1d4ed8;
  --pt-brand-ink: #ffffff;
  --pt-accent: #0ea5a4;
  --pt-sidebar-bg: #0f172a;
  --pt-sidebar-ink: #cbd5e1;
  --pt-sidebar-muted: #64748b;
  --pt-sidebar-active: rgba(59, 130, 246, .18);
  --pt-surface: #f5f7fb;
  --pt-card: #ffffff;
  --pt-border: #e5e7eb;
  --pt-radius: .75rem;
  --pt-sidebar-w: 256px;

  --bs-primary: var(--pt-brand);
  --bs-primary-rgb: 29, 78, 216;
  --bs-body-bg: var(--pt-surface);
  --bs-border-radius: .5rem;
  --bs-font-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-bs-theme="dark"] {
  --pt-surface: #0b1220;
  --pt-card: #111a2e;
  --pt-border: #1f2a44;
  --pt-sidebar-bg: #070d1a;
  --bs-body-bg: var(--pt-surface);
  --bs-body-color: #e2e8f0;
  --bs-secondary-color: #94a3b8;
  --bs-tertiary-bg: #16213a;
  --bs-border-color: var(--pt-border);
}

body { background: var(--pt-surface); font-size: .925rem; }
.btn-primary { --bs-btn-bg: var(--pt-brand); --bs-btn-border-color: var(--pt-brand); --bs-btn-hover-bg: #1e40af; --bs-btn-hover-border-color: #1e40af; --bs-btn-active-bg: #1e3a8a; }
.btn-outline-primary { --bs-btn-color: var(--pt-brand); --bs-btn-border-color: var(--pt-brand); --bs-btn-hover-bg: var(--pt-brand); --bs-btn-hover-border-color: var(--pt-brand); }
a { color: var(--pt-brand); }
[data-bs-theme="dark"] a { color: #93b4ff; }

/* ─── Shell ─────────────────────────────────────────────── */
.skip-link { position: absolute; left: 1rem; top: 1rem; z-index: 2000; background: #fff; padding: .5rem 1rem; border-radius: .5rem; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--pt-sidebar-w); z-index: 1040;
  background: var(--pt-sidebar-bg); color: var(--pt-sidebar-ink);
  display: flex; flex-direction: column; transition: transform .2s ease;
}
.sidebar-brand, .auth-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.25rem 1rem; }
.brand-mark {
  width: 2.25rem; height: 2.25rem; border-radius: .6rem; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--pt-brand), var(--pt-accent)); color: #fff; font-weight: 700; font-size: 1.1rem;
}
.brand-text { font-weight: 700; line-height: 1.1; color: #fff; }
.brand-text small { display: block; font-weight: 400; font-size: .72rem; color: var(--pt-sidebar-muted); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .5rem .75rem; }
.nav-group-label { text-transform: uppercase; letter-spacing: .06em; font-size: .68rem; color: var(--pt-sidebar-muted); padding: 1rem .75rem .35rem; }
.nav-link-item {
  display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border-radius: .5rem;
  color: var(--pt-sidebar-ink); text-decoration: none; font-weight: 500;
}
.nav-link-item i { font-size: 1.05rem; opacity: .85; }
.nav-link-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link-item.active { background: var(--pt-sidebar-active); color: #fff; box-shadow: inset 3px 0 0 #3b82f6; }
.sidebar-footer { padding: 1rem 1.25rem; color: var(--pt-sidebar-muted); border-top: 1px solid rgba(255, 255, 255, .06); }
.sidebar-backdrop { display: none; }

.app-main { margin-left: var(--pt-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1030; height: 60px; display: flex; align-items: center; gap: .5rem;
  padding: 0 1.5rem; background: color-mix(in srgb, var(--pt-card) 85%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--pt-border);
}
.btn-icon { width: 2.4rem; height: 2.4rem; display: grid; place-items: center; border-radius: .5rem; font-size: 1.15rem; color: var(--bs-body-color); }
.btn-icon:hover { background: var(--bs-tertiary-bg); }
.user-chip { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--pt-border); border-radius: 2rem; padding: .25rem .75rem .25rem .25rem; color: var(--bs-body-color); }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: var(--pt-brand); color: #fff; font-size: .78rem; font-weight: 600; }
.content { padding: 1.5rem 2rem; flex: 1; width: 100%; min-width: 0; }
@media (min-width: 1800px) { .content { padding-left: 2.5rem; padding-right: 2.5rem; } }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 1035; }
  .app-main { margin-left: 0; }
  .topbar, .content { padding-left: 1rem; padding-right: 1rem; }
}

/* ─── Page elements ─────────────────────────────────────── */
.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; }
.page-title { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--bs-secondary-color); margin: .15rem 0 0; }
.breadcrumb { font-size: .8rem; }

.card { background: var(--pt-card); border: 1px solid var(--pt-border); border-radius: var(--pt-radius); box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-header, .card-footer { background: transparent; border-color: var(--pt-border); }
.card-header { font-weight: 600; padding: .9rem 1.25rem; }
.table { --bs-table-bg: transparent; }
.table > thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); font-weight: 600; background: var(--bs-tertiary-bg); border-bottom-width: 1px; white-space: nowrap; }
.table > :not(caption) > * > * { padding: .7rem 1rem; border-color: var(--pt-border); }

.stat-card { transition: transform .15s ease, box-shadow .15s ease; color: inherit; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16, 24, 40, .08); }
.stat-icon { width: 2.5rem; height: 2.5rem; border-radius: .6rem; display: grid; place-items: center; background: rgba(29, 78, 216, .1); color: var(--pt-brand); font-size: 1.2rem; margin-bottom: .75rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--bs-secondary-color); margin-top: .25rem; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--bs-secondary-color); }
.empty-state i { font-size: 2.25rem; display: block; margin-bottom: .5rem; opacity: .6; }
.cell-reason { max-width: 260px; }
.hash { font-size: .7rem; }
.diff-old { background: rgba(220, 38, 38, .06); }
.diff-new { background: rgba(22, 163, 74, .08); }
.form-label { font-weight: 500; font-size: .85rem; }

/* ─── Auth screens ──────────────────────────────────────── */
.auth .auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: 2rem clamp(1rem, 6vw, 5rem); background: var(--pt-card); }
.auth-brand { padding: 0 0 2rem; }
.auth-brand .brand-text { color: var(--bs-body-color); }
.auth-card { width: 100%; max-width: 400px; }
.auth-foot { color: var(--bs-secondary-color); margin-top: 2rem; }
.auth-hero { background: radial-gradient(circle at 20% 20%, #2563eb 0, transparent 50%), radial-gradient(circle at 80% 80%, #0ea5a4 0, transparent 45%), #0f172a; color: #e2e8f0; display: flex; align-items: center; padding: 3rem; }
.auth-hero-inner { max-width: 440px; }
.auth-hero h2 { color: #fff; font-weight: 700; font-size: 2.25rem; }
.auth-hero ul { list-style: none; padding: 0; margin: 2rem 0 0; }
.auth-hero li { display: flex; gap: .75rem; align-items: center; padding: .5rem 0; }
.auth-hero li i { color: #5eead4; font-size: 1.2rem; }
@media (max-width: 991.98px) { .auth .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ─── Error page ────────────────────────────────────────── */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.error-box { text-align: center; max-width: 520px; }
.error-code { font-size: 4.5rem; font-weight: 800; background: linear-gradient(135deg, var(--pt-brand), var(--pt-accent)); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }
.error-debug { text-align: left; font-size: .72rem; max-height: 50vh; overflow: auto; margin-top: 1.5rem; padding: 1rem; background: #0f172a; color: #e2e8f0; border-radius: .5rem; }

/* ─── Phase 1b ──────────────────────────────────────────── */
.notif-badge { position: absolute; top: 2px; right: 0; min-width: 1.1rem; height: 1.1rem; padding: 0 .25rem; border-radius: 1rem; background: #dc2626; color: #fff; font-size: .65rem; font-weight: 700; display: grid; place-items: center; }
.notif-menu { width: 340px; max-height: 420px; overflow-y: auto; }
.notif-unread { background: rgba(29, 78, 216, .06); }
.notif-unread .fw-medium::before { content: ""; display: inline-block; width: .45rem; height: .45rem; border-radius: 50%; background: var(--pt-brand); margin-right: .4rem; vertical-align: middle; }
.role-option, .perm-option { display: flex; gap: .65rem; align-items: flex-start; padding: .6rem .75rem; border: 1px solid var(--pt-border); border-radius: .5rem; cursor: pointer; height: 100%; margin: 0; }
.role-option:hover, .perm-option:hover { border-color: var(--pt-brand); }
.role-option .form-check-input, .perm-option .form-check-input { margin-top: .2rem; flex-shrink: 0; }
.perm-locked { opacity: .55; cursor: not-allowed; }
.temp-password { display: inline-block; font-size: 1.25rem; padding: .4rem .8rem; background: var(--pt-card); border: 1px dashed currentColor; border-radius: .4rem; letter-spacing: .05em; }
.otp-input { letter-spacing: .4em; font-size: 1.5rem; }
.setup-steps { padding-left: 1.2rem; }
.setup-steps > li { margin-bottom: 1.25rem; }
.qr-box { display: inline-block; padding: .75rem; background: #fff; border-radius: .5rem; border: 1px solid var(--pt-border); line-height: 0; }
.qr-box svg { width: 200px; height: 200px; }
.setup-code { max-width: 320px; }
.recovery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem 1.5rem; font-size: 1.1rem; }
.recovery-grid span { padding: .35rem .6rem; background: var(--bs-tertiary-bg); border-radius: .35rem; text-align: center; }
.seq-prefix { width: 90px; }
.seq-pad { width: 60px; }
@media print {
  .sidebar, .topbar, .card-footer, .alert { display: none !important; }
  .app-main { margin: 0; }
}

/* ─── Phase 2: accounting ───────────────────────────────── */
.coa-heading td { font-weight: 600; background: var(--bs-tertiary-bg); }
.coa-depth-1 { padding-left: 1.75rem !important; }
.coa-depth-2 { padding-left: 3rem !important; }
.coa-depth-3 { padding-left: 4.25rem !important; }
.coa-depth-4 { padding-left: 5.5rem !important; }
.journal-lines .jl-account { min-width: 260px; }
.journal-lines .jl-dim { min-width: 130px; }
.journal-lines .jl-amt { width: 150px; min-width: 130px; }
@media print { .nav-tabs, form .btn, .page-header form { display: none !important; } }
td.font-monospace, th.text-end { white-space: nowrap; }
.row-group > td { background: var(--bs-tertiary-bg) !important; }

/* ─── Phase 3: HR ───────────────────────────────────────── */
.avatar-lg { width: 3.25rem; height: 3.25rem; font-size: 1.15rem; }
.pre-wrap { white-space: pre-wrap; }
.appraisal-cell { min-width: 220px; }
.stage-tracker { display: flex; list-style: none; padding: 0; margin: 0; gap: .25rem; flex-wrap: wrap; counter-reset: stage; }
.stage-tracker li { flex: 1; min-width: 120px; padding: .5rem .75rem; border-radius: .5rem; background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); font-size: .8rem; font-weight: 500; counter-increment: stage; }
.stage-tracker li::before { content: counter(stage) ". "; }
.stage-tracker li.done { background: rgba(22, 163, 74, .12); color: #15803d; }
.stage-tracker li.current { background: var(--pt-brand); color: #fff; }
[data-bs-theme="dark"] .stage-tracker li.done { color: #4ade80; }

/* ─── Phase 4: payroll ──────────────────────────────────── */
.payslip { max-width: 900px; margin: 0 auto; }
.payslip-net { background: rgba(29, 78, 216, .08); border: 1px solid rgba(29, 78, 216, .25); }
@media print {
  .payslip { border: 0; box-shadow: none; }
  body.app { background: #fff; }
}

/* ─── Phase 5: spend ────────────────────────────────────── */
.req-qty { width: 90px; }
.req-cost { width: 150px; }
.petty-low { background: #dc2626; }
.petty-ok { background: var(--pt-brand); }

/* ─── Phase 6: revenue ─────────────────────────────────── */
.doc-sheet { max-width: 1000px; }
.doc-title { letter-spacing: .08em; color: var(--pt-brand); }
.doc-label { font-size: .7rem; letter-spacing: .06em; }
.doc-balance { background: rgba(29, 78, 216, .08); border: 1px solid rgba(29, 78, 216, .25); }
.doc-lines .dl-service { min-width: 180px; }
.doc-lines .dl-qty { width: 80px; }
.doc-lines .dl-price { min-width: 140px; }
.doc-lines .dl-tax { min-width: 110px; }
.receipt-qr { width: 120px; }
.receipt-qr svg { width: 100%; height: auto; display: block; }
.catalogue-edit[open] > .card { min-width: 320px; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
@media print {
  .doc-sheet { border: 0; box-shadow: none; max-width: none; }
  .page-header { display: none !important; }
}

/* ─── Phase 7: reports ─────────────────────────────────── */
.report-card { transition: border-color .15s, box-shadow .15s; }
.report-card:hover { border-color: var(--pt-brand); box-shadow: 0 .25rem .75rem rgba(29, 78, 216, .08); }
.report-table .rt-heading td { font-weight: 600; background: var(--bs-tertiary-bg); }
.report-table .rt-subtotal td { font-weight: 600; border-top: 1px solid var(--bs-border-color); }
.report-table .rt-total td { font-weight: 700; border-top: 2px solid var(--bs-emphasis-color); border-bottom: 3px double var(--bs-emphasis-color); }
.report-table .rt-indent-1 { padding-left: 1.5rem !important; }
.report-table .rt-indent-2 { padding-left: 2.75rem !important; }
.report-table .rt-indent-3 { padding-left: 4rem !important; }
.report-table .rt-indent-4 { padding-left: 5.25rem !important; }
.dash-chart svg { width: 100%; height: auto; display: block; }
.dash-chart .bar-in { fill: #16a34a; }
.dash-chart .bar-out { fill: #dc2626; opacity: .8; }
.dash-chart text { font-size: 10px; fill: var(--bs-secondary-color); }
@media print {
  .report-sheet { border: 0; box-shadow: none; }
  .report-table { font-size: 10pt; }
}

/* ─── Phase 10: internships ────────────────────────────── */
.certificate { max-width: 900px; margin: 0 auto; border: 6px double var(--pt-brand); }
.certificate .card-body { padding: 3rem; }
.certificate-company { font-size: 1.4rem; font-weight: 700; letter-spacing: .04em; }
.certificate-title { font-size: 2rem; font-weight: 600; color: var(--pt-brand); margin-bottom: 1.5rem; }
.certificate-name { font-size: 1.8rem; font-weight: 700; border-bottom: 1px solid var(--bs-border-color); display: inline-block; padding: 0 2rem .25rem; }
.certificate-remarks { max-width: 640px; }
.certificate-sign { width: 220px; border-bottom: 1px solid var(--bs-emphasis-color); height: 2.5rem; }
@media print { .certificate { border-width: 6px; box-shadow: none; } }

/* Tasks (Phase 15) */
.task-assignees { max-height: 14rem; overflow-y: auto; }
.task-note { min-width: 12rem; }
.task-board .list-group-item-action { border-left: 0; border-right: 0; }

/* ─── Phase 17: shell polish ───────────────────────────── */
.brand-logo { width: 2.5rem; height: 2.5rem; object-fit: contain; flex-shrink: 0; }
.auth-brand .brand-logo { width: 3rem; height: 3rem; }
.topbar-brand img { width: 2rem; height: 2rem; object-fit: contain; }
.sidebar-close { color: var(--pt-sidebar-ink); }

/* Theme toggle: the icon shows what you switch *to* (moon in light mode, sun in dark mode). */
.theme-toggle .theme-icon-dark { display: none; }
[data-bs-theme="dark"] .theme-toggle .theme-icon-light { display: none; }
[data-bs-theme="dark"] .theme-toggle .theme-icon-dark { display: inline-block; color: #fbbf24; }
.theme-toggle i { transition: transform .35s ease; }
.theme-toggle:hover i { transform: rotate(-20deg); }

/* Search trigger in the top bar */
.search-trigger {
  display: flex; align-items: center; gap: .6rem; min-width: 0; width: min(420px, 100%); height: 2.4rem;
  padding: 0 .75rem; border: 1px solid var(--pt-border); border-radius: .6rem; background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color); font-size: .875rem; text-align: left; cursor: pointer;
}
.search-trigger:hover { border-color: var(--pt-brand); color: var(--bs-body-color); }
.search-trigger-text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.search-trigger-kbd { font-size: .68rem; background: var(--pt-card); color: var(--bs-secondary-color); border: 1px solid var(--pt-border); padding: .1rem .35rem; }
@media (max-width: 767.98px) {
  .search-trigger { width: 2.4rem; padding: 0; justify-content: center; border: 0; background: transparent; font-size: 1.15rem; color: var(--bs-body-color); }
  .search-trigger-text, .search-trigger-kbd { display: none; }
}

/* Page progress bar (shown while the next page loads) */
.page-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 2100; background: linear-gradient(90deg, var(--pt-brand), var(--pt-accent)); opacity: 0; transition: width .3s ease, opacity .3s ease; pointer-events: none; }
.page-progress.is-loading { opacity: 1; width: 85%; transition: width 8s cubic-bezier(.1, .7, .2, 1), opacity .2s; }
.page-progress.is-done { opacity: 0; width: 100%; }

/* Buttons that are working */
.btn.is-busy { position: relative; pointer-events: none; }
.btn.is-busy::after { content: ""; display: inline-block; width: .9em; height: .9em; margin-left: .5rem; vertical-align: -.1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: pt-spin .7s linear infinite; }
@keyframes pt-spin { to { transform: rotate(360deg); } }

/* Skeleton placeholders */
.skeleton { display: block; height: .85rem; border-radius: .35rem; background: linear-gradient(90deg, var(--bs-tertiary-bg) 25%, var(--pt-border) 50%, var(--bs-tertiary-bg) 75%); background-size: 200% 100%; animation: pt-shimmer 1.2s ease-in-out infinite; }
@keyframes pt-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Toasts */
.toast-stack { position: fixed; top: 72px; right: 1rem; z-index: 2050; display: flex; flex-direction: column; gap: .5rem; width: min(380px, calc(100vw - 2rem)); pointer-events: none; }
.pt-toast { pointer-events: auto; width: 100%; background: var(--pt-card); border: 1px solid var(--pt-border); border-left: 4px solid var(--pt-brand); border-radius: .6rem; box-shadow: 0 10px 30px rgba(15, 23, 42, .15); font-size: .9rem; }
.pt-toast-success { border-left-color: #16a34a; } .pt-toast-success .pt-toast-icon { color: #16a34a; }
.pt-toast-info { border-left-color: #0ea5e9; } .pt-toast-info .pt-toast-icon { color: #0ea5e9; }
.pt-toast-warning { border-left-color: #f59e0b; } .pt-toast-warning .pt-toast-icon { color: #f59e0b; }
.pt-toast-danger { border-left-color: #dc2626; } .pt-toast-danger .pt-toast-icon { color: #dc2626; }
.pt-toast-icon { font-size: 1.1rem; line-height: 1.3; }
.pt-toast.show { animation: pt-toast-in .25s ease-out; }
@keyframes pt-toast-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Phone bottom navigation */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; justify-content: space-around;
  background: var(--pt-card); border-top: 1px solid var(--pt-border);
  padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(15, 23, 42, .06);
}
.bottom-nav a, .bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .3rem 0; border: 0; background: none;
  color: var(--bs-secondary-color); font-size: .68rem; font-weight: 500; text-decoration: none; border-radius: .5rem;
}
.bottom-nav i { font-size: 1.25rem; line-height: 1; }
.bottom-nav a.active { color: var(--pt-brand); }
[data-bs-theme="dark"] .bottom-nav a.active { color: #93b4ff; }
.bottom-nav .bottom-nav-search i { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; margin-top: -1.1rem; border-radius: 50%; color: #fff; background: linear-gradient(135deg, var(--pt-brand), var(--pt-accent)); box-shadow: 0 6px 16px rgba(29, 78, 216, .35); }
@media (max-width: 991.98px) {
  .content { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }
  .toast-stack { top: auto; bottom: calc(5rem + env(safe-area-inset-bottom)); left: 1rem; right: 1rem; width: auto; align-items: center; }
  .pt-toast { max-width: 420px; }
  .topbar { gap: .25rem; }
  .notif-menu { width: min(340px, calc(100vw - 1.5rem)); }
}
@media (max-width: 575.98px) {
  .content { padding-top: 1rem; }
  .page-title { font-size: 1.2rem; }
  .page-header { margin-bottom: 1rem; }
  .user-chip { padding: .2rem; border: 0; }
  .user-chip.dropdown-toggle::after { display: none; }
}
@media print { .bottom-nav, .toast-stack, .page-progress { display: none !important; } }

/* Search palette */
.search-overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px); display: flex; justify-content: center; align-items: flex-start; padding: 10vh 1rem 1rem; animation: pt-fade .15s ease-out; }
@keyframes pt-fade { from { opacity: 0; } }
.search-box { width: min(640px, 100%); max-height: 75vh; display: flex; flex-direction: column; background: var(--pt-card); border: 1px solid var(--pt-border); border-radius: .9rem; box-shadow: 0 24px 60px rgba(15, 23, 42, .35); overflow: hidden; }
.search-head { display: flex; align-items: center; gap: .6rem; padding: .25rem 1rem; border-bottom: 1px solid var(--pt-border); }
.search-head > i { color: var(--bs-secondary-color); font-size: 1.1rem; }
.search-input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--bs-body-color); font-size: 1.05rem; padding: .85rem 0; }
.search-input::-webkit-search-cancel-button { display: none; }
.search-spin { width: 1rem; height: 1rem; border: 2px solid var(--pt-border); border-top-color: var(--pt-brand); border-radius: 50%; animation: pt-spin .7s linear infinite; visibility: hidden; flex-shrink: 0; }
.search-box.is-loading .search-spin { visibility: visible; }
.search-close { border: 0; background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); border-radius: .35rem; font-size: .72rem; padding: .15rem .45rem; }
.search-list { overflow-y: auto; padding: .4rem; }
.search-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bs-secondary-color); padding: .6rem .75rem .25rem; font-weight: 600; }
.search-row { display: flex; align-items: center; gap: .75rem; padding: .5rem .75rem; border-radius: .5rem; color: var(--bs-body-color); text-decoration: none; }
.search-row > i { width: 1.9rem; height: 1.9rem; display: grid; place-items: center; border-radius: .45rem; background: rgba(29, 78, 216, .1); color: var(--pt-brand); flex-shrink: 0; }
.search-text { min-width: 0; flex: 1; }
.search-title { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-note { display: block; font-size: .78rem; color: var(--bs-secondary-color); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-row mark { padding: 0; background: rgba(250, 204, 21, .35); color: inherit; border-radius: 2px; }
.search-row.is-active, .search-row:hover { background: rgba(29, 78, 216, .08); color: var(--bs-body-color); }
.search-skeleton { padding: .5rem .75rem; display: grid; gap: .6rem; }
.search-none { padding: 2rem 1rem; text-align: center; color: var(--bs-secondary-color); }
.search-foot { padding: .5rem 1rem; border-top: 1px solid var(--pt-border); font-size: .74rem; color: var(--bs-secondary-color); display: flex; gap: 1rem; }
@media (max-width: 575.98px) { .search-overlay { padding: 0; } .search-box { max-height: none; height: 100%; border-radius: 0; border: 0; } .search-foot { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ─── Phase 17: dashboard ──────────────────────────────── */
.dash-hero { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; }
.quick-actions { display: flex; gap: .5rem; overflow-x: auto; max-width: 100%; padding-bottom: 2px; scrollbar-width: none; }
.quick-actions::-webkit-scrollbar { display: none; }
.quick-action { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; padding: .45rem .8rem; border: 1px solid var(--pt-border); border-radius: 2rem; background: var(--pt-card); color: var(--bs-body-color); font-size: .82rem; font-weight: 500; text-decoration: none; transition: border-color .15s, color .15s, transform .15s; }
.quick-action i { color: var(--pt-brand); }
.quick-action:hover { border-color: var(--pt-brand); color: var(--pt-brand); transform: translateY(-1px); }
[data-bs-theme="dark"] .quick-action i, [data-bs-theme="dark"] .quick-action:hover { color: #93b4ff; }

.kpi-card { color: inherit; transition: transform .15s ease, box-shadow .15s ease, border-color .15s; }
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(16, 24, 40, .08); border-color: color-mix(in srgb, var(--pt-brand) 35%, var(--pt-border)); }
.kpi-icon { width: 2.5rem; height: 2.5rem; border-radius: .7rem; display: grid; place-items: center; font-size: 1.15rem; }
.kpi-label { color: var(--bs-secondary-color); font-size: .8rem; font-weight: 500; margin-top: .85rem; }
.kpi-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; margin-top: .15rem; letter-spacing: -.01em; overflow-wrap: anywhere; }
.kpi-sub { font-size: .76rem; color: var(--bs-secondary-color); margin-top: .35rem; }
.kpi-delta { display: inline-flex; align-items: center; gap: .15rem; font-size: .74rem; font-weight: 600; padding: .15rem .45rem; border-radius: 2rem; }
.kpi-delta.is-good { background: rgba(22, 163, 74, .12); color: #15803d; }
.kpi-delta.is-bad { background: rgba(220, 38, 38, .1); color: #b91c1c; }
[data-bs-theme="dark"] .kpi-delta.is-good { color: #4ade80; }
[data-bs-theme="dark"] .kpi-delta.is-bad { color: #f87171; }
.tone-blue { background: rgba(37, 99, 235, .12); color: #2563eb; }
.tone-green { background: rgba(22, 163, 74, .12); color: #16a34a; }
.tone-red { background: rgba(220, 38, 38, .1); color: #dc2626; }
.tone-amber { background: rgba(245, 158, 11, .14); color: #d97706; }
.tone-teal { background: rgba(13, 148, 136, .12); color: #0d9488; }
.tone-indigo { background: rgba(79, 70, 229, .12); color: #4f46e5; }
.tone-violet { background: rgba(124, 58, 237, .12); color: #7c3aed; }
.tone-slate { background: rgba(71, 85, 105, .12); color: #475569; }
[data-bs-theme="dark"] .tone-slate { color: #94a3b8; }
.attention-card { border-left: 4px solid #f59e0b; }

/* 12-month chart */
.trend-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.trend-chart .grid { stroke: var(--pt-border); stroke-dasharray: 3 4; }
.trend-chart .zero { stroke: var(--bs-secondary-color); stroke-width: 1; opacity: .5; }
.trend-chart .axis { font-size: 10px; fill: var(--bs-secondary-color); }
.trend-chart .bar-in { fill: #2563eb; }
.trend-chart .bar-out { fill: #f59e0b; opacity: .85; }
.trend-chart .net-line { fill: none; stroke: #16a34a; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.trend-chart .net-dot { fill: var(--pt-card); stroke: #16a34a; stroke-width: 2; }
.trend-chart .hit { fill: transparent; }
.trend-chart .month:hover .hit { fill: rgba(37, 99, 235, .06); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .78rem; color: var(--bs-secondary-color); margin-top: .5rem; }
.legend-swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: .2rem; margin-right: .35rem; vertical-align: -.05rem; }
.sw-in { background: #2563eb; } .sw-out { background: #f59e0b; } .sw-net { background: #16a34a; height: .2rem; vertical-align: .15rem; }

/* Ageing */
.stack-bar { width: 100%; height: .75rem; display: block; border-radius: .4rem; overflow: hidden; }
.stack-bar rect.seg-0, .legend-swatch.seg-0 { fill: #16a34a; background: #16a34a; }
.stack-bar rect.seg-1, .legend-swatch.seg-1 { fill: #facc15; background: #facc15; }
.stack-bar rect.seg-2, .legend-swatch.seg-2 { fill: #f59e0b; background: #f59e0b; }
.stack-bar rect.seg-3, .legend-swatch.seg-3 { fill: #ef4444; background: #ef4444; }
.stack-bar rect.seg-4, .legend-swatch.seg-4 { fill: #991b1b; background: #991b1b; }
.ageing-list li { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px dashed var(--pt-border); font-size: .85rem; }
.ageing-list li:last-child { border-bottom: 0; }
.ageing-pct { width: 2.5rem; text-align: right; }

/* Ranked lists */
.ranked-list { list-style: none; padding: 0; margin: 0; counter-reset: rank; display: grid; gap: .8rem; }
.ranked-list li { counter-increment: rank; position: relative; padding-left: 1.6rem; font-size: .875rem; }
.ranked-list li::before { content: counter(rank); position: absolute; left: 0; top: .05rem; width: 1.15rem; height: 1.15rem; border-radius: 50%; background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); font-size: .68rem; font-weight: 700; display: grid; place-items: center; }
.rank-bar { width: 100%; height: 6px; display: block; margin-top: .3rem; }
.rank-bar .track { fill: var(--bs-tertiary-bg); }
.rank-bar .fill { fill: var(--pt-brand); }
.ranked-list li:nth-child(n+2) .rank-bar .fill { opacity: .75; }
.ranked-list li:nth-child(n+4) .rank-bar .fill { opacity: .55; }

.people-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; text-align: center; }
.people-grid .stat-value { font-size: 1.5rem; }
.avatar-sm { width: 1.9rem; height: 1.9rem; font-size: .72rem; flex-shrink: 0; }
.min-w-0 { min-width: 0; }
@media (max-width: 575.98px) {
  .dash-hero { flex-direction: column; align-items: stretch; }
  .kpi-value { font-size: 1.25rem; }
}

/* Phase 17 fixes after the visual check */
.kpi-card, [data-bs-theme="dark"] .kpi-card, .stat-card, [data-bs-theme="dark"] .stat-card { color: var(--bs-body-color); }
.chart-scroll { overflow-x: auto; }
@media (max-width: 575.98px) {
  .chart-scroll svg { min-width: 520px; }
  .kpi-card .card-body { padding: .85rem; }
  .kpi-icon { width: 2rem; height: 2rem; font-size: .95rem; border-radius: .55rem; }
  .kpi-label { margin-top: .6rem; font-size: .74rem; }
  .kpi-value { font-size: 1.02rem; }
  .kpi-sub { font-size: .7rem; }
  .kpi-delta { font-size: .66rem; padding: .1rem .35rem; }
}

/* ─── Dashboard: three-year comparison, top clients, expense mix ─── */
.year-chart { width: 100%; max-width: 420px; height: auto; display: block; margin: 0 auto; }
.year-chart .base { stroke: var(--pt-border); }
.year-chart .bar-in { fill: #2563eb; }
.year-chart .bar-out { fill: #f59e0b; }
.year-chart .bar-net { fill: #16a34a; }
.year-chart .bar-loss { fill: #dc2626; }
.year-chart .axis { font-size: 10px; fill: var(--bs-secondary-color); }
.year-chart .axis.is-current { font-weight: 600; fill: var(--bs-body-color); }
.sw-netbar { background: #16a34a; }
.year-table th, .year-table td { white-space: nowrap; }
.year-table tr.is-current > * { background: rgba(37, 99, 235, .05); }

.client-rank { list-style: none; padding: 0; margin: 0; display: grid; gap: .9rem; }
.client-rank li { display: flex; gap: .75rem; align-items: flex-start; }
.client-avatar { width: 2.4rem; height: 2.4rem; flex-shrink: 0; border-radius: .7rem; display: grid; place-items: center; font-size: .78rem; font-weight: 700; letter-spacing: .02em; }
.client-rank-body { flex: 1; min-width: 0; }
.client-rank-name { font-weight: 600; color: var(--bs-body-color); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.client-rank-name:hover { color: var(--pt-brand); text-decoration: underline; }
[data-bs-theme="dark"] .client-rank-name { color: var(--bs-body-color); }
.client-rank-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.client-rank .rank-bar { margin-top: .4rem; }
.client-rank li:first-child .rank-bar .fill { fill: #2563eb; }

.expense-mix { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 1.25rem; align-items: center; }
.donut-wrap { position: relative; width: 170px; height: 170px; }
.donut { width: 100%; height: 100%; transform: rotate(0deg); }
.donut-track { fill: none; stroke: var(--bs-tertiary-bg); stroke-width: 6; }
.donut-seg { fill: none; stroke-width: 6; transition: stroke-width .15s; }
.donut-seg:hover { stroke-width: 7.5; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-total { font-size: 1.35rem; font-weight: 700; line-height: 1; }
.donut-caption { font-size: .72rem; color: var(--bs-secondary-color); margin-top: .2rem; }
.expense-legend { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; font-size: .85rem; }
.expense-legend li { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.expense-legend .legend-swatch { flex-shrink: 0; margin-right: 0; }
.expense-share { width: 2.6rem; text-align: right; color: var(--bs-secondary-color); font-size: .78rem; }
.exp-c0 { stroke: #2563eb; background: #2563eb; }
.exp-c1 { stroke: #f59e0b; background: #f59e0b; }
.exp-c2 { stroke: #0d9488; background: #0d9488; }
.exp-c3 { stroke: #7c3aed; background: #7c3aed; }
.exp-c4 { stroke: #ef4444; background: #ef4444; }
.exp-c5 { stroke: #0ea5e9; background: #0ea5e9; }
.exp-c6 { stroke: #84cc16; background: #84cc16; }
.exp-c7 { stroke: #94a3b8; background: #94a3b8; }
@media (max-width: 575.98px) {
  .expense-mix { grid-template-columns: 1fr; justify-items: center; }
  .expense-legend { width: 100%; }
}
.expense-mix { grid-template-columns: 150px minmax(0, 1fr); }
.donut-wrap { width: 150px; height: 150px; }
.expense-name { min-width: 0; line-height: 1.25; }
.year-table { font-size: .85rem; }
.year-table > :not(caption) > * > * { padding: .5rem .55rem; }
.client-rank-body > .d-flex > :first-child { flex: 1 1 auto; min-width: 0; }
.client-rank-body > .d-flex > :last-child { flex-shrink: 0; }
.client-rank-name { display: block; }
@media (max-width: 575.98px) {
  .expense-mix { grid-template-columns: 1fr; justify-items: center; }
  .client-avatar { width: 2rem; height: 2rem; font-size: .7rem; }
}
.client-rank, .expense-legend, .ranked-list { grid-template-columns: minmax(0, 1fr); }
.client-rank li, .expense-legend li { min-width: 0; }

/* Dashboard: ratio meter, revenue sources, renewals */
.kpi-meter { width: 100%; height: 8px; display: block; margin-top: .55rem; }
.kpi-meter .track { fill: var(--bs-tertiary-bg); }
.kpi-meter .mark { stroke: var(--bs-body-color); stroke-width: .8; opacity: .55; }
.tone-fill-green { fill: #16a34a; } .tone-fill-amber { fill: #f59e0b; } .tone-fill-red { fill: #dc2626; } .tone-fill-slate { fill: #94a3b8; }
.src-c0 { fill: #2563eb; background: #2563eb; }
.src-c1 { fill: #0d9488; background: #0d9488; }
.src-c2 { fill: #7c3aed; background: #7c3aed; }
.src-c3 { fill: #f59e0b; background: #f59e0b; }
.src-c4 { fill: #0ea5e9; background: #0ea5e9; }
.src-c5 { fill: #ec4899; background: #ec4899; }
.src-c6 { fill: #84cc16; background: #84cc16; }
.src-c7 { fill: #94a3b8; background: #94a3b8; }
.source-bar { height: .9rem; }
.renewal-table td, .renewal-table th { vertical-align: middle; }

/* 12-month grouped bars */
.trend-chart .bar-in { fill: #16a34a; opacity: 1; }
.trend-chart .bar-out { fill: #dc2626; opacity: 1; }
.trend-chart .bar-net { fill: #2563eb; }
.trend-chart .bar-net.is-loss { fill: #93c5fd; }
.trend-chart .axis { font-size: 11px; }
.trend-chart .month-label { font-weight: 600; fill: var(--bs-secondary-color); }
.trend-chart .grid { stroke-dasharray: 4 4; }
.trend-chart .month:hover .hit { fill: rgba(37, 99, 235, .05); }
.trend-chart .chart-scroll svg { min-width: 760px; }
.legend-dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .35rem; vertical-align: -.05rem; }
.legend-dot.sw-in { background: #16a34a; } .legend-dot.sw-out { background: #dc2626; } .legend-dot.sw-net { background: #2563eb; height: .7rem; }
.section-title { display: inline-flex; align-items: center; gap: .55rem; text-transform: uppercase; letter-spacing: .04em; font-size: .82rem; }
.section-title::before { content: ""; width: 4px; height: 1.05rem; border-radius: 2px; background: #4f46e5; }
.year-chart .bar-in { fill: #16a34a; } .year-chart .bar-out { fill: #dc2626; } .year-chart .bar-net { fill: #2563eb; } .year-chart .bar-loss { fill: #93c5fd; }
