/* ════════════════════════════════════════════════════════════════════
   NPO Accounting — UI styled after Artemis Accounting design language.
   Plain CSS (no Tailwind build step) to keep the project portable.

   Uses a system font stack — no external font fetch. Pages render
   instantly even on first load and the system works fully offline.
   ════════════════════════════════════════════════════════════════════ */

/* Self-hosted Inter (variable, latin) — DESIGN.md's open-source SF Pro
   substitute. Bundled in static/fonts/ so the LAN/offline deployment fetches
   no external webfont; one variable file carries weights 100–900. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/InterVariable.woff2') format('woff2');
}

/* ════════════════════════════════════════════════════════════════════
   Apple design tokens (DESIGN.md). The original slate/primary VARIABLE
   NAMES are preserved so every existing class and inline `var(--token)`
   reference inherits the new palette automatically — only the VALUES are
   remapped to the Apple language. Status colors (emerald/amber/rose) stay
   as load-bearing accounting encoding.
   ════════════════════════════════════════════════════════════════════ */
:root {
  /* neutrals — Apple grays (the "slate" ramp, re-toned) */
  --slate-50:  #f5f5f7;   /* parchment — default canvas */
  --slate-100: #f0f0f0;   /* divider-soft */
  --slate-200: #e0e0e0;   /* hairline */
  --slate-300: #d2d2d7;
  --slate-400: #6f6f73;   /* darkened: AA (4.5:1) as text on white + parchment */
  --slate-500: #5c5c61;
  --slate-600: #424245;
  --slate-700: #333333;   /* ink-muted-80 */
  --slate-800: #1d1d1f;   /* ink */
  --slate-900: #1d1d1f;   /* ink */

  /* Action Blue — the single interactive accent (the "primary" ramp) */
  --primary-50:  #e8f0fe;
  --primary-100: #d2e3fc;
  --primary-500: #0071e3;  /* focus ring / brighter hover */
  --primary-600: #0066cc;  /* Action Blue — default action */
  --primary-700: #0055b3;  /* pressed */
  --primary-800: #00417f;
  --primary-on-dark: #2997ff;  /* in-copy links on dark surfaces */

  /* status — load-bearing semantic encoding (posted/draft/reversed,
     approval workflow, compliance). NOT an interactive accent. */
  --emerald-50:  #ecfdf5;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --amber-50:    #fffbeb;
  --amber-600:   #d97706;
  --amber-700:   #b45309;
  --rose-50:     #fff1f2;
  --rose-500:    #f43f5e;
  --rose-600:    #e11d48;
  --rose-700:    #be123c;

  /* sidebar — flat near-black ink (equal gradient stops render solid) */
  --sb-bg-from:  #1d1d1f;
  --sb-bg-to:    #1d1d1f;
  --sb-hover:    #2a2a2c;
  --sb-text:     #a1a1a6;
  --sb-text-active: #ffffff;
  --sb-border:   #2c2c2e;
  --sb-section:  #6e6e73;

  /* radii — DESIGN.md scale (xs5 / sm8 / md11 / lg18 / pill) */
  --radius-sm: 8px;
  --radius:    11px;
  --radius-lg: 18px;
  --radius-xl: 18px;
  --radius-pill: 9999px;

  /* elevation — flat. DESIGN.md uses surface-color change + hairlines, not
     shadows on chrome. The one soft shadow is reserved for floating overlays
     (popovers/dropdowns), the closest analog to the spec's backdrop layer. */
  --shadow-sm:   none;
  --shadow-card: none;
  --shadow-card-hover: none;
  --shadow-button: none;
  --shadow-overlay: 0 12px 32px rgba(0,0,0,0.18);
}

* { box-sizing: border-box; }

html {
  /* Inter feature flags that approximate SF Pro: ss03 = single-storey 'a',
     cv05 = tailless 'l'. */
  font-feature-settings: 'ss03', 'cv05';
}

body {
  margin: 0;
  /* Self-hosted Inter (DESIGN.md's SF Pro substitute); system stack as the
     offline fallback before the woff2 loads. */
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;            /* DESIGN.md body — full Apple density */
  line-height: 1.47;
  letter-spacing: -0.022em;   /* Apple-tight body tracking (-0.374px @ 17px) */
  background: var(--slate-50);
  color: var(--slate-900);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--slate-900);
  font-weight: 600;
  letter-spacing: -0.02em;    /* negative tracking — the "Apple tight" cadence */
  margin: 0 0 12px;
}
h1 { font-size: 28px; line-height: 1.10; letter-spacing: -0.028em; }
h2 { font-size: 21px; line-height: 1.19; }
h3 { font-size: 17px; line-height: 1.24; }

a {
  color: var(--primary-600);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

::-webkit-scrollbar       { width: 22px; height: 22px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 999px; border: 4px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); background-clip: padding-box; border: 4px solid transparent; }

/* ── Layout ─────────────────────────────────────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 256px;
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sb-bg-from) 0%, var(--sb-bg-to) 100%);
  overflow: hidden;
  z-index: 30;
  transition: transform 200ms ease;
}

/* Collapsed sidebar: slide off-screen and reclaim the main column. */
html.sb-collapsed .sidebar { transform: translateX(-100%); }
html.sb-collapsed .main    { margin-left: 0; }

.sb-logo {
  padding: 16px;
  border-bottom: 1px solid var(--sb-border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sb-logo-square {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  background: var(--primary-600);   /* flat Action Blue — no gradient, no shadow */
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.sb-logo-text { line-height: 1.2; }
.sb-logo-text .name { color: #fff; font-weight: 700; font-size: 14px; }
.sb-logo-text .sub  { color: var(--sb-section); font-size: 11px; }

.sb-org-pill {
  margin: 10px 12px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--sb-border);
  border-radius: var(--radius);
  display: flex; align-items: center; gap: 8px;
  color: var(--sb-text);
  font-size: 11px;
  font-weight: 500;
}
.sb-org-pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--emerald-500);
  flex-shrink: 0;
}
.sb-org-pill .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 8px;
  scrollbar-width: none;
}
.sb-nav::-webkit-scrollbar { display: none; }

.sb-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sb-section);
  padding: 10px 12px 6px;
  margin: 0;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: var(--radius);
  color: var(--sb-text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 1px;
  transition: background 120ms, color 120ms;
  position: relative;
}
.sb-link:hover {
  background: var(--sb-hover);
  color: var(--sb-text-active);
  text-decoration: none;
}
.sb-link svg {
  flex-shrink: 0;
  width: 15px; height: 15px;
}
.sb-link .chevron {
  margin-left: auto;
  opacity: 0;
  transition: opacity 120ms;
}
.sb-link:hover .chevron { opacity: 0.3; }
.sb-link.active {
  background: var(--primary-600);
  color: #fff;
  font-weight: 600;
}
.sb-link.active:hover {
  background: var(--primary-700);
}

/* Sidebar shortcut hint — small, faded, ghost-like; brighter on hover. */
.sb-link kbd,
.sb-link .nav-kbd {
  margin-left: auto;
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-size: 9px;
  line-height: 1;
  padding: 0;
  min-width: 0;
  height: auto;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--sb-section);
  opacity: 0.55;
  letter-spacing: 0;
}
.sb-link:hover kbd,
.sb-link:hover .nav-kbd { opacity: 0.9; color: var(--sb-text-active); }
.sb-link.active kbd,
.sb-link.active .nav-kbd { color: rgba(255,255,255,0.7); opacity: 0.75; }
/* Hide the chevron when a shortcut hint is shown — they'd both fight for the
   right edge of the link. */
.sb-link:has(kbd) .chevron,
.sb-link:has(.nav-kbd) .chevron { display: none; }

.sb-user {
  flex-shrink: 0;
  padding: 12px;
  border-top: 1px solid var(--sb-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sb-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-600);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  object-fit: cover;
}
img.sb-avatar { background: var(--slate-200); }
.sb-user-info { min-width: 0; flex: 1; }
.sb-user-info .name { color: #e2e8f0; font-size: 13px; font-weight: 600; line-height: 1.2; }
.sb-user-info .role { color: var(--sb-section); font-size: 11px; text-transform: capitalize; line-height: 1.3; }

.sb-version {
  flex-shrink: 0;
  padding: 6px 16px 12px;
  color: var(--sb-section);
  font-size: 11px;
  letter-spacing: .02em;
  opacity: .7;
  font-variant-numeric: tabular-nums;
}

/* main column */
.main {
  flex: 1;
  margin-left: 256px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 200ms ease;
}

.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--slate-200);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: none;   /* flat — the hairline border-bottom is the only divider */
}
.breadcrumb {
  display: flex; align-items: center; gap: 4px;
  font-size: 13px;
  min-width: 0;
}
.breadcrumb a {
  color: var(--slate-400);
  display: flex; align-items: center;
}
.breadcrumb a:hover { color: var(--slate-600); text-decoration: none; }
.breadcrumb .sep { color: var(--slate-300); margin: 0 2px; }
.breadcrumb .current { color: var(--slate-800); font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 4px; }

/* Sidebar collapse toggle — circular handle straddling the sidebar's right
   edge so it is unmistakably clickable. Slides to the viewport's left edge
   when the sidebar is collapsed. */
.sidebar-toggle {
  position: fixed;
  top: 64px;            /* sits just below the 56px topbar */
  left: 242px;          /* 256px sidebar - 14px (half of 28px button) -> straddles edge */
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 50%;
  color: var(--slate-600);
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.08);
  transition: left 200ms ease, color 120ms, background 120ms, box-shadow 120ms, transform 120ms;
  z-index: 40;          /* above sidebar (30) and topbar (20) */
}
.sidebar-toggle:hover {
  color: var(--primary-600);
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18), 0 2px 4px rgba(0,0,0,0.08);
  transform: scale(1.08);
}
.sidebar-toggle:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}
.sidebar-toggle svg { width: 16px; height: 16px; stroke-width: 2.5; }

/* When collapsed: hop to the viewport edge. */
html.sb-collapsed .sidebar-toggle { left: 12px; }

/* Chevron swap: show "left" arrow when open ("click to hide"), "right" arrow
   when collapsed ("click to show"). */
.sidebar-toggle .when-open,
.sidebar-toggle .when-closed { display: inline-flex; align-items: center; }
.sidebar-toggle .when-closed { display: none; }
html.sb-collapsed .sidebar-toggle .when-open   { display: none; }
html.sb-collapsed .sidebar-toggle .when-closed { display: inline-flex; }

.sidebar-toggle .when-open,
.sidebar-toggle .when-closed { display: inline-flex; align-items: center; }
.sidebar-toggle .when-closed { display: none; }
html.sb-collapsed .sidebar-toggle .when-open   { display: none; }
html.sb-collapsed .sidebar-toggle .when-closed { display: inline-flex; }
.topbar-right .sep { width: 1px; height: 20px; background: var(--slate-200); margin: 0 8px; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-user .who { text-align: right; }
.topbar-user .who .name { font-size: 12px; font-weight: 600; color: var(--slate-700); line-height: 1.2; }
.topbar-user .who .role { font-size: 11px; color: var(--slate-400); line-height: 1.3; text-transform: capitalize; }

.btn-icon {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  background: transparent;
  border: 0;
  color: var(--slate-500);
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.btn-icon:hover { background: var(--slate-100); color: var(--slate-700); }

.logout-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-500);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 120ms;
  font-family: inherit;
}
.logout-btn:hover { color: var(--rose-600); background: var(--rose-50); }

.page {
  flex: 1;
  padding: 24px;
  max-width: 1600px;
  width: 100%;
}

/* ── Sticky sheet-tab strips ───────────────────────────────────────────
   Tabs (D/PFR, CV, Liquidation, Master Data, Staff, etc.) stay pinned
   under the topbar (56px) when scrolling. The page background bleed-
   through is masked with the same slate-50 used by body. */
.tabs {
  position: sticky;
  top: 56px;
  z-index: 10;
  background: var(--slate-50);
  /* Inline margin in the partials sets top:8px — keep that off the
     sticky position so the strip sits flush against the topbar. */
  margin-top: 0 !important;
  padding-top: 8px;
}
@media print { .tabs { position: static !important; } }

.footer-bar {
  padding: 12px 24px;
  border-top: 1px solid var(--slate-100);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px;
  color: var(--slate-400);
}

/* ── Components ─────────────────────────────────────────────────────── */

.card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.card-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--slate-100);
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.card-header h2 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate-600); }
.card-body { padding: 14px; }
.card-table { padding: 0; }
.card-table table { margin: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* Sticky table header — every table's column-header row pins below the
   56px topbar AND below the sticky tab strip (~40px) as the user scrolls.
   On pages without a tab strip the thead floats ~40px below the topbar,
   which is acceptable; the alternative would be the strip overlapping the
   thead because they share the same sticky offset.

   `tr` also gets `position: sticky` so the entire row pins, not just the
   individual th cells — keeps a clean horizontal line.

   Opt-out: any table with class `no-sticky-thead`, or any table inside a
   container with class `no-sticky-thead`, falls back to normal scroll.
   Used by wide forms (e.g. Asset Reconciliation Form) where the table is
   nested in a horizontally-scrolling parent — sticky thead is viewport-
   relative, so it can't track horizontal scroll inside the parent and
   would otherwise misalign with the body columns. */
table thead {
  position: sticky;
  top: 96px;
  z-index: 2;
}
table thead th {
  position: sticky;
  top: 96px;
  z-index: 2;
  background: var(--slate-50);
  box-shadow: 0 1px 0 var(--slate-200);
}
table.no-sticky-thead thead,
table.no-sticky-thead thead th,
.no-sticky-thead table thead,
.no-sticky-thead table thead th {
  position: static;
  top: auto;
  box-shadow: none;
}
@media print {
  table thead, table thead th {
    position: static; box-shadow: none;
  }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--primary-600);
  border: 0;
  border-radius: var(--radius-pill);   /* DESIGN.md signature blue pill */
  cursor: pointer;
  font-family: inherit;
  letter-spacing: -0.01em;
  text-decoration: none;
  box-shadow: var(--shadow-button);    /* flat (token = none) */
  transition: background 120ms, transform 80ms;
}
.btn:hover { background: var(--primary-500); color: #fff !important; text-decoration: none; }
/* DESIGN.md system-wide press micro-interaction */
.btn:active { background: var(--primary-700); transform: scale(0.95); }
.btn:focus-visible { outline: 2px solid var(--primary-500); outline-offset: 2px; }

.btn-secondary {
  background: #fff;
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
  box-shadow: none;
  font-weight: 600;
}
.btn-secondary:hover {
  background: var(--slate-50);
  border-color: var(--slate-300);
  color: var(--slate-900) !important;
}

.btn-danger {
  background: var(--rose-600);
  box-shadow: none;
}
.btn-danger:hover { background: var(--rose-700); }

.btn-ghost {
  background: transparent;
  color: var(--slate-600);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--slate-100); color: var(--slate-800) !important; }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 4px 11px; font-size: 12px; gap: 4px; box-shadow: none; }
.btn-xs svg { width: 12px; height: 12px; }

kbd, .kbd {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-size: 10px;
  font-weight: 600;
  min-width: 14px;
  padding: 0 4px;
  height: 16px;
  border-radius: 4px;
  background: rgba(255,255,255,0.9);
  color: var(--slate-600);
  border: 1px solid var(--slate-200);
  box-shadow: 0 1px 0 0 var(--slate-200);
  margin-left: 4px;
  line-height: 1;
}
kbd:empty { display: none; }

/* tables — COMPACT data density (airy chrome, dense data). Back-office
   ledgers/journals need rows-per-screen; the marketing scale lives on the
   page chrome, not the data grid. */
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 13px;
}
th, td {
  padding: 7px 12px;
  text-align: left;
  border-bottom: 1px solid var(--slate-100);
  letter-spacing: -0.01em;
}
th {
  background: var(--slate-50);
  color: var(--slate-500);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
tbody tr:hover { background: var(--slate-50); }
/* Numeric column: right-align both header and body cells, and use
   tabular-nums so digits line up. The monospace font + larger size
   apply only to the data cells — headers keep the uniform `th` style
   (11px uppercase) so every column header looks the same. */
td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;   /* Apple-style equal-width digits */
}
td.num {
  font-size: 13px;
}
tr.total td {
  font-weight: 700;
  background: var(--slate-50);
  color: var(--slate-900);
  border-top: 2px solid var(--slate-200);
}

code { font-family: 'JetBrains Mono', Menlo, monospace; font-size: 12px; color: var(--slate-700); }

/* forms — minimalist density */
.field { display: flex; flex-direction: column; margin-bottom: 8px; }
.field > label {
  font-size: 10px;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"],
select, textarea {
  padding: 8px 12px;
  font: inherit;
  font-size: 15px;
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  color: var(--slate-900);
  transition: border-color 120ms, box-shadow 120ms;
}
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.15);   /* Action Blue focus halo */
}
/* DESIGN.md: search uses the pill grammar */
input[type="search"] { border-radius: var(--radius-pill); }
textarea { resize: vertical; min-height: 44px; }
input[type="checkbox"], input[type="radio"] { width: auto; padding: 0; }
.errors { color: var(--rose-600); font-size: 11px; margin-top: 2px; }
.help-text { color: var(--slate-500); font-size: 10px; margin-top: 2px; }
.actions { display: flex; gap: 6px; margin-top: 12px; }

/* ── Accessibility & data-entry safety ─────────────────────────────────
   Visible keyboard focus on every interactive control, readable
   placeholders, a required-field marker, and a submit "loading" state that
   doubles as a double-submit guard (paired with the JS in base.html). */
.btn-icon:focus-visible, .icon-action:focus-visible, .logout-btn:focus-visible,
.pill-toggle:focus-visible, .pagination-bar a:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}
a.sb-link:focus-visible {
  outline: 2px solid var(--primary-on-dark);
  outline-offset: -2px;
}
input::placeholder, textarea::placeholder { color: var(--slate-400); opacity: 1; }
.field > label .req { color: var(--rose-600); margin-left: 2px; font-weight: 700; }

.btn.is-loading { color: transparent !important; pointer-events: none; position: relative; }
.btn.is-loading::after {
  content: ""; position: absolute;
  width: 14px; height: 14px; top: calc(50% - 7px); left: calc(50% - 7px);
  border: 2px solid rgba(255,255,255,0.55); border-top-color: #fff;
  border-radius: 50%; animation: btn-spin 0.6s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after {
  border-color: rgba(0,0,0,0.2); border-top-color: var(--primary-600);
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Checkbox-list multi-selects (e.g. Client.departments) — compact 2-col grid */
.field ul {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px;
}
.field ul li label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 400;
  color: var(--slate-700);
  text-transform: none; letter-spacing: 0; margin: 0;
}

/* badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-draft     { background: var(--slate-100);   color: var(--slate-600); }
.badge-posted    { background: var(--emerald-50);  color: #065f46; }
.badge-cancelled, .badge-reversed { background: var(--rose-50); color: var(--rose-700); }
.badge-active    { background: #dcfce7; color: #15803d; }
.badge-inactive  { background: #fee2e2; color: #b91c1c; }
.badge-role-super       { background: #ede9fe; color: #6d28d9; }
.badge-role-accountant  { background: #ccfbf1; color: #0f766e; }
.badge-role-bookkeeper  { background: #dbeafe; color: #1d4ed8; }
.badge-role-viewer      { background: var(--slate-100); color: var(--slate-600); }

/* D/PFR (RCA) transaction status badges — four user-facing states.
   Color logic: amber pending → blue ready-for-CV → violet paid-not-liquidated
   → emerald done. Disapproved / Cancelled stay red / slate respectively. */
.badge-rca-fa  { background: #fef3c7; color: #78350f; }   /* For Approval — amber (AA) */
.badge-rca-auu { background: #dbeafe; color: #1d4ed8; }   /* Approved-Unpaid-Unliquidated — blue */
.badge-rca-apu { background: #ede9fe; color: #6d28d9; }   /* Approved-Paid-Unliquidated — violet */
.badge-rca-apl { background: #d1fae5; color: #065f46; }   /* Approved-Paid-Liquidated — emerald (AA) */
.badge-rca-draft       { background: var(--slate-100); color: var(--slate-600); }
.badge-rca-disapproved { background: #fee2e2; color: #b91c1c; }
.badge-rca-cancelled   { background: var(--slate-100); color: var(--slate-500); text-decoration: line-through; }
/* Tag chip appended to AUU rows that already have a Liquidation filed —
   signals the FR is fully accounted for, just waiting on payment. */
.badge-rca-liq         { background: #ccfbf1; color: #0f766e; font-weight: 700; letter-spacing: 0.04em; }

/* ── Hover-popover preview for the D/PFR "Entries" column ───────────
   Pure-CSS hover — no JS needed. Anchored to the trigger button; pops
   up above-left so it doesn't get clipped by the rightmost column.
   The whole popover stays on hover (no flicker) because the wrapper
   container is what carries the `:hover` state. */
.je-hover-wrap {
  position: relative;
  display: inline-block;
}
.je-popover {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  width: min(520px, 80vw);
  background: #fff;
  border: 1px solid var(--slate-300, #cbd5e1);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  padding: 10px 12px;
  z-index: 200;
  text-align: left;
  display: none;
  font-size: 11.5px;
  color: var(--slate-700, #334155);
}
.je-hover-wrap:hover .je-popover,
.je-hover-wrap:focus-within .je-popover {
  display: block;
}
.je-popover-head {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slate-500, #64748b);
  border-bottom: 1px solid var(--slate-200, #e2e8f0);
  padding-bottom: 4px;
  margin-bottom: 6px;
}
.je-popover-block + .je-popover-block {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--slate-200, #e2e8f0);
}
.je-popover-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 4px;
}
.je-popover-meta strong { font-weight: 600; color: var(--slate-900, #0f172a); }
.je-popover-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
.je-popover-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--slate-500, #64748b);
  padding: 2px 6px;
  border-bottom: 1px solid var(--slate-200, #e2e8f0);
}
.je-popover-table td {
  padding: 3px 6px;
  border-bottom: 1px dotted var(--slate-100, #f1f5f9);
  vertical-align: top;
}
.je-popover-table td.num,
.je-popover-table th.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.je-popover-table .acct-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--primary-600, #2563eb);
  font-weight: 600;
}

.icon-action {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 0; background: transparent;
  color: var(--slate-500);
  cursor: pointer;
  transition: background 120ms, color 120ms;
  font-family: inherit;
}
.icon-action:hover { background: var(--slate-100); color: var(--slate-700); }
.icon-action.edit:hover    { background: #dbeafe; color: #0055b3; }
.icon-action.key:hover     { background: #fef3c7; color: #b45309; }
.icon-action.delete:hover  { background: var(--rose-50); color: var(--rose-700); }
.icon-action svg { width: 14px; height: 14px; }

.pill-toggle {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background 120ms;
}
.pill-toggle.deactivate { border-color: #fecaca; color: var(--rose-600); }
.pill-toggle.deactivate:hover { background: var(--rose-50); }
.pill-toggle.activate { border-color: #bbf7d0; color: #15803d; }
.pill-toggle.activate:hover { background: #ecfdf5; }

/* kpi card */
.kpi {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);   /* flat */
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi .kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
}
.kpi .kpi-value {
  font-size: 34px;
  font-weight: 600;
  color: var(--slate-900);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.kpi .kpi-sub { font-size: 11px; color: var(--slate-400); margin-top: 2px; }

/* grid */
.grid { display: grid; gap: 10px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) { .grid-2, .grid-4 { grid-template-columns: 1fr; } }

/* messages */
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.msg {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}
.msg-success { background: var(--emerald-50); color: var(--emerald-700); border-color: #a7f3d0; }
.msg-error   { background: var(--rose-50);    color: var(--rose-700);    border-color: #fecdd3; }
.msg-warning { background: var(--amber-50);   color: var(--amber-700);   border-color: #fde68a; }
.msg-info    { background: var(--primary-50); color: var(--primary-700); border-color: var(--primary-100); }

/* page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 10px;
  flex-wrap: wrap;
}
.page-title { display: flex; flex-direction: column; gap: 1px; }
.page-title h1 { margin: 0; font-size: 18px; }
.page-title .subtitle { font-size: 12px; color: var(--slate-500); }
.page-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* toolbar (filters above tables) */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { font-size: 13px; }

/* small + muted helpers */
.small { font-size: 11px; }
.muted { color: var(--slate-500); }
.pos   { color: var(--emerald-600); }
.neg   { color: var(--rose-600); }

/* reports */
.report-header { text-align: center; margin-bottom: 24px; }
.report-header h1 { margin: 0 0 4px; font-size: 18px; }
.report-header h2 { font-size: 16px; color: var(--slate-700); font-weight: 600; margin: 0 0 4px; }
.report-header .subtitle { color: var(--slate-500); font-size: 13px; }

.print-area {
  background: #fff;
  padding: 32px 36px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-card);
}
.print-area table { box-shadow: none; border: 0; }
.print-area table th, .print-area table td { border-color: var(--slate-100); }

@media print {
  .sidebar, .sidebar-toggle, .topbar, .footer-bar, .toolbar, .page-actions, .messages, .actions { display: none !important; }
  body { background: #fff; }
  .main { margin-left: 0; }
  .page { padding: 0; }
  .print-area { border: 0; padding: 0; box-shadow: none; }
  a { color: inherit; }
}

/* login */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--slate-50);   /* solid parchment — DESIGN.md: no decorative gradients */
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 32px;
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-overlay);   /* lone soft lift on the focal auth card */
}
.login-brand {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 10px; margin-bottom: 22px;
}
.login-brand .sq {
  width: 56px; height: 56px;
  border-radius: var(--radius-lg);
  background: var(--primary-600);   /* flat Action Blue (initials fallback) */
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 24px;
  overflow: hidden;
  flex-shrink: 0;
}
img.sq { object-fit: contain; background: #fff; }   /* uploaded logo, contained on white */
.login-brand .who {
  font-size: 21px; font-weight: 700; letter-spacing: -0.02em;
  line-height: 1.2; color: var(--slate-900);
}
.login-brand .who .sub {
  font-size: 12px; color: var(--slate-500); font-weight: 500; letter-spacing: 0;
  margin-top: 3px;
}

/* Centered auth card (login): brand artwork left, sign-in form right,
   floating as one rounded card on a parchment backdrop. */
.auth-split {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: var(--slate-50);       /* backdrop behind the card */
}
.auth-card {
  width: 100%; max-width: 960px;
  min-height: 560px;
  display: flex;
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-overlay);
  overflow: hidden;                  /* clip the cover image to the rounded corners */
}
.auth-brand {
  position: relative;                /* anchors the full-bleed cover image */
  flex: 1 1 50%;
  background: #000;                  /* dark backdrop behind logo/fallback + cover letterboxing */
  display: flex; align-items: center; justify-content: center;
  padding: 32px; overflow: hidden;
}
/* Org-uploaded sign-in image — fills the brand half (any web image incl. animated GIF). */
.auth-brand .auth-cover {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.auth-brand .auth-logo {
  width: min(78%, 320px); height: auto; display: block;
}
.auth-brand-fallback {
  color: #fff; font-size: 28px; font-weight: 800;
  letter-spacing: -0.02em; line-height: 1.15; text-align: center; padding: 0 20px;
}
.auth-panel {
  flex: 1 1 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 44px 40px;
}
.auth-form { width: 100%; max-width: 340px; }
.auth-form .auth-mark {
  width: 44px; height: 44px; object-fit: contain;
  border-radius: var(--radius-md); margin-bottom: 20px; display: block;
}
.auth-form h1 {
  font-size: 28px; font-weight: 800; letter-spacing: -0.02em;
  line-height: 1.1; color: var(--slate-900); margin: 0 0 6px;
}
.auth-form .lede { font-size: 14px; color: var(--slate-500); margin: 0 0 22px; }
.auth-form .msg-error { margin-bottom: 16px; }
.auth-form .field { margin-bottom: 14px; }
.auth-foot { margin-top: 20px; font-size: 12px; color: var(--slate-400); }

/* Stack inside the card on small screens: brand becomes a compact top band. */
@media (max-width: 760px) {
  .auth-card { flex-direction: column; max-width: 420px; min-height: 0; }
  .auth-brand { flex: 0 0 auto; min-height: 150px; padding: 24px; }
  .auth-brand .auth-logo { width: min(58%, 220px); }
  .auth-panel { flex: 1 1 auto; align-items: stretch; padding: 30px 26px 36px; }
  .auth-form { max-width: none; }
}

/* Password field with a show/hide toggle (login + change-password). */
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { width: 100%; padding-right: 40px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: var(--radius-sm);
  color: var(--slate-400); cursor: pointer; padding: 0;
}
.pw-toggle:hover { color: var(--slate-600); background: var(--slate-100); }
.pw-toggle:focus-visible { outline: 2px solid var(--primary-500); outline-offset: 1px; }
.pw-toggle svg { width: 16px; height: 16px; }
