*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Bareket brand — deep navy + muted cyan on white (sampled from bareket.co.il) */
  --navy:        #002142;
  --navy-dark:   #001629;
  --accent:      #256f96;
  --accent-hover:#1d5a7c;
  --accent-dim:  rgba(37, 111, 150, 0.12);
  --bg:          #ffffff;
  --panel:       #ffffff;
  --surface:     #f2f6fa;
  --border:      rgba(0, 33, 66, 0.15);
  --border-soft: rgba(0, 33, 66, 0.07);
  --text:        #002142;
  --muted:       #55636f;
  --icon:        #333333;
  --ok:          #0e9f6e;
  --ok-dim:      rgba(14, 159, 110, 0.13);
  --warn:        #c88a04;
  --warn-dim:    rgba(200, 138, 4, 0.14);
  --err:         #dc2626;
  --info:        #256f96;
  /* doc-type gem hues — same list chrome, hue encodes type (from brand) */
  --doc-account:   #256f96;
  --doc-payment:   #0e9f6e;
  --doc-appraisal: #4054b2;
  --radius:      10px;
  --shadow-lg:   0 8px 30px -14px rgba(0, 33, 66, 0.35), 0 1px 2px rgba(0, 33, 66, 0.07);
  --shadow-sm:   0 1px 2px rgba(0, 33, 66, 0.08), 0 6px 18px -14px rgba(0, 33, 66, 0.25);
  --header-h:    76px;
  --font:        system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans Hebrew", sans-serif;
  --mono:        ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --content-max-width: min(80rem, calc(100vw - 3rem));
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  direction: rtl;
}

.app-header {
  position: fixed; top: 0; right: 0; left: 0;
  width: 100%;
  height: var(--header-h);
  background: var(--bg);
  padding: 0 clamp(1rem, 3vw, 2.25rem);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  border-bottom: 2px solid var(--navy);
  box-shadow: var(--shadow-sm);
  z-index: 200;
}
.app-header__start { display: flex; align-items: center; gap: 1.1rem; justify-self: start; min-width: 0; }

/* BRKT brand wordmark + Bareket downward-triangle gem */
.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; flex: none; }
.brand__gem {
  width: 20px; height: 18px; flex: none;
  background: linear-gradient(150deg, var(--navy), var(--accent));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.brand__mark {
  font-size: 1.25rem; font-weight: 800; letter-spacing: .28em;
  padding-inline-start: .28em; color: var(--navy); line-height: 1;
}
.brand__he {
  font-size: .72rem; color: #3a81ab; letter-spacing: .01em;
  border-inline-start: 1px solid var(--border); padding-inline-start: .6rem;
  white-space: nowrap;
}
@media (max-width: 640px) { .brand__he { display: none; } }

.header-title-wrap { justify-self: center; text-align: center; max-width: 100%; min-width: 0; }
.header-title { font-size: 17px; font-weight: 700; display: block; color: var(--navy); }
.header-sub { margin-top: 3px; font-size: 12px; line-height: 1.25; display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.header-muted { color: var(--muted); }
.header-project-label { font-weight: 500; }
.header-project-name { color: var(--accent-hover); }

.projects-layout {
  width: 100%; max-width: var(--content-max-width);
}

.projects-grid {
  display: grid;
  grid-template-columns: minmax(0, 26rem) 1fr;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 840px) {
  .projects-grid { grid-template-columns: 1fr; }
}

.projects-form .form-group { margin-bottom: 1rem; }

.projects-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.projects-list__item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: .85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.projects-list__main { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.projects-list__name { font-weight: 600; }
.projects-list__meta { font-size: .85rem; color: var(--muted); word-break: break-word; }
.projects-list__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 4px;
  font-size: .82rem;
  color: var(--muted);
}
.projects-list__stat-item { white-space: nowrap; }

.projects-footnote { margin-top: 1rem; font-size: .88rem; }
.projects-footnote a { color: var(--accent); }
.user-info {
  justify-self: end;
  display: flex; align-items: center; gap: 10px;
}
.user-name { font-size: 14px; color: var(--muted); max-width: 12rem; overflow: hidden; text-overflow: ellipsis; }

.main-full {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 2rem;
  padding-top: calc(var(--header-h) + 1rem);
  background: var(--surface);
}
.main-full--top { align-items: flex-start; }

.documents-layout { width: 100%; max-width: var(--content-max-width); }

.login-container { width: 100%; max-width: 400px; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  border-top: 3px solid var(--navy);
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-header h1 { font-size: 1.3rem; font-weight: 700; margin-bottom: .3rem; color: var(--accent); }
.login-header p { color: var(--muted); font-size: .9rem; }
.login-form .form-group { margin-bottom: 1.1rem; }

.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.page-header__lead { margin-top: .5rem; color: var(--muted); font-size: .92rem; line-height: 1.45; }

/* Tabs — one per document type (hue encodes type) */
.doc-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  max-width: min(100%, 52rem);
}
.doc-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .75rem .7rem;
  font-size: .85rem;
  font-weight: 600;
  font-family: var(--font);
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.doc-tab:hover { color: var(--doc, var(--accent)); background: color-mix(in srgb, var(--doc, var(--accent)) 10%, transparent); }
.doc-tab--active {
  color: #fff;
  background: var(--doc, var(--accent));
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.22);
}
.doc-tab__gem {
  width: 11px; height: 10px; flex: none;
  background: var(--doc, var(--accent));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transition: background .15s;
}
.doc-tab--active .doc-tab__gem { background: #fff; }
.doc-tab__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-tab__count {
  font-family: var(--mono); font-size: .72rem; font-weight: 700;
  padding: .02rem .42rem; border-radius: 99px;
  background: var(--border-soft); color: var(--muted);
  font-variant-numeric: tabular-nums; transition: background .15s, color .15s;
}
.doc-tab--active .doc-tab__count { background: rgba(255, 255, 255, 0.24); color: #fff; }
.doc-tab__count--bump {
  animation: doc-tab-count-bump 0.45s ease;
}
@keyframes doc-tab-count-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
@media (max-width: 560px) {
  .doc-tab { font-size: .74rem; padding: .6rem .35rem; gap: .3rem; }
  .doc-tab__gem { display: none; }
}

/* Tab panels — each holds one doc type's list */
.doc-panel { display: flex; flex-direction: column; gap: 1.1rem; }

/* Upload strips: consistent header band above the drop zone across account vs payment tabs */
.doc-upload-card > .card-header {
  box-sizing: border-box;
  min-height: 5.875rem;
  display: flex;
  align-items: center;
}

.doc-upload-card .doc-card-header-actions {
  width: 100%;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
}
.doc-upload-card .doc-card-header-actions h2 { margin: 0; }
.doc-card-header-actions__btns {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.excel-export-link { text-decoration: none; flex-shrink: 0; }

.doc-table-scroll { overflow-x: auto; }

/* Frozen thead + vertical scroll: inner wrapper only (no padding on scrollport) — avoids row paint bleeding into card padding above sticky header. */
.doc-table-scroll--sticky {
  isolation: isolate;
  overflow: auto;
  max-height: min(62vh, 560px);
  -webkit-overflow-scrolling: touch;
}

/* border-collapse:collapse breaks sticky thead in some engines */
.doc-table-scroll--sticky table {
  border-collapse: separate;
  border-spacing: 0;
}
.doc-table-scroll--sticky table thead th {
  position: sticky;
  top: 0;
  z-index: 15;
  background-color: var(--panel);
  background-clip: padding-box;
  box-shadow: 0 2px 6px rgba(0, 33, 71, 0.1);
}

/* Main document lists: one visual line per row where possible */
.doc-files-table {
  min-width: 58rem;
  table-layout: auto;
}
.doc-files-table th {
  white-space: nowrap;
}
.doc-files-table td {
  vertical-align: middle;
}
.doc-files-table td.doc-filename-cell {
  max-width: 18rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-files-table .doc-row-actions {
  flex-wrap: nowrap;
  white-space: nowrap;
}
.doc-files-table .payment-corpus-count {
  width: 1%;
  white-space: nowrap;
  text-align: center;
}
.doc-files-table .doc-extraction-status-cell {
  white-space: nowrap;
}

.doc-files-table--accounts {
  min-width: 70rem;
}

.doc-duplicate-cell {
  font-size: 0.8rem;
  max-width: 11rem;
  line-height: 1.35;
  vertical-align: middle;
}
.doc-duplicate-of-link {
  color: var(--muted);
  word-break: break-word;
}
.doc-duplicate-of-link:hover {
  color: var(--accent);
}

.doc-sort-btn.th-btn {
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: right;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.15rem;
}
.doc-sort-btn.th-btn:hover {
  color: var(--accent);
}
.doc-sort-btn--active.th-btn {
  color: var(--accent);
  font-weight: 600;
}
.doc-sort-ind {
  font-size: 0.78em;
  opacity: 0.82;
}

.doc-holder-cell {
  max-width: 16rem;
  word-break: break-word;
  font-size: 0.84rem;
  vertical-align: middle;
}

.doc-row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; justify-content: flex-end; }

.doc-panel[hidden] { display: none !important; }

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.5rem;
}

.upload-form__submit { margin-top: 1rem; }
.upload-form--busy .upload-form__submit {
  cursor: wait;
  opacity: 0.88;
}
.upload-form--busy .file-drop-zone {
  pointer-events: none;
  opacity: 0.62;
}
.upload-form--busy .file-drop-zone__input {
  cursor: not-allowed;
}

.upload-status--busy {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--info) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--info) 22%, var(--border));
  color: var(--navy);
  font-size: 0.88rem;
  font-weight: 500;
}
.upload-status--busy::before {
  content: "";
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  border: 2px solid color-mix(in srgb, var(--info) 22%, transparent);
  border-top-color: var(--info);
  border-radius: 50%;
  animation: upload-status-spin 0.7s linear infinite;
}
@keyframes upload-status-spin {
  to { transform: rotate(360deg); }
}

.file-drop-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: var(--surface);
  min-height: 8.5rem;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.file-drop-zone--active {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 1px rgba(0, 140, 186, 0.35);
}
.file-drop-zone__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.file-drop-zone__surface {
  pointer-events: none;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 8.5rem;
  padding: 1rem 1.1rem;
  text-align: center;
  gap: 0.35rem;
}
.file-drop-zone__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.file-drop-zone__sub {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.38;
  max-width: 18rem;
}
.file-drop-zone__filelist {
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--accent);
  max-width: 100%;
  padding: 0 0.5rem;
  list-style: none;
  text-align: right;
  max-height: 7.5rem;
  overflow-y: auto;
}
.file-drop-zone__filelist li {
  word-break: break-all;
  padding: 0.15rem 0;
  border-bottom: 1px solid rgba(0, 33, 71, 0.08);
}
.file-drop-zone__filelist li:last-child { border-bottom: none; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 1rem; font-weight: 600; color: var(--navy); }
.card-body { padding: 1.25rem; }

.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
  text-align: right; font-weight: 600; color: var(--muted);
  font-size: .78rem; text-transform: uppercase;
  padding: .7rem .5rem; border-bottom: 2px solid var(--border);
}
.table td { padding: .7rem .5rem; border-bottom: 1px solid rgba(0, 33, 71, 0.08); }
.table a { color: var(--accent); }

.badge { display: inline-block; padding: .2rem .55rem; font-size: .72rem; font-weight: 600; border-radius: 999px; }
.badge--info { background: var(--accent-dim); color: var(--accent-hover); }
.badge--payment { background: rgba(22,163,74,.12); color: #15803d; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .55rem 1.1rem; font-size: .88rem; font-weight: 600;
  border-radius: var(--radius); border: 1px solid var(--accent);
  cursor: pointer; text-decoration: none; font-family: var(--font);
  background: var(--accent); color: #fff;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-danger { background: var(--err); color: #fff; border-color: var(--err); }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline:hover { background: var(--accent-dim); color: var(--accent-hover); }
.btn-sm { padding: .3rem .65rem; font-size: .78rem; }
.btn-block { width: 100%; }

.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.form-group input {
  padding: .55rem .75rem; font-size: .9rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; color: var(--text); font-family: var(--font);
}
.form-group input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }

.alert { padding: .75rem 1rem; border-radius: var(--radius); font-size: .88rem; }
.alert-error { background: rgba(220,38,38,.08); color: #b91c1c; border: 1px solid rgba(220,38,38,.22); }
.alert-warning {
  background: rgba(234,179,8,.1);
  color: #a16207;
  border: 1px solid rgba(234,179,8,.28);
}

.extraction-alert-block { margin-bottom: 1rem; }
.extraction-section-stack {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  margin-bottom: 1.25rem;
}
.extraction-data-card { margin-bottom: 0; }
.extraction-raw-json-card {
  margin-top: 0;
}
.payment-summary-value--multiline {
  white-space: pre-wrap;
  line-height: 1.45;
}
.extraction-inline-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.84em;
  background: rgba(0, 33, 71, 0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.extraction-ltr-value {
  direction: ltr;
  unicode-bidi: plaintext;
  display: inline-block;
}

/* inline-block breaks <td>/<th> layout; keep numeric/IBAN columns as real table cells */
.table td.extraction-ltr-value,
.table th.extraction-ltr-value {
  display: table-cell;
  vertical-align: middle;
  text-align: right;
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}
.extraction-empty-hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.extraction-signatories-table th,
.extraction-signatories-table td {
  font-size: 0.82rem;
}
.account-incoming-payments-card { margin-bottom: 1.25rem; }
.account-incoming-payments-lead {
  font-size: 0.88rem;
  margin-bottom: 1rem !important;
}
.account-incoming-payments-table {
  min-width: 56rem;
}
.account-incoming-payments-table th,
.account-incoming-payments-table td {
  font-size: 0.8rem;
  vertical-align: top;
}
.account-incoming-payments-table .account-incoming-pay-file {
  max-width: 14rem;
  word-break: break-all;
}
.account-incoming-payments-total {
  margin-top: 1rem;
  font-size: 0.95rem;
}
.account-incoming-payments-meta {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.88rem;
}
.upload-status.alert-success {
  background: rgba(22,163,74,.1); color: #15803d;
  border: 1px solid rgba(22,163,74,.22); margin-top: .75rem; padding: .5rem .75rem; border-radius: var(--radius);
}
.upload-status.alert-error {
  background: rgba(220,38,38,.08); color: #b91c1c;
  border: 1px solid rgba(220,38,38,.22); margin-top: .75rem; padding: .5rem .75rem; border-radius: var(--radius);
}

.extraction-guessed-badge {
  display: inline-block;
  margin-inline-start: 0.25rem;
  padding: 0.05rem 0.4rem;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 600;
  vertical-align: middle;
  color: #92400e;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.doc-extraction-status-cell {
  vertical-align: middle;
  white-space: nowrap;
}

/* Document extraction status (lists + extraction headers) */
.extraction-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  line-height: 1.25;
  margin-inline-start: 0.35rem;
}
.extraction-status-badge--succeeded {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
  box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.25);
}
.extraction-status-badge--failed {
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.28);
}
.extraction-status-badge--processing {
  background: var(--accent-dim);
  color: var(--accent-hover);
  box-shadow: inset 0 0 0 1px rgba(0, 140, 186, 0.3);
}
.extraction-status-badge--skipped {
  background: rgba(234, 179, 8, 0.12);
  color: #a16207;
  box-shadow: inset 0 0 0 1px rgba(234, 179, 8, 0.25);
}
.extraction-status-badge--pending {
  background: rgba(92, 107, 122, 0.1);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px rgba(92, 107, 122, 0.2);
}

/* Inline “processing” indicator in document tables */
.doc-status-processing {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  color: inherit;
  line-height: 0;
}
.doc-status-spinner {
  width: 1.125rem;
  height: 1.125rem;
  animation: doc-status-spin 0.75s linear infinite;
}
@keyframes doc-status-spin {
  to { transform: rotate(-360deg); }
}

.extraction-view-header { margin-bottom: 1.25rem; }
.extraction-view-filename {
  font-size: 1.15rem;
  font-weight: 600;
  word-break: break-all;
}
.extraction-view-meta { margin-top: 0.4rem !important; }
.extraction-view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.extraction-json-card-body { padding: 0 !important; overflow: hidden; }
/* Collapsible raw JSON — closed by default (<details> without open) */
details.card.extraction-json-details {
  overflow: hidden;
}
details.card.extraction-json-details > summary.extraction-json-details-summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-inline-start: 1.85rem;
}
details.card.extraction-json-details > summary.extraction-json-details-summary::-webkit-details-marker {
  display: none;
}
details.card.extraction-json-details > summary.extraction-json-details-summary::before {
  content: "";
  position: absolute;
  inset-inline-start: 0.55rem;
  top: 50%;
  width: 0.4rem;
  height: 0.4rem;
  border-inline-end: 2px solid var(--accent);
  border-block-end: 2px solid var(--accent);
  transform: translateY(-50%) rotate(-45deg);
  transition: transform 0.15s ease;
}
details.card.extraction-json-details[open] > summary.extraction-json-details-summary::before {
  transform: translateY(-30%) rotate(45deg);
}
.extraction-json {
  margin: 0;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text);
  background: var(--surface);
  border-top: 1px solid var(--border);
  white-space: pre;
  unicode-bidi: plaintext;
}

.doc-toast-host {
  position: fixed;
  bottom: 1.25rem;
  left: 0;
  right: 0;
  z-index: 400;
  display: flex;
  justify-content: center;
  pointer-events: none;
  padding: 0 12px;
}
.doc-toast {
  max-width: min(92vw, 28rem);
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.35;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.doc-toast--visible {
  opacity: 1;
  transform: translateY(0);
}
.doc-toast--hide {
  opacity: 0;
  transform: translateY(6px);
}
.doc-toast--success {
  border-color: rgba(22,163,74,.3);
  background: rgba(22,163,74,.08);
}
.doc-toast--error {
  border-color: rgba(220,38,38,.35);
  background: rgba(220,38,38,.08);
  color: #b91c1c;
}

.payment-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.85rem 1.25rem;
}
.payment-summary-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.payment-summary-item--wide {
  grid-column: 1 / -1;
}
.payment-summary-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.payment-summary-value {
  font-size: 0.92rem;
  word-break: break-word;
}
.payment-lines-table th,
.payment-lines-table td {
  font-size: 0.82rem;
}

.payment-subtable-header {
  background: var(--surface);
  color: var(--text);
  padding: .4rem .75rem;
  font-weight: 600;
  border-top: 1px solid var(--border);
  margin-top: .5rem;
}

.appraisal-subtotal-row {
  font-weight: 600;
  background: var(--accent-dim);
  color: var(--text);
}
.appraisal-subtotal-row td {
  color: var(--text);
}

.appraisal-deduction-row,
.appraisal-deduction-row td {
  color: #b91c1c;
}

.payment-lines-table--with-match {
  min-width: 70rem;
}
.payment-line-row--ok td,
.appraisal-line-row--ok td {
  background: rgba(22, 163, 74, 0.12);
  border-bottom-color: rgba(22, 163, 74, 0.14);
}
.payment-line-row--ok td:first-child,
.appraisal-line-row--ok td:first-child {
  box-shadow: inset 3px 0 0 #16a34a;
}
.payment-line-row--warn td,
.appraisal-line-row--warn td {
  background: rgba(234, 179, 8, 0.12);
  border-bottom-color: rgba(217, 119, 6, 0.18);
}
.payment-line-row--warn td:first-child,
.appraisal-line-row--warn td:first-child {
  box-shadow: inset 3px 0 0 #d97706;
}
.payment-line-row--none td {
  background: rgba(92, 107, 122, 0.06);
}
/* Deep-link targets from appraisal match cells (and future cross-doc links). */
.payment-line-row:target td {
  background: rgba(0, 140, 186, 0.12);
  scroll-margin-top: 5rem;
}
.payment-line-row:target td:first-child {
  box-shadow: inset 3px 0 0 var(--accent, #008cba);
}
#account-approval:target {
  scroll-margin-top: 5rem;
  box-shadow: 0 0 0 2px rgba(0, 140, 186, 0.35);
}
.doc-payment-row--match-warn td {
  background: rgba(234, 179, 8, 0.08);
}
.doc-payment-row--match-warn td:first-child {
  box-shadow: inset 3px 0 0 #d97706;
}
.payment-corpus-count--warn {
  color: #a16207;
  font-weight: 700;
  background: rgba(234, 179, 8, 0.18);
}
.payment-corpus-count {
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}
.payment-match-cell {
  font-size: 0.78rem;
  line-height: 1.45;
  vertical-align: top;
  max-width: 22rem;
  word-break: break-word;
}
.payment-lines-match-hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 1rem 0;
  line-height: 1.45;
}
.payment-match-primary {
  display: block;
}
.payment-ambiguity-box {
  margin-top: 0.45rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
}
.payment-ambiguity-label {
  flex: 1 0 100%;
  font-size: 0.74rem;
  color: var(--muted);
  margin: 0;
  font-weight: 500;
}
.payment-ambiguity-select {
  flex: 1 1 14rem;
  min-width: 11rem;
  max-width: 100%;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 0.8rem;
}
.payment-match-method {
  display: inline-block;
}
.payment-match-link {
  color: var(--accent);
  text-decoration: underline;
  word-break: break-word;
}
.payment-match-cell--ok,
.appraisal-match-cell--ok {
  background: rgba(22, 163, 74, 0.1);
  box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.22);
}
.payment-match-cell--warn,
.appraisal-match-cell--warn {
  background: rgba(234, 179, 8, 0.16);
  box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.35);
  color: #92400e;
}
.payment-match-cell--warn .payment-match-primary {
  font-weight: 600;
}
.payment-match-cell--none,
.appraisal-match-cell--none {
  background: rgba(92, 107, 122, 0.08);
  color: var(--muted);
}

/* Appraisal ambiguity candidate list (method sub-text reuses .payment-match-method). */
.appraisal-candidates {
  margin: 0.25rem 0 0;
  padding-inline-start: 1rem;
  font-size: 0.75rem;
}
/* Composite state badge (dot) in the מצב column. */
.appraisal-state-badge {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--muted);
}
.appraisal-state-badge--ok {
  background: #16a34a;
}
.appraisal-state-badge--warn {
  background: #d97706;
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.timeline-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
}
.timeline-item--failure {
  border-color: rgba(220,38,38,.3);
}
.timeline-item__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.timeline-item__time {
  font-size: 0.8rem;
  color: var(--muted);
}
.timeline-status {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}
.timeline-status--success { background: rgba(22,163,74,.12); color: #15803d; }
.timeline-status--failure { background: rgba(220,38,38,.1); color: #b91c1c; }
.timeline-status--pending { background: rgba(92,107,122,.1); color: var(--muted); }
.timeline-status--info { background: var(--accent-dim); color: var(--accent-hover); }
.timeline-status--skipped { background: rgba(234,179,8,.12); color: #a16207; }

.timeline-item__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.timeline-item__key {
  margin-bottom: 0.5rem;
}
.timeline-item__key code {
  font-size: 0.75rem;
  color: var(--muted);
}
.timeline-item__msg {
  font-size: 0.9rem;
  line-height: 1.45;
  margin-bottom: 0.5rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.timeline-item__dur {
  font-size: 0.8rem;
  color: var(--muted);
}
.timeline-item__meta {
  margin-top: 0.65rem;
}
.timeline-item__meta summary {
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--accent);
}
.timeline-meta-pre {
  margin-top: 0.5rem;
  max-height: 14rem;
  overflow: auto;
  font-size: 0.76rem;
  border-radius: var(--radius);
}

/* Account dedupe preview modal */
.dedupe-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 33, 71, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.dedupe-modal-backdrop[hidden] {
  display: none;
}
.dedupe-modal {
  width: 100%;
  max-width: min(44rem, calc(100vw - 2rem));
  max-height: min(85vh, 880px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  outline: none;
}
.dedupe-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.dedupe-modal__title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}
.dedupe-modal__close {
  flex-shrink: 0;
}
.dedupe-modal__lead {
  padding: 0.75rem 1.25rem 0;
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}
.dedupe-modal__body {
  padding: 0.85rem 1.25rem 1rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.dedupe-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.25rem 1rem;
  border-top: 1px solid var(--border);
}
.dedupe-group-card {
  margin-bottom: 0.85rem;
}
.dedupe-group-card:last-child {
  margin-bottom: 0;
}
.dedupe-group-card .card-body {
  padding-top: 0.65rem;
}
.dedupe-group-title {
  font-size: 0.98rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.35;
}
.dedupe-doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: dedupe-li;
}
.dedupe-doc-row {
  position: relative;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  counter-increment: dedupe-li;
}
.dedupe-doc-row:last-child {
  border-bottom: none;
}
.dedupe-doc-row::before {
  content: counter(dedupe-li) ". ";
  font-weight: 600;
  color: var(--muted);
  margin-inline-end: 0.35rem;
}
.dedupe-doc-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  margin-top: 0.35rem;
}
.dedupe-doc-meta {
  display: inline-block;
  margin-inline-start: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.dedupe-doc-sum {
  margin-top: 0.35rem;
  font-size: 0.84rem;
  color: var(--text);
  opacity: 0.92;
}
.dedupe-badge {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  margin-inline-end: 0.35rem;
  vertical-align: middle;
}
.dedupe-badge--kept {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--border);
}
.dedupe-badge--dup {
  background: rgba(220, 38, 38, 0.08);
  color: var(--err);
  border: 1px solid rgba(220, 38, 38, 0.28);
}

/* ── Document progress bar (in table status cells + upload panel) ──────── */
.doc-progress {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 7rem;
}
.doc-progress__bar {
  height: 6px;
  background: var(--panel);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.doc-progress__fill {
  height: 100%;
  background: var(--info);
  border-radius: 3px;
  transition: width 0.5s ease;
}
.doc-progress__fill--failed { background: var(--err); }
.doc-progress__meta {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: .7rem;
  color: var(--muted);
  direction: ltr;
}
.doc-progress__label { direction: rtl; flex: 1; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-progress__pct { font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* ── Upload pipeline progress bars ──────────────────────────────────────── */
.upload-progress-list {
  margin-top: .75rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
.upload-progress-list--pending {
  margin-top: .65rem;
}
.upload-progress-row--pending {
  border-style: dashed;
  opacity: 0.95;
}
.upload-progress-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .85rem .65rem;
  overflow: hidden;
}
.upload-progress-name {
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: .45rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: ltr;
  text-align: left;
}
.upload-progress-steps {
  display: flex;
  align-items: flex-start;
  direction: ltr;
}
.upload-progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  gap: 4px;
  min-width: 52px;
}
.upload-progress-step__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--panel);
  border: 2px solid var(--border);
  transition: background .25s, border-color .25s, box-shadow .25s;
  flex-shrink: 0;
}
.upload-progress-step__label {
  font-size: .6rem;
  color: var(--muted);
  white-space: nowrap;
  transition: color .25s;
  text-align: center;
  line-height: 1.2;
}
.upload-progress-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin-top: 5px;
  margin-bottom: 20px;
  transition: background .3s;
  min-width: 10px;
}
/* done */
.upload-progress-step--done .upload-progress-step__dot  { background: var(--ok); border-color: var(--ok); }
.upload-progress-step--done .upload-progress-step__label { color: var(--ok); }
.upload-progress-connector--done { background: var(--ok); }
/* active */
.upload-progress-step--active .upload-progress-step__dot {
  background: var(--info);
  border-color: var(--info);
  animation: up-step-pulse 1.15s ease-in-out infinite;
}
.upload-progress-step--active .upload-progress-step__label { color: var(--info); font-weight: 600; }
/* failed */
.upload-progress-step--failed .upload-progress-step__dot  { background: var(--err); border-color: var(--err); }
.upload-progress-step--failed .upload-progress-step__label { color: var(--err); }
@keyframes up-step-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,140,186,.45); }
  50%       { box-shadow: 0 0 0 6px rgba(0,140,186,0); }
}

/* ═══════════════════════════════════════════════════════════════════════
   BRKT redesign — validation console: ribbon, triptych board, gem chips
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Page head (upload console) ─────────────────────────────────────────── */
.console-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: .4rem 2rem; margin-bottom: 1.35rem;
}
.console-head__eyebrow {
  font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent-hover); margin-bottom: .35rem;
}
.console-head__title { font-size: 1.6rem; font-weight: 800; letter-spacing: -.01em; color: var(--navy); text-wrap: balance; }
.console-head__lead { color: var(--muted); font-size: .92rem; max-width: 44ch; line-height: 1.45; }

/* ── Validation ribbon (summary before detail) ──────────────────────────── */
.val-ribbon {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 1.1rem 1.4rem;
  padding: .95rem 1.15rem; margin-bottom: 1.5rem;
  background: linear-gradient(90deg, var(--accent-dim), transparent 42%), var(--panel);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm);
}
.val-ribbon__state { display: flex; align-items: center; gap: .7rem; }
.val-ribbon__pulse { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); animation: val-pulse 1.9s infinite; flex: none; }
.val-ribbon__now { font-weight: 700; color: var(--navy); }
.val-ribbon__sub { font-size: .78rem; color: var(--muted); }
.val-ribbon__steps { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.vstep {
  display: flex; align-items: center; gap: .55rem; flex: 1; min-width: 11rem;
  padding: .5rem .75rem; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border-soft);
}
.vstep__gem { width: 12px; height: 11px; flex: none; background: var(--doc, var(--accent)); clip-path: polygon(0 0, 100% 0, 50% 100%); }
.vstep__body { display: flex; flex-direction: column; min-width: 0; }
.vstep__label { font-size: .8rem; font-weight: 600; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vstep__count { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
@keyframes val-pulse {
  0% { box-shadow: 0 0 0 0 var(--accent-dim); }
  70% { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ── Upload board (unified auto-detect) ─────────────────────────────────── */
.upload-board {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.6rem;
  align-items: stretch;
}
.upload-board--unified {
  grid-template-columns: 1fr;
}
@media (max-width: 820px) { .upload-board { grid-template-columns: 1fr; } }
.upload-cell { display: flex; flex-direction: column; }
.upload-cell .upload-form { display: flex; flex-direction: column; flex: 1; }
.upload-cell--unified .upload-cell__type { color: var(--navy); }
.upload-cell__hint {
  margin: 0 0 .75rem;
  font-size: .82rem;
  line-height: 1.45;
  color: var(--muted);
}
.upload-cell__type {
  display: flex; align-items: center; gap: .5rem; margin-bottom: .55rem;
  font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--doc, var(--accent));
}
.upload-cell__type::before {
  content: ""; width: 12px; height: 11px; flex: none;
  background: var(--doc, var(--accent)); clip-path: polygon(0 0, 100% 0, 50% 100%);
}

/* Themed drop zone (reuses .file-drop-zone JS hooks) */
.file-drop-zone--gem {
  flex: 1;
  border-color: color-mix(in srgb, var(--doc, var(--accent)) 32%, var(--border));
  background: var(--panel);
}
.file-drop-zone--gem::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: radial-gradient(150px 90px at 50% 0%, color-mix(in srgb, var(--doc, var(--accent)) 12%, transparent), transparent 72%);
}
.file-drop-zone--gem.file-drop-zone--active {
  border-color: var(--doc, var(--accent));
  background: color-mix(in srgb, var(--doc, var(--accent)) 7%, var(--panel));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--doc, var(--accent)) 20%, transparent);
}
.file-drop-zone--gem .file-drop-zone__title { color: var(--navy); }
.file-drop-zone--unified {
  min-height: 9.5rem;
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
}
.file-drop-zone--unified::after {
  background: radial-gradient(220px 110px at 50% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 72%);
}

/* ── Unified list card (identical chrome; hue = doc type) ────────────────── */
.doc-lists { display: flex; flex-direction: column; gap: 1.1rem; }
.listcard { --doc: var(--accent); }
.listcard > .card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: linear-gradient(90deg, color-mix(in srgb, var(--doc) 7%, transparent), transparent 55%);
}
.listcard__id { display: flex; align-items: center; gap: .55rem; }
.listcard__id::before {
  content: ""; width: 13px; height: 12px; flex: none;
  background: var(--doc); clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.listcard__id h2 { margin: 0; }
.listcard__count {
  font-family: var(--mono); font-size: .74rem; font-weight: 700; color: var(--doc);
  background: color-mix(in srgb, var(--doc) 13%, transparent);
  padding: .05rem .5rem; border-radius: 99px; font-variant-numeric: tabular-nums;
}

/* ── Extraction view — functionality pinned at top (docbar) ──────────────── */
.docbar {
  --doc: var(--accent);
  position: sticky; top: calc(var(--header-h) + .4rem); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .8rem 1.1rem; margin-bottom: 1.4rem;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border: 1px solid var(--border); border-inline-start: 3px solid var(--doc);
  border-radius: 14px; box-shadow: var(--shadow-sm);
}
.docbar__id { display: flex; align-items: center; gap: .7rem; min-width: 0; flex-wrap: wrap; }
.docbar__id::before {
  content: ""; width: 20px; height: 18px; flex: none;
  background: var(--doc); clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.docbar__text { display: flex; flex-direction: column; min-width: 0; }
.docbar__type { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--doc); }
.docbar__file { font-size: 1.05rem; font-weight: 700; word-break: break-all; color: var(--navy); }
.docbar__act { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }

/* confidence meter (extraction classification) */
.conf-meter { display: inline-flex; align-items: center; gap: .5rem; }
.conf-meter__track { width: 6.5rem; max-width: 40vw; height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; }
.conf-meter__fill { display: block; height: 100%; background: var(--ok); }
.conf-meter__val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .85rem; }

/* Document-pairing banner on the appraisal extraction page.
   Reuses the payment/appraisal row tone palette so states read consistently. */
.pair-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 0.85rem;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.92rem;
  line-height: 1.5;
}
.pair-banner__message { font-weight: 600; }
.pair-banner__doc { font-weight: 600; text-decoration: underline; }
.pair-banner__candidates {
  flex-basis: 100%;
  margin: 0.35rem 0 0;
  padding-inline-start: 1.1rem;
}
.pair-banner__candidates li { margin: 0.15rem 0; }
.pair-banner__meta { opacity: 0.75; font-size: 0.86rem; }

.pair-banner--strong {
  background: rgba(22, 163, 74, 0.12);
  box-shadow: inset 3px 0 0 #16a34a;
}
.pair-banner--ambiguous {
  background: rgba(234, 179, 8, 0.12);
  box-shadow: inset 3px 0 0 #d97706;
}
.pair-banner--none {
  background: rgba(148, 163, 184, 0.16);
  box-shadow: inset 3px 0 0 #64748b;
}
