/* Shared blue business theme — used across budget, revenue, and AI pages. */
:root {
  --blue-100: #cde2fb;
  --blue-200: #9ec5f4;
  --blue-400: #3987e5;
  --blue-450: #2a78d6;
  --blue-550: #1c5cab;
  --blue-600: #184f95;
  --blue-700: #0d366b;
  --ink-primary: #0b0b0b;
  --ink-secondary: #52514e;
  --ink-muted: #898781;
  --surface: #fcfcfb;
  --page-plane: #f4f8fd;
  --hairline: #e1e0d9;
}

body { background: var(--page-plane); }

.page-header { color: var(--blue-700); }
.page-note { color: var(--ink-secondary); font-size: 0.92rem; }

/* KPI tile row */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
@media (max-width: 900px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.kpi-tile { border-radius: 10px; padding: 18px 20px; }
.kpi-tile .kpi-label { font-size: 0.85rem; margin-bottom: 6px; }
.kpi-tile .kpi-value { font-size: 1.9rem; font-weight: 600; line-height: 1.1; }
.kpi-tile.kpi-total {
  background: linear-gradient(135deg, var(--blue-600), var(--blue-550));
  color: #fff;
  box-shadow: 0 4px 14px rgba(13, 54, 107, 0.25);
}
.kpi-tile.kpi-total .kpi-label { color: var(--blue-100); }
.kpi-tile.kpi-division {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-top: 3px solid var(--blue-450);
}
.kpi-tile.kpi-division .kpi-label { color: var(--ink-secondary); }
.kpi-tile.kpi-division .kpi-value { color: var(--blue-600); }

/* Division card (used by both budget tree and revenue) */
.division-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  margin-bottom: 20px;
  overflow: hidden;
}
.division-card-header {
  background: var(--blue-600);
  color: #fff;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border: none;
  text-align: right;
}
.division-card-header .div-name { font-weight: 600; font-size: 1.05rem; }
.division-card-header .div-total { font-weight: 600; font-size: 1.1rem; }
.division-card-body { padding: 6px 0; }
.division-card-body.collapse:not(.show) { display: none; }

/* Generic collapsible row (subgroup / category / line-item group headers) */
.tree-row {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 10px 18px; cursor: pointer; border-bottom: 1px solid var(--hairline);
  transition: background 0.1s; background: none; border-inline: none; border-top: none; text-align: right;
}
.tree-row:hover { background: var(--blue-100); }
.tree-row:last-child { border-bottom: none; }
.tree-row .row-name { color: var(--ink-primary); font-weight: 500; }
.tree-row .row-amount { color: var(--blue-550); font-weight: 600; }
.tree-row .row-caret { color: var(--ink-muted); margin-inline-start: 8px; transition: transform 0.15s; display: inline-block; }
.tree-row[aria-expanded="true"] .row-caret { transform: rotate(90deg); }
.tree-row.tree-row-sub .row-amount { color: var(--blue-450); font-weight: 500; }

.tree-panel { padding: 4px 18px 14px; background: var(--page-plane); }
.tree-table { width: 100%; font-size: 0.92rem; }
.tree-table th { color: var(--ink-muted); font-weight: 500; text-align: right; padding: 4px 8px; }
.tree-table td { padding: 4px 8px; color: var(--ink-primary); }
.tree-table .amount-cell { font-variant-numeric: tabular-nums; }

.amount { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* Budget-vs-actual diff coloring (revenue/actual.ejs) */
.diff-positive { color: #1f8a4c; font-weight: 600; }
.diff-negative { color: #c23a3a; font-weight: 600; }
.diff-pending { color: var(--ink-muted); font-weight: 500; }
.kpi-tile.kpi-diff-positive { border-top: 3px solid #1f8a4c; }
.kpi-tile.kpi-diff-negative { border-top: 3px solid #c23a3a; }
.actual-count-input { width: 70px; padding: 2px 6px; border: 1px solid var(--hairline); border-radius: 4px; text-align: center; }

/* Same diff semantics, but readable on the dark-blue division-card-header (plain red/green fail
   contrast there) — lighter, higher-contrast tints instead. */
.diff-positive-inverse { color: #8fe6b0; font-weight: 700; }
.diff-negative-inverse { color: #ffb0a3; font-weight: 700; }
.diff-pending-inverse { color: rgba(255, 255, 255, 0.7); font-weight: 500; }

/* Table-style aligned columns for the budget/actual/diff figures on subgroup rows (actual.ejs) —
   fixed-width cells so numbers line up vertically across every row instead of flowing inline. */
.actual-amount-cols { display: flex; gap: 10px; }
.actual-amount-cols .amount-col {
  display: inline-block; width: 84px; text-align: left;
  font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate;
}
.actual-header-row {
  cursor: default; font-size: 0.72rem; color: var(--ink-muted); font-weight: 600; padding-top: 4px; padding-bottom: 4px;
}
.actual-header-row:hover { background: none; }
.remark-spacer { width: 46px; flex: 0 0 auto; }
/* Fixed width regardless of whether a count badge is shown ("💬" vs "💬 (3)") — otherwise rows
   with a remark count are narrower than rows without one, throwing off the amount-cols alignment
   in actual.ejs's budget/actual/diff table. */
.remark-badge { min-width: 46px; text-align: center; }

/* Mini-tab switcher (revenue: תקציב vs בפועל) */
.mini-tabs { display: flex; gap: 6px; margin-bottom: 20px; }
.mini-tabs a {
  padding: 6px 16px; border-radius: 20px; font-size: 0.9rem; font-weight: 500;
  color: var(--blue-600); background: var(--surface); border: 1px solid var(--hairline);
  text-decoration: none;
}
.mini-tabs a.active { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.mini-tabs a:hover:not(.active) { background: var(--blue-100); }

/* Budget-by-type cross-tab (budget/matrix.ejs) — rows collapsible by category, columns
   collapsible by division. Columns are toggled by adding/removing d-none on every cell sharing a
   division's column class, not by re-rendering the table. */
.matrix-table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--hairline); border-radius: 10px; margin-bottom: 24px; }
.matrix-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.matrix-table th, .matrix-table td { padding: 8px 14px; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
.matrix-table thead th { background: var(--blue-600); color: #fff; font-weight: 600; text-align: center; }
.matrix-table thead th[data-div-toggle] { cursor: pointer; }
.matrix-table thead th[data-div-toggle]:hover { background: var(--blue-550); }
.matrix-table thead th[data-div-toggle] .row-caret { transition: transform 0.15s; display: inline-block; }
.matrix-table thead th[data-div-toggle].expanded .row-caret { transform: rotate(90deg); }
.matrix-label-col { position: sticky; right: 0; background: var(--surface); text-align: right; min-width: 220px; z-index: 1; }
.matrix-table thead .matrix-label-col { background: var(--blue-700); z-index: 3; }
.matrix-cat-row { cursor: pointer; background: var(--page-plane); font-weight: 600; }
.matrix-cat-row:hover, .matrix-cat-row:hover .matrix-label-col { background: var(--blue-100); }
.matrix-cat-row .row-caret { color: var(--ink-muted); margin-inline-end: 6px; display: inline-block; transition: transform 0.15s; }
.matrix-cat-row.expanded .row-caret { transform: rotate(90deg); }
.matrix-item-row .matrix-item-label { padding-right: 34px; color: var(--ink-secondary); font-weight: 400; }
.matrix-table .amount-cell { text-align: left; direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; color: var(--ink-primary); }
.matrix-total-col { font-weight: 600; background: var(--page-plane); text-align: left; direction: ltr; unicode-bidi: isolate; }
.matrix-table thead .matrix-total-col { background: var(--blue-700); text-align: center; direction: rtl; unicode-bidi: normal; }
.matrix-table tfoot td { font-weight: 700; background: var(--blue-100); }
.matrix-table tfoot .matrix-label-col { background: var(--blue-100); }
