/* ============ Bank Loan System look (user request 2026-09-18) ============
   Loaded AFTER styles.css and only overrides it: fonts, colors, cards,
   tables and buttons, with values copied from the Bank Loan System's
   public/css/app.css. Spec: docs/superpowers/specs/
   2026-09-18-detail-screens-and-restyle-design.md, Part 2. */
:root {
  --bl-bg: #f4f6fa; --bl-surface: #ffffff; --bl-surface-2: #f9fafc; --bl-border: #e3e8f0;
  --bl-text: #1e2a3a; --bl-text-2: #5a6b80; --bl-text-3: #8b99ad;
  --bl-primary: #4a6fa5; --bl-primary-dark: #37547e; --bl-primary-soft: #e8eef7;
  --bl-green: #3d8b62; --bl-green-soft: #e2f2e9;
  --bl-yellow: #a07d1c; --bl-yellow-soft: #faf1d7; --bl-gold: #d8b64a;
  --bl-orange: #b3591a; --bl-orange-soft: #fce8da; --bl-orange-bar: #d98a4d;
  --bl-red: #b03a3a; --bl-red-soft: #fbe3e3;
  --bl-blue: #2f6fa7; --bl-blue-soft: #e1eefa;
  --bl-sidebar: #223148;
  --bl-shadow: 0 1px 3px rgba(30,42,58,.07), 0 4px 14px rgba(30,42,58,.05);

  /* Re-point the existing tokens so every older rule follows the palette. */
  --navy: var(--bl-sidebar); --navy-soft: var(--bl-primary-dark);
  --bg: var(--bl-bg); --band: var(--bl-surface-2); --line: var(--bl-border);
  --ink: var(--bl-text); --muted: var(--bl-text-3);
  --p-blue: var(--bl-blue-soft); --p-mint: var(--bl-green-soft); --p-amber: var(--bl-yellow-soft);
  --p-rose: var(--bl-red-soft); --p-gray: #eef1f6;
  --a-blue: var(--bl-primary); --a-green: var(--bl-green); --a-amber: var(--bl-yellow);
  --a-rose: var(--bl-red);
  --radius: 10px; --radius-sm: 10px; --shadow: var(--bl-shadow);
}

body { font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; -webkit-font-smoothing: antialiased;
  background: var(--bl-bg); color: var(--bl-text); }
h1, h2, h3, h4 { color: var(--bl-text); }
.page-title { font-size: 21px; font-weight: 800; letter-spacing: .01em; }
.muted { color: var(--bl-text-3); }

/* ---- staff shell: white top bar beside a navy sidebar ---- */
body.has-sidebar .topbar { background: var(--bl-surface); color: var(--bl-text);
  border-bottom: 1px solid var(--bl-border); }
body.has-sidebar .topbar .brand-text strong { color: var(--bl-text); }
body.has-sidebar .topbar .brand-text span { color: var(--bl-text-3); opacity: 1; }
body.has-sidebar .topbar .icon-btn { color: var(--bl-text-2); }
body.has-sidebar .topbar .icon-btn:hover { background: var(--bl-surface-2); }
body.has-sidebar .user-chip { background: var(--bl-primary-soft); color: var(--bl-primary-dark); font-weight: 600; }
/* Suppliers and brokers keep their header menu, in the sidebar navy. */
.topbar { background: var(--bl-sidebar); }

.sidebar { background: var(--bl-sidebar); width: 248px; padding: 10px 8px 14px; }
.sidebar .side-lbl { color: #8fa0b8; font-size: 9.5px; letter-spacing: .1em; padding: 4px 12px; }
.sidebar a { color: #b9c6d8; font-size: 13px; font-weight: 500; text-transform: uppercase;
  letter-spacing: .01em; border-left: 0; border-radius: 8px; padding: 9px 12px; margin: 1px 0; }
.sidebar a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar a.active { background: var(--bl-primary); color: #fff; font-weight: 600; }

/* ---- cards, bands ---- */
.card { background: var(--bl-surface); border: 1px solid var(--bl-border); border-radius: 10px; box-shadow: var(--bl-shadow); }
.band { background: transparent; border: 0; padding: 0; margin-bottom: 22px; }
.band .card { box-shadow: var(--bl-shadow); }
.band-head h3, .chart-card h3, .card h3 { font-size: 14px; font-weight: 700; letter-spacing: .02em; }
.sec-label { color: var(--bl-text-2); font-size: 12px; letter-spacing: .1em; }

/* ---- KPI tiles: white card, 3px colored top edge ---- */
.kpi { background: var(--bl-surface); border: 1px solid var(--bl-border); border-top: 3px solid var(--bl-blue);
  border-radius: 10px; box-shadow: var(--bl-shadow); padding: 16px 18px 14px; }
.kpi.blue { background: var(--bl-surface); border-top-color: var(--bl-blue); }
.kpi.mint { background: var(--bl-surface); border-top-color: var(--bl-green); }
.kpi.amber { background: var(--bl-surface); border-top-color: var(--bl-gold); }
.kpi.lav { background: var(--bl-surface); border-top-color: var(--bl-orange-bar); }
.kpi.rose { background: var(--bl-surface); border-top-color: var(--bl-red); }
.kpi.gray { background: var(--bl-surface); border-top-color: var(--bl-text-3); }
/* Wider tiles (Bank Loan's grid is 4-up): at the old 160px minimum a
   ₱1,578,822,505.75 total could only fit at an unreadable size. */
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 14px; }
/* One line per value and label, always (user report 2026-09-18: long peso
   totals wrapped and ran under the icon). Length classes set the starting
   size; fitKpiText() in app.js shrinks whatever still overflows its box. */
.kpi-n { font-size: 20px; font-weight: 800; letter-spacing: -.01em; color: var(--bl-text);
  white-space: nowrap; overflow: hidden; }
.kpi-n.kpi-n-md { font-size: 17px; }
.kpi-n.kpi-n-sm { font-size: 15px; }
.kpi:has(.kpi-ic) .kpi-n { padding-right: 34px; }
.kpi.rose .kpi-n { color: var(--bl-red); }
.kpi-l { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--bl-text-3); margin-top: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-ic { background: var(--bl-surface-2); color: var(--bl-primary); }
.kpi.clickable:hover { box-shadow: 0 2px 6px rgba(30,42,58,.1), 0 8px 20px rgba(30,42,58,.08); }

/* ---- tables ---- */
table { background: var(--bl-surface); font-size: 13px; }
th { background: var(--bl-surface-2); color: var(--bl-text-2); font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; }
th, td { border-bottom-color: var(--bl-surface-2); }
th:not(:last-child), td:not(:last-child) { border-right-color: var(--bl-surface-2); }
thead tr:first-child th { border-bottom: 1px solid var(--bl-border); }
tbody tr:nth-child(even) { background: var(--bl-surface); }
tbody tr:hover { background: #f6f9fd; }

/* ---- inputs ---- */
input, select, textarea { border: 1px solid var(--bl-border); border-radius: 8px; color: var(--bl-text); background: var(--bl-surface); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--bl-primary); box-shadow: 0 0 0 3px var(--bl-primary-soft); }

/* ---- buttons: every clickable control is its own colored box ----
   primary  = blue fill (default <button>, .btn)
   outline  = white with a grey border (.btn-ghost, .back, Back/Close/Cancel, pagers)
   danger   = soft red (delete / reject / deactivate)
   success  = soft green (approve / confirm / accept) */
.btn, button { background: var(--bl-primary); color: #fff; border: 1px solid transparent; border-radius: 8px;
  font-weight: 600; font-size: 13.5px; }
.btn:hover, button:hover { background: var(--bl-primary-dark); }
button:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; }
.perf-bar button, .sup-actions button, .trade-actions button, .detail-backrow button { white-space: nowrap; }

.btn-ghost, .btn-outline, .back, .perf-pager button,
button[id$="-close"], button[id$="-cancel"], button[id$="-back"],
.sup-del-reject, .chk-del-reject, .chk-undo {
  background: var(--bl-surface); color: var(--bl-text); border: 1px solid var(--bl-border); }
.btn-ghost:hover, .btn-outline:hover, .back:hover, .perf-pager button:hover,
button[id$="-close"]:hover, button[id$="-cancel"]:hover, button[id$="-back"]:hover,
.sup-del-reject:hover, .chk-del-reject:hover, .chk-undo:hover { background: var(--bl-surface-2); }

.btn-danger, .c7-delete, .c7-reject, .sup-del-request, .sup-del-approve, .chk-del-approve,
.gd-delete-sample, .gd-hdel, .terms-del, .tm-delete, .sr-reject, #rg-reject, .rowbtn,
[data-review="reject"], [data-rm], .acct-toggle[data-active=""], .brk-acct-toggle[data-active=""] {
  background: var(--bl-red-soft); color: var(--bl-red); border: 1px solid transparent; }
.btn-danger:hover, .c7-delete:hover, .c7-reject:hover, .sup-del-request:hover, .sup-del-approve:hover,
.chk-del-approve:hover, .gd-delete-sample:hover, .gd-hdel:hover, .terms-del:hover, .tm-delete:hover,
.sr-reject:hover, #rg-reject:hover, .rowbtn:hover, [data-review="reject"]:hover, [data-rm]:hover,
.acct-toggle[data-active=""]:hover, .brk-acct-toggle[data-active=""]:hover { background: #f5d0d0; }

.btn-success, .c7-approve, #c7-bulk-approve, .sr-approve, #rg-approve, #soa-accept,
.chk-release, .chk-conf-save, [data-review="approve"] {
  background: var(--bl-green-soft); color: var(--bl-green); border: 1px solid transparent; }
.btn-success:hover, .c7-approve:hover, #c7-bulk-approve:hover, .sr-approve:hover, #rg-approve:hover,
#soa-accept:hover, .chk-release:hover, .chk-conf-save:hover, [data-review="approve"]:hover { background: #cfe9da; }

/* Text links become small soft-blue boxes (APV numbers, "Search all
   statuses", "Mark all read", filter-chip ✕, ...). */
.linklike { display: inline-flex; align-items: center; gap: 4px; background: var(--bl-primary-soft);
  color: var(--bl-primary-dark); border: 1px solid transparent; border-radius: 6px; padding: 2px 8px;
  font-size: 12px; font-weight: 600; text-decoration: none; }
.linklike:hover { background: #d8e3f2; color: var(--bl-primary-dark); text-decoration: none; }
.btn-link { background: var(--bl-primary-soft); color: var(--bl-primary-dark); border-radius: 8px;
  padding: 7px 12px; font-weight: 600; }
.btn-link:hover { background: #d8e3f2; text-decoration: none; }

/* ---- SYNC NOW: top bar, left of the bell (user request 2026-09-23) ---- */
.sync-top { display: inline-flex; align-items: center; gap: 10px; font-size: 11px; margin-right: 4px; }
.sync-top .btn-sync { background: var(--bl-primary); color: #fff; font-size: 13px; font-weight: 800;
  letter-spacing: .06em; padding: 8px 16px; border-radius: 8px; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(74,111,165,.35); display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.sync-top .btn-sync:hover { background: var(--bl-primary-dark); }
.sync-top .btn-sync .sync-ico { font-size: 16px; line-height: 1; }
.sync-top .btn-sync:disabled .sync-ico { animation: sync-spin 1s linear infinite; }
@keyframes sync-spin { to { transform: rotate(360deg); } }
.sync-top-meta { display: flex; flex-direction: column; gap: 1px; text-align: right; line-height: 1.25; }
.sync-top-meta > span:empty { display: none; }

/* ---- pills keep their colors on the new palette ---- */
.perf-chip.green, .pill-settled { background: var(--bl-green-soft); color: var(--bl-green); }
.perf-chip.red, .pill-void { background: var(--bl-red-soft); color: var(--bl-red); }
.perf-chip.amber, .pill-open { background: var(--bl-yellow-soft); color: var(--bl-yellow); }

@media (max-width: 760px) {
  /* Phone top bar: the stamp goes, the button keeps its icon only. */
  .sync-top-meta { display: none; }
  .sync-top .btn-sync { padding: 8px 10px; font-size: 0; gap: 0; }
  .sync-top .btn-sync .sync-ico { font-size: 18px; }
}

/* Stacked cards on one screen (detail screens) never touch. */
main .card + .card { margin-top: 14px; }

/* Chart with no data yet: a readable empty state, not a greyed placeholder
   (user report 2026-09-18). */
.chart-card.chart-empty { display: flex; flex-direction: column; }
.chart-empty-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; padding: 12px 18px; color: var(--bl-text-2); }
.chart-empty-body strong { color: var(--bl-text); font-size: 14px; }
.chart-empty-body .muted { font-size: 12.5px; max-width: 260px; }
.chart-empty-ic { width: 40px; height: 40px; border-radius: 10px; background: var(--bl-primary-soft);
  color: var(--bl-primary); display: grid; place-items: center; margin-bottom: 4px; }
.chart-empty-ic svg { width: 20px; height: 20px; }
/* Ghost charts (VAT TREND): the Soon pill is pinned top-right only — the base
   .soon rule's bottom offset stretched it down the whole card. */
.chart-card.ghost-chart .soon { bottom: auto; }

/* ---- Announcements: the one band on the dashboard that is meant to be read
   (user ruling 2026-09-21). It sits right under the greeting, so it carries
   the gold accent instead of the theme's transparent band: styles.css gives
   .ann-band an amber wash, but this file's later `.band { background:
   transparent; border: 0 }` won it back — these rules restate the emphasis in
   the Bank Loan palette, for admins and suppliers alike. */
.band.ann-band { background: var(--bl-yellow-soft); border: 1px solid #ecdcae;
  border-radius: 12px; padding: 14px 16px 4px; }
.band.ann-band .band-head h3 { color: var(--bl-yellow); }
.band.ann-band .band-head .kpi-ic { background: #f4e4b4; color: #8a6a12; }
.band.ann-band .card.ann-card { border-left: 4px solid var(--bl-gold);
  border-color: #ecdcae; border-left-color: var(--bl-gold); margin-bottom: 12px; }
.ann-card h4 { color: #8a6a12; font-size: 15px; letter-spacing: .01em; }
.ann-card p { color: var(--bl-text); }

/* Purchases: one term for suppliers (user ruling 2026-09-24) — page head and the Local / Imported switch. */
.pv-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 0 0 16px; }
.pv-head .page-title { margin: 0; }
.pv-switch { display: inline-flex; background: var(--bl-surface); border: 1px solid var(--bl-border); border-radius: 999px; padding: 3px; }
.pv-switch a { border: 0; background: transparent; color: var(--bl-text-2); font-size: 13px; font-weight: 700; padding: 5px 14px; border-radius: 999px; text-decoration: none; cursor: pointer; }
.pv-switch a.on { background: var(--bl-primary); color: #fff; }
.band-head .pv-switch { margin-left: 6px; }
