/*
 * HriVer Finance — design system
 * Layout: fixed ink sidebar (nav) + light working area. Panels are white with a 1px rule,
 * no drop shadows; hierarchy comes from type and spacing, not boxes.
 * Money colours carry meaning everywhere: collected = green, outstanding = amber,
 * overdue = red, still to bill = slate. The gold accent marks "you are here" and focus only.
 */

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../vendor/fonts/plus-jakarta-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../vendor/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --ink: #14213d;
  --ink-2: #24365c;
  --ink-soft: #3c4a66;
  --paper: #f5f6f8;
  --surface: #ffffff;
  --line: #e1e5eb;
  --line-strong: #cdd3dc;
  --text: #1b2333;
  --muted: #5f6b7d;
  --faint: #8a94a5;
  --gold: #c9a227;
  --gold-soft: #f6eed3;

  --collected: #1f7a55;
  --collected-soft: #e5f3ec;
  --outstanding: #a96a10;
  --outstanding-soft: #fbf0dc;
  --overdue: #b42318;
  --overdue-soft: #fbe7e5;
  --tobill: #5b6b82;
  --tobill-soft: #eceff4;
  --info: #24589c;
  --info-soft: #e6eef9;

  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-w: 240px;
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* Bootstrap hooks */
  --bs-body-font-family: var(--font);
  --bs-body-font-size: 0.9375rem;
  --bs-body-color: var(--text);
  --bs-body-bg: var(--paper);
  --bs-border-color: var(--line);
  --bs-primary: var(--ink);
  --bs-primary-rgb: 20, 33, 61;
  --bs-link-color: var(--info);
  --bs-link-color-rgb: 36, 88, 156;
  --bs-link-hover-color: var(--ink);
  --bs-secondary-color: var(--muted);
  --bs-success-rgb: 31, 122, 85;
  --bs-danger-rgb: 180, 35, 24;
  --bs-warning-rgb: 169, 106, 16;
  --bs-info-rgb: 36, 88, 156;
  --bs-border-radius: var(--radius-sm);
  --bs-border-radius-lg: var(--radius);
  --bs-focus-ring-color: rgba(201, 162, 39, 0.35);
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.text-muted { color: var(--muted) !important; }
.text-success { color: var(--collected) !important; }
.text-danger { color: var(--overdue) !important; }
.text-warning { color: var(--outstanding) !important; }
.text-info { color: var(--info) !important; }
.text-primary { color: var(--ink) !important; }
.text-dark { color: var(--text) !important; }
code, kbd, .font-monospace, .doc-no { font-family: var(--mono); font-size: 0.85em; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

h1, .h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); text-wrap: balance; }
h2, .h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.015em; color: var(--ink); }
h3, .h3 { font-size: 1.1rem; font-weight: 650; color: var(--ink); }
h4, .h4, h5, .h5 { font-size: 1rem; font-weight: 650; color: var(--ink); }
h6, .h6 { font-size: 0.9rem; font-weight: 650; color: var(--ink); }
.text-uppercase { text-transform: none !important; letter-spacing: 0 !important; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  background: var(--ink);
  color: #c9d1e0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 22px;
  color: #fff;
  text-decoration: none;
}
.brand:hover { color: #fff; }
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--gold);
  color: var(--ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 0.95rem;
  flex: none;
}
.brand-name { font-weight: 700; font-size: 0.95rem; line-height: 1.15; }
.brand-sub { display: block; font-size: 0.75rem; font-weight: 500; color: #8f9bb3; }

.nav-group { margin-top: 14px; }
.nav-group-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #7f8ba3;
  padding: 0 10px 6px;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: #c9d1e0;
  text-decoration: none;
  font-weight: 550;
  font-size: 0.9rem;
  position: relative;
}
.side-link .bi { font-size: 1.05rem; opacity: 0.85; width: 18px; text-align: center; }
.side-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.side-link.active { background: rgba(255, 255, 255, 0.1); color: #fff; }
.side-link.active::before {
  content: "";
  position: absolute; left: -14px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--gold);
}
.sidebar-foot {
  margin-top: auto;
  padding: 14px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
}
.sidebar-foot a { color: #c9d1e0; text-decoration: none; }
.sidebar-foot a:hover { color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: 12px;
  height: 60px;
  padding: 0 32px;
  background: rgba(245, 246, 248, 0.92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-weight: 650; color: var(--ink); font-size: 0.95rem; }
.topbar .ms-auto { display: flex; align-items: center; gap: 10px; }
.menu-toggle { display: none; }
.content { padding: 28px 32px 48px; flex: 1; }
.content > .alert { max-width: 960px; }

@media (max-width: 991.98px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 1045;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(10, 16, 30, 0.45); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 40px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------- Page header ---------- */
.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 12px 24px; margin-bottom: 24px;
}
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 64ch; }

/* ---------- Panels (Bootstrap cards) ---------- */
.card {
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  box-shadow: none !important;
  background: var(--surface);
  margin-bottom: 20px;
}
.row > [class*="col"] > .card { margin-bottom: 0; }
.card.h-100 { margin-bottom: 0; }
.card-header {
  background: var(--surface) !important;
  color: var(--ink) !important;
  border-bottom: 1px solid var(--line) !important;
  font-weight: 650;
  font-size: 0.95rem;
  padding: 14px 18px;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-header .text-white, .card-header.text-white { color: var(--ink) !important; }
.card-header small, .card-header .small { font-weight: 500; color: var(--muted); }
.card-body { padding: 18px; }
.card-footer { background: #fafbfc; border-top: 1px solid var(--line); }
.shadow, .shadow-sm, .shadow-lg { box-shadow: none !important; }
.bg-light { background: #f7f8fa !important; }
.bg-primary { background: var(--ink) !important; }
.bg-white { background: var(--surface) !important; }

/* ---------- Buttons ---------- */
.btn { font-weight: 600; border-radius: var(--radius-sm); font-size: 0.9rem; padding: 0.45rem 0.9rem; }
.btn-sm { font-size: 0.82rem; padding: 0.3rem 0.65rem; }
.btn-primary {
  --bs-btn-bg: var(--ink); --bs-btn-border-color: var(--ink);
  --bs-btn-hover-bg: var(--ink-2); --bs-btn-hover-border-color: var(--ink-2);
  --bs-btn-active-bg: #0d1730; --bs-btn-active-border-color: #0d1730;
  --bs-btn-disabled-bg: var(--ink-soft); --bs-btn-disabled-border-color: var(--ink-soft);
  background: var(--ink); border-color: var(--ink);
}
.btn-primary:hover { background: var(--ink-2); }
.btn-outline-primary {
  --bs-btn-color: var(--ink); --bs-btn-border-color: var(--line-strong);
  --bs-btn-hover-bg: var(--ink); --bs-btn-hover-border-color: var(--ink); --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--ink); --bs-btn-active-border-color: var(--ink);
}
.btn-outline-secondary, .btn-light, .btn-secondary {
  --bs-btn-color: var(--text); --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--line-strong);
  --bs-btn-hover-bg: #eef1f5; --bs-btn-hover-border-color: var(--line-strong); --bs-btn-hover-color: var(--ink);
  --bs-btn-active-bg: #e6eaf0; --bs-btn-active-border-color: var(--line-strong); --bs-btn-active-color: var(--ink);
}
.btn-success {
  --bs-btn-bg: var(--collected); --bs-btn-border-color: var(--collected);
  --bs-btn-hover-bg: #186446; --bs-btn-hover-border-color: #186446;
}
.btn-outline-success {
  --bs-btn-color: var(--collected); --bs-btn-border-color: #a9d3bf;
  --bs-btn-hover-bg: var(--collected); --bs-btn-hover-border-color: var(--collected);
}
.btn-danger { --bs-btn-bg: var(--overdue); --bs-btn-border-color: var(--overdue); --bs-btn-hover-bg: #941c13; --bs-btn-hover-border-color: #941c13; }
.btn-outline-danger { --bs-btn-color: var(--overdue); --bs-btn-border-color: #f0b9b3; --bs-btn-hover-bg: var(--overdue); --bs-btn-hover-border-color: var(--overdue); }
.btn-warning { --bs-btn-bg: var(--gold); --bs-btn-border-color: var(--gold); --bs-btn-color: var(--ink); --bs-btn-hover-bg: #b38f1f; --bs-btn-hover-border-color: #b38f1f; }
.btn-info, .btn-outline-info { --bs-btn-color: var(--info); --bs-btn-bg: transparent; --bs-btn-border-color: #b9cde8; --bs-btn-hover-bg: var(--info); --bs-btn-hover-border-color: var(--info); --bs-btn-hover-color: #fff; }
.btn-link { --bs-btn-color: var(--info); font-weight: 600; text-decoration: none; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 0.3rem; }
.form-control, .form-select {
  border-color: var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--surface);
}
.form-control-sm, .form-select-sm { font-size: 0.85rem; padding: 0.35rem 0.6rem; }
.form-control:focus, .form-select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.22); }
.form-text, .form-control + small, .help-text { color: var(--muted); font-size: 0.8rem; }
.form-check-input:checked { background-color: var(--ink); border-color: var(--ink); }
.input-group-text { background: #f2f4f7; border-color: var(--line-strong); color: var(--muted); }

/* ---------- Tables ---------- */
.table {
  --bs-table-bg: transparent;
  --bs-table-hover-bg: #f7f9fb;
  --bs-table-striped-bg: #fafbfc;
  margin-bottom: 0;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  background: transparent;
}
.table > :not(caption) > * > * { padding: 0.7rem 0.85rem; border-bottom-color: var(--line); vertical-align: middle; }
.table thead th, .table > thead > tr > th, .table-light th, thead.table-light th, thead.table-dark th {
  background: #f8f9fb !important;
  color: var(--muted) !important;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid var(--line) !important;
  white-space: nowrap;
}
.table-dark { --bs-table-bg: #f8f9fb; --bs-table-color: var(--muted); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table td.text-end, .table th.text-end { white-space: nowrap; }
.table a { font-weight: 600; text-decoration: none; }
.table-responsive { border-radius: var(--radius); }
.card > .table-responsive, .card > .table, .card > .card-body > .table-responsive:only-child { margin: 0; }
.card-body.p-0 .table thead th:first-child, .card > .table-responsive .table thead th:first-child { padding-left: 18px; }
.card-body.p-0 .table td:first-child, .card > .table-responsive .table td:first-child { padding-left: 18px; }

/* ---------- Status pills (badges) ---------- */
.badge {
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.32em 0.6em;
  border-radius: 999px;
  letter-spacing: 0;
}
.badge.bg-success, .badge.text-bg-success { background: var(--collected-soft) !important; color: var(--collected) !important; }
.badge.bg-danger, .badge.text-bg-danger { background: var(--overdue-soft) !important; color: var(--overdue) !important; }
.badge.bg-warning, .badge.text-bg-warning { background: var(--outstanding-soft) !important; color: var(--outstanding) !important; }
.badge.bg-info, .badge.text-bg-info, .badge.bg-primary, .badge.text-bg-primary { background: var(--info-soft) !important; color: var(--info) !important; }
.badge.bg-secondary, .badge.text-bg-secondary, .badge.bg-light, .badge.bg-dark { background: var(--tobill-soft) !important; color: var(--tobill) !important; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius); border: 1px solid; font-size: 0.92rem; }
.alert-success { background: var(--collected-soft); border-color: #b6dcc9; color: #155c3f; }
.alert-danger, .alert-error { background: var(--overdue-soft); border-color: #f1c0ba; color: #8c1c13; }
.alert-warning { background: var(--outstanding-soft); border-color: #efd29f; color: #7d4f0c; }
.alert-info { background: var(--info-soft); border-color: #bcd0ec; color: #1d4a85; }

/* ---------- Misc Bootstrap ---------- */
.nav-tabs { border-bottom-color: var(--line); }
.nav-tabs .nav-link { color: var(--muted); font-weight: 600; border: 0; border-bottom: 2px solid transparent; }
.nav-tabs .nav-link.active { color: var(--ink); border-bottom-color: var(--gold); background: transparent; }
.nav-pills .nav-link.active { background: var(--ink); }
.list-group-item { border-color: var(--line); }
.dropdown-menu { border-color: var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(20, 33, 61, 0.12); font-size: 0.9rem; }
.progress { background: #e9edf2; border-radius: 99px; }
.progress-bar { background: var(--ink); }
.modal-content { border-radius: var(--radius); border-color: var(--line); }
.pagination .page-link { color: var(--ink); border-color: var(--line); }
.pagination .active > .page-link { background: var(--ink); border-color: var(--ink); }

/* ---------- Money flow (dashboard hero) ---------- */
.flow {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px 20px;
  margin-bottom: 20px;
}
.flow-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 16px; }
.flow-label { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.flow-total { font-size: clamp(1.9rem, 3.4vw, 2.6rem); font-weight: 750; letter-spacing: -0.03em; color: var(--ink); line-height: 1.1; }
.flow-note { color: var(--muted); font-size: 0.85rem; }
.flow-bar {
  display: flex; height: 14px; border-radius: 99px; overflow: hidden;
  background: var(--tobill-soft); margin: 18px 0 16px;
}
.flow-bar span { display: block; min-width: 2px; }
.flow-bar .seg-collected { background: var(--collected); }
.flow-bar .seg-outstanding { background: #e1a640; }
.flow-bar .seg-overdue { background: var(--overdue); }
.flow-bar .seg-tobill { background: repeating-linear-gradient(135deg, #cfd6e0 0 6px, #e3e8ef 6px 12px); }
.flow-legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.flow-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; text-decoration: none; color: inherit; }
.flow-item .k { display: flex; align-items: center; gap: 7px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.flow-item .k i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.flow-item .v { font-size: 1.2rem; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.flow-item .d { font-size: 0.78rem; color: var(--faint); }
a.flow-item:hover .v { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 767.98px) {
  .flow { padding: 18px 16px; }
  .flow-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Metric strip: secondary numbers in one ruled row */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.metric { padding: 14px 18px; border-right: 1px solid var(--line); min-width: 0; }
.metric:last-child { border-right: 0; }
.metric .k { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.metric .v { font-size: 1.1rem; font-weight: 700; margin-top: 2px; }
.metric .d { font-size: 0.75rem; color: var(--faint); }
@media (max-width: 767.98px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { border-bottom: 1px solid var(--line); }
  .metric:nth-child(2n) { border-right: 0; }
}

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 8px 0 12px; }
.section-title h2 { font-size: 1.05rem; margin: 0; }
.empty { color: var(--muted); padding: 18px; text-align: center; font-size: 0.9rem; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; font-size: 0.9rem; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Login ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
}
.auth-side {
  background: var(--ink);
  color: #dbe2ee;
  padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side h2 { color: #fff; font-size: clamp(1.6rem, 2.6vw, 2.2rem); font-weight: 750; letter-spacing: -0.025em; max-width: 18ch; line-height: 1.15; }
.auth-side p { color: #a9b4c8; max-width: 40ch; }
.auth-ledger { border-top: 1px solid rgba(255,255,255,0.12); margin-top: 28px; max-width: 360px; font-variant-numeric: tabular-nums; }
.auth-ledger div { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.08); font-size: 0.9rem; }
.auth-ledger span:last-child { color: #fff; font-weight: 650; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--paper); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 1.6rem; margin-bottom: 6px; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  body { background: #fff; }
}
