/* Стилистика «tear sheet»: светло-серый фон, белые карточки, моноширинный шрифт,
   чёрные акцентные кнопки, янтарные индикаторы. Зелёный — приходы, красный — расходы. */
:root {
  --bg: #ededed;
  --card: #ffffff;
  --border: #dcdcdc;
  --border-soft: #e9e9e9;
  --text: #141414;
  --muted: #7a7a7a;
  --accent: #e8a020;
  --accent-light: #fdf3e0;
  --green: #2e7d32;
  --green-light: #eaf4ea;
  --red: #c22f2f;
  --red-light: #fbecec;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 13.5px/1.5 var(--mono);
}
#root { max-width: 1320px; margin: 0 auto; padding: 0 20px 60px; }

h1 {
  font-size: 17px; margin: 0; color: var(--text);
  text-transform: uppercase; letter-spacing: .14em; font-weight: 800;
}
h2 {
  font-size: 15px; margin: 0 0 12px; font-weight: 700;
  letter-spacing: .02em;
}

/* --- шапка --- */
.topbar {
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
  background: var(--card); border-bottom: 1px solid var(--border);
  margin: 0 calc(50% - 50vw) 18px;                 /* белая полоса на всю ширину окна */
  padding: 13px calc(50vw - 50% + 20px);
}
.tabs { display: flex; gap: 22px; flex: 1; }
.tab {
  padding: 4px 0; border: none; background: none; color: var(--muted);
  font: inherit; font-size: 13.5px; cursor: pointer;
  border-bottom: 2px solid transparent; border-radius: 0;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); font-weight: 700; }
.userbox { color: var(--muted); font-size: 12.5px; display: flex; gap: 10px; align-items: center; }

/* --- кнопки --- */
button { font: inherit; cursor: pointer; }
.btn {
  background: var(--text); color: #fff; border: 1px solid var(--text);
  border-radius: 8px; padding: 8px 16px; font-size: 13px;
}
.btn:hover { background: #333; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-outline {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 14px; font-size: 13px;
}
.btn-outline:hover { border-color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-link {
  background: none; border: none; color: var(--muted); padding: 2px 4px;
  font-size: 12px; text-decoration: underline; text-underline-offset: 3px;
}
.btn-link:hover { color: var(--text); }
.btn-link.danger { color: var(--red); }

/* --- формы --- */
input, select {
  font: inherit; color: inherit; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card);
}
input:focus, select:focus { outline: 2px solid var(--text); outline-offset: -1px; }
input::placeholder { color: #a8a8a8; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--text); }

/* --- тулбар (фильтры) --- */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 14px;
}
.toolbar .spacer { flex: 1; }
.section .toolbar { border: none; padding: 0 0 12px; border-radius: 0; }

/* --- блок сверки --- */
.recon {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 18px; margin-bottom: 14px;
}
.recon-row { display: flex; gap: 34px; flex-wrap: wrap; align-items: baseline; }
.recon-cell .k {
  font-size: 10.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .09em;
}
.recon-cell .v { font-size: 18px; font-weight: 700; margin-top: 2px; }
.recon table { margin-top: 12px; }
.ok { color: var(--green); }
.bad { color: var(--red); }

/* --- итоги по фильтру --- */
.filter-totals {
  display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap;
  background: var(--accent-light); border: 1px solid #f0ddb4;
  border-radius: 12px; padding: 9px 16px; margin-bottom: 12px; font-size: 13px;
}

/* --- таблица --- */
table {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden;
}
th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .09em;
  padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--card);
}
td { padding: 8px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tr:hover td { background: #f7f7f5; }
tr.split-row td { background: #fafafa; color: var(--muted); font-size: 12.5px; }
tr.deleted td { opacity: .5; }
tr.deleted .amount, tr.deleted .badge { text-decoration: line-through; }

.amount { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.minus { font-size: .75em; margin-right: 4px; vertical-align: 1px; }
.income { color: var(--green); }
.expense { color: var(--red); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 5px;
  font-size: 11.5px; border: 1px solid transparent;
}
.badge.income { background: var(--green-light); border-color: #cfe5cf; }
.badge.expense { background: var(--red-light); border-color: #efd2d2; }
.badge.gray { background: #f1f1f1; color: var(--muted); border-color: var(--border-soft); }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* --- модалка (существующие диалоги; новых всплывающих окон нет) --- */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 20, 20, .45);
  display: flex; align-items: flex-start; justify-content: center; z-index: 50;
  overflow-y: auto; padding: 7vh 16px;   /* скроллится подложка — модалка не режет комбо-списки */
}
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 22px; width: 680px; max-width: 94vw; overflow: visible;
}
.modal .combo { flex: 1; }
.modal h3 { margin: 0 0 14px; font-size: 15px; }
.modal .row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.checksum { padding: 10px 12px; border-radius: 8px; margin: 10px 0; font-weight: 700; }
.checksum.ok { background: var(--green-light); }
.checksum.bad { background: var(--red-light); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

/* --- логин --- */
.login {
  max-width: 360px; margin: 14vh auto; text-align: center;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 34px 30px;
}
.login h1 { font-size: 15px; }
.error { color: var(--red); font-size: 13px; }
.notice {
  background: var(--accent-light); border: 1px solid #f0ddb4; border-radius: 10px;
  padding: 10px 14px; font-size: 13px; margin-bottom: 14px;
}
.notice.error { background: var(--red-light); border-color: #efd2d2; }

.section {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; margin-bottom: 18px;
}
.section table { border: none; border-top: 1px solid var(--border); border-radius: 0; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; font-size: 12.5px; }

/* --- инлайн-комбобокс (статья, SubID) --- */
.combo { position: relative; min-width: 130px; }
.combo input { width: 100%; padding: 5px 8px; font-size: 12.5px; border-radius: 6px; }
.combo input.combo-empty { border-color: #e4b7b7; }
.combo input.combo-empty::placeholder { color: var(--red); opacity: .6; }
.combo-list {
  position: absolute; top: 100%; left: 0; min-width: 100%; width: max-content; max-width: 340px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 22px rgba(20, 20, 20, .14); max-height: 260px; overflow: auto; z-index: 30;
}
.combo-opt { padding: 7px 10px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-opt:hover { background: var(--accent-light); }
.combo-opt.combo-clear { color: var(--muted); font-style: italic; border-bottom: 1px solid var(--border-soft); }

/* --- инлайн-редактирование текста в ячейке --- */
.inline-edit { display: inline-flex; align-items: center; gap: 4px; width: 100%; }
.inline-edit input {
  width: 100%; min-width: 80px; padding: 4px 6px; font-size: 12.5px;
  border-radius: 6px; border-color: transparent; background: transparent;
}
.inline-edit input:hover { border-color: var(--border); }
.inline-edit input:focus { background: var(--card); }
.inline-edit input::placeholder { color: #c2c2c2; }

/* --- слайдер активности --- */
.switch {
  width: 38px; height: 22px; border-radius: 999px; border: none; padding: 2px;
  background: #cfcfcf; cursor: pointer; display: inline-flex; align-items: center;
  transition: background .15s;
}
.switch .knob {
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s;
}
.switch.on { background: var(--accent); }
.switch.on .knob { transform: translateX(16px); }

/* --- прочее --- */
.sync-ico { font-size: 17px; line-height: 1; vertical-align: -2px; }
.copy { background: none; border: none; color: #b0b0b0; cursor: pointer; font-size: 12px; padding: 0 4px; vertical-align: baseline; }
.copy:hover { color: var(--text); }
td a.mono { color: var(--text); }
a { color: var(--text); }
