/* =====================================================================
   MMM Engineering ERP — theme
   Modelled on the Flowbite admin dashboard design system: a light/white
   surface throughout (including the sidebar), Flowbite's default primary
   blue + gray scale, Inter typeface, and Tailwind's shadow/radius scale.
   ===================================================================== */

:root {
  /* Flowbite default primary (blue) scale */
  --primary-50:  #ebf5ff;
  --primary-100: #e1effe;
  --primary-200: #c3ddfd;
  --primary-300: #a4cafe;
  --primary-400: #76a9fa;
  --primary-500: #3f83f8;
  --primary-600: #1c64f2;
  --primary-700: #1a56db;
  --primary-800: #1e429f;
  --primary-900: #233876;

  /* Flowbite default gray scale */
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Aliases kept from the previous theme so component rules below don't
     all need renaming — every one now resolves into the Flowbite scale. */
  --navy-900: var(--gray-900);
  --navy-800: var(--gray-800);
  --navy-700: var(--primary-800);
  --navy-600: var(--primary-700);
  --navy-500: var(--primary-600);
  --navy-400: var(--primary-500);
  --navy-300: var(--primary-300);

  --accent: var(--primary-700);
  --accent-hover: var(--primary-800);
  --accent-soft: var(--primary-50);

  /* Royal violet — used nowhere else in the app; reserved for the company
     switcher (partials/sidebar.php) so picking a company reads as a
     deliberate, elevated moment rather than just another blue hover. */
  --royal-50:  #f5f3ff;
  --royal-100: #ede9fe;
  --royal-500: #8b5cf6;
  --royal-600: #7c3aed;
  --royal-700: #6d28d9;

  --bg: var(--gray-50);
  --surface: #ffffff;
  --surface-alt: var(--gray-50);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);

  --text: var(--gray-900);
  --text-muted: var(--gray-500);
  --text-faint: var(--gray-400);

  /* Flowbite's own badge/alert semantic colors */
  --success: #03543f;
  --success-soft: #def7ec;
  --warning: #723b13;
  --warning-soft: #fdf6b2;
  --danger: #9b1c1c;
  --danger-soft: #fde8e8;
  --neutral-soft: var(--gray-100);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
  --shadow-navy: 0 4px 11px rgba(28, 100, 242, 0.3);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sidebar-w: 256px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4, h5 { font-weight: 600; letter-spacing: -0.01em; color: var(--gray-900); margin: 0 0 .4em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

::selection { background: var(--primary-200); color: var(--gray-900); }

/* ---------------- scrollbars ---------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ---------------- keyframe animations ---------------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(28, 100, 242, .35); }
  100% { box-shadow: 0 0 0 10px rgba(28, 100, 242, 0); }
}
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in-up { animation: fadeInUp .5s var(--ease) both; }
.fade-in { animation: fadeIn .4s var(--ease) both; }
.stagger > * { animation: fadeInUp .5s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .1s; }
.stagger > *:nth-child(4) { animation-delay: .14s; }
.stagger > *:nth-child(5) { animation-delay: .18s; }
.stagger > *:nth-child(6) { animation-delay: .22s; }
.stagger > *:nth-child(n+7) { animation-delay: .26s; }

/* ================= App shell layout ================= */
/* .sidebar is position:fixed (taken out of flow), so .app-shell must NOT be a
   flex container here — flex:1 on .main-col would size it to the *full*
   container width (since fixed elements don't count as flex siblings), and
   adding margin-left on top of that double-counts the sidebar's width and
   overflows the viewport. A plain block with margin-left is all that's needed. */
.app-shell { min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  color: var(--gray-700);
  position: fixed;
  inset: 0 auto 0 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
  transition: transform .3s var(--ease);
  padding-bottom: 28px;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 22px 20px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.sidebar-brand .name { font-weight: 600; font-size: 1rem; color: var(--gray-900); line-height: 1.35; max-width: 100%; }

.company-switcher { margin: 16px 18px; }

/* Custom-styled company switcher (initCompanySwitcher() in
   company-switcher.js): a plain native <select> can't be given a hover/
   selected color per-option in most browsers, so a styled button + menu
   sits visually on top of it — same "real control stays untouched, JS only
   layers UI on top" pattern as .fk-combo (crud/form.php). The <select> is
   still the real, submitted control (same id/name), just invisible
   (opacity: 0, not display:none) so it keeps a real bounding box — that's
   what Playwright's selectOption()/toBeVisible() need (its visibility check
   only cares about visibility/box size, not opacity), so existing
   automation targeting #company-switcher-select keeps working untouched. */
.company-combo { position: relative; }
.company-combo select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; border: none; padding: 0; margin: 0; }

.company-combo-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--gray-50); border: 1px solid var(--border-strong); color: var(--gray-900);
  padding: 10px 13px; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 500;
  cursor: pointer; transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.company-combo-toggle:hover { background: var(--gray-100); }
.company-combo-toggle:focus-visible, .company-combo-toggle.open {
  outline: none; border-color: var(--royal-600); background: #fff; box-shadow: 0 0 0 3px var(--royal-100);
}
.company-combo-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-combo-toggle i { font-size: .75rem; color: var(--gray-400); transition: transform .2s var(--ease); flex-shrink: 0; }
.company-combo-toggle.open i { transform: rotate(180deg); color: var(--royal-600); }

.company-combo-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; max-height: 320px; overflow-y: auto;
}
.company-combo-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 500;
  color: var(--gray-700); cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease);
}
.company-combo-item i { font-size: .8rem; opacity: 0; }
/* The "royal" hover the request asked for — a deep violet gradient (this
   app's one deliberate departure from its blue accent, reserved for exactly
   this moment) rather than the flat gray-100 hover every other row uses. */
.company-combo-item:hover {
  background: linear-gradient(135deg, var(--royal-700), var(--royal-500));
  color: #fff;
}
.company-combo-item.is-active { background: var(--royal-50); color: var(--royal-700); }
.company-combo-item.is-active i { opacity: 1; color: var(--royal-600); }
.company-combo-item:hover i { opacity: 1; color: #fff; }

.nav-group { margin: 4px 12px; }
.nav-group-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-400);
  padding: 16px 12px 6px;
  font-weight: 600;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--gray-700);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease);
  position: relative;
}
.nav-link i { font-size: 1rem; width: 18px; text-align: center; color: var(--gray-500); transition: color .18s var(--ease); }
.nav-link:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-link:hover i { color: var(--gray-700); }
.nav-link.active {
  background: var(--primary-50);
  color: var(--primary-700);
}
.nav-link.active i { color: var(--primary-700); }
.nav-link.active::before {
  content: "";
  position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  background: var(--primary-700);
  border-radius: 4px;
}
.nav-parent { cursor: pointer; }
.nav-children { max-height: 0; overflow: hidden; transition: max-height .28s var(--ease); }
.nav-children.open { max-height: 1200px; }
.nav-children .nav-link { padding: 7px 14px 7px 42px; font-size: .82rem; }
.nav-subheading {
  padding: 12px 14px 4px 42px; font-size: .66rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--gray-400);
}
.nav-subheading:first-child { padding-top: 6px; }
.nav-chevron { margin-left: auto; transition: transform .25s var(--ease); font-size: .75rem; opacity: .6; }
.nav-parent.open .nav-chevron { transform: rotate(90deg); }

.main-col { margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  height: var(--topbar-h);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .page-title { font-weight: 600; font-size: 1.05rem; color: var(--gray-900); }
.hamburger { display: none; background: none; border: none; font-size: 1.3rem; color: var(--gray-600); cursor: pointer; }
.topbar-spacer { flex: 1; }
.topbar-search {
  position: relative;
  width: 260px;
}
.topbar-search input[type=text] {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--gray-50);
  font-size: .85rem;
  transition: box-shadow .15s var(--ease), border-color .15s var(--ease);
}
.topbar-search input[type=text]:focus { outline: none; border-color: var(--primary-500); box-shadow: 0 0 0 3px var(--primary-100); background: #fff; }
.topbar-search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }

.user-menu { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 7px 12px; border-radius: var(--radius-lg); transition: background .15s var(--ease); }
.user-menu:hover { background: var(--gray-100); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-700);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .8rem; flex-shrink: 0;
}
.user-menu .u-name { font-size: .82rem; font-weight: 600; color: var(--gray-900); line-height: 1.1; }
.user-menu .u-role { font-size: .7rem; color: var(--text-muted); }

.content { padding: 32px 36px 64px; flex: 1; }

/* ================= Cards, KPI, tables ================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .25s var(--ease), transform .25s var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-body { padding: 24px; }
.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 28px; }
.kpi-grid > * { min-width: 0; }
.kpi-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
  position: relative;
  overflow: hidden;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.kpi-card .kpi-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-100); color: var(--primary-700); font-size: 1.2rem;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.kpi-card .kpi-value { font-size: 1.6rem; font-weight: 600; color: var(--gray-900); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-card .kpi-label { font-size: .78rem; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }
.kpi-card .kpi-trend { position: absolute; top: 22px; right: 22px; font-size: .72rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.kpi-card .kpi-trend.up { color: var(--success); background: var(--success-soft); }
.kpi-card .kpi-trend.down { color: var(--danger); background: var(--danger-soft); }
/* Pinned to the bottom of the card via margin-top:auto (the flex column
   above) so a row of KPI cards lines up along the same bottom edge no
   matter how much each card's value/label text wraps — plain muted text
   rather than a badge/pill, since a pill that wraps to two lines just
   looks broken. */
.kpi-card .kpi-caption {
  display: block;
  margin-top: auto;
  padding-top: 12px;
  font-size: .72rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.panel-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
/* Grid items default to a content-based minimum width, so a card containing
   a wide table (which itself has min-width:640px for mobile horizontal
   scroll) refuses to shrink to its 1fr track and overflows the page. This
   lets the grid track win; .table-wrap's own overflow-x:auto still handles
   any genuinely narrow viewport. */
.panel-grid > * { min-width: 0; }
/* The 640px table floor below exists so a wide CRUD list table (5-6+
   real data columns) doesn't get illegibly squished on a narrow screen —
   these dashboard summary panels are narrow, few-column tables that fit
   comfortably well under that, so the floor just forces a pointless
   horizontal scrollbar and clips the last header off the narrower
   (1fr) column instead. */
.panel-grid .table-wrap table { min-width: 0; }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-bottom: 28px; }
.chart-card .card-body { position: relative; height: 280px; }
/* Stacked instead of the default card-header row: a title + a longer
   date-range caption side by side collide and wrap into each other at
   these card widths (3-up on a laptop screen), whereas title-then-subtitle
   never collides at any width. */
.chart-card .card-header { flex-direction: column; align-items: flex-start; gap: 3px; }
.chart-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--text-faint); font-size: .82rem; text-align: center;
}
.chart-empty i { font-size: 1.7rem; }

table.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.data-table thead th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--gray-50);
}
table.data-table thead th:first-child { border-top-left-radius: var(--radius-sm); }
table.data-table thead th:last-child { border-top-right-radius: var(--radius-sm); }
table.data-table tbody td { padding: 14px 18px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
table.data-table tbody tr { transition: background .15s var(--ease); }
table.data-table tbody tr:hover { background: var(--gray-50); }
table.data-table tbody tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.table-wrap table { min-width: 640px; }

/* Reports & Books' wide, column-heavy registers (Sales Register, Payment
   Statement, Supplier Ledger) — the default 14px/18px list padding forces
   short cells like dates, amounts and reference numbers to wrap onto 2-3
   ragged lines once a table hits a dozen-plus columns. Every cell here is
   nowrap by default (tight and legible; .table-wrap's horizontal scroll
   handles the overflow) except columns explicitly marked .wrap, where the
   content (client/supplier names, descriptions) is genuinely open-ended and
   would otherwise blow the table out far wider than its data warrants. */
.data-table.report-table thead th,
.data-table.report-table tbody td { padding: 10px 14px; white-space: nowrap; }
.data-table.report-table tbody td.wrap { white-space: normal; min-width: 160px; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text-muted);
  cursor: pointer; transition: all .15s var(--ease);
  text-decoration: none;
}
.icon-btn:hover { background: var(--primary-50); color: var(--primary-700); border-color: var(--primary-200); transform: translateY(-1px); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ================= badges ================= */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: .72rem; font-weight: 600; text-transform: capitalize; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--neutral-soft); color: var(--text-muted); }

/* Per-status "royal" solid-fill badges (config['fields'][col]['badge_colors'])
   — used where a module needs distinct, bold colors per status value instead
   of the shared soft success/warning/danger/neutral palette above (e.g.
   Quotation status: Draft/Sent/Accepted/Rejected/Expired all read distinctly
   at a glance). White text for contrast against the solid fill. */
.badge-royal-yellow { background: #b45309; color: #fff; }
.badge-royal-blue { background: #1e429f; color: #fff; }
.badge-royal-green { background: #15803d; color: #fff; }
.badge-royal-red { background: #b91c1c; color: #fff; }
.badge-royal-black { background: #111827; color: #fff; }

/* List-page one-click status change (config['list_quick_edit']) — a compact
   pill-shaped dropdown colored to match the current value; picking a new
   option saves immediately. Deep, saturated "jewel tone" fills (not the
   softer shared .badge-* palette used elsewhere) so the status reads clearly
   at a glance, with white text/chevron for contrast against them. */
.quick-status-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  border: none; cursor: pointer; outline: none; text-transform: capitalize;
  padding: 4px 26px 4px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700;
  /* The browser sizes a <select> from its options' normal-weight text, which
     clipped the bold label ("Approve" for "Approved") — size to content instead. */
  field-sizing: content;
  background-repeat: no-repeat; background-position: right 9px center; background-size: 9px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  transition: filter .15s var(--ease);
}
.quick-status-select:hover { filter: brightness(1.08); }
.quick-status-select:focus { box-shadow: 0 0 0 2px rgba(0,0,0,.18); }
.quick-status-select.badge-success { background-color: #15803d; color: #fff; }
.quick-status-select.badge-warning { background-color: #b45309; color: #fff; }
.quick-status-select.badge-danger { background-color: #b91c1c; color: #fff; }
.quick-status-select.badge-neutral { background-color: var(--neutral-soft); color: var(--text-muted); }
.quick-status-select.badge-royal-green { background-color: #15803d; color: #fff; }
.quick-status-select.badge-royal-blue { background-color: #1e429f; color: #fff; }
.quick-status-select.badge-royal-yellow { background-color: #b45309; color: #fff; }
.quick-status-select.badge-royal-red { background-color: #b91c1c; color: #fff; }
.quick-status-select.badge-royal-black { background-color: #111827; color: #fff; }
.quick-status-select:focus { box-shadow: 0 0 0 2px rgba(0,0,0,.12); }

/* iOS-style switch for a boolean list_quick_edit field (e.g. Invoice's
   Auto Reminder toggle) — plain checkbox underneath, submits on change. */
.toggle-switch { position: relative; display: inline-block; width: 38px; height: 22px; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background-color: var(--neutral-soft);
  border-radius: 999px; transition: background-color .15s var(--ease);
}
.toggle-slider::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
  background-color: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: transform .15s var(--ease);
}
.toggle-switch input:checked + .toggle-slider { background-color: var(--primary-600, var(--primary-700)); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }
.toggle-switch input:focus-visible + .toggle-slider { box-shadow: 0 0 0 2px rgba(0,0,0,.18); }

/* ================= buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .16s var(--ease), box-shadow .2s var(--ease), background .18s var(--ease), border-color .18s var(--ease);
  text-decoration: none;
  min-height: 42px;
  line-height: 1;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--primary-700);
  color: #fff;
  box-shadow: var(--shadow-navy);
}
.btn-primary:hover { background: var(--primary-800); box-shadow: 0 6px 14px rgba(28,100,242,.35); color: #fff; }
.btn-outline { background: #fff; border-color: var(--border-strong); color: var(--gray-700); }
.btn-outline:hover { border-color: var(--primary-400); color: var(--primary-700); background: var(--primary-50); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--gray-100); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: .78rem; min-height: 34px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn-primary::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(circle, rgba(255,255,255,.25) 0%, transparent 60%);
  opacity: 0; transition: opacity .3s var(--ease);
}
.btn-primary:active::after { opacity: 1; }

/* ================= forms ================= */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px 24px; }
.form-grid .span-2 { grid-column: span 2; }
/* Dashboard's period/from/to/apply filter row — a fixed 4-column layout
   that .form-grid's own responsive collapse (below) can't reach when it's
   set inline, since an inline style always wins over a media query in an
   external stylesheet. Named class instead so mobile actually collapses it. */
/* align-items: flex-start (not flex-end) so the Period/From/To/Apply
   controls all sit on the same horizontal line regardless of the Period
   field's extra hint line below it — bottom-aligning would instead push
   the shorter fields' controls down to match that hint's extra height. */
.dash-filter-grid { grid-template-columns: 1fr 1fr 1fr auto; align-items: flex-start; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: .8rem; font-weight: 600; color: var(--gray-700); }
.field .hint { font-size: .72rem; color: var(--text-faint); }
.view-value { padding: 8px 0 2px; font-size: .92rem; color: var(--gray-800); min-height: 20px; }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: .88rem; }
.history-list li { padding: 10px 14px; background: var(--gray-50); border-radius: var(--radius-sm); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=month], input[type=time], input[type=datetime-local], select, textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--gray-50);
  font-family: inherit;
  font-size: .875rem;
  color: var(--text);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary-500); background: #fff;
  box-shadow: 0 0 0 3px var(--primary-100);
}
input[readonly] { background: var(--gray-100); color: var(--text-muted); }

/* Searchable combobox over an fk <select> — see initFkCombo() in app.js.
   The select is kept at full size behind the search input, just fully
   transparent and unclickable, so it stays a normal, visible-to-automation
   form control (Playwright's visibility check only cares about `visibility`
   and bounding-box size, not `opacity`) even though a person only ever sees
   and interacts with the text input + menu on top of it. */
.fk-combo { position: relative; }
.fk-combo-select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; border: none; padding: 0; margin: 0; }
.fk-combo-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); max-height: 240px; overflow-y: auto;
}
.fk-combo-menu:empty { display: none; }
.fk-combo-item { padding: 8px 12px; font-size: .875rem; cursor: pointer; }
.hint.billing-note { color: var(--success); }
/* ---- Email History on a document's view page ---- */
.email-history { margin-top: 20px; scroll-margin-top: 80px; }
.eh-empty { color: var(--text-muted); font-size: .86rem; text-align: center; padding: 14px 0; }
.eh-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.eh-summary > div { background: var(--gray-50, #f9fafb); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; }
.eh-summary span { display: block; font-size: .66rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.eh-summary strong { display: block; font-size: .95rem; margin-top: 2px; }
.eh-summary em { display: block; font-style: normal; font-size: .72rem; color: var(--text-muted); }
.eh-summary .is-bad strong { color: var(--danger); }
.eh-day + .eh-day { margin-top: 14px; }
.eh-day-head { display: flex; justify-content: space-between; align-items: baseline; font-size: .78rem; font-weight: 600; color: var(--text); padding: 6px 0; border-bottom: 1px solid var(--border); }
.eh-day-head span { font-weight: 400; color: var(--text-muted); }
.eh-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: .82rem; }
.eh-time { color: var(--text-muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.eh-line1 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.eh-kind { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eef2ff; color: #3730a3; }
.eh-kind.eh-auto_reminder { background: #fff7e6; color: #9a5b00; }
.eh-kind.eh-manual_reminder { background: #fdecec; color: #b42318; }
.eh-subject { font-weight: 500; color: var(--text); overflow-wrap: anywhere; }
.eh-line2 { color: var(--text-muted); margin-top: 3px; overflow-wrap: anywhere; }
.eh-line2 strong { color: var(--text); font-weight: 500; }
.eh-error { color: var(--danger); margin-top: 3px; font-size: .78rem; }
@media (max-width: 640px) {
  .eh-row { grid-template-columns: minmax(0, 1fr) auto; }
  .eh-time { grid-column: 1 / -1; padding: 0; font-weight: 600; }
}
.hint.billing-note.is-error { color: var(--danger); font-weight: 500; }
.fk-combo-item:hover, .fk-combo-item.is-active { background: var(--primary-50); color: var(--primary-700); }

.checkbox-field { display: flex; align-items: center; gap: 9px; flex-direction: row; }
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--primary-700); }

/* WYSIWYG for config/entities.php fields flagged 'rich' => true — see
   initRichText() in app.js. .richtext-source is the actual submitted
   <textarea>, hidden behind the visible toolbar + contenteditable surface. */
.richtext-wrapper { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--gray-50); overflow: hidden; }
.richtext-toolbar { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--surface); }
.richtext-toolbar button {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent;
  color: var(--gray-700); cursor: pointer; font-size: .9rem;
}
.richtext-toolbar button:hover { background: var(--primary-50); color: var(--primary-700); }
.richtext-toolbar .richtext-template-picker {
  margin-left: auto; width: auto; max-width: 190px;
  padding: 4px 8px; font-size: .78rem; height: 30px;
}
.richtext-editor {
  min-height: 120px; max-height: 340px; overflow-y: auto; padding: 10px 14px;
  font-size: .875rem; color: var(--text); background: var(--gray-50);
}
.richtext-editor:focus { outline: none; background: #fff; }
.richtext-editor img { max-width: 100%; border-radius: var(--radius-sm); }
.richtext-editor ul, .richtext-editor ol { padding-left: 22px; }

.items-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
/* One per item-row shape (crud/form.php) — a plain wrapper, not a visible group box. */
.item-variant { border: 0; margin: 0; padding: 0; min-width: 0; }
.item-variant[hidden] { display: none; }
.items-table th { text-align: left; font-size: .72rem; color: var(--text-muted); text-transform: uppercase; padding: 7px 9px; }
.items-table td { padding: 7px 9px; }
.items-table input { min-width: 100px; }
.items-table .desc-col input { min-width: 220px; }
.items-table .s-no-col { width: 36px; text-align: center; }
.items-table .s-no-cell { text-align: center; color: var(--text-muted); font-size: .8rem; }
/* A rich-text item cell (config/entities.php item_fields[x]['rich'] => true)
   needs to fit a full toolbar + editable area inside a table row without
   ballooning every row to a full-field's height — see crud/form.php. */
.richtext-wrapper-compact { min-width: 320px; }
.richtext-wrapper-compact .richtext-toolbar button { width: 26px; height: 26px; font-size: .8rem; }
.richtext-wrapper-compact .richtext-editor { min-height: 90px; max-height: 220px; padding: 10px 12px; font-size: .875rem; }
/* A rich cell beside the description (e.g. a quotation rate card's Rate /
   Hour, O.T. and Sunday & P.H. Rate) — same editor, narrower, so a row of
   four still fits; the table scrolls sideways on a narrow screen instead of
   squeezing the editors. */
.items-table td:not(.desc-col) .richtext-wrapper-compact { min-width: 170px; }
.item-variant { overflow-x: auto; }

/* Clickable item-row-shape switch (config['item_fields_variant_field'], e.g.
   Quotation Type: Timecard/General) — crud/form.php renders this as pills
   right above the items table instead of a plain <select> further up. */
.seg-control { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 10px; }
.seg-btn {
  padding: 8px 18px; border: none; background: var(--surface); color: var(--gray-700);
  font-size: .85rem; font-weight: 600; cursor: pointer; border-right: 1px solid var(--border-strong);
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: var(--primary-50); color: var(--primary-700); }
.seg-btn.active { background: var(--primary-600); color: #fff; }

/* Payment Receipt form: each invoice option in the "Against Invoice" dropdown
   (.fk-combo-menu, see initFkCombo() in app.js) previews its own payment
   progress — how much is already receipted vs. what's actually still owed
   net of Credit/Debit Notes — right in the row, while it's being browsed. */
.fk-combo-item-label { margin-bottom: 4px; }
.invoice-progress-bar { height: 8px; border-radius: 999px; background: var(--gray-200); overflow: hidden; }
.invoice-progress-bar-mini { height: 5px; }
.invoice-progress-fill { height: 100%; width: 0; background: var(--primary-600); border-radius: 999px; transition: width .25s ease; }
.invoice-progress-fill.full { background: #15803d; }
.invoice-progress-text { margin-top: 4px; font-size: .78rem; color: var(--text-muted); }

/* Visually matches .items-table but stays out of its subtotal/line-total JS
   (document.querySelectorAll('.items-table tbody tr')) — a second repeatable
   child collection (e.g. a payment schedule) must never be swept into that
   calculation. */
.pterm-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.pterm-table th { text-align: left; font-size: .72rem; color: var(--text-muted); text-transform: uppercase; padding: 7px 9px; }
.pterm-table td { padding: 7px 9px; }
.pterm-table input { min-width: 100px; }
.pterm-table .label-col input { min-width: 220px; }
.pterm-total-hint { font-size: .78rem; margin-top: 8px; text-align: right; }
.pterm-total-hint.warn { color: var(--warning); }
.pterm-total-hint.ok { color: var(--success); }

/* ================= login / otp ================= */
.auth-shell {
  min-height: 100vh;
  display: flex;
  background: var(--gray-900);
}
.auth-visual {
  flex: 1.1;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  padding: 64px 72px;
  color: rgba(255,255,255,.92);
  position: relative;
  overflow: hidden;
}
.auth-visual::before {
  content: "";
  position: absolute; width: 480px; height: 480px; border-radius: 50%;
  background: radial-gradient(circle, rgba(63,131,248,.25), transparent 65%);
  top: -140px; right: -140px;
}
.auth-visual::after {
  content: "";
  position: absolute; width: 360px; height: 360px; border-radius: 50%;
  background: radial-gradient(circle, rgba(28,100,242,.2), transparent 65%);
  bottom: -120px; left: -80px;
}
.auth-visual-logo { height: 46px; width: auto; margin-bottom: 36px; position: relative; z-index: 1; }
.auth-visual h1 { color: #fff; font-size: 2rem; font-weight: 600; max-width: 480px; position: relative; z-index: 1; }
.auth-visual p { color: var(--gray-300); max-width: 440px; font-size: .95rem; position: relative; z-index: 1; }
.auth-feature-list { list-style: none; padding: 0; margin: 30px 0 0; display: flex; flex-direction: column; gap: 16px; position: relative; z-index: 1; }
.auth-feature-list li { display: flex; gap: 12px; align-items: flex-start; color: var(--gray-200); font-size: .88rem; }
.auth-feature-list i { color: var(--primary-400); margin-top: 2px; }

.auth-panel {
  flex: 1;
  max-width: 480px;
  background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px;
}
.auth-logo {
  width: 100%; max-width: 360px;
  display: flex; justify-content: center;
  margin-bottom: 40px;
}
.auth-logo img {
  height: 96px;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .1));
  transition: transform .25s ease;
}
.auth-logo img:hover { transform: translateY(-2px); }
.auth-card { width: 100%; max-width: 360px; }
.auth-card .eyebrow { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--primary-700); font-weight: 600; margin-bottom: 9px; }
.auth-card h2 { margin-bottom: 7px; }
.auth-card p.sub { color: var(--text-muted); font-size: .87rem; margin-bottom: 30px; }
.otp-boxes { display: flex; gap: 11px; justify-content: center; margin: 10px 0 24px; }
.otp-boxes input {
  width: 46px; height: 54px; text-align: center; font-size: 1.3rem; font-weight: 600;
  padding: 0;
}

/* ================= alerts / flash ================= */
.flash-stack { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; width: 320px; }
.flash {
  background: #fff; border-left: 4px solid var(--primary-600);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 14px 18px;
  font-size: .85rem; animation: slideInRight .4s var(--ease) both;
  display: flex; align-items: flex-start; gap: 10px;
}
.flash.success { border-color: var(--success); }
.flash.error { border-color: var(--danger); }
.flash.warning { border-color: var(--warning); }
.flash-close { margin-left: auto; cursor: pointer; color: var(--text-faint); background:none; border:none; font-size: 1rem; }

.alert { padding: 13px 18px; border-radius: var(--radius-sm); font-size: .85rem; margin-bottom: 18px; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #f8b4b4; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: #84e1bc; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: #f5d97a; }
.alert-info { background: var(--primary-50); color: var(--primary-800); border-color: var(--primary-200); }

/* ================= page header / breadcrumb ================= */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .crumb { font-size: .78rem; color: var(--text-muted); margin-bottom: 5px; }
.page-head .crumb a { color: var(--text-muted); }
.page-head h1 { margin: 0; }
.page-actions { display: flex; gap: 12px; flex-wrap: wrap; }
@media (max-width: 640px) { .page-actions { gap: 8px; } .page-actions .btn { padding: 7px 12px; font-size: .8rem; } }

.empty-state { text-align: center; padding: 70px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.4rem; color: var(--text-faint); margin-bottom: 14px; display: block; }

.pagination { display: flex; gap: 7px; justify-content: flex-end; margin-top: 18px; }
.pagination a, .pagination span {
  min-width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); color: var(--text-muted); font-size: .82rem;
  transition: all .15s var(--ease);
}
.pagination a:hover { background: var(--primary-50); color: var(--primary-700); }
.pagination .active { background: var(--primary-700); color: #fff; border-color: var(--primary-700); }

/* ================= mailbox (Outlook-style) ================= */
.content-full { padding: 0; display: flex; flex-direction: column; flex: none; height: calc(100vh - var(--topbar-h)); overflow: hidden; }

.ol-shell { display: grid; grid-template-columns: 232px 360px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); flex: 1; min-height: 0; background: #fff; }
.ol-shell > * { min-width: 0; min-height: 0; }

/* folder pane */
.ol-nav { background: var(--gray-50); border-right: 1px solid var(--border); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.ol-new { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 9px 12px; margin-bottom: 14px; border: 0; border-radius: var(--radius-sm); background: var(--primary-700); color: #fff; font-family: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; transition: background .15s var(--ease); }
.ol-new:hover { background: var(--primary-800); }
.ol-nav-label { padding: 4px 12px 6px; font-size: .68rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--gray-400); }
.ol-folder { display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: 6px; color: var(--gray-700); font-size: .85rem; position: relative; transition: background .12s var(--ease); }
.ol-folder i { font-size: .95rem; color: var(--gray-500); width: 16px; text-align: center; }
.ol-folder:hover { background: var(--gray-100); }
.ol-folder.active { background: var(--primary-50); color: var(--primary-800); font-weight: 600; }
.ol-folder.active i { color: var(--primary-700); }
.ol-folder.active::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 3px; background: var(--primary-700); }
.ol-count { margin-left: auto; font-size: .72rem; font-weight: 600; color: var(--primary-700); }
.ol-count-plain { margin-left: auto; font-size: .72rem; font-style: normal; color: var(--gray-400); }
.ol-account { margin-top: auto; display: flex; align-items: center; gap: 9px; padding: 12px 10px 4px; border-top: 1px solid var(--border); min-width: 0; }
.ol-account-text { display: flex; flex-direction: column; min-width: 0; font-size: .72rem; color: var(--gray-700); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-account-text small { font-size: .64rem; color: var(--gray-400); text-transform: uppercase; letter-spacing: .05em; }

.ol-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-100); color: var(--primary-800); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; flex-shrink: 0; }
.ol-avatar.sm { width: 28px; height: 28px; font-size: .72rem; background: var(--primary-700); color: #fff; }
.ol-avatar.lg { width: 44px; height: 44px; font-size: 1rem; }

/* message list */
.ol-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; background: #fff; }
.ol-list-head { padding: 14px 14px 0; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ol-list-title { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.ol-list-title h2 { font-size: 1.05rem; font-weight: 600; color: var(--gray-900); margin: 0; }
.ol-list-title span { font-size: .72rem; color: var(--gray-400); }
.ol-search { position: relative; margin-bottom: 8px; }
.ol-search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--gray-400); font-size: .8rem; }
.ol-search input { width: 100%; padding: 7px 12px 7px 32px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--gray-50); font-size: .82rem; font-family: inherit; }
.ol-search input:focus { outline: none; border-color: var(--primary-500); background: #fff; box-shadow: 0 0 0 3px var(--primary-100); }
.ol-tabs { display: flex; gap: 4px; }
.ol-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 10px; font-family: inherit; font-size: .8rem; font-weight: 500; color: var(--gray-500); cursor: pointer; margin-bottom: -1px; }
.ol-tabs button:hover { color: var(--gray-800); }
.ol-tabs button.active { color: var(--primary-700); border-bottom-color: var(--primary-700); font-weight: 600; }
.ol-items { overflow-y: auto; flex: 1; }
.ol-group { padding: 10px 14px 4px; font-size: .68rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--gray-500); background: #fff; position: sticky; top: 0; z-index: 1; }
.ol-item { display: flex; gap: 11px; padding: 11px 14px; border-bottom: 1px solid var(--gray-100); color: inherit; position: relative; transition: background .12s var(--ease); }
.ol-item:hover { background: var(--gray-50); }
.ol-item.active { background: var(--primary-50); }
.ol-item.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary-700); }
.ol-item-body { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.ol-row1 { display: flex; align-items: baseline; gap: 8px; }
.ol-from { flex: 1; min-width: 0; font-size: .84rem; color: var(--gray-800); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-from i { color: var(--gray-400); font-size: .72rem; }
.ol-date { font-size: .7rem; color: var(--gray-400); white-space: nowrap; flex-shrink: 0; }
.ol-subject { font-size: .82rem; color: var(--gray-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-snippet { font-size: .76rem; color: var(--gray-400); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-item.unread .ol-from, .ol-item.unread .ol-subject { font-weight: 700; color: var(--gray-900); }
.ol-item.unread .ol-subject { color: var(--primary-800); }
.ol-item.unread .ol-date { color: var(--primary-700); font-weight: 600; }
.ol-no-match[hidden] { display: none; }

/* reading pane */
.ol-reader { display: flex; flex-direction: column; background: #fff; }
.ol-reader-bar { display: flex; gap: 4px; padding: 8px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ol-tool { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border: 0; border-radius: 6px; background: none; color: var(--gray-700); font-family: inherit; font-size: .82rem; font-weight: 500; cursor: pointer; }
.ol-tool:hover { background: var(--gray-100); color: var(--primary-700); }
.ol-reader-scroll { overflow-y: auto; padding: 22px 28px 40px; flex: 1; }
.ol-r-subject { font-size: 1.3rem; font-weight: 600; line-height: 1.3; color: var(--gray-900); margin: 0 0 18px; overflow-wrap: anywhere; }
.ol-r-head { display: flex; align-items: flex-start; gap: 12px; padding-bottom: 16px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.ol-r-meta { flex: 1; min-width: 0; font-size: .82rem; line-height: 1.5; }
.ol-r-from strong { font-size: .92rem; color: var(--gray-900); }
.ol-r-addr { color: var(--gray-500); margin-left: 4px; }
.ol-r-to { color: var(--gray-500); overflow-wrap: anywhere; }
.ol-r-date { font-size: .78rem; color: var(--gray-500); white-space: nowrap; }
.ol-body { width: 100%; border: 0; display: block; min-height: 120px; }
.ol-reader-empty { margin: auto; text-align: center; color: var(--gray-400); padding: 24px; }
.ol-reader-empty i { font-size: 3.4rem; display: block; margin-bottom: 10px; }
.ol-reader-empty h3 { font-size: 1.05rem; color: var(--gray-600); margin: 0 0 4px; font-weight: 600; }
.ol-reader-empty p { font-size: .82rem; margin: 0; }

/* compose window, docked bottom-right like Outlook */
.ol-compose { position: fixed; right: 28px; bottom: 0; width: 540px; max-width: calc(100vw - 24px); background: #fff; border: 1px solid var(--border-strong); border-bottom: 0; border-radius: 10px 10px 0 0; box-shadow: var(--shadow-lg); z-index: 250; display: none; flex-direction: column; }
.ol-compose.open { display: flex; }
.ol-compose-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--primary-800); color: #fff; border-radius: 9px 9px 0 0; font-size: .85rem; font-weight: 600; }
.ol-x { background: none; border: 0; color: #fff; cursor: pointer; opacity: .85; font-size: .85rem; }
.ol-x:hover { opacity: 1; }
.ol-compose-form { display: flex; flex-direction: column; }
.ol-crow { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--gray-100); }
.ol-crow span { width: 52px; font-size: .78rem; color: var(--gray-500); flex-shrink: 0; }
.ol-crow input { flex: 1; border: 0; padding: 10px 0; font-size: .85rem; font-family: inherit; background: none; }
.ol-crow input:focus { outline: none; }
.ol-compose textarea { border: 0; resize: vertical; min-height: 220px; max-height: 50vh; padding: 12px 14px; font-size: .86rem; font-family: inherit; line-height: 1.55; }
.ol-compose textarea:focus { outline: none; }
.ol-compose-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); }
.ol-from-note { margin-left: auto; font-size: .7rem; color: var(--gray-400); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1200px) { .ol-shell { grid-template-columns: 200px 300px minmax(0, 1fr); } }
@media (max-width: 991px) {
  .content-full { height: auto; overflow: visible; flex: 1; }
  .ol-shell { grid-template-columns: 1fr; grid-template-rows: none; }
  .ol-nav { flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--border); }
  .ol-nav-label, .ol-account { display: none; }
  .ol-new { width: auto; margin: 0 8px 0 0; }
  .ol-list { border-right: 0; border-bottom: 1px solid var(--border); max-height: 50vh; }
  .ol-reader { min-height: 50vh; }
  .ol-compose { right: 0; width: 100%; max-width: 100%; border-radius: 0; }
}

/* ================= print view ================= */
.print-sheet { background: #fff; max-width: 820px; margin: 0 auto; padding: 44px; border-radius: var(--radius); box-shadow: var(--shadow-md); }
.print-toolbar { max-width: 820px; margin: 0 auto 18px; display: flex; justify-content: flex-end; gap: 10px; }
@media print {
  .print-toolbar, .sidebar, .topbar { display: none !important; }
  .main-col { margin-left: 0 !important; }
  .print-sheet { box-shadow: none; }
  body { background: #fff; }
}

/* ================= loaders ================= */
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; }
.skeleton { background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 37%, var(--gray-100) 63%); background-size: 400px 100%; animation: shimmer 1.4s infinite linear; border-radius: var(--radius-sm); }

/* ================= modal (delete confirm etc) ================= */
.modal-overlay { position: fixed; inset: 0; background: rgba(17,24,39,.5); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 300; opacity: 0; pointer-events: none; transition: opacity .2s var(--ease); }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 28px; width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); transform: scale(.94) translateY(8px); transition: transform .22s var(--ease); }
.modal-overlay.open .modal-box { transform: scale(1) translateY(0); }
.modal-box h3 { margin-bottom: 9px; }
.modal-box p { color: var(--text-muted); font-size: .87rem; margin-bottom: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; }

/* Email modal (#mail-modal, see flash.php + initMailModal() in app.js) —
   wider than the plain confirm dialog since it holds a real form-grid. */
.modal-box-lg { max-width: 560px; text-align: left; position: relative; }
/* e-Sign popup: the client-signature card, scrolls within the screen. */
/* ---- e-Sign popup: compact, same dark header as the email popup ---- */
.modal-box-esign { max-width: 480px; width: calc(100% - 32px); padding: 0; position: relative; text-align: left; max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; font-size: .84rem; }
.modal-box-esign #esign-modal-body { overflow-y: auto; min-height: 0; padding: 14px 18px 18px; }
.modal-box-esign .modal-loading { padding: 8px 0; }
.es-head { display: flex; align-items: center; gap: 8px; background: #14104a; color: #fff; padding: 12px 48px 12px 18px; font-size: .74rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; flex-shrink: 0; }
.es-head i { color: #8b93ff; }
.modal-box-esign > .modal-close { position: absolute; top: 6px; right: 8px; z-index: 2; color: #c7cbe6; background: transparent; }
.modal-box-esign > .modal-close:hover { background: rgba(255,255,255,.12); color: #fff; }
.esign-panel { display: flex; flex-direction: column; gap: 12px; font-size: .84rem; }
.es-summary { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--gray-50, #f9fafb); border: 1px solid var(--border); border-radius: 8px; }
.es-summary-main { min-width: 0; flex: 1; }
.es-quote-no { font-weight: 600; font-size: .88rem; color: var(--text); }
.es-client { font-size: .76rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.es-chip { display: inline-flex; align-items: center; gap: 5px; font-size: .7rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.es-chip.is-none { background: #eef2ff; color: #3730a3; }
.es-chip.is-sent { background: #fff7e6; color: #9a5b00; }
.es-chip.is-signed { background: #e7f6ec; color: #0e7a3d; }
.es-pdf { font-size: .76rem; font-weight: 600; white-space: nowrap; }
.es-alert { margin: 0; font-size: .8rem; padding: 8px 12px; }
.es-section { display: flex; flex-direction: column; gap: 6px; }
.es-section + .es-section { border-top: 1px solid var(--border); padding-top: 12px; }
.es-label { font-size: .66rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); margin: 0; }
.es-label-row { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.es-edit-sig { text-transform: none; letter-spacing: 0; font-size: .74rem; font-weight: 500; }
.es-send-row, .es-link-row { display: flex; gap: 6px; align-items: stretch; }
.es-send-row input, .es-link-row input { flex: 1; min-width: 0; font-size: .84rem; padding: 7px 10px; height: auto; }
.es-send-row .btn, .es-link-row .btn { white-space: nowrap; }
.es-hint { font-size: .72rem; color: var(--text-muted); line-height: 1.45; }
.es-sent-note { background: #fff7e6; border-radius: 6px; padding: 7px 10px; color: #7a4a00; }
.es-signature { border: 1px dashed var(--border-strong, #d1d5db); border-radius: 6px; padding: 8px 10px; font-size: .78rem; line-height: 1.45; color: #374151; max-height: 110px; overflow-y: auto; background: #fff; }
.modal-box .es-signature p, .es-signature p { margin: 0 0 4px; font-size: inherit; color: inherit; }
.es-signature img { max-width: 100%; height: auto; }
.es-signature.is-empty { color: var(--text-muted); font-style: italic; }
.es-warning { font-size: .76rem; background: #fffbea; border: 1px solid #f5d77a; border-radius: 6px; padding: 7px 10px; color: #7a4a00; }
.es-warning summary { cursor: pointer; font-weight: 600; }
.es-warning div { margin-top: 6px; line-height: 1.45; }
.es-signed { align-items: flex-start; }
.es-signed-name { font-weight: 600; }
.es-reset { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 4px; }
/* Full-page fallback (quotations/esign.php): the same panel in a card. */
.page-head + .esign-panel { max-width: 560px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.modal-close {
  position: absolute; top: 18px; right: 18px; width: 30px; height: 30px;
  border: none; background: transparent; color: var(--text-muted);
  font-size: 1.3rem; line-height: 1; cursor: pointer; border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-900); }
.modal-loading { color: var(--text-muted); font-size: .87rem; padding: 12px 0; }
.modal-loading .spin { display: inline-block; animation: spin 1s linear infinite; }
.mail-form-error {
  background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: .85rem; margin-bottom: 16px;
}
/* Read-only preview of the sender's saved signature (mail_form_body.php) —
   deliberately styled like inert, already-sent content (muted background,
   no input chrome) so it doesn't read as another editable field. */
.mail-signature-preview {
  background: var(--gray-50); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: .85rem; color: var(--gray-700); line-height: 1.6;
}

/* ================= error pages ================= */
.error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.error-card { text-align: center; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 56px; box-shadow: var(--shadow-md); }
.error-code { font-size: 3rem; font-weight: 600; color: var(--primary-700); }

/* ================= utility ================= */
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.d-flex { display: flex; } .align-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }

/* ================= responsive ================= */
/* Tablets: two-column KPI grid before the sidebar collapses fully. */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main-col { margin-left: 0; }
  .hamburger { display: inline-flex; align-items: center; justify-content: center; }
  .panel-grid { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .dash-filter-grid { grid-template-columns: 1fr; align-items: stretch; }
  .auth-visual { display: none; }
  .auth-panel { max-width: 100%; }
  .content { padding: 26px 22px 56px; }
}
@media (max-width: 575px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .content { padding: 20px 16px 48px; }
  .btn, .icon-btn { min-height: 44px; }
  .topbar { padding: 0 16px; gap: 10px; }
  .auth-panel { padding: 32px 22px; }
}

.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(17,24,39,.5); z-index: 35; display: none;
}
.sidebar-backdrop.show { display: block; animation: fadeIn .2s var(--ease); }

/* -- Quotation e-Sign page (app/views/quotations/esign.php) -------------- */
.esign-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; align-items: start; }
.esign-grid > * { min-width: 0; }
.sig-canvas-wrap { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: #fff; touch-action: none; }
.sig-canvas { display: block; width: 100%; height: 170px; cursor: crosshair; touch-action: none; }
.esign-sig-img { display: block; max-width: 280px; max-height: 110px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px; margin-bottom: 8px; }
.esign-signed { font-size: .9rem; }
@media (max-width: 480px) { .esign-grid { grid-template-columns: 1fr; } }
/* e-Sign row action on the Quotations list — tinted by where it stands. */
.icon-btn.esign-success { color: var(--success); }
.icon-btn.esign-info { color: var(--primary-700); }
/* Company Profile > Authorised Signatory preview. */
.signatory-preview { width: 220px; height: 100px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: #fff; display: flex; align-items: center; justify-content: center; padding: 8px; }
.signatory-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.signature-uploads { display: flex; flex-wrap: wrap; gap: 24px; margin-bottom: 16px; }
.signature-upload { display: flex; gap: 14px; align-items: flex-start; flex: 1 1 340px; min-width: 0; }
.signature-upload .field { flex: 1; min-width: 0; }
.signature-upload input[type=file] { max-width: 100%; }
.signature-doc-actions { display: flex; gap: 6px; margin-bottom: 6px; }
.signature-doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-alt); margin-bottom: 6px; }
.signature-doc { display: flex; align-items: center; gap: 8px; font-size: .84rem; font-weight: 500; margin: 0; cursor: pointer; }
.signature-doc input { width: auto; margin: 0; }
@media (max-width: 560px) { .signature-upload { flex-direction: column; } }
/* Invoice auto-reminder: schedule summary under the list toggle, and the
   schedule fields on the form (shown only while Auto Reminder is ticked). */
.reminder-summary { font-size: .72rem; color: var(--text-muted); margin-top: 4px; max-width: 190px; line-height: 1.35; }
.reminder-schedule-field { background: var(--primary-50); border-radius: var(--radius-sm); padding: 10px 12px; }

/* Totals bar above a list (config['list_totals'], e.g. Costing) — sums of the filtered rows. */
.list-totals { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: stretch; }
.list-totals-count { align-self: center; padding: 8px 14px; font-size: .82rem; color: var(--text-muted); }
.list-total { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; min-width: 120px; }
.list-total span { display: block; font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.list-total strong { font-size: .95rem; font-variant-numeric: tabular-nums; }
.list-total.is-profit strong { color: var(--success); }
.list-total.is-loss strong { color: var(--danger); }
input.is-computed { background: var(--surface-alt); font-variant-numeric: tabular-nums; }

/* Mailbox > Sent Items: status + type of each app email (Queued / Sent / Failed). */
.ol-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 5px; font-size: .7rem; }
.ol-tags .badge { font-size: .66rem; padding: 2px 7px; }
.ol-kind { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); font-size: .72rem; }
.ol-r-info .ol-kind { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; }
.ol-kind-link { color: var(--primary, #1d4ed8); text-decoration: none; }
.ol-kind-link:hover { text-decoration: underline; }
.ol-r-info { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 16px; }
.ol-r-hint { font-size: .75rem; color: var(--text-muted); }
.ol-sent-note { font-size: .72rem; color: var(--text-muted); margin-top: 6px; }
.ol-count-danger { background: var(--danger) !important; color: #fff !important; }
.ol-account-note { display: block; margin-top: 2px; font-size: .66rem; color: var(--text-muted); text-transform: none; letter-spacing: 0; }
/* ---- Settings > Users & Roles ---- */
.user-kpis { margin-bottom: 20px; }
.user-kpis .kpi-card { padding: 18px 20px; }
.user-kpis .kpi-icon { margin-bottom: 10px; width: 38px; height: 38px; font-size: 1.05rem; }
.users-toolbar { flex-wrap: wrap; gap: 10px; justify-content: flex-start; }
.users-toolbar select { max-width: 180px; }
.users-status-tabs { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 3px; background: var(--surface-alt); margin-left: auto; }
.users-status-tabs button { border: 0; background: none; padding: 5px 14px; border-radius: 999px; font-size: .8rem; font-weight: 500; color: var(--text-muted); cursor: pointer; }
.users-status-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.users-table td { vertical-align: middle; }
.users-table tr.is-inactive td { opacity: .62; }
.users-table tr.is-inactive td:last-child { opacity: 1; }
.user-cell { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.user-cell strong { font-weight: 600; }
.user-email { display: block; font-size: .78rem; color: var(--text-muted); }
.user-you { font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--primary-700); background: var(--primary-100); padding: 1px 6px; border-radius: 999px; vertical-align: 1px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .8rem; flex-shrink: 0; background: var(--gray-100); color: var(--gray-700); }
.user-avatar.role-super_admin, .user-avatar.role-admin { background: var(--primary-100); color: var(--primary-700); }
.user-avatar.role-manager { background: var(--success-soft); color: var(--success); }
.user-avatar.role-supervisor { background: var(--warning-soft); color: var(--warning); }
.role-pill { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--gray-100); color: var(--gray-700); white-space: nowrap; }
.role-pill.role-super_admin { background: var(--primary-700); color: #fff; }
.role-pill.role-admin { background: var(--primary-100); color: var(--primary-700); }
.role-pill.role-manager { background: var(--success-soft); color: var(--success); }
.role-pill.role-supervisor { background: var(--warning-soft); color: var(--warning); }
.user-access, .user-mail { font-size: .82rem; }
.user-mail { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-warn { color: var(--warning); font-size: .8rem; }
.user-more { position: relative; display: inline-block; }
.user-more > summary { list-style: none; cursor: pointer; }
.user-more > summary::-webkit-details-marker { display: none; }
.user-more-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 350; width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; text-align: left; }
.user-more-menu a, .user-more-menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 7px; font-size: .84rem; color: var(--text); text-decoration: none; cursor: pointer; font-family: inherit; }
.user-more-menu a:hover, .user-more-menu button:hover { background: var(--surface-alt); }
.user-more-menu button.danger { color: var(--danger); }
.user-more:not([open]) .user-more-menu { display: none; }
.user-more-menu.is-floating { display: block; }
.user-more-menu form { margin: 0; }
.user-credentials { margin-bottom: 20px; border-left: 4px solid var(--success); }
.user-credentials-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.user-credentials-head > i { font-size: 1.3rem; color: var(--success); }
.user-credentials-grid { display: grid; grid-template-columns: minmax(240px, 1.5fr) minmax(180px, 1fr) minmax(170px, 1fr) auto; gap: 12px; align-items: end; }
.user-credentials-grid span { display: block; font-size: .72rem; color: var(--text-muted); margin-bottom: 3px; }
.user-credentials-grid code { display: block; font-size: .9rem; padding: 7px 10px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 7px; word-break: break-all; }
.user-add-box { max-width: 620px; max-height: 92vh; overflow-y: auto; margin: 0 16px; }
.role-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.role-choice { display: flex; gap: 9px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; margin: 0; font-weight: 400; }
.role-choice:has(input:checked) { border-color: var(--primary-600, #1d4ed8); background: var(--primary-100); }
.role-choice input { margin-top: 3px; width: auto; }
.role-choice-title { display: block; font-weight: 600; font-size: .85rem; }
.role-choice-desc { display: block; font-size: .74rem; color: var(--text-muted); line-height: 1.35; margin-top: 2px; }
.password-row { display: flex; gap: 8px; }
.password-row input { flex: 1; font-family: Consolas, Menlo, monospace; }
.users-table .row-actions { flex-wrap: nowrap; white-space: nowrap; }
.users-table th, .users-table td:nth-child(2), .users-table td:nth-child(3), .users-table td:nth-child(5) { white-space: nowrap; }
table.data-table.users-table thead th, table.data-table.users-table tbody td { padding-left: 12px; padding-right: 12px; }
.user-sub { font-size: .74rem; color: var(--text-muted); margin-top: 2px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.users-toolbar .topbar-search input { width: 100%; }
@media (max-width: 900px) {
  .user-credentials-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .users-status-tabs { margin-left: 0; }
  .user-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .user-kpis .kpi-card { padding: 12px 14px; }
  .user-kpis .kpi-icon { display: none; }
  .user-kpis .kpi-value { font-size: 1.3rem; }
  .user-credentials-grid { grid-template-columns: 1fr; }
  .users-toolbar .topbar-search { display: block; max-width: none !important; flex: 1 1 100% !important; }
  .users-toolbar select { flex: 1; max-width: none; }
  .user-add-box .form-grid { grid-template-columns: 1fr !important; }
}
/* ---- Dashboard: Profit & Loss section ---- */
.dash-section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin: 4px 0 12px; }
.dash-section-title { font-size: 1.02rem; font-weight: 600; margin: 4px 0 12px; }
.dash-section-head .dash-section-title { margin: 0; }
.dash-section-title span { font-weight: 400; color: var(--text-muted); font-size: .85rem; margin-left: 6px; }
.fin-kpis { margin-bottom: 14px; }
.fin-net.is-profit .kpi-value { color: var(--success); }
.fin-net.is-loss .kpi-value { color: var(--danger); }
.fin-net.is-profit .kpi-icon { background: var(--success-soft); color: var(--success); }
.fin-net.is-loss .kpi-icon { background: var(--danger-soft); color: var(--danger); }
.fin-delta { display: inline-flex; align-items: center; gap: 3px; font-size: .74rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.fin-delta.is-good { color: var(--success); background: var(--success-soft); }
.fin-delta.is-bad { color: var(--danger); background: var(--danger-soft); }
.fin-delta.is-flat { color: var(--text-muted); background: var(--neutral-soft); font-weight: 500; }
.fin-mini-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.fin-mini { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; min-width: 0; }
.fin-mini span { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.fin-mini strong { display: block; font-size: 1.02rem; margin: 3px 0 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-mini strong.is-good { color: var(--success); }
.fin-mini strong.is-bad { color: var(--danger); }
.fin-mini em { display: block; font-style: normal; font-size: .72rem; color: var(--text-muted); }
.fin-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; margin-bottom: 28px; }
.fin-grid > .fin-clients { grid-column: 1 / -1; }
.fin-trend .card-body { height: 300px; }
.fin-table-toggle { border-top: 1px solid var(--border); }
.fin-table-toggle > summary { cursor: pointer; padding: 10px 20px; font-size: .8rem; color: var(--text-muted); }
.fin-table-toggle .data-table { margin: 0; }
.fin-bar { margin-bottom: 12px; }
.fin-bar-row { display: flex; justify-content: space-between; gap: 10px; font-size: .82rem; }
.fin-bar-row strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-bar-track { height: 8px; background: var(--neutral-soft); border-radius: 4px; margin-top: 5px; overflow: hidden; }
.fin-bar-fill { height: 100%; background: #e8590c; border-radius: 4px; }
.fin-bar-share { font-size: .7rem; color: var(--text-muted); margin-top: 2px; }
.fin-neg { color: var(--danger); }
@media (max-width: 1280px) {
  .fin-mini-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .fin-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .fin-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .fin-kpis .kpi-card { padding: 14px; }
  .fin-kpis .kpi-icon { display: none; }
  .fin-kpis .kpi-value { font-size: 1.15rem; }
  .fin-mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .fin-trend .card-body { height: 240px; }
}
/* ---- Email popup: compose (left) + live preview (right) ---- */
.modal-box-mail { max-width: 1040px; width: calc(100% - 32px); padding: 0; overflow: hidden; position: relative; text-align: left; max-height: 94vh; display: flex; flex-direction: column; }
.modal-box-mail > .modal-close { position: absolute; top: 10px; right: 12px; z-index: 2; color: #c7cbe6; background: transparent; }
.modal-box-mail > .modal-close:hover { background: rgba(255,255,255,.12); color: #fff; }
.modal-box-mail #mail-modal-body { overflow-y: auto; min-height: 0; }
.modal-box-mail .modal-loading { padding: 28px; }
.mail-compose { display: flex; flex-direction: column; }
.mc-head { display: flex; align-items: center; gap: 10px; background: #14104a; color: #fff; padding: 15px 56px 15px 24px; font-size: .82rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.mc-head i { color: #8b93ff; }
.mc-body { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 0; }
.mc-form { padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; font-size: .84rem; }
.mc-form input[type=text], .mc-form input[type=email] { font-size: .84rem; padding: 8px 11px; }
.mc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mc-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.mc-field > label, .mc-label-row > label:first-child { font-size: .66rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); margin: 0; }
.mc-label-row { display: flex; justify-content: space-between; align-items: center; }
.mc-save-default { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; color: var(--primary-700); margin: 0; cursor: pointer; font-weight: 500; }
.mc-save-default input { width: auto; margin: 0; }
.mc-editor-wrap { border: 1px solid var(--border-strong, #d1d5db); border-radius: 8px; background: #fff; overflow: hidden; }
.mc-editor-wrap:focus-within { border-color: var(--primary-500, #3f83f8); box-shadow: 0 0 0 3px var(--primary-100); }
.mc-toolbar { display: flex; align-items: center; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.mc-toolbar button { width: 32px; height: 30px; border: 0; background: none; border-radius: 6px; color: var(--gray-700); cursor: pointer; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; }
.mc-toolbar button:hover { background: var(--gray-100); }
.mc-toolbar button.is-on { background: var(--primary-100); color: var(--primary-700); }
.mc-tool-gap { width: 12px; }
.mc-editor { min-height: 96px; max-height: 180px; overflow-y: auto; padding: 9px 12px; font-size: .84rem; line-height: 1.55; outline: none; color: var(--text); }
.mc-editor-sig { min-height: 70px; max-height: 130px; }
.mc-editor p { margin: 0 0 8px; }
.mc-editor ul, .mc-editor ol { margin: 0 0 8px 20px; padding: 0; }
.mc-editor img { max-width: 100%; height: auto; }
.mc-hint { font-size: .74rem; color: var(--text-muted); }
.mc-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 2px; }
.mc-actions-right { display: inline-flex; gap: 8px; }
.mc-attached { font-size: .8rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
.mc-attached i { color: #e02424; font-size: 1rem; }
.mc-attached i.bi-file-earmark-excel-fill { color: #0e7a3d; }
.mc-send { background: #14104a; border-color: #14104a; }
.mc-send:hover { background: #221c6e; border-color: #221c6e; }
.mc-from { margin-top: -6px; }
.mc-preview { background: var(--surface-alt); border-left: 1px solid var(--border); padding: 18px 20px; min-width: 0; }
.mc-preview-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-sm); overflow: hidden; }
.mc-preview-meta { background: var(--gray-50, #f9fafb); border-bottom: 1px solid var(--border); padding: 12px 18px; font-size: .82rem; display: flex; flex-direction: column; gap: 5px; }
.mc-preview-meta > div { display: flex; gap: 10px; min-width: 0; }
.mail-compose [hidden] { display: none !important; }
.mc-preview-meta span { color: var(--text-muted); width: 60px; flex-shrink: 0; }
.mc-preview-meta b { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.mc-preview-body { padding: 16px 18px 18px; font-size: .82rem; line-height: 1.6; color: #374151; overflow-wrap: anywhere; }
.mc-pv-message p, .mc-pv-signature p { margin: 0 0 10px; }
.mc-pv-message ul, .mc-pv-message ol { margin: 0 0 10px 20px; padding: 0; }
.mc-pv-message img, .mc-pv-signature img { max-width: 100%; height: auto; }
.mc-pv-divider { border-top: 1px solid var(--border); margin: 16px 0; }
.mc-pv-attachment { display: inline-flex; align-items: center; gap: 10px; margin-top: 18px; border: 1px solid var(--border); border-radius: 8px; padding: 9px 14px; background: var(--gray-50, #f9fafb); max-width: 100%; }
.mc-pv-attachment i { font-size: 1.6rem; color: #e02424; }
.mc-pv-attachment i.is-excel { color: #0e7a3d; }
.mc-pv-attachment b { display: block; font-size: .82rem; font-weight: 500; color: var(--text); overflow-wrap: anywhere; }
.mc-pv-attachment em { display: block; font-style: normal; font-size: .64rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
/* Full-page fallback (no popup): the same layout inside a card. */
.card .mail-compose { margin: -24px; border-radius: inherit; overflow: hidden; }
@media (max-width: 860px) {
  .mc-body { grid-template-columns: minmax(0, 1fr); }
  .mc-preview { border-left: 0; border-top: 1px solid var(--border); }
  .mc-row { grid-template-columns: minmax(0, 1fr); }
  .mc-actions { flex-wrap: wrap; }
  .mc-actions-right { width: 100%; justify-content: flex-end; }
}
@media (max-width: 640px) {
  #mail-modal, #esign-modal { align-items: stretch; }
  .modal-box-mail, .modal-box-esign { width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; margin: 0; }
  .modal-box-mail #mail-modal-body, .modal-box-esign #esign-modal-body { flex: 1; }
  .mc-head { position: sticky; top: 0; z-index: 1; padding: 12px 48px 12px 16px; font-size: .74rem; }
  .modal-box-mail > .modal-close { top: 4px; right: 6px; }
  .mc-form { padding: 14px 16px 0; }
  .mc-actions { position: sticky; bottom: 0; background: #fff; padding: 10px 0 12px; margin: 0; z-index: 1; box-shadow: 0 -6px 12px -10px rgba(17,24,39,.35); }
  .mc-preview { padding: 14px 16px 20px; }
  .modal-box-esign #esign-modal-body { padding: 12px 14px 16px; }
  .mc-actions { flex-wrap: nowrap; }
  .mc-actions-right { width: auto; }
  .mc-actions .btn { padding: 8px 14px; }
  .es-send-row { flex-direction: column; }
  .es-send-row .btn { justify-content: center; }
}

/* Filter bar above a list: one card, fields on an even grid, search first, buttons last. */
.list-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 14px; align-items: end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 14px 16px; margin-bottom: 16px; }
.list-filters .list-filters-search { grid-column: span 2; width: auto; max-width: none; }
.list-filters .list-filters-search input[type=text] { width: 100%; }
.list-filters .field { gap: 5px; margin-bottom: 0; min-width: 0; }
.list-filters .field label { font-size: .7rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.list-filters .field input, .list-filters .field select { width: 100%; }
.list-filters-actions { grid-column: -2 / -1; display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 640px) { .list-filters .list-filters-search, .list-filters-actions { grid-column: 1 / -1; } }

/* Totals bar: equal boxes in one row, the Net figure set apart at the end. */
.list-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); }
.list-totals-count { grid-column: 1 / -1; padding: 0 2px; }
.list-total { min-width: 0; padding: 10px 14px; }
.list-total strong { display: block; margin-top: 2px; font-size: 1rem; white-space: nowrap; }
.list-total.is-net { border-width: 2px; }
.list-total.is-net.is-profit { border-color: var(--success); background: color-mix(in srgb, var(--success) 7%, var(--surface)); }
.list-total.is-net.is-loss { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }

/* List tables: dates and figures stay on one line; figures line up on the right. */
table.data-table th.tight, table.data-table td.tight { white-space: nowrap; }
table.data-table th.num, table.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data-table td.net-cell { font-weight: 600; }
table.data-table td.net-cell.is-profit { color: var(--success); }
table.data-table td.net-cell.is-loss { color: var(--danger); }

/* "How Costing is filled in automatically" - a quiet help strip, not a second card. */
.costing-flow { box-shadow: none; background: var(--primary-50); border-color: transparent; }
.costing-flow > summary { list-style: none; display: flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--primary-700, var(--text)); }
.costing-flow > summary::-webkit-details-marker { display: none; }
.costing-flow > summary::after { content: "Show"; margin-left: auto; font-weight: 500; font-size: .78rem; text-decoration: underline; }
.costing-flow[open] > summary::after { content: "Hide"; }
.costing-flow .flow-step { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }

/* Compact list (config['list_compact'], e.g. Costing): many figure columns on one screen. */
table.data-table.compact thead th { padding: 10px 12px; }
table.data-table.compact tbody td { padding: 10px 12px; font-size: .84rem; }
table.data-table.compact .row-actions { gap: 2px; }
table.data-table.compact .row-actions .icon-btn { width: 30px; height: 30px; }
table.data-table .cell-sub { font-size: .76rem; color: var(--text-muted); margin-top: 2px; }
table.data-table.compact td:has(.cell-sub) { min-width: 190px; }
.list-total strong { font-size: .92rem; }
.list-total { padding: 10px 12px; }

/* ---------------- Filter bars (every page) ----------------
   Any GET form is a filter bar: the report pages' <form class="card"> and the
   list pages' .list-filters. One compact look for all of them - small
   uppercase labels, 36px controls, every field on one even grid (the page's
   own .form-grid rows are flattened into it), buttons tucked bottom-right. */
form.card[method="get"] > .card-body,
.list-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px 14px; align-items: start; padding: 14px 16px; }
form.card[method="get"] > .card-body > .form-grid:not(.dash-filter-grid) { display: contents; }
form.card[method="get"] > .card-body > .form-grid.dash-filter-grid,
form.card[method="get"] > .card-body > :not(.form-grid) { grid-column: 1 / -1; margin-top: 0 !important; }
form.card[method="get"] { margin-bottom: 16px !important; }
form.card[method="get"] .field,
.list-filters .field { gap: 4px; margin-bottom: 0; min-width: 0; }
form.card[method="get"] .field > label,
.list-filters .field > label { font-size: .68rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
form.card[method="get"] .field input:not([type=checkbox]):not([type=radio]),
form.card[method="get"] .field select,
.list-filters input:not([type=checkbox]):not([type=radio]),
.list-filters select { width: 100%; min-height: 36px; height: 36px; padding-top: 6px; padding-bottom: 6px; font-size: .84rem; }
form.card[method="get"] .field .hint { font-size: .68rem; line-height: 1.3; }
form.card[method="get"] > .card-body > .hint { font-size: .74rem; }
form.card[method="get"] > .card-header { border-top: none !important; padding: 0 16px 14px; min-height: 0; }
form.card[method="get"] .btn,
.list-filters .btn { padding: 7px 14px; font-size: .8rem; min-height: 36px; }
.list-filters { align-items: end; }

/* Tab strip for pages that share one sidebar entry (config/navigation.php 'tab_group'). */
.page-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 16px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); width: fit-content; max-width: 100%; }
.page-tab { padding: 7px 14px; border-radius: var(--radius-sm); font-size: .84rem; font-weight: 500; color: var(--text-muted); text-decoration: none; white-space: nowrap; }
.page-tab:hover { background: var(--gray-100); color: var(--text); }
.page-tab.active { background: var(--primary-50); color: var(--primary-700); font-weight: 600; }

/* List pages: every table is compact; name columns keep a readable width instead of
   breaking into five lines, and the Actions column stays in view when a wide table scrolls. */
table.data-table.list-table td:not(.tight):not(.actions-col) { min-width: 130px; }
table.data-table.list-table td:first-child:not(.tight) { min-width: 180px; }
table.data-table.list-table thead th { white-space: nowrap; }
table.data-table.list-table .actions-col { position: sticky; right: 0; background: var(--surface); box-shadow: -8px 0 8px -8px rgba(15, 23, 42, .12); }
table.data-table.list-table thead .actions-col { background: var(--gray-50); }
table.data-table.list-table tbody tr:hover .actions-col { background: var(--gray-50); }
table.data-table.list-table .row-actions { flex-wrap: nowrap; }
/* Text buttons inside a list row (Remind) are icon-only, like their neighbours - the title still says what they do. */
table.data-table.list-table .row-actions .btn-sm { font-size: 0; gap: 0; padding: 0; width: 30px; height: 30px; min-height: 30px; }
table.data-table.list-table .row-actions .btn-sm i { font-size: .9rem; }

/* Where a document stands in its flow (Material Request: Requested > Approved > Issued). */
.flow-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.flow-step-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: .8rem; font-weight: 500; background: var(--gray-100); color: var(--text-muted); }
.flow-step-pill.is-done { background: color-mix(in srgb, var(--success) 12%, var(--surface)); color: var(--success); }
.flow-step-pill.is-rejected { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.flow-step-sep { color: var(--text-faint); font-size: .7rem; }

/* Type-to-search dropdown that takes several picks (Site form: its Quotations
   and Invoices) - the menu is the single-pick .fk-combo's. */
.multi-combo { position: relative; }
.multi-combo .fk-combo-menu { top: 46px; }
.multi-combo-none { color: var(--text-muted); cursor: default; }
.multi-combo-none:hover { background: none; color: var(--text-muted); }
.multi-combo-note { font-size: .75rem; color: var(--warning); margin-top: 2px; }
.multi-combo-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.multi-combo-tags:not(:empty) { margin-top: 8px; }
.multi-combo-tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--primary-50); color: var(--primary-700); font-size: .8rem; font-weight: 600; max-width: 100%; }
.multi-combo-tag button { border: none; background: none; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 4px; border-radius: 50%; }
.multi-combo-tag button:hover { background: var(--primary-700); color: #fff; }

/* 'file' field (a receipt): the saved file's link + Remove tick above the picker. */
.file-current { display: flex; align-items: center; gap: 16px; font-size: .875rem; }
.file-current label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; color: var(--text-muted); cursor: pointer; }
.file-current input { width: auto; }

/* List filter that picks a record (Site, Client, Supplier): the forms' type-to-search dropdown. */
.list-filters { position: relative; z-index: 5; } /* its dropdown opens over the table card below */
.list-filters .fk-combo-menu { min-width: 240px; }

/* List pages' filter bar: one tight row instead of an even grid - the search
   box takes the spare width, each filter only what it needs, Apply at the end.
   It wraps to a second row only on a narrow screen. */
.list-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; padding: 10px 14px; }
.list-filters .list-filters-search { flex: 1 1 140px; min-width: 130px; }
.list-filters .field { flex: 0 1 116px; gap: 3px; }
.list-filters .field:has(input[type=date]) { flex: 0 0 120px; }
.list-filters .field:has(.fk-combo) { flex: 0 1 132px; }
.list-filters input:not([type=checkbox]):not([type=radio]),
.list-filters select { min-height: 32px; height: 32px; padding: 4px 9px; font-size: .8rem; }
.list-filters select { padding-right: 24px; }
.list-filters input[type=date] { padding-right: 4px; }
.list-filters .list-filters-search input[type=text] { padding-left: 34px; }
.list-filters .field > label { font-size: .64rem; }
.list-filters .btn { min-height: 32px; padding: 5px 12px; }
.list-filters-actions { margin-left: auto; flex: 0 0 auto; }

/* Bell in the top bar: signatures waiting (app/views/partials/topbar.php). */
.notif-wrap { position: relative; margin-right: 6px; }
.notif-bell { list-style: none; position: relative; display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; cursor: pointer; color: var(--gray-700); font-size: 1.1rem; }
.notif-bell::-webkit-details-marker { display: none; }
.notif-bell:hover { background: var(--gray-100); }
.notif-count { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #dc2626; color: #fff; font-size: .66rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.notif-count-muted { background: var(--gray-500); }
.notif-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 330px; max-width: 86vw; max-height: 420px; overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 60; }
.notif-head { padding: 10px 14px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.notif-empty { padding: 18px 14px; font-size: .86rem; color: var(--text-muted); }
.notif-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: .86rem; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-alt); }
.notif-dot { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: #dc2626; }
.notif-dot-muted { background: var(--gray-400); }
.notif-sub { display: block; font-size: .76rem; color: var(--text-muted); }

/* Signatures panel on a document's view page (crud/partials/doc_signatures.php). */
.doc-sign-img { max-height: 44px; max-width: 170px; display: block; }
.doc-sign-form { margin-top: 18px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-alt); }
.doc-sign-sources { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.doc-sign-source { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--border-strong); border-radius: 999px; background: #fff; font-size: .84rem; cursor: pointer; margin: 0; }
.doc-sign-source input, .doc-sign-remember input, .doc-sign-saved-item input { width: auto; }
.doc-sign-saved { display: flex; flex-wrap: wrap; gap: 10px; }
.doc-sign-saved-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; cursor: pointer; margin: 0; }
.doc-sign-saved-item:has(input:checked) { border-color: var(--primary-700); box-shadow: 0 0 0 2px var(--primary-50); }
.doc-sign-saved-item img { height: 54px; max-width: 190px; object-fit: contain; }
.doc-sign-forget { position: absolute; top: 2px; right: 4px; border: none; background: none; color: var(--text-muted); font-size: 1rem; line-height: 1; cursor: pointer; }
.doc-sign-forget:hover { color: var(--danger); }
.doc-sign-canvas-wrap { max-width: 460px; background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); touch-action: none; }
.doc-sign-canvas-wrap .sig-canvas { display: block; width: 100%; height: 160px; cursor: crosshair; touch-action: none; }
.doc-sign-remember { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; font-size: .86rem; cursor: pointer; }
.doc-sign-link { display: flex; align-items: center; gap: 6px; margin-top: 4px; max-width: 380px; }
.doc-sign-link input { flex: 1; min-width: 0; height: 28px; padding: 2px 8px; font-size: .74rem; color: var(--text-muted); }
/* The Signatures panel is jumped to from the e-Sign buttons: keep it clear of the sticky top bar and flash it. */
#signatures { scroll-margin-top: 84px; }
#signatures:target { box-shadow: 0 0 0 2px var(--primary-700); }

/* "Email for signature" under a signer on a document form, and in the Signatures panel. */
.signer-email { margin-top: 8px; }
.signer-email label { font-size: 12px; color: var(--text-muted, #6b7280); }
.doc-sign-email { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.doc-sign-email input { height: 30px; padding: 2px 8px; font-size: 13px; max-width: 260px; }

/* Reminders (views/reminders): summary, tabs, the form's side column, Send to tags. */
.badge-info { background: #dbeafe; color: #1e40af; }
.quick-status-select.badge-info { background-color: #1e40af; color: #fff; }
.notif-dot.notif-dot-danger { background: var(--danger); }
.reminder-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.reminder-stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; display: flex; flex-direction: column; }
.reminder-stat strong { font-size: 1.5rem; line-height: 1.2; }
.reminder-stat span { font-size: .8rem; color: var(--text-muted); }
.reminder-stat.tone-danger strong { color: var(--danger); }
.reminder-stat.tone-warning strong { color: var(--warning); }
.reminder-stat.tone-success strong { color: var(--success); }
.reminder-tabs { display: flex; gap: 4px; margin-right: auto; }
.reminder-tabs a { padding: 6px 14px; border-radius: 999px; font-size: .82rem; font-weight: 600; color: var(--text-muted); text-decoration: none; }
.reminder-tabs a.active { background: var(--primary-700); color: #fff; }
.reminder-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.reminder-layout > form:only-child { grid-column: 1 / -1; max-width: 900px; }
.reminder-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.reminder-chips button { border: 1px solid var(--border-strong); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: .75rem; cursor: pointer; color: var(--gray-700); }
.reminder-chips button.active { background: var(--primary-700); border-color: var(--primary-700); color: #fff; }
.reminder-people-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.reminder-tag { display: inline-flex; align-items: center; gap: 6px; background: var(--neutral-soft); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: .82rem; }
.reminder-tag button { border: none; background: transparent; cursor: pointer; font-size: 1rem; line-height: 1; color: var(--text-muted); padding: 0 4px; }
.reminder-people-add { display: flex; gap: 8px; align-items: center; }
.reminder-people-add input { max-width: 380px; }
.reminder-status-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.reminder-snooze { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: .82rem; color: var(--text-muted); }
.reminder-history { list-style: none; margin: 0; padding: 0; font-size: .86rem; }
.reminder-history li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.reminder-history li:last-child { border-bottom: none; }
@media (max-width: 900px) {
  .reminder-layout { grid-template-columns: 1fr; }
  .reminder-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Reminder form, compact: three cards (What / When / Send to) side by side using the full width. */
.reminder-layout.is-new { grid-template-columns: minmax(0, 1fr); }
.reminder-layout { grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; }
.rm-form fieldset { border: none; padding: 0; margin: 0; min-width: 0; }
.rm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.rm-card { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.rm-card.rm-wide { grid-column: 1 / -1; }
.rm-card h3 { margin: 0 0 2px; font-size: .92rem; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.rm-card h3 > i { color: var(--primary-700); }
.rm-soft { font-weight: 400; color: var(--text-muted); font-size: .76rem; }
.rm-row { display: grid; gap: 10px; }
.rm-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rm-row-3 { grid-template-columns: 1.3fr .8fr 1fr; }
.rm-form .field { gap: 4px; margin-bottom: 0; min-width: 0; }
.rm-form .field > label { font-size: .74rem; font-weight: 600; color: var(--gray-700); }
.rm-form .field > label > i { color: var(--text-faint); font-size: .7rem; cursor: help; }
.rm-form input:not([type=hidden]), .rm-form select { min-height: 36px; height: 36px; padding: 5px 10px; font-size: .86rem; width: 100%; }
.rm-form textarea { padding: 8px 10px; font-size: .86rem; min-height: 0; flex: 1; resize: vertical; }
.rm-card .field:has(textarea) { flex: 1; }
.rm-form .reminder-chips { margin-top: 0; align-items: center; gap: 5px; }
.rm-form .reminder-chips button { padding: 2px 10px; min-width: 34px; }
.rm-summary { margin-top: auto; background: var(--neutral-soft); border-radius: var(--radius-sm); padding: 8px 10px; font-size: .78rem; color: var(--gray-700); line-height: 1.45; }
.rm-summary:empty { display: none; }
.rm-form .reminder-people-add { margin-bottom: 8px; }
.rm-form .reminder-people-add input { max-width: 420px; }
.rm-form .reminder-people-add .btn { min-height: 36px; }
.rm-form .reminder-people-tags { margin-bottom: 0; }
.rm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
@media (max-width: 1100px) { .reminder-layout:not(.is-new) .rm-grid { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .reminder-layout { grid-template-columns: 1fr; } .rm-grid { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .rm-row-2, .rm-row-3 { grid-template-columns: 1fr; } }
.reminder-layout > form.rm-form:only-child { max-width: none; }
.reminder-status-buttons { gap: 6px; }
.reminder-status-buttons .btn { padding: 6px 10px; }
.reminder-snooze .btn { padding: 3px 8px; min-height: 28px; }

/* "Authorised Signatory" picker on document forms (partials/signatory_picker.php) and the saved list in Company Profile. */
.signatory-picker { display: grid; grid-template-columns: minmax(240px, 380px) 1fr; gap: 10px 18px; align-items: end; margin-top: 18px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.signatory-picker .field { margin-bottom: 0; }
.signatory-preview { display: flex; align-items: center; min-height: 44px; }
.signatory-preview img { max-height: 54px; max-width: 220px; }
.signatory-new { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; }
.signatory-new[hidden], .signatory-preview[hidden] { display: none; }
.signatory-saved-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.signatory-saved { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: .86rem; }
.signatory-saved img { max-width: 90px; max-height: 46px; }
@media (max-width: 700px) { .signatory-picker, .signatory-new { grid-template-columns: 1fr; } }
