/*
 * audit.css — custom layer on top of Bootstrap 5
 * Sidebar: flex column — main shifts with the nav; width animates open/closed.
 */

:root {
  /* Layout */
  --audit-sidebar-w: 260px;
  --audit-vh: 100vh;
  --audit-vh: 100dvh;

  /* Brand & surfaces */
  --audit-primary: #f59e0b;
  --audit-primary-hover: #d97706;
  --audit-primary-muted: #fffbeb;
  --audit-accent: #ca8a04;
  --audit-accent-muted: #fef3c7;

  --audit-bg: #f1f5f9;
  --audit-surface: #ffffff;
  --audit-surface-raised: #f8fafc;
  --audit-border: #e2e8f0;
  --audit-border-strong: #cbd5e1;

  /* Text */
  --audit-text: #0f172a;
  --audit-text-secondary: #475569;
  --audit-text-muted: #64748b;
  --audit-text-subtle: #94a3b8;

  /* Semantic */
  --audit-success: #16a34a;
  --audit-success-muted: #ecfdf5;
  --audit-danger: #dc2626;
  --audit-danger-muted: #fef2f2;
  --audit-warning: #d97706;
  --audit-warning-muted: #fffbeb;
  --audit-buy: #f59e0b;
  --audit-buy-muted: rgba(245, 158, 11, 0.14);
  --audit-sell: #ea580c;
  --audit-sell-muted: rgba(234, 88, 12, 0.12);

  /* Sidebar */
  --audit-sidebar-bg: #0f172a;
  --audit-sidebar-border: #1e293b;
  --audit-sidebar-text: #cbd5e1;
  --audit-sidebar-active: var(--audit-primary);

  /* Elevation & radius */
  --audit-radius-sm: 8px;
  --audit-radius-md: 12px;
  --audit-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --audit-shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --audit-shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.1);

  /* Typography */
  --audit-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --audit-text-xs: 0.6875rem;   /* 11px */
  --audit-text-sm: 0.75rem;     /* 12px */
  --audit-text-base: 0.875rem;  /* 14px */
  --audit-label: var(--audit-text-xs);

  /* Charts */
  --audit-chart-1: #f59e0b;
  --audit-chart-2: #d97706;
  --audit-chart-3: #fbbf24;
  --audit-chart-4: #ca8a04;
  --audit-chart-5: #22c55e;
  --audit-chart-6: #94a3b8;
  --audit-chart-pending: #f59e0b;
  --audit-chart-partial: #6366f1;
  --audit-chart-settled: #22c55e;
  --audit-chart-voided: #94a3b8;
}

html {
  height: 100%;
}

body {
  font-family: var(--audit-font);
  font-size: var(--audit-text-base);
  color: var(--audit-text);
  background-color: var(--audit-bg);
  min-height: var(--audit-vh);
  -webkit-font-smoothing: antialiased;
}

/* ── Skip link ── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 9999;
  padding: 8px 14px;
  background: #b45309;
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
}
.skip-link:focus {
  left: 12px;
  top: 12px;
}

/* ── Sidebar toggle (hidden checkbox — powers mobile drawer with CSS only) ── */
.sidebar-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── App shell: flex row — sidebar width toggles, main grows/shrinks (no overlay) ── */
.app-layout {
  display: flex;
  align-items: stretch;
  min-height: var(--audit-vh);
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* ── Sidebar: width animates via max-width (smooth push like a drawer) ── */
.sidebar {
  --audit-sidebar-actual: min(var(--audit-sidebar-w), 100vw);
  flex: 0 0 auto;
  box-sizing: border-box;
  width: var(--audit-sidebar-actual);
  max-width: 0;
  min-width: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  border: 0 solid transparent;
  background: var(--audit-sidebar-bg);
  color: var(--audit-sidebar-text);
  display: flex;
  flex-direction: column;
  align-self: stretch;
  min-height: var(--audit-vh);
  transition:
    max-width 0.32s cubic-bezier(0.4, 0, 0.2, 1),
    min-width 0.32s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.28s ease,
    box-shadow 0.28s ease,
    padding-top 0.28s ease,
    padding-bottom 0.28s ease;
}

.sidebar-toggle:checked + .app-layout .sidebar {
  max-width: var(--audit-sidebar-actual);
  min-width: var(--audit-sidebar-actual);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
  border-right: 1px solid var(--audit-sidebar-border);
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.1);
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}

/* ── Main column: fills remaining width (never sits under the nav) ── */
.app-main {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  min-height: var(--audit-vh);
  display: flex;
  flex-direction: column;
}

/* Hide inline sync script inside aside (must not affect flex layout) */
.sidebar > script {
  display: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 18px;
  border-bottom: 1px solid var(--audit-sidebar-border);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.sidebar-brand-mark {
  width: 38px;
  height: 38px;
  border-radius: var(--audit-radius-sm);
  background: linear-gradient(135deg, var(--audit-primary), var(--audit-primary-hover));
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.sidebar-brand-name {
  display: block;
  font-weight: 700;
  font-size: 15px;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-tag {
  display: block;
  font-size: var(--audit-text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--audit-text-muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 10px 12px;
  flex: 1 1 auto;
  min-height: 0;
}

.sidebar-link {
  display: block;
  padding: 9px 12px;
  border-radius: 7px;
  color: var(--audit-sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #f8fafc;
}

.sidebar-link.is-active {
  background: rgba(245, 158, 11, 0.22);
  color: #fff;
  border-left-color: var(--audit-sidebar-active);
  font-weight: 600;
}

/* ── Top header ── */
.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--audit-surface);
  border-bottom: 1px solid var(--audit-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--audit-shadow-sm);
}

.sidebar-open-btn {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: var(--audit-radius-sm);
  border: 1px solid var(--audit-border);
  background: var(--audit-surface-raised);
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-open-icon {
  display: block;
  width: 17px;
  height: 2px;
  background: var(--audit-text);
  box-shadow: 0 -5px 0 var(--audit-text), 0 5px 0 var(--audit-text);
}

.app-header-title {
  flex: 1;
  min-width: 0;
}

.app-header-heading {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ── Role badge ── */
.role-chip {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--audit-primary-hover);
  background: var(--audit-primary-muted);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ── Content area ── */
.app-content {
  flex: 1;
  padding: 24px 16px 48px;
  /* Slightly wider than classic 1140; sidebar closed uses more horizontal space below */
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
}

/* More room for tables/dashboards when the nav rail is collapsed */
.sidebar-toggle:not(:checked) + .app-layout .app-content {
  max-width: min(1600px, calc(100vw - 24px));
}

/* ── Dashboard stat cards ── */
.stat-card {
  position: relative;
  padding: 18px 20px;
}

.stat-label {
  display: block;
  font-size: var(--audit-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--audit-text-muted);
  margin-bottom: 6px;
}

.stat-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
}

.stat-hint {
  display: block;
  margin-top: 4px;
  font-size: var(--audit-text-sm);
  color: var(--audit-text-subtle);
}

/* ── Login hero (left panel) ── */
.guest-hero {
  background: linear-gradient(160deg, #0f172a 0%, #3f2b02 45%, #d97706 100%);
  color: #e2e8f0;
  padding: 48px 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

.guest-hero h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3.5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fff;
}

.guest-hero > p {
  margin: 0;
  max-width: 38ch;
  font-size: 15px;
  line-height: 1.65;
  color: #cbd5e1;
}

.guest-hero-list {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guest-hero-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #e2e8f0;
}

.guest-hero-list li::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #38bdf8;
  flex-shrink: 0;
}

.guest-hero-footnote {
  margin: 6px 0 0;
  font-size: 13px;
  color: #94a3b8;
  max-width: 42ch;
}

/* ── Login page (sign-in only) ── */
.login-page {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(160deg, #fffbeb 0%, #fef3c7 40%, #fde68a 100%);
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  width: min(100%, 420px);
  border-radius: var(--audit-radius-lg, 12px);
}

.login-brand-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  box-shadow: 0 8px 24px rgba(217, 119, 6, 0.25);
}

.login-brand-name {
  letter-spacing: -0.02em;
}

/* ── Transaction party picker ── */
.party-picker-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1060;
  max-height: 14rem;
  overflow-y: auto;
  margin-top: 2px;
  border-radius: 0.375rem;
  background-color: #fff;
  border: 1px solid var(--bs-border-color, #dee2e6);
}
.party-picker-menu .list-group-item {
  cursor: pointer;
  font-size: 13px;
  padding: 0.45rem 0.65rem;
  border-left: 0;
  border-right: 0;
  background-color: #fff;
  color: #212529;
}
.party-picker-menu .list-group-item:first-child {
  border-top: 0;
}
.party-picker-menu .list-group-item-action:hover,
.party-picker-menu .list-group-item-action:focus {
  background-color: #fef3c7;
  color: #0f172a;
}
.party-picker-menu .list-group-item-action:active {
  background-color: #fde68a;
  color: #0f172a;
}
.party-picker-item-meta {
  font-size: 11px;
  color: #64748b;
}
.party-picker-menu .list-group-item-action:hover .party-picker-item-meta,
.party-picker-menu .list-group-item-action:focus .party-picker-item-meta {
  color: #475569;
}

.dashboard-activity-feed .list-group-item:last-child {
  border-bottom: 0;
}

/* ── Shared surface cards (dashboard + modules) ── */
.audit-surface-card {
  background: var(--audit-surface);
  border: 1px solid var(--audit-border) !important;
  border-radius: var(--audit-radius-md);
  box-shadow: var(--audit-shadow-sm) !important;
}

/* ── Dashboard ── */
.dashboard-eyebrow {
  font-size: var(--audit-label);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--audit-accent);
}
.dashboard-period-badge {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.2rem 0.65rem;
  font-size: var(--audit-text-sm);
  font-weight: 600;
  color: var(--audit-text-secondary);
  background: var(--audit-surface-raised);
  border: 1px solid var(--audit-border);
  border-radius: 999px;
}
.dashboard-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.dashboard-insights-row > [class*="col-"] {
  min-width: 0;
}
.kpi-card {
  position: relative;
  overflow: hidden;
  background: var(--audit-surface);
  border: 1px solid var(--audit-border) !important;
  border-radius: var(--audit-radius-md);
  box-shadow: var(--audit-shadow-sm) !important;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.kpi-card:hover {
  box-shadow: var(--audit-shadow-md) !important;
  border-color: var(--audit-border-strong) !important;
}
.kpi-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
}
.kpi-card--txn::before { background: var(--audit-accent); }
.kpi-card--in::before { background: var(--audit-success); }
.kpi-card--out::before { background: var(--audit-danger); }
.kpi-card--net::before { background: var(--audit-primary); }
.kpi-icon {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--audit-radius-sm);
  font-size: 1.1rem;
  color: var(--audit-text-muted);
  background: var(--audit-surface-raised);
  border: 1px solid var(--audit-border);
}
.dashboard-summary-title,
.kpi-label {
  font-weight: 700;
  color: var(--audit-text);
}
.dashboard-summary-title {
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
}
.kpi-label {
  display: block;
  font-size: var(--audit-text-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
  padding-right: 2.5rem;
}
.kpi-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--audit-text);
}
.kpi-hint {
  display: block;
  font-size: var(--audit-text-sm);
  margin-top: 0.35rem;
  color: var(--audit-text-subtle);
}
.kpi-hint:not(.text-muted) {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.kpi-pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: var(--audit-text-xs);
  font-weight: 600;
}
.kpi-pill--buy {
  color: var(--audit-buy);
  background: var(--audit-buy-muted);
}
.kpi-pill--sell {
  color: var(--audit-sell);
  background: var(--audit-sell-muted);
}
.dashboard-chart-panel {
  background: var(--audit-surface);
  border: 1px solid var(--audit-border) !important;
  border-radius: var(--audit-radius-md);
  box-shadow: var(--audit-shadow-sm) !important;
}
.dashboard-insights-row .dashboard-chart-canvas-wrap,
.dashboard-insights-row .dashboard-chart-canvas-wrap--featured {
  height: 200px;
}
.dashboard-flow-mini-track {
  height: 6px;
  border-radius: 999px;
  background: var(--audit-border);
  overflow: hidden;
}
.dashboard-flow-mini-bar {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.45s ease;
  min-width: 0;
}
.dashboard-flow-mini-bar--in {
  background: var(--audit-success);
}
.dashboard-flow-mini-bar--out {
  background: var(--audit-danger);
}
.dashboard-module-card {
  background: var(--audit-surface);
  border: 1px solid var(--audit-border) !important;
  border-radius: var(--audit-radius-md);
  box-shadow: var(--audit-shadow-sm) !important;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.dashboard-module-card:hover {
  box-shadow: var(--audit-shadow-md) !important;
  border-color: var(--audit-border-strong) !important;
}
.dashboard-module-icon {
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--audit-radius-sm);
  font-size: 1.25rem;
}
.dashboard-module-icon--stock {
  color: var(--audit-primary);
  background: var(--audit-primary-muted);
}
.dashboard-module-icon--contacts {
  color: var(--audit-accent);
  background: var(--audit-accent-muted);
}
.dashboard-stat-chip {
  padding: 0.65rem 0.75rem;
  border-radius: var(--audit-radius-sm);
  background: var(--audit-surface-raised);
  border: 1px solid var(--audit-border);
}
.dashboard-stat-chip--highlight {
  background: var(--audit-primary-muted);
  border-color: #bfdbfe;
}
.dashboard-stat-chip-label {
  display: block;
  font-size: var(--audit-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--audit-text-muted);
}
.dashboard-stat-chip-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--audit-text);
}
.dashboard-feed-card {
  min-height: 320px;
  background: var(--audit-surface);
  border: 1px solid var(--audit-border) !important;
  border-radius: var(--audit-radius-md);
  box-shadow: var(--audit-shadow-sm) !important;
}
.dashboard-feed-header {
  border-bottom: 1px solid var(--audit-border);
  background: var(--audit-surface);
  border-left: 3px solid var(--audit-warning);
}
.dashboard-feed-icon {
  color: var(--audit-warning);
}
.dashboard-timeline {
  max-height: 420px;
  overflow-y: auto;
}
.dashboard-timeline-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--audit-border);
}
.dashboard-timeline-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.dashboard-timeline-dot {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.95rem;
}
.dashboard-timeline-dot--buy {
  color: var(--audit-buy);
  background: var(--audit-buy-muted);
}
.dashboard-timeline-dot--sell {
  color: var(--audit-sell);
  background: var(--audit-sell-muted);
}
.dashboard-timeline-dot--danger {
  color: var(--audit-danger);
  background: var(--audit-danger-muted);
}
.dashboard-timeline-dot--primary {
  color: var(--audit-primary);
  background: var(--audit-primary-muted);
}
.dashboard-timeline-dot--muted {
  color: var(--audit-text-muted);
  background: var(--audit-surface-raised);
}
.dashboard-timeline-body {
  flex: 1;
  min-width: 0;
}
.dashboard-timeline-title {
  font-size: var(--audit-text-sm);
  font-weight: 600;
  color: var(--audit-text);
}
.dashboard-timeline-time {
  font-size: 11px;
  white-space: nowrap;
}
.dashboard-timeline-badge {
  font-size: var(--audit-text-xs);
  background: var(--audit-surface-raised) !important;
  color: var(--audit-text-secondary);
  border: 1px solid var(--audit-border) !important;
}
.dashboard-timeline-text {
  font-size: var(--audit-text-sm);
  margin-top: 0.25rem;
  color: var(--audit-text-secondary);
  word-break: break-word;
}
.dashboard-timeline-user {
  display: block;
  font-size: var(--audit-text-xs);
  color: var(--audit-text-muted);
  margin-top: 0.2rem;
}
.dashboard-feed-empty {
  text-align: center;
  padding-top: 2rem;
}
.dashboard-chart-panel--featured {
  background: var(--audit-surface);
}
.dashboard-chart-canvas-wrap {
  position: relative;
  height: 200px;
}
.dashboard-chart-canvas-wrap--featured {
  height: 200px;
}
.dashboard-chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}
.dashboard-chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(248, 250, 252, 0.94);
  border-radius: var(--audit-radius-sm);
  color: var(--audit-text-muted);
}

/* Bootstrap alignment with design tokens */
.btn-primary {
  --bs-btn-bg: var(--audit-primary);
  --bs-btn-border-color: var(--audit-primary);
  --bs-btn-hover-bg: var(--audit-primary-hover);
  --bs-btn-hover-border-color: var(--audit-primary-hover);
  --bs-btn-active-bg: var(--audit-primary-hover);
  --bs-btn-active-border-color: var(--audit-primary-hover);
}
.btn-outline-primary {
  --bs-btn-color: var(--audit-primary);
  --bs-btn-border-color: var(--audit-border-strong);
  --bs-btn-hover-bg: var(--audit-primary-muted);
  --bs-btn-hover-border-color: var(--audit-primary);
  --bs-btn-hover-color: var(--audit-primary-hover);
}
.text-primary {
  color: var(--audit-primary) !important;
}
.text-success {
  color: var(--audit-success) !important;
}
.text-danger {
  color: var(--audit-danger) !important;
}
.dashboard-activity-feed .list-group-item:last-child {
  border-bottom: 0;
}

/* ── Contacts table ── */
.contacts-table .contacts-cell-truncate {
  max-width: 12rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Contacts modal: solid dropdowns (no see-through / gradient bleed on dark header themes) */
#contactModal .form-select,
#contactModal .form-control,
#contactModal textarea {
  background-color: #fff;
  color: #212529;
  border-color: #ced4da;
}
#contactModal .form-select option,
#contactModal .form-select optgroup {
  background-color: #fff;
  color: #212529;
}

/* ── Buy/Sell ledger table (bilingual headers) ── */
/*
 * Many columns + sidebar open = narrow main. Without a width floor, table-layout:fixed
 * squeezes columns and text can paint over neighbours. min-width forces horizontal scroll.
 */
.ledger-table {
  table-layout: fixed;
  width: 100%;
  min-width: var(--ledger-min-full, 1020px);
}

.ledger-table th,
.ledger-table td {
  vertical-align: middle;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}

/* Column width hints (colgroup); table min-width is the overlap guard */
.ledger-col-bil {
  width: 3rem;
}
.ledger-col-date {
  width: 3.3rem; /* dd.mm.yyyy */
}
.ledger-col-type {
  width: 2.2rem;
}
.ledger-col-desc {
  width: 5rem;
}
.ledger-col-ccy {
  width: 2.5rem; /* 3–5 letter codes */
}
.ledger-col-qty {
  width: 3.8rem;
}
.ledger-col-rate {
  width: 3.0rem;
}
.ledger-col-party {
  width: 3rem;
}
.ledger-col-amt {
  width: 4.25rem;
}
.ledger-col-status {
  width: 2.25rem;
}
.ledger-col-actions {
  width: 6.0rem;
}

.ledger-table td.ledger-cell-date {
  font-size: 12px;
  letter-spacing: -0.02em;
}
.ledger-table td.ledger-cell-ccy {
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}
.ledger-table td.ledger-cell-ccy .badge {
  font-size: 10px;
  padding: 0.1em 0.3em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ledger-table th.ledger-th-status,
.ledger-table td.ledger-cell-status {
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}
.ledger-table td.ledger-cell-status .badge {
  font-size: 10px;
  font-weight: 600;
  padding: 0.2em 0.35em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.ledger-table th.ledger-th-actions,
.ledger-table td.ledger-cell-actions {
  padding-left: 0.2rem;
  padding-right: 0.35rem;
}
.ledger-table td.ledger-cell-actions {
  white-space: nowrap;
}
.ledger-table td.ledger-cell-actions .btn {
  padding: 0.1rem 0.35rem;
  line-height: 1.2;
}
.ledger-table td.ledger-cell-actions .btn + .btn,
.ledger-table td.ledger-cell-actions .btn + span {
  margin-left: 0.15rem !important;
}

/*
 * Fixed columns: never wrap into the next cell — clip with ellipsis.
 * max-width:0 + table-layout:fixed respects <col> widths.
 */
.ledger-table td.ledger-cell-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
  vertical-align: middle;
}
.ledger-table td.ledger-cell-truncate .ledger-cell-inner {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ledger-table td.ledger-cell-desc {
  font-weight: 600;
}
.ledger-table td.ledger-cell-party {
  font-size: 12px;
  color: var(--bs-secondary-color);
}
.ledger-table td.ledger-cell-qty,
.ledger-table td.ledger-cell-rate {
  font-family: var(--bs-font-monospace);
}
.ledger-table td.ledger-cell-amt {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
}


/* Bilingual headers: clip unless column allows wrap (说明 / 名字) */
.ledger-table thead th.ledger-th:not(.ledger-th-wrap) {
  overflow: hidden;
  max-width: 0;
}
.ledger-table thead th.ledger-th:not(.ledger-th-wrap) .cn,
.ledger-table thead th.ledger-th:not(.ledger-th-wrap) .en {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.ledger-table thead th.ledger-th-wrap {
  overflow: visible;
  max-width: none;
  white-space: normal;
}
.ledger-table thead th.ledger-th-wrap .cn,
.ledger-table thead th.ledger-th-wrap .en {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow: visible;
  text-overflow: unset;
  max-width: none;
}

/* IN / OUT / BAL: more horizontal room and slightly stronger typography */
.ledger-table thead th.ledger-th-amt {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}
.ledger-table thead th.ledger-th-amt .en {
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

.ledger-table tbody td.ledger-cell-amt,
.ledger-table tfoot td.ledger-cell-amt {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  font-size: 13px;
  letter-spacing: 0.015em;
}

.ledger-th {
  vertical-align: middle;
  line-height: 1.25;
  font-size: 12px;
}

.ledger-th .cn {
  display: block;
  color: #64748b;
  font-weight: 500;
}

.ledger-th .en {
  display: block;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #0f172a;
}

/* Ledger currency column bands (cycles when many CCYs) */
.ledger-group-ccy--0 {
  background: rgba(13, 110, 253, 0.06) !important;
}
.ledger-group-ccy--1 {
  background: rgba(25, 135, 84, 0.07) !important;
}
.ledger-group-ccy--2 {
  background: rgba(245, 158, 11, 0.08) !important;
}
.ledger-group-ccy--3 {
  background: rgba(124, 58, 237, 0.07) !important;
}
.ledger-group-ccy--4 {
  background: rgba(14, 165, 233, 0.07) !important;
}
.ledger-group-ccy--5 {
  background: rgba(100, 116, 139, 0.09) !important;
}

/* Row dividers: tinted cells used to force transparent borders — use normal cell borders instead. */
.ledger-table > thead > tr > th,
.ledger-table > tbody > tr > td,
.ledger-table > tfoot > tr > td {
  border-bottom: 1px solid var(--bs-table-border-color, var(--bs-border-color-translucent, #dee2e6));
}
.ledger-table > tfoot > tr > td {
  border-top: 1px solid var(--bs-table-border-color, var(--bs-border-color-translucent, #dee2e6));
}

/* ══════════════════════════════════════════════════
   Sticky column pins
══════════════════════════════════════════════════ */

/* Base sticky behaviour */
.ledger-table th.ledger-th-sticky,
.ledger-table td.ledger-cell-sticky {
  position: sticky;
  z-index: 2;
  /* Inherit the row background; override for explicit colours below */
  background: var(--bs-body-bg, #fff);
}

/* thead cells need to sit above scrolling body cells */
.ledger-table > thead > tr > th.ledger-th-sticky {
  z-index: 3;
  background: #f8f9fa; /* matches Bootstrap table-light */
}

/* Left pin */
.ledger-th-sticky-left,
.ledger-cell-sticky-left {
  left: 0;
}

/* Right pin */
.ledger-th-sticky-right,
.ledger-cell-sticky-right {
  right: 0;
}

/* Drop-shadow when the table has scrolled — applied via JS adding .ledger-wrap-scrolled */
.ledger-wrap-scrolled .ledger-th-sticky-left,
.ledger-wrap-scrolled .ledger-cell-sticky-left {
  box-shadow: 3px 0 6px -2px rgba(0, 0, 0, 0.12);
}
.ledger-wrap-scrolled .ledger-th-sticky-right,
.ledger-wrap-scrolled .ledger-cell-sticky-right {
  box-shadow: -3px 0 6px -2px rgba(0, 0, 0, 0.12);
}

/* Ensure voided rows (opacity-50) keep white backgrounds on pinned cells */
.ledger-table tr.opacity-50 > td.ledger-cell-sticky {
  background: var(--bs-body-bg, #fff);
}
/* Child rows use table-hover which may tint; keep sticky clean */
.ledger-table > tbody > tr:hover > td.ledger-cell-sticky {
  background: var(--bs-table-hover-bg, rgba(0, 0, 0, 0.035));
}

/* ══════════════════════════════════════════════════
   Compact view — hide non-essential columns
══════════════════════════════════════════════════ */

/*
 * table-layout:fixed + hidden <col> slots still reserve width → gaps.
 * Compact uses auto layout, ignores colgroup, and only shows RM + essentials.
 */
.ledger-table.ledger-compact {
  table-layout: auto;
  min-width: 0;
  width: 100%;
}
.ledger-table.ledger-compact > colgroup {
  display: none;
}
.ledger-compact .ledger-hide-compact {
  display: none !important;
}
/* Allow desc / party to use their share of width in compact */
.ledger-compact td.ledger-cell-truncate {
  max-width: none;
}
.ledger-compact td.ledger-cell-desc,
.ledger-compact td.ledger-cell-party {
  width: auto;
  min-width: 4rem;
}

/* ── Compact/Full toggle pill ───────────────────── */
.ledger-compact-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  padding: 0.25rem 0.65rem;
}

/* ── Single row action button ───────────────────── */
.btn-row-menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.1rem 0.35rem;
  font-size: 15px;
  line-height: 1;
  color: #6c757d;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.btn-row-menu:hover {
  background: #e9ecef;
  border-color: #dee2e6;
  color: #343a40;
}

/* ══════════════════════════════════════════════════
   Transaction entry modal
══════════════════════════════════════════════════ */

/* Coloured header */
.txn-modal-header {
  padding: 20px 24px;
  border-radius: 0;
  border-bottom: none;
  color: #fff;
}
.txn-modal-header--buy  { background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%); }
.txn-modal-header--sell { background: linear-gradient(135deg, #065f46 0%, #059669 100%); }
.txn-modal-header .btn-close-white { filter: brightness(0) invert(1) brightness(2); }

/* Icon circle in header */
.txn-modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
}
.txn-modal-icon--buy  { background: rgba(255, 255, 255, 0.18); color: #fff; }
.txn-modal-icon--sell { background: rgba(255, 255, 255, 0.18); color: #fff; }

/* Numbered sections */
.txn-section {
  padding: 20px 24px;
  border-bottom: 1px solid #f1f5f9;
}
.txn-section--last {
  border-bottom: none;
}

.txn-section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #475569;
  margin-bottom: 16px;
}

.txn-step {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #0f172a;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Field labels with bilingual tag */
.txn-field-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}

.cn-tag {
  font-size: 11px;
  font-weight: 500;
  color: #94a3b8;
  margin-right: 2px;
}

/* Currency amount blocks */
.txn-currency-block {
  border-radius: 10px;
  padding: 14px 16px;
}
.txn-currency-block--tone0 { background: #eff6ff; border: 1px solid #bfdbfe; }
.txn-currency-block--tone1 { background: #f0fdf4; border: 1px solid #bbf7d0; }
.txn-currency-block--tone2 { background: #fffbeb; border: 1px solid #fde68a; }

.txn-currency-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}
.txn-currency-block--tone0 .txn-currency-label { color: #1d4ed8; }
.txn-currency-block--tone1 .txn-currency-label { color: #15803d; }
.txn-currency-block--tone2 .txn-currency-label { color: #b45309; }

/* Read-only BAL field */
.txn-bal-field {
  background: #fff !important;
  border-style: dashed !important;
  color: #1e293b;
  font-weight: 600;
}

/* Rate calculator hint */
.txn-calc-hint {
  font-size: 12px;
  font-weight: 600;
  color: #7c3aed;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
}

/* Repeating row items (charges / commission) */
.txn-row-item {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

/* Transactions filter — single compact row on large screens (no gap before actions) */
@media (min-width: 992px) {
  .txn-filter-form {
    flex-wrap: nowrap;
  }
  .txn-filter-form > [class*="col-"] {
    flex: 0 0 auto;
    width: auto;
    max-width: none;
  }
  .txn-filter-form .txn-filter-field--bil {
    min-width: 7.5rem;
    max-width: 9rem;
  }
  .txn-filter-form .txn-filter-field--party {
    min-width: 6rem;
    max-width: 10rem;
  }
  .txn-filter-form .txn-filter-field input[type="date"],
  .txn-filter-form .txn-filter-field .form-select {
    min-width: 7.25rem;
  }
  .txn-filter-form .txn-filter-actions {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
  }
}

.stock-alloc-table {
  font-size: 12px;
}
.stock-alloc-table .stock-alloc-qty {
  max-width: 9rem;
}

/* ── EOD Closing ── */
.eod-section-label {
  font-size: var(--audit-text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--audit-text-muted);
}
.eod-status-banner {
  border-radius: var(--audit-radius-md);
  padding: 1.1rem 1.4rem;
  border-left: 4px solid transparent;
}
.eod-status-banner--open {
  background: var(--audit-surface);
  border: 1px solid var(--audit-border);
  border-left-color: var(--audit-primary);
}
.eod-status-banner--closed {
  background: var(--audit-success-muted);
  border: 1px solid #bbf7d0;
  border-left-color: var(--audit-success);
}
.eod-status-banner--overdue {
  background: var(--audit-warning-muted);
  border: 1px solid #fde68a;
  border-left-color: var(--audit-warning);
}
.eod-status-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}
.eod-status-banner--open .eod-status-icon { color: var(--audit-primary); }
.eod-status-banner--closed .eod-status-icon { color: var(--audit-success); }
.eod-status-banner--overdue .eod-status-icon { color: var(--audit-warning); }
.eod-status-label {
  font-weight: 700;
  font-size: 1rem;
  color: var(--audit-text);
}
.eod-status-sub {
  font-size: var(--audit-text-sm);
  color: var(--audit-text-muted);
}
.eod-badge-closed {
  background: var(--audit-success-muted);
  color: var(--audit-success);
  border: 1px solid #bbf7d0;
}
.eod-pending-card {
  background: var(--audit-surface);
  border: 1px solid var(--audit-border) !important;
  border-radius: var(--audit-radius-md);
  overflow: hidden;
}
.eod-pending-header {
  border-bottom: 1px solid var(--audit-border);
  border-left: 3px solid var(--audit-warning);
  background: var(--audit-warning-muted);
}
.eod-warn-icon {
  color: var(--audit-warning);
}
.eod-pending-table th,
.eod-history-table th {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--audit-text-muted);
  background: var(--audit-surface-raised);
  border-bottom: 1px solid var(--audit-border);
  padding: 0.55rem 0.75rem;
  white-space: nowrap;
}
.eod-pending-table td,
.eod-history-table td {
  padding: 0.55rem 0.75rem;
  vertical-align: middle;
  border-color: var(--audit-border);
}
.eod-pending-table tbody tr:hover,
.eod-history-table tbody tr:hover {
  background: var(--audit-surface-raised);
}
.eod-cell-truncate {
  max-width: 10rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.eod-type-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}
.eod-type-badge--buy {
  color: var(--audit-buy);
  background: var(--audit-buy-muted);
}
.eod-type-badge--sell {
  color: var(--audit-sell);
  background: var(--audit-sell-muted);
}
.eod-status-chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.eod-status-chip--pending {
  color: var(--audit-warning);
  background: var(--audit-warning-muted);
}
.eod-status-chip--partial {
  color: var(--audit-accent);
  background: var(--audit-accent-muted);
}
.eod-history-card {
  background: var(--audit-surface);
  border: 1px solid var(--audit-border) !important;
  border-radius: var(--audit-radius-md);
  overflow: hidden;
}
.eod-modal-header {
  background: linear-gradient(135deg, #1e3a5f 0%, var(--audit-primary) 100%);
  color: #fff;
  padding: 1.25rem 1.5rem;
  border-radius: var(--audit-radius-md) var(--audit-radius-md) 0 0;
}
.eod-modal-icon {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--audit-radius-sm);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.eod-modal-summary {
  background: var(--audit-surface-raised);
  border: 1px solid var(--audit-border);
  border-radius: var(--audit-radius-sm);
  padding: 0.85rem;
}
.eod-modal-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.eod-modal-stat-val {
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--audit-text);
}
.eod-modal-stat-label {
  font-size: var(--audit-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--audit-text-muted);
}

/* ── Debtor / Creditor ── */
.dc-tabs .nav-link {
  font-size: var(--audit-text-sm);
  font-weight: 600;
  color: var(--audit-text-muted);
}
.dc-tabs .nav-link.active {
  color: var(--audit-primary-hover);
  border-bottom-color: var(--audit-primary);
}
.dc-table-card {
  background: var(--audit-surface);
  border: 1px solid var(--audit-border) !important;
  border-radius: var(--audit-radius-md);
  overflow: hidden;
}
.dc-table-header {
  border-bottom: 1px solid var(--audit-border);
  background: var(--audit-surface-raised);
}
.dc-data-table th {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--audit-text-muted);
  background: var(--audit-surface-raised);
  border-bottom: 1px solid var(--audit-border);
  padding: 0.55rem 0.75rem;
  white-space: nowrap;
}
.dc-data-table td {
  padding: 0.55rem 0.75rem;
  vertical-align: middle;
  border-color: var(--audit-border);
}
.dc-data-table tbody tr:hover {
  background: var(--audit-surface-raised);
}
.dc-cell-truncate {
  max-width: 10rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dc-party-list .list-group-item {
  border-color: var(--audit-border);
}

/* Ledger deal group (Excel-style child lines) */
.ledger-row-child td {
  background: var(--audit-surface-raised);
  font-size: 12px;
}
.ledger-row-child .ledger-cell-desc {
  font-weight: 500;
  color: var(--audit-text-secondary);
}
.ledger-row-child .ledger-cell-bil {
  color: var(--audit-text-muted);
  font-weight: 600;
}

/* Expand / collapse toggle (chevron button inside BIL cell) */
.btn-group-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--audit-primary-muted);
  border: 1px solid var(--audit-accent);
  border-radius: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  cursor: pointer;
  color: var(--audit-primary-hover);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  vertical-align: middle;
  flex-shrink: 0;
}
.btn-group-toggle:hover {
  background: var(--audit-accent-muted);
  color: var(--audit-primary);
  border-color: var(--audit-primary);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}
.btn-group-toggle[data-expanded="1"] {
  background: var(--audit-accent-muted);
  color: var(--audit-primary);
  border-color: var(--audit-primary);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.28);
}

/* Deal row paid/outstanding summary chip */
.ledger-deal-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 3px;
}
.lds-chip {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  border-radius: 20px;
  padding: 1px 7px;
  white-space: nowrap;
  line-height: 1.6;
}
.lds-chip--open {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
}
.lds-chip--done {
  background: #d1e7dd;
  color: #0a5238;
  border: 1px solid #75b798;
}
.lds-meta {
  font-size: 10px;
  color: var(--audit-text-muted);
}

/* Payment modal outstanding block */
.payment-outstanding-block {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  color: #856404;
}

/* ── Reports ── */
.report-nav-card,
.report-filter-card,
.report-preview-card {
  background: var(--audit-surface);
  border: 1px solid var(--audit-border) !important;
  border-radius: var(--audit-radius-md);
  box-shadow: var(--audit-shadow-sm) !important;
}
.report-type-nav {
  padding: 0.35rem 0;
}
.report-type-link {
  display: block;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--audit-text-secondary);
  border-left: 3px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.report-type-link:hover {
  background: var(--audit-surface-raised);
  color: var(--audit-text);
}
.report-type-link.is-active {
  background: var(--audit-primary-muted);
  border-left-color: var(--audit-primary);
  color: var(--audit-text);
}
.report-type-link-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
}
.report-type-link-desc {
  display: block;
  font-size: var(--audit-text-xs);
  color: var(--audit-text-muted);
  margin-top: 0.15rem;
  line-height: 1.4;
}
.report-preview-header {
  border-bottom: 1px solid var(--audit-border);
  background: var(--audit-surface-raised);
}
.report-preview-eyebrow {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--audit-primary-hover);
}
.report-preview-title {
  font-weight: 700;
  letter-spacing: -0.02em;
}
.report-preview-subtitle {
  color: var(--audit-text-muted);
}
.report-print-generated-label {
  color: var(--audit-text-muted);
}
.report-meta-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.report-meta-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.45rem 0.75rem;
  border-radius: var(--audit-radius-sm);
  background: color-mix(in srgb, var(--audit-primary) 10%, var(--audit-surface));
  border: 1px solid color-mix(in srgb, var(--audit-primary) 35%, var(--audit-border));
  min-width: 7rem;
}
.report-meta-card--currency {
  border-left: 3px solid var(--audit-primary);
}
.report-meta-card-label {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #334155;
}
.report-meta-card-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--audit-text);
  line-height: 1.2;
  margin-top: 0.1rem;
}
.report-meta-card-hint {
  font-size: 10px;
  font-weight: 600;
  color: var(--audit-text-secondary);
  margin-top: 0.15rem;
}
.report-summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.report-summary-chip {
  padding: 0.4rem 0.65rem;
  border-radius: var(--audit-radius-sm);
  background: var(--audit-surface);
  border: 1px solid var(--audit-border);
  min-width: 6rem;
}
.report-summary-chip-label {
  display: block;
  font-size: var(--audit-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--audit-text-muted);
}
.report-summary-chip-value {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--audit-text);
}
.report-data-table th {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--audit-text-muted);
  background: var(--audit-surface);
  border-bottom: 1px solid var(--audit-border);
  white-space: nowrap;
  padding: 0.55rem 0.75rem;
}
.report-data-table td {
  padding: 0.5rem 0.75rem;
  vertical-align: middle;
  border-color: var(--audit-border);
}
.report-data-table tbody tr:hover {
  background: var(--audit-surface-raised);
}
/* ── Report typography — numbers readable on screen and B&W print ── */
.rp-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--audit-text);
  white-space: nowrap;
}
.rp-num-key {
  font-weight: 800;
  font-size: 1.02em;
  letter-spacing: -0.01em;
}
.rp-num-outstanding {
  font-weight: 800;
}
.rp-label {
  font-size: 0.85em;
  font-weight: 600;
  color: var(--audit-text-secondary);
  letter-spacing: 0.02em;
}
.report-summary-chip--money {
  border-left: 3px solid var(--audit-primary);
  background: color-mix(in srgb, var(--audit-primary) 8%, var(--audit-surface));
  min-width: 7.5rem;
}
.report-summary-chip--money .report-summary-chip-value {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--audit-text);
}
.ds-th-outstanding {
  color: var(--audit-text) !important;
}

/* Report table headers — darker than default muted gray */
.ca-table thead th,
.txlog-table thead th,
.ds-table thead th,
.pnl-table thead th,
.comm-table thead th,
.dc-report-table thead th,
.ds-period-table thead th,
.report-data-table th {
  color: #334155;
}

/* ── Closing Account Statement ─────────────────────────────────────────── */
.ca-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.ca-section {
  border-top: 2px solid var(--audit-primary);
  background: var(--audit-surface);
}
.ca-section + .ca-section {
  margin-top: 1.5rem;
  border-top: 2px solid var(--audit-primary);
}
.ca-section-head {
  background: linear-gradient(135deg, color-mix(in srgb, var(--audit-primary) 8%, transparent), transparent);
  border-bottom: 1px solid var(--audit-border);
}
.ca-section-date {
  font-size: var(--audit-text-base);
  font-weight: 700;
  color: var(--audit-text);
}
.ca-eod-badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--audit-text-xs);
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  border-radius: 99px;
}
.ca-eod-badge--closed {
  background: color-mix(in srgb, #22c55e 12%, transparent);
  color: #166534;
}
.ca-eod-badge--open {
  background: color-mix(in srgb, #f59e0b 12%, transparent);
  color: #92400e;
}

/* Balance blocks */
.ca-balance-block {
  border-top: 1px solid var(--audit-border);
}
.ca-balance-block--opening {
  background: color-mix(in srgb, var(--audit-surface-raised) 60%, transparent);
}
.ca-balance-block--closing {
  background: color-mix(in srgb, var(--audit-primary) 5%, var(--audit-surface));
  border-top: 2px solid var(--audit-border);
}
.ca-balance-label {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--audit-text-muted);
  min-width: 7rem;
}
.ca-balance-item {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}
.ca-balance-ccy {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--audit-text-muted);
  letter-spacing: 0.05em;
}
.ca-balance-val {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ca-bal-pos { color: #16a34a; }
.ca-bal-neg { color: #dc2626; }
.ca-bal-zero { color: var(--audit-text-muted); }

.ca-net-item { color: var(--audit-text-muted); }

/* Transactions table */
.ca-table {
  border-collapse: collapse;
  width: 100%;
}
.ca-table thead tr.ca-thead-top th {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--audit-text-muted);
  background: var(--audit-surface);
  border-bottom: none;
  padding: 0.5rem 0.5rem 0.15rem;
  white-space: nowrap;
}
.ca-table thead tr.ca-thead-sub th {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--audit-text-muted);
  background: var(--audit-surface);
  border-top: none;
  border-bottom: 2px solid var(--audit-border);
  padding: 0 0.5rem 0.45rem;
  white-space: nowrap;
}
.ca-th-seq    { width: 6rem; }
.ca-th-desc   { min-width: 14rem; }
.ca-th-ccy    { border-left: 1px solid var(--audit-border); }
.ca-th-in,
.ca-th-out,
.ca-th-bal    { text-align: right; min-width: 6.5rem; }
.ca-th-in     { border-left: 1px solid var(--audit-border); }
.ca-th-status { width: 6rem; }

.ca-row-deal td {
  padding: 0.45rem 0.5rem;
  border-color: var(--audit-border);
  vertical-align: top;
}
.ca-row-child td {
  padding: 0.3rem 0.5rem;
  border-color: transparent;
  background: color-mix(in srgb, var(--audit-surface-raised) 50%, transparent);
  vertical-align: top;
}
.ca-row-child + .ca-row-deal td,
.ca-row-deal + .ca-row-deal td {
  border-top: 1px solid var(--audit-border);
}
.ca-table tbody tr:last-child td {
  border-bottom: 1px solid var(--audit-border);
}

.ca-td-seq    { color: var(--audit-text-muted); vertical-align: middle !important; }
.ca-desc-main { font-size: var(--audit-text-sm); font-weight: 600; color: var(--audit-text); }
.ca-desc-party { font-size: var(--audit-text-xs); color: var(--audit-text-muted); }
.ca-row-child .ca-desc-main { font-weight: 400; color: var(--audit-text-muted); padding-left: 0.75rem; }
.ca-row-child .ca-desc-party { padding-left: 0.75rem; }

.ca-td-in, .ca-td-out, .ca-td-bal { text-align: right; vertical-align: middle !important; }
.ca-td-in  { border-left: 1px solid var(--audit-border); }
.ca-td-status { vertical-align: middle !important; }

.ca-amt-in  { color: #15803d; }
.ca-amt-out { color: #b91c1c; }

.ca-status-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ca-status-badge--settled  { background: #dcfce7; color: #166534; }
.ca-status-badge--partial  { background: #fef9c3; color: #854d0e; }
.ca-status-badge--pending  { background: #fee2e2; color: #991b1b; }
.ca-status-badge--voided   { background: #f3f4f6; color: #6b7280; }

/* EOD footer */
.ca-eod-footer {
  border-top: 1px dashed var(--audit-border);
  font-size: var(--audit-text-sm);
}
.ca-eod-footer--closed { background: color-mix(in srgb, #22c55e 5%, var(--audit-surface)); }
.ca-eod-footer--open   { background: color-mix(in srgb, #f59e0b 5%, var(--audit-surface)); }

/* ── Report filter — period presets ────────────────────────────────────── */
.rp-presets-label {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--audit-text-muted);
  white-space: nowrap;
}
.rp-preset-btn {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  font-size: var(--audit-text-xs);
  font-weight: 600;
  border: 1px solid var(--audit-border);
  border-radius: 4px;
  background: var(--audit-surface);
  color: var(--audit-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.rp-preset-btn:hover {
  background: var(--audit-surface-raised);
  color: var(--audit-text);
  border-color: var(--audit-primary);
}
.rp-preset-btn.is-active {
  background: var(--audit-primary);
  color: #000;
  border-color: var(--audit-primary);
}

.rp-filter-period .form-control[type="date"] {
  min-width: 10.5rem;
}

/* ── Daily sales — period summary table (monthly / yearly) ──────────────── */
.ds-period-table thead th {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--audit-text-muted);
  background: var(--audit-surface);
  border-bottom: 2px solid var(--audit-border);
  white-space: nowrap;
  padding: 0.5rem 0.75rem;
}
.ds-period-table td { padding: 0.5rem 0.75rem; border-color: var(--audit-border); vertical-align: middle; }
.ds-period-table tbody tr:hover td { background: var(--audit-surface-raised); }
.ds-period-total-row td {
  background: color-mix(in srgb, var(--audit-primary) 7%, var(--audit-surface));
  border-top: 3px solid var(--audit-primary);
  padding: 0.5rem 0.75rem;
}
.ds-grand-period-rm { color: var(--audit-primary); font-size: var(--audit-text-base); }

/* ── Debtor / Creditor Report ────────────────────────────────────────────── */
.dc-report-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.dc-report-section {
  border-top: 2px solid var(--audit-border);
}
.dc-report-section + .dc-report-section {
  margin-top: 1rem;
  border-top: 2px solid var(--audit-border);
}
.dc-report-head {
  border-bottom: 1px solid var(--audit-border);
}
.dc-report-section--debtor .dc-report-head {
  background: color-mix(in srgb, #22c55e 6%, var(--audit-surface));
  border-left: 4px solid #16a34a;
}
.dc-report-section--creditor .dc-report-head {
  background: color-mix(in srgb, #ef4444 6%, var(--audit-surface));
  border-left: 4px solid #dc2626;
}
.dc-report-title {
  font-size: var(--audit-text-base);
  font-weight: 700;
  color: var(--audit-text);
}
.dc-report-subtitle { margin-top: 1px; }
.dc-report-total { font-size: 1.1rem; }
.dc-total--debtor  { color: #16a34a; }
.dc-total--creditor { color: #dc2626; }
.dc-th-outstanding { color: var(--audit-text) !important; }
.dc-report-table thead th {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--audit-text-muted);
  background: var(--audit-surface);
  border-bottom: 2px solid var(--audit-border);
  white-space: nowrap;
  padding: 0.45rem 0.75rem;
}
.dc-report-table td { padding: 0.45rem 0.75rem; border-color: var(--audit-border); vertical-align: middle; }
.dc-report-table tbody tr:hover td { background: var(--audit-surface-raised); }
.dc-td-outstanding { font-size: var(--audit-text-sm); }
.dc-report-subtotal td {
  background: var(--audit-surface);
  border-top: 2px solid var(--audit-border);
  padding: 0.45rem 0.75rem;
}

/* Debtor / creditor — optional side-by-side print layout */
.dc-report-wrapper--columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  align-items: start;
}
.dc-report-wrapper--columns .dc-report-section {
  min-width: 0;
  margin-top: 0 !important;
}
.dc-report-wrapper--columns .dc-report-section--creditor {
  border-left: 1px solid var(--audit-border);
}
.dc-report-wrapper--columns .dc-report-table {
  font-size: 11px;
}
.dc-report-wrapper--columns .dc-report-table th,
.dc-report-wrapper--columns .dc-report-table td {
  padding: 0.3rem 0.35rem;
}
.dc-report-wrapper--columns .dc-report-head {
  flex-direction: column;
  align-items: flex-start !important;
  gap: 0.5rem !important;
}
.dc-report-wrapper--columns .dc-report-head .d-flex.gap-4 {
  gap: 1rem !important;
}

.report-print-toolbar {
  background: color-mix(in srgb, var(--audit-primary) 5%, var(--audit-surface));
  border-radius: var(--audit-radius-sm);
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}
.report-print-toolbar--sticky {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 0 1rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--audit-border);
  border-radius: var(--audit-radius-sm);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}
.report-print-toolbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
}
.report-print-toolbar-hint {
  font-size: var(--audit-text-xs);
  color: var(--audit-text-muted);
  margin-left: auto;
  align-self: center;
}

/* Report print preview (?print=1) — full-width canvas, hide app chrome on screen */
body.app-shell--report-print .sidebar,
body.app-shell--report-print .app-header,
body.app-shell--report-print .skip-link {
  display: none !important;
}
body.app-shell--report-print .app-layout {
  display: block;
  min-height: 0;
}
body.app-shell--report-print .app-main {
  min-height: 0;
}
body.app-shell--report-print .app-content {
  max-width: min(1480px, calc(100vw - 32px));
  padding: 16px 20px 32px;
}

@media print {
  .dc-report-wrapper--columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    page-break-inside: avoid;
  }
  .dc-report-wrapper--columns .dc-report-table {
    font-size: 8.5px;
  }
  .dc-report-wrapper--columns .dc-report-table th,
  .dc-report-wrapper--columns .dc-report-table td {
    padding: 0.15rem 0.2rem !important;
  }
  .reports-page--closing .ca-table,
  .reports-page--transactions .txlog-table {
    font-size: 8.5px;
  }
}

/* ── Report summary chips — bold values ────────────────────────────────── */
.report-summary-chip-value {
  font-weight: 700;
}
.report-preview-title {
  font-weight: 800;
}

/* ── Daily Sales Report ─────────────────────────────────────────────────── */
.ds-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.ds-day-section {
  border-top: 1px solid var(--audit-border);
}
.ds-day-section + .ds-day-section {
  margin-top: 0.5rem;
  border-top: 2px solid var(--audit-border);
}
.ds-day-head {
  background: color-mix(in srgb, var(--audit-primary) 6%, var(--audit-surface));
  border-bottom: 1px solid var(--audit-border);
}
.ds-day-label {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--audit-text-muted);
}
.ds-table thead th {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--audit-text-muted);
  background: var(--audit-surface);
  border-bottom: 2px solid var(--audit-border);
  white-space: nowrap;
  padding: 0.45rem 0.65rem;
}
.ds-th-rm { color: var(--audit-primary) !important; }
.ds-table td { padding: 0.45rem 0.65rem; border-color: var(--audit-border); vertical-align: middle; }
.ds-table tbody tr:hover td { background: var(--audit-surface-raised); }
.ds-td-rm    { color: var(--audit-text); }
.ds-td-bil   { color: var(--audit-text-muted); }
.ds-td-party { color: var(--audit-text); }
.ds-qty-by-ccy { display: inline-flex; align-items: baseline; gap: 0.25rem; margin-right: 0.5rem; }
.ds-day-total-row td {
  background: color-mix(in srgb, var(--audit-primary) 5%, var(--audit-surface));
  border-top: 2px solid var(--audit-border);
  padding: 0.45rem 0.65rem;
  font-size: var(--audit-text-sm);
}
.ds-day-total-rm {
  color: var(--audit-primary);
  font-size: var(--audit-text-base);
}
.ds-grand-total {
  background: color-mix(in srgb, var(--audit-primary) 10%, var(--audit-surface));
  border-top: 3px solid var(--audit-primary);
  margin-top: 0.5rem;
}
.ds-grand-ccy-item { display: inline-flex; align-items: baseline; }
.ds-grand-rm {
  font-size: 1.1rem;
  color: var(--audit-primary);
}

/* ── Profit & Loss Report ────────────────────────────────────────────────── */
.pnl-table thead th {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--audit-text-muted);
  background: var(--audit-surface);
  border-bottom: 2px solid var(--audit-border);
  white-space: nowrap;
  padding: 0.5rem 0.65rem;
}
.pnl-th-pl { color: var(--audit-text) !important; }
.pnl-table td { padding: 0.45rem 0.65rem; border-color: var(--audit-border); vertical-align: middle; }
.pnl-table tbody tr:hover td { background: var(--audit-surface-raised); }
.pnl-td-pl { font-size: var(--audit-text-sm); }
.pnl-positive { color: #16a34a; }
.pnl-negative { color: #dc2626; }
.pnl-row--profit .pnl-td-pl { background: color-mix(in srgb, #22c55e 7%, transparent); }
.pnl-row--loss   .pnl-td-pl { background: color-mix(in srgb, #ef4444 7%, transparent); }
.pnl-total-row td {
  background: var(--audit-surface);
  border-top: 3px double var(--audit-border);
  padding: 0.5rem 0.65rem;
}
.pnl-total-row .pnl-td-pl { font-size: var(--audit-text-base); }

/* ── Transaction Log ───────────────────────────────────────────────────── */
.txlog-table {
  border-collapse: collapse;
  width: 100%;
}
.txlog-table thead th {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--audit-text-muted);
  background: var(--audit-surface);
  border-bottom: 2px solid var(--audit-border);
  white-space: nowrap;
  padding: 0.5rem 0.65rem;
}
.txlog-th-bil    { width: 7.5rem; }
.txlog-th-date   { width: 6.5rem; }
.txlog-th-amt    { min-width: 7rem; }
.txlog-th-bal    { min-width: 8rem; }
.txlog-th-status { width: 5.5rem; }

/* Date separator rows */
.txlog-date-sep td {
  padding: 0.75rem 0.65rem 0.3rem;
  border-top: 2px solid var(--audit-border);
  border-bottom: none;
}
.txlog-date-sep-cell span {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--audit-text-muted);
}

/* Deal rows */
.txlog-row-deal td {
  padding: 0.5rem 0.65rem;
  border-color: var(--audit-border);
  border-top: 1px solid var(--audit-border);
  vertical-align: top;
}
.txlog-row-deal + .txlog-row-deal td {
  border-top: 1px solid var(--audit-border);
}
/* Child rows */
.txlog-row-child td {
  padding: 0.28rem 0.65rem;
  border-top: none;
  border-color: transparent;
  background: color-mix(in srgb, var(--audit-surface-raised) 45%, transparent);
  vertical-align: top;
}
.txlog-table tbody tr:last-child td {
  border-bottom: 1px solid var(--audit-border);
}

/* Cell specific */
.txlog-td-bil { color: var(--audit-text-muted); vertical-align: middle !important; }
.txlog-td-date { color: var(--audit-text-muted); vertical-align: middle !important; }
.txlog-td-amt  { vertical-align: middle !important; }
.txlog-td-bal  { vertical-align: middle !important; }
.txlog-td-status { vertical-align: middle !important; }

/* Description cell */
.txlog-desc-main  { font-size: var(--audit-text-sm); font-weight: 600; color: var(--audit-text); }
.txlog-desc-sub   { font-size: var(--audit-text-xs); color: var(--audit-text-muted); margin-top: 1px; }
.txlog-desc-party { font-size: var(--audit-text-xs); color: var(--audit-text-muted); }
.txlog-row-child .txlog-desc-main {
  font-weight: 400;
  color: var(--audit-text-muted);
  padding-left: 1rem;
}
.txlog-row-child .txlog-desc-party {
  padding-left: 1rem;
}

/* Amounts */
.txlog-in      { color: #15803d; }
.txlog-out     { color: #b91c1c; }
.txlog-bal-pos { color: #16a34a; font-weight: 600; }
.txlog-bal-neg { color: #dc2626; font-weight: 600; }
.txlog-bal-zero { color: var(--audit-text-muted); }

/* ── Commission Report — Grouped by Recipient ──────────────────────────── */
.comm-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.comm-group {
  border-top: 1px solid var(--audit-border);
}
.comm-group + .comm-group {
  margin-top: 0.75rem;
  border-top: 2px solid var(--audit-border);
}
.comm-group-head {
  background: color-mix(in srgb, var(--audit-primary) 6%, var(--audit-surface));
  border-bottom: 1px solid var(--audit-border);
}
.comm-group-name {
  font-size: var(--audit-text-sm);
  font-weight: 700;
  color: var(--audit-text);
  letter-spacing: 0.01em;
}
.comm-group-count {
  font-size: var(--audit-text-xs);
}
.comm-table thead th {
  font-size: var(--audit-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--audit-text-muted);
  background: var(--audit-surface);
  border-bottom: 2px solid var(--audit-border);
  white-space: nowrap;
  padding: 0.45rem 0.65rem;
}
.comm-table td {
  padding: 0.4rem 0.65rem;
  border-color: var(--audit-border);
  vertical-align: middle;
}
.comm-table tbody tr:hover td {
  background: var(--audit-surface-raised);
}
.comm-rate-cell  { color: var(--audit-text-muted); }
.comm-amount-cell { color: #15803d; font-weight: 600; }
.comm-subtotal-row td {
  background: color-mix(in srgb, var(--audit-primary) 5%, var(--audit-surface));
  border-top: 2px solid var(--audit-border);
  padding: 0.45rem 0.65rem;
}
.comm-subtotal-row .comm-amount-cell {
  color: var(--audit-primary);
  font-size: var(--audit-text-sm);
}
.comm-grand-total {
  background: color-mix(in srgb, var(--audit-primary) 10%, var(--audit-surface));
  border-top: 3px solid var(--audit-primary);
  margin-top: 0.5rem;
}
.comm-grand-amount {
  font-size: 1.1rem;
  color: var(--audit-primary);
}

/* ── User management ── */
.um-page .um-table-card {
  box-shadow: var(--audit-shadow-sm);
  border-radius: var(--audit-radius-md);
  overflow: hidden;
}
.um-table-header {
  border-bottom: 1px solid var(--audit-border);
  background: var(--audit-surface-raised);
}
.um-data-table thead th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--audit-text-muted);
  border-bottom-width: 1px;
  white-space: nowrap;
}
.um-data-table tbody td {
  vertical-align: middle;
  font-size: 13px;
}
.um-role-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 2px 8px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.um-role-badge--admin {
  background: color-mix(in srgb, var(--audit-primary) 18%, #fff);
  color: var(--audit-primary-hover);
  border: 1px solid var(--audit-primary);
}
.um-role-badge--manager {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
}
.um-role-badge--user {
  background: var(--audit-surface-raised);
  color: var(--audit-text-secondary);
  border: 1px solid var(--audit-border);
}
.um-modal-header {
  background: linear-gradient(135deg, #422006 0%, var(--audit-primary) 100%);
  color: #fff;
}

@media print {
  @page {
    margin: 10mm 8mm;
  }
  html,
  body,
  .app-layout,
  .app-main,
  .sidebar {
    min-height: 0 !important;
    height: auto !important;
  }
  .app-content {
    flex: none !important;
    padding-bottom: 0 !important;
  }
  .sidebar,
  .app-header,
  .sidebar-toggle,
  .report-nav-card,
  .report-filter-card,
  .skip-link,
  .d-print-none {
    display: none !important;
  }
  .app-layout {
    display: block !important;
  }
  .app-main {
    width: 100% !important;
    max-width: 100% !important;
  }
  .app-content {
    max-width: 100% !important;
    padding: 0 !important;
  }
  .reports-page .table-responsive {
    overflow: visible !important;
  }
  .reports-page table {
    width: 100% !important;
    max-width: 100% !important;
  }
  .reports-page .ca-td-desc,
  .reports-page .txlog-td-desc,
  .reports-page .ds-td-party {
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  .report-preview-card {
    box-shadow: none !important;
    border: none !important;
  }
  .report-data-table {
    font-size: 10px;
  }
  .report-data-table th,
  .report-data-table td {
    padding: 0.25rem 0.35rem;
  }
  .ca-section + .ca-section {
    margin-top: 0;
    page-break-before: always;
  }
  .ca-table {
    font-size: 9.5px;
  }
  .ca-table th,
  .ca-table td {
    padding: 0.2rem 0.3rem !important;
  }
  .ca-section-head,
  .ca-balance-block,
  .ca-eod-footer {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .ds-table, .pnl-table, .txlog-table {
    font-size: 9.5px;
  }
  .ds-table th, .ds-table td,
  .pnl-table th, .pnl-table td {
    padding: 0.2rem 0.3rem !important;
  }
  .ds-day-head { padding: 0.25rem 0.5rem !important; }
  .ds-grand-total { padding: 0.25rem 0.5rem !important; }
  .ds-day-section + .ds-day-section { margin-top: 0; }
  .ds-day-head, .ds-day-total-row td, .ds-grand-total,
  .pnl-row--profit .pnl-td-pl, .pnl-row--loss .pnl-td-pl,
  .pnl-total-row td {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .txlog-table th,
  .txlog-row-deal td,
  .txlog-row-child td,
  .txlog-date-sep td {
    padding: 0.2rem 0.3rem !important;
  }
  .txlog-date-sep td {
    padding-top: 0.5rem !important;
  }
  .comm-table {
    font-size: 9.5px;
  }
  .comm-table th,
  .comm-table td {
    padding: 0.2rem 0.35rem !important;
  }
  .comm-group-head,
  .comm-subtotal-row td,
  .comm-grand-total,
  .ca-status-badge,
  .ca-eod-badge,
  .dc-report-head {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .comm-group + .comm-group {
    margin-top: 0;
    page-break-inside: avoid;
  }
  .dc-report-table th,
  .dc-report-table td,
  .ds-period-table th,
  .ds-period-table td {
    padding: 0.2rem 0.3rem !important;
  }
}

/* Reports print preview (?print=1) — white canvas only */
.reports-page--print {
  background: #fff;
}
.reports-page--print .report-preview-card {
  box-shadow: none !important;
}

/*
 * Reports: darken gray/muted text for B&W printers.
 * Green, red, and status badge colours are unchanged (print-color-adjust above).
 */
.reports-page--print .text-muted,
.reports-page--print .report-preview-subtitle,
.reports-page--print .report-print-generated-label,
.reports-page--print .report-meta-card-label,
.reports-page--print .report-summary-chip-label,
.reports-page--print .ca-balance-label,
.reports-page--print .ca-balance-ccy,
.reports-page--print .ca-td-seq,
.reports-page--print .ca-desc-party,
.reports-page--print .ca-row-child .ca-desc-main,
.reports-page--print .ca-bal-zero,
.reports-page--print .ca-net-item,
.reports-page--print .txlog-td-bil,
.reports-page--print .txlog-td-date,
.reports-page--print .txlog-date-sep-cell span,
.reports-page--print .txlog-desc-party,
.reports-page--print .txlog-desc-sub,
.reports-page--print .txlog-row-child .txlog-desc-main,
.reports-page--print .txlog-bal-zero,
.reports-page--print .ds-day-label,
.reports-page--print .ds-td-bil,
.reports-page--print .comm-group-count,
.reports-page--print .comm-rate-cell,
.reports-page--print .dc-report-subtitle,
.reports-page--print table thead th,
.reports-page--print .ca-table thead th,
.reports-page--print .txlog-table thead th,
.reports-page--print .ds-table thead th,
.reports-page--print .pnl-table thead th,
.reports-page--print .comm-table thead th,
.reports-page--print .dc-report-table thead th,
.reports-page--print .ds-period-table thead th {
  color: #1a1a1a !important;
  opacity: 1 !important;
}

.reports-page--print .report-preview-title,
.reports-page--print .report-summary-chip-value,
.reports-page--print .report-meta-card-value,
.reports-page--print .report-print-generated-value,
.reports-page--print .ca-section-date,
.reports-page--print .ca-desc-main,
.reports-page--print .txlog-desc-main,
.reports-page--print .comm-group-name,
.reports-page--print .dc-report-title {
  color: #000 !important;
}

.reports-page--print .rp-num,
.reports-page--print .rp-num-key {
  font-weight: 700 !important;
}
.reports-page--print .rp-num-key,
.reports-page--print .rp-num-outstanding {
  font-weight: 800 !important;
}
.reports-page--print td.rp-num:not(.comm-amount-cell):not(.dc-td-outstanding),
.reports-page--print .rp-label {
  color: #000 !important;
}

@media print {
  .reports-page .text-muted,
  .reports-page .report-preview-subtitle,
  .reports-page .report-print-generated-label,
  .reports-page .report-meta-card-label,
  .reports-page .report-summary-chip-label,
  .reports-page .ca-balance-label,
  .reports-page .ca-balance-ccy,
  .reports-page .ca-td-seq,
  .reports-page .ca-desc-party,
  .reports-page .ca-row-child .ca-desc-main,
  .reports-page .ca-bal-zero,
  .reports-page .ca-net-item,
  .reports-page .txlog-td-bil,
  .reports-page .txlog-td-date,
  .reports-page .txlog-date-sep-cell span,
  .reports-page .txlog-desc-party,
  .reports-page .txlog-desc-sub,
  .reports-page .txlog-row-child .txlog-desc-main,
  .reports-page .txlog-bal-zero,
  .reports-page .ds-day-label,
  .reports-page .ds-td-bil,
  .reports-page .comm-group-count,
  .reports-page .comm-rate-cell,
  .reports-page .dc-report-subtitle,
  .reports-page table thead th,
  .reports-page .ca-table thead th,
  .reports-page .txlog-table thead th,
  .reports-page .ds-table thead th,
  .reports-page .pnl-table thead th,
  .reports-page .comm-table thead th,
  .reports-page .dc-report-table thead th,
  .reports-page .ds-period-table thead th {
    color: #1a1a1a !important;
    opacity: 1 !important;
  }

  .reports-page .report-preview-title,
  .reports-page .report-summary-chip-value,
  .reports-page .report-meta-card-value,
  .reports-page .report-print-generated-value,
  .reports-page .ca-section-date,
  .reports-page .ca-desc-main,
  .reports-page .txlog-desc-main,
  .reports-page .comm-group-name,
  .reports-page .dc-report-title {
    color: #000 !important;
  }

  .reports-page table thead th,
  .reports-page .ca-balance-label,
  .reports-page .ds-day-label,
  .reports-page .txlog-date-sep-cell span {
    font-weight: 700 !important;
  }

  .reports-page .report-summary-chip-value,
  .reports-page .ca-balance-val,
  .reports-page .ds-day-total-rm,
  .reports-page .ds-grand-rm,
  .reports-page .comm-grand-amount,
  .reports-page .dc-report-total {
    font-weight: 700 !important;
  }

  .reports-page .rp-num,
  .reports-page .rp-num-key {
    font-weight: 700 !important;
  }
  .reports-page .rp-num-key,
  .reports-page .rp-num-outstanding {
    font-weight: 800 !important;
  }
  .reports-page td.rp-num:not(.comm-amount-cell):not(.dc-td-outstanding),
  .reports-page .rp-label {
    color: #000 !important;
  }
}
