  :root {
    --bg: #f6f7fb;
    --panel: #fff;
    --ink: #1a2233;
    --muted: #6b7280;
    --line: #e5e7eb;
    --accent: #2456ff;
    --good: #16a34a;
    --warn: #d97706;
    --bad: #dc2626;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(20,30,80,.06);
  }
  * { box-sizing: border-box; }
  html, body { overflow-x: hidden; }
  body {
    margin: 0; padding: 32px 16px;
    font: 14px/1.5 -apple-system, "Segoe UI", "Noto Sans Hebrew", sans-serif;
    background: var(--bg); color: var(--ink);
  }
  @media (max-width: 600px) { body { padding: 16px 10px; } }
  .container { max-width: 1320px; margin: 0 auto; }
  h1 { margin: 0 0 4px; font-size: 22px; }
  .sub { color: var(--muted); margin: 0 0 24px; font-size: 13px; }
  .panel {
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px;
  }
  .row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  @media (max-width: 700px) { .row { grid-template-columns: 1fr; } }
  label { display: block; font-weight: 600; margin-bottom: 6px; }
  label small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }
  input[type=file], input[type=password] {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line);
    border-radius: 8px; background: #fafbfc; font: inherit;
  }
  input[type=password] { direction: ltr; text-align: left; }
  .text-input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line);
    border-radius: 8px; background: #fafbfc; font: inherit;
  }
  .text-input.ltr { direction: ltr; text-align: left; }
  .btn {
    padding: 12px 24px; font: inherit; font-weight: 600;
    border: 0; border-radius: 8px; cursor: pointer;
    transition: background .15s, opacity .15s;
  }
  .btn-primary { background: var(--accent); color: #fff; }
  .btn-primary:hover:not(:disabled) { background: #1a47e6; }
  .btn-primary:disabled { background: #9ca3af; cursor: not-allowed; }
  .btn-success { background: var(--good); color: #fff; }
  .btn-success:hover:not(:disabled) { background: #138536; }
  button#compare {
    margin-top: 16px; padding: 12px 24px; font: inherit; font-weight: 600;
    background: var(--accent); color: #fff; border: 0; border-radius: 8px;
    cursor: pointer; transition: background .15s;
  }
  button#compare:hover:not(:disabled) { background: #1a47e6; }
  button#compare:disabled { background: #9ca3af; cursor: not-allowed; }
  .status { margin-top: 12px; color: var(--muted); min-height: 20px; font-size: 13px; }
  .status.error { color: var(--bad); }
  .grid4 {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px;
    margin-bottom: 20px;
  }
  @media (max-width: 860px)  { .grid4 { grid-template-columns: repeat(3, 1fr); } }
  @media (max-width: 540px)  { .grid4 { grid-template-columns: repeat(2, 1fr); } }
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-scroll > table { min-width: 600px; }
  .tile {
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    padding: 16px; box-shadow: var(--shadow);
  }
  .tile .n { font-size: 28px; font-weight: 700; line-height: 1; }
  .tile .l { color: var(--muted); font-size: 12px; margin-top: 6px; }
  .tile.headline .n { color: var(--bad); }
  .tile.good .n { color: var(--good); }
  .tile.warn .n { color: var(--warn); }
  .tile.low .n { color: #ca8a04; }
  .tile-clickable { cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; }
  .tile-clickable:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,.06), 0 12px 28px rgba(20,30,80,.10); border-color: #c7cad1; }
  .tile-clickable.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(36,86,255,.18), var(--shadow); }
  table { width: 100%; border-collapse: collapse; background: var(--panel); }
  th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
  th { background: #f8fafc; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  .id { font-family: "SF Mono", Consolas, monospace; direction: ltr; text-align: left; }
  .empty { color: var(--muted); padding: 12px 0; font-style: italic; }
  details { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0 16px; box-shadow: var(--shadow); }
  details + details { margin-top: 12px; }
  summary { padding: 14px 0; cursor: pointer; font-weight: 600; }
  summary::marker { color: var(--muted); }
  details[open] { padding-bottom: 12px; }
  .hidden { display: none; }
  .controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 0 12px; }
  .chips { display: flex; gap: 6px; flex-wrap: wrap; }
  .chip {
    padding: 6px 10px; border: 1px solid var(--line); background: #fff; color: var(--ink);
    border-radius: 999px; font: inherit; font-size: 12px; cursor: pointer; transition: all .12s;
    white-space: nowrap;
  }
  .chip:hover { border-color: #c7cad1; }
  .chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
  .search {
    flex: 1; min-width: 160px; padding: 7px 10px; border: 1px solid var(--line);
    border-radius: 8px; font: inherit; direction: ltr; text-align: left;
  }
  .diff-row { cursor: pointer; transition: background .1s; }
  .diff-row:hover { background: #f8fafc; }
  .diff-row.expanded { background: #eef2ff; }
  .note-row td { background: #fafbff; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .note p { margin: 0 0 6px; }
  .note p:last-child { margin-bottom: 0; }
  .note .hint { color: var(--muted); font-size: 12px; }
  .note .delta-pos { color: var(--bad); font-weight: 600; }
  .note .delta-neg { color: var(--good); font-weight: 600; }
  .emp-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; }
  .emp-card.critical { border-color: var(--bad); border-width: 2px; }
  .emp-card summary { padding: 12px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .emp-card .emp-name { font-weight: 600; }
  .emp-card .emp-id { color: var(--muted); font-family: "SF Mono", Consolas, monospace; font-size: 12px; direction: ltr; }
  .emp-card .emp-totals { margin-inline-start: auto; font-size: 12px; color: var(--muted); }
  .emp-card .badge {
    display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  }
  .emp-card .badge.critical { background: #fee2e2; color: var(--bad); }
  .emp-card .badge.ok { background: #dcfce7; color: var(--good); }
  .emp-card .recon-table { padding: 0 16px 16px; }
  .emp-card .delta-explain {
    padding: 8px 16px 4px;
    color: var(--muted);
    font-size: 12px;
    border-top: 1px dashed var(--line);
    background: #fafbfc;
  }
  .emp-card .delta-explain .lbl { color: var(--ink); font-weight: 600; }
  .emp-card .delta-explain .pos { color: var(--bad); font-weight: 600; }
  .emp-card .delta-explain .neg { color: var(--good); font-weight: 600; }
  .recon-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .recon-table table { font-size: 13px; min-width: 500px; }
  .status-cell { font-weight: 600; font-size: 11px; padding: 2px 6px; border-radius: 4px; }
  .status-match           { background: #dcfce7; color: var(--good); }
  .status-amount-diff     { background: #fef3c7; color: var(--warn); }
  .status-only-in-t040    { background: #fee2e2; color: var(--bad); }
  .status-only-in-hisuvit { background: #e5e7eb; color: var(--muted); }
  .status-gilum           { background: #ede9fe; color: #6d28d9; }
  .status-niqui           { background: #ccfbf1; color: #0f766e; }
  .gilum-row td           { background: #faf5ff; }
  .result-count {
    display: inline-flex; align-items: baseline; gap: 6px;
    padding: 8px 14px; background: var(--accent); color: #fff;
    border-radius: 999px; font-weight: 700; font-size: 18px;
    white-space: nowrap; box-shadow: 0 1px 3px rgba(36,86,255,.3);
  }
  .result-count .label { font-size: 11px; font-weight: 500; opacity: .85; }
  .result-count.empty { background: var(--muted); box-shadow: none; }
  .result-count.large { background: var(--good); }
  .salary-row td          { background: #fee2e2 !important; border-color: var(--bad) !important; }
  .salary-row td.id       { font-weight: 700; }
  .amount-diff-row td     { background: #fffbeb; }
  .client-cell            { color: #475569; font-size: 12px; max-width: 260px; line-height: 1.35; }
  .client-group-header { cursor: pointer; user-select: none; }
  .client-group-header td {
    background: #eef2ff; color: #1e3a8a; font-weight: 700; font-size: 13px;
    padding: 10px 12px; border-top: 2px solid #c7d2fe; border-bottom: 1px solid #c7d2fe;
    text-align: right; letter-spacing: 0; transition: background .12s;
  }
  .client-group-header:hover td { background: #dfe7ff; }
  .client-group-header .chevron {
    display: inline-block; font-size: 10px; color: #6366f1;
    margin-inline-end: 8px; transition: transform .15s;
  }
  .client-group-header.collapsed .chevron { transform: rotate(-90deg); }
  .client-group-header .group-name  { display: inline-block; margin-inline-end: 14px; }
  .client-group-header .group-stat  { color: #475569; font-weight: 500; font-size: 12px; margin-inline-end: 14px; }
  .client-group-header .group-stat strong { color: #1a2233; font-variant-numeric: tabular-nums; }
  .mark-done-btn {
    background: transparent; border: 1px solid var(--line); border-radius: 6px;
    width: 24px; height: 24px; padding: 0; cursor: pointer; font-size: 14px;
    color: var(--muted); line-height: 1; transition: background .12s, color .12s, border-color .12s;
  }
  .mark-done-btn:hover { background: #f1f5f9; border-color: #94a3b8; }
  .mark-done-btn.done { background: var(--good); border-color: var(--good); color: #fff; }
  .diff-row.row-done td:not(:last-child) {
    opacity: .45; text-decoration: line-through; text-decoration-color: var(--muted);
  }
  .diff-row.row-done td:last-child { opacity: .55; }
  .diff-row.row-done .mark-done-btn { opacity: 1; text-decoration: none; }

.delta-attribution-list { margin: 4px 0 4px 1.2em; padding: 0; list-style: disc; }
.delta-attribution-list li { margin: 2px 0; }
.gross-delta-warning { color: #b45309; }
.gross-delta-info { color: #1d4ed8; }
.delta-explained { color: #15803d; font-weight: 600; }
.delta-partial { color: #b45309; }
.delta-note { font-style: italic; }

/* ─── Tab bar ─── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 24px;
}
.tab {
  padding: 10px 20px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  color: var(--muted);
  border-radius: 6px 6px 0 0;
  transition: color .15s, border-color .15s, background .15s;
}
.tab:hover { color: var(--ink); background: #f1f5f9; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); background: transparent; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─── Tab panels ─── */
.tab-panel[hidden] { display: none; }

/* ─── Compare2 upload grid ─── */
.compare2-uploads {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
@media (max-width: 860px) { .compare2-uploads { grid-template-columns: 1fr; } }

/* ─── Compare2 results table ─── */
.compare2-table { min-width: 900px; }
.compare2-table td.num { font-variant-numeric: tabular-nums; }
.compare2-table td.empty-cell { color: var(--muted); font-style: italic; }
.compare2-table tbody tr:hover { background: #f8fafc; }
.compare2-table .profit-pos { color: var(--good); font-weight: 600; }
.compare2-table .profit-neg { color: var(--bad); font-weight: 600; }
.compare2-table .profit-low { color: #ca8a04; font-weight: 600; }
