/* ЮгСтройИнвест — согласование реестров счетов.
   Палитра и пластика взяты из образца, вёрстка переработана под адаптив:
   таблица живёт на десктопе, на узких экранах те же данные показываются карточками. */

:root {
  --bg: #f4f4ef;
  --surface: #ffffff;
  --surface-soft: #f8f8f4;
  --line: #e6e7e2;
  --line-strong: #d9dcd5;
  --text: #1c252c;
  --muted: #6d777c;
  --blue: #115c8d;
  --blue-deep: #0b4b76;
  --blue-soft: #eaf3f8;
  --green: #557a46;
  --green-soft: #edf4e8;
  --amber: #9b6c13;
  --amber-soft: #fff5dc;
  --red: #9b4d47;
  --red-soft: #faeceb;
  --shadow: 0 14px 40px rgba(26, 45, 55, 0.07);
  --shadow-soft: 0 7px 22px rgba(26, 45, 55, 0.06);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
a { color: var(--blue); }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ─────────────────────────── Шапка ─────────────────────────── */

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; flex: 0 0 auto; }
.brand-logo { height: 60px; width: auto; display: block; }

.top-nav { display: flex; gap: 4px; margin-left: 10px; }
.top-nav button {
  border: 0; background: transparent; color: #56636a;
  font-weight: 650; font-size: 13px; padding: 9px 14px; border-radius: 999px;
}
.top-nav button:hover { background: var(--surface-soft); color: var(--text); }
.top-nav button.active { background: var(--blue-soft); color: var(--blue-deep); }

.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.topbar-link { border: 0; background: transparent; color: var(--blue-deep); font-weight: 650; padding: 10px 4px; font-size: 13px; }
.topbar-link:hover { color: var(--blue); }

.logout-button {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-soft); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 15px;
  color: #455158; font-size: 13px; font-weight: 650;
}
.logout-button svg {
  width: 17px; height: 17px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.logout-button:hover { background: var(--red-soft); border-color: #efd6d3; color: var(--red); }

/* ─────────────────────────── Общее ─────────────────────────── */

.main-content { padding: 26px 28px 40px; max-width: 1920px; margin: 0 auto; width: 100%; flex: 1; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--blue); font-weight: 760; }
h1 { margin: 0; font-size: 30px; line-height: 1.1; letter-spacing: -.035em; font-weight: 720; }

.secondary-button, .primary-button {
  min-height: 44px; border-radius: 13px; padding: 0 16px; font-weight: 680;
  border: 1px solid var(--line-strong); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.secondary-button { background: var(--surface); color: #455158; }
.secondary-button:hover { background: #fbfbf8; border-color: #cfd4cc; }
.primary-button { background: var(--blue-deep); color: #fff; border-color: var(--blue-deep); }
.primary-button:hover { background: var(--blue); }
.primary-button:disabled, .secondary-button:disabled { cursor: default; opacity: .5; }
.danger-button { background: #8e4944; color: #fff; border-color: #8e4944; }
.danger-button:hover { background: #7d403c; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  border-radius: 999px; padding: 6px 11px; font-size: 12px; font-weight: 700;
  background: var(--surface-soft); color: #55616a; border: 1px solid var(--line);
}
.badge.city { background: var(--blue-soft); color: var(--blue-deep); border-color: #d7e8f0; }
.badge.pending { background: var(--amber-soft); color: var(--amber); border-color: #f0e1b6; }
.badge.approved { background: var(--green-soft); color: var(--green); border-color: #dce9d4; }
.badge.rejected { background: var(--red-soft); color: var(--red); border-color: #efd6d3; }

.field-label { display: block; font-size: 11px; font-weight: 700; color: #5d686e; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em; }
.text-input, .select-input, .textarea-input {
  width: 100%; min-height: 44px; padding: 10px 13px;
  border: 1px solid var(--line-strong); border-radius: 11px;
  background: #fff; color: var(--text); font-size: 13px; outline: 0;
}
.textarea-input { min-height: 92px; resize: vertical; line-height: 1.4; }
.text-input:focus, .select-input:focus, .textarea-input:focus { border-color: #9bb7c8; box-shadow: 0 0 0 3px #eaf3f8; }
.text-input.invalid, .textarea-input.invalid { border-color: #d3a19c; box-shadow: 0 0 0 3px #faeceb; }
.hint { margin: 6px 0 0; font-size: 11px; color: var(--muted); line-height: 1.45; }
.error-text { margin: 8px 0 0; font-size: 12px; color: #9a4945; font-weight: 620; }

/* ─────────────────────────── Вход ─────────────────────────── */

.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #e7f1f6 0%, var(--bg) 60%);
}
.login-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-xl); box-shadow: var(--shadow); padding: 34px 30px 28px;
}
.login-card .brand { justify-content: center; margin-bottom: 22px; }
.login-card .brand-logo { height: 52px; }
.login-card h1 { font-size: 22px; text-align: center; margin: 0 0 22px; }
.login-form { display: grid; gap: 14px; }
.login-form .primary-button { width: 100%; min-height: 48px; margin-top: 4px; }

/* ─────────────────────── Реестр: шапка ─────────────────────── */

.hero-panel { display: flex; justify-content: space-between; align-items: flex-end; gap: 22px; padding: 4px 4px 20px; flex-wrap: wrap; }
.hero-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hero-meta { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.hero-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-box {
  width: 300px; max-width: 100%; height: 44px; display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 13px;
  padding: 0 13px; box-shadow: 0 2px 8px rgba(26, 45, 55, .02);
}
.search-icon { width: 14px; height: 14px; border: 2px solid #8a9499; border-radius: 50%; position: relative; flex: 0 0 auto; }
.search-icon:after { content: ""; position: absolute; width: 6px; height: 2px; background: #8a9499; transform: rotate(45deg); right: -5px; bottom: -2px; border-radius: 2px; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }
.search-box input::placeholder { color: #9aa2a6; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card {
  padding: 17px 19px 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: 0 4px 20px rgba(26, 45, 55, .035);
}
.stat-card.accent-card { background: #f0f6f8; border-color: #dce9ee; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 620; }
.stat-value { margin-top: 8px; font-size: 23px; font-weight: 740; letter-spacing: -.03em; overflow-wrap: anywhere; }
.stat-note { margin-top: 5px; color: #8b9498; font-size: 11px; }

.registry-card, .summary-card, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl);
  box-shadow: var(--shadow); overflow: hidden;
}
.registry-card-head, .panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 22px 17px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.registry-card-head h2, .panel-head h2 { margin: 0; font-size: 17px; font-weight: 720; letter-spacing: -.02em; }
.registry-card-head p, .panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.legend { display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: 11px; flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.legend-dot.pending { background: #d7ad50; }
.legend-dot.approved { background: #73935e; }
.legend-dot.rejected { background: #b8756f; }

/* ───────────────────── Реестр: таблица ─────────────────────── */

.table-wrap { overflow-x: auto; }
.registry-table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; min-width: 1240px; }
.registry-table thead th {
  padding: 13px 12px; background: #f8f8f5;
  color: #606b70; font-size: 10px; line-height: 1.25; font-weight: 700;
  text-align: left; text-transform: uppercase; letter-spacing: .055em;
  border-bottom: 1px solid var(--line);
}
.registry-table thead th span { text-transform: none; letter-spacing: 0; font-weight: 600; display: block; }
.registry-table tbody td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 12px; }
.registry-table tbody tr.invoice-row:hover td { background: #fcfcfa; }
.registry-table tbody tr.invoice-row.is-approved td { background: #fdfefc; }
.registry-table tbody tr.invoice-row.is-rejected td { background: #fdfaf9; }
.registry-table tbody tr:last-child td { border-bottom: 0; }
.col-number { width: 48px; }
.col-details { width: 145px; }
.col-action { width: 180px; }
.col-comment { width: 225px; }
.row-number { color: #8a9499; font-weight: 700; }
.cell-title { color: var(--blue-deep); font-weight: 670; line-height: 1.35; overflow-wrap: anywhere; }
.cell-meta { margin-top: 4px; color: #8a9499; font-size: 10px; }
.cell-text { line-height: 1.38; color: #2d393f; overflow-wrap: anywhere; }
.purpose-link { color: var(--blue); font-weight: 620; text-decoration: none; }
.purpose-link:hover { text-decoration: underline; }
.cell-date { white-space: nowrap; color: #566267; }
.cell-money { white-space: nowrap; font-weight: 730; font-variant-numeric: tabular-nums; }

.details-button {
  width: 100%; min-height: 38px; border: 1px solid #cfe1e9; background: #eaf5f8; color: var(--blue-deep);
  border-radius: 10px; font-weight: 720; font-size: 11px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px;
}
.details-button:hover { background: #e1f0f4; }
.details-button:after { content: "⌄"; font-size: 15px; transform: translateY(-1px); transition: .2s ease; }
.details-button.expanded:after { transform: rotate(180deg) translateY(-1px); }

.action-menu { position: relative; }
.action-trigger {
  width: 100%; min-height: 38px; border-radius: 999px; padding: 0 12px;
  border: 1px solid transparent; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11px; font-weight: 720;
}
.action-trigger:after { content: ""; width: 6px; height: 6px; border-right: 1.7px solid currentColor; border-bottom: 1.7px solid currentColor; transform: rotate(45deg) translateY(-2px); opacity: .75; }
.action-trigger[disabled]:after { display: none; }
.action-trigger.status-pending { background: var(--amber-soft); color: var(--amber); border-color: #f0e1b6; }
.action-trigger.status-approved { background: var(--green-soft); color: var(--green); border-color: #dbe8d5; }
.action-trigger.status-rejected { background: var(--red-soft); color: var(--red); border-color: #efd6d3; }
.action-trigger.status-locked { background: #f1f2ef; color: #747d81; border-color: #e3e5df; cursor: default; }
.action-dropdown {
  display: none; position: fixed; min-width: 225px; padding: 7px;
  background: #fff; border: 1px solid var(--line); border-radius: 13px;
  box-shadow: 0 16px 38px rgba(19, 39, 51, .15); z-index: 100;
}
.action-dropdown.open { display: block; }
.action-option {
  width: 100%; min-height: 38px; border: 0; border-radius: 9px; background: transparent;
  text-align: left; padding: 0 11px; color: #3e4b52; font-size: 12px; font-weight: 630;
}
.action-option:hover { background: #f4f5f1; }
.action-option.approve { color: #4b7040; }
.action-option.reject { color: #9a4945; }

.comment-field {
  width: 100%; min-height: 54px; max-height: 120px; resize: vertical;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 10px;
  color: #3e4a50; background: #fff; outline: 0; line-height: 1.35; font-size: 11px;
}
.comment-field:focus { border-color: #9bb7c8; box-shadow: 0 0 0 3px #eaf3f8; }
.comment-field:disabled { background: #fafaf7; color: #697478; opacity: 1; }

.detail-row td { padding: 0 !important; background: #f4f8f9 !important; }
.detail-panel {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1px;
  background: #dfeaed; border-bottom: 1px solid #dfeaed;
}
.detail-block { background: #f1f7f8; padding: 17px; }
.detail-block-title { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #75858d; font-weight: 730; margin-bottom: 11px; }
.detail-list { display: grid; gap: 9px; }
.detail-item { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; font-size: 11px; line-height: 1.3; }
.detail-item span:first-child { color: #78858b; }
.detail-item span:last-child { color: #35434a; font-weight: 600; overflow-wrap: anywhere; }
.detail-source { display: inline-flex; align-items: center; gap: 7px; color: var(--blue-deep); background: #e5f0f4; border-radius: 999px; padding: 6px 9px; font-size: 10px; font-weight: 680; }
.open-invoice-button { margin-top: 12px; min-height: 36px; padding: 0 12px; border: 1px solid #b9d2dd; background: #fff; color: var(--blue-deep); border-radius: 9px; font-weight: 680; font-size: 10px; }
.open-invoice-button:hover { background: #f7fbfc; }

/* ─────────── Реестр: карточки для узких экранов ─────────── */

.invoice-cards { display: none; padding: 14px; gap: 12px; grid-template-columns: 1fr; }
.invoice-card { border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff; overflow: hidden; }
.invoice-card.is-approved { background: #fcfefb; }
.invoice-card.is-rejected { background: #fefaf9; }
.invoice-card-head { display: flex; justify-content: space-between; gap: 12px; padding: 14px 15px 12px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.invoice-card-head .num { font-size: 11px; color: #8a9499; font-weight: 700; }
.invoice-card-head .title { margin-top: 3px; font-size: 13px; font-weight: 700; color: var(--blue-deep); line-height: 1.3; overflow-wrap: anywhere; }
.invoice-card-body { padding: 12px 15px; display: grid; gap: 9px; }
.card-line { display: grid; grid-template-columns: minmax(96px, 40%) minmax(0, 1fr); gap: 10px; font-size: 12px; line-height: 1.35; }
.card-line span:first-child { color: #78858b; }
.card-line span:last-child { color: #2d393f; font-weight: 620; overflow-wrap: anywhere; }
.card-line.total span:last-child { font-weight: 760; }
.invoice-card-foot { padding: 0 15px 14px; display: grid; gap: 9px; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card-actions button { min-height: 40px; border-radius: 11px; font-size: 12px; font-weight: 700; border: 1px solid var(--line-strong); }
.card-actions .approve { background: var(--green-soft); color: var(--green); border-color: #dbe8d5; }
.card-actions .reject { background: var(--red-soft); color: var(--red); border-color: #efd6d3; }
.card-extra { padding: 0 15px 14px; }

.empty-state { padding: 52px 20px; text-align: center; }
.empty-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; margin: 0 auto 13px; background: #edf2f3; color: #75858d; font-weight: 760; }
.empty-state h3 { margin: 0; font-size: 16px; }
.empty-state p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }

.summary-card { margin-top: 16px; }
.summary-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding: 20px 22px 17px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.summary-head h2 { margin: 6px 0 0; font-size: 17px; font-weight: 720; }
.summary-total { text-align: right; }
.summary-total strong { font-size: 22px; letter-spacing: -.03em; }
.summary-total span { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.registry-bulk-actions {
  display: flex; justify-content: flex-end; align-items: center; gap: 12px;
  padding: 18px 22px 20px; border-top: 1px solid var(--line); background: #fbfbf8; flex-wrap: wrap;
}
.registry-bulk-actions button { min-width: 190px; }
.bulk-reject-button { color: var(--red); border-color: #e6c9c6; }
.bulk-reject-button:hover { background: var(--red-soft); border-color: #ddb8b4; }

.sync-line { padding: 12px 4px 0; color: #90999d; font-size: 11px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.sync-line b { color: #636f75; font-weight: 650; }

/* ─────────────────────────── Настройки ─────────────────────────── */

.settings-head { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.settings-head .icon {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: 0 0 auto;
  background: linear-gradient(140deg, var(--blue-deep), #3a86ad); color: #fff; font-size: 19px;
  box-shadow: 0 8px 18px rgba(11, 75, 118, .22);
}
.settings-head h1 { font-size: 24px; }
.settings-head p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.settings-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.settings-tabs button {
  display: flex; align-items: center; gap: 10px; padding: 12px 15px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; background: transparent; color: #667177; text-align: left;
}
.settings-tabs button:hover { color: var(--text); border-bottom-color: var(--line-strong); }
.settings-tabs button.active { color: var(--text); border-bottom-color: var(--blue); }
.settings-tabs .tab-ico {
  width: 18px; height: 18px; flex: 0 0 auto; opacity: .8;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.settings-tabs button.active .tab-ico { opacity: 1; color: var(--blue); }
.settings-tabs .tab-label { font-size: 13px; font-weight: 700; display: block; }

.panel { max-width: 980px; margin-bottom: 18px; }
.panel-body { padding: 20px 22px 22px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 15px; }
.form-row { display: grid; gap: 0; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.checkbox-row { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 620; color: #404c53; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--blue-deep); }

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table thead th {
  padding: 11px 14px; background: var(--surface-soft); color: #606b70;
  font-size: 10px; font-weight: 700; text-align: left; text-transform: uppercase; letter-spacing: .055em;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data-table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #fbfbf8; }
.data-table .right { text-align: right; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
  background: linear-gradient(140deg, var(--blue-deep), #3a86ad); color: #fff; font-weight: 750; font-size: 11px;
}
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell b { font-weight: 640; font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); }
.icon-action {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid transparent; background: transparent;
  color: #8d979c; display: inline-grid; place-items: center; font-size: 14px;
}
.icon-action:hover { background: var(--surface-soft); color: var(--blue-deep); border-color: var(--line); }
.icon-action.danger:hover { color: #9a4945; background: #faeceb; border-color: #efd6d3; }

.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.perm-group { border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.perm-group h4 { margin: 0; padding: 11px 14px; background: var(--surface-soft); font-size: 12px; font-weight: 730; border-bottom: 1px solid var(--line); }
.perm-item { display: flex; gap: 11px; padding: 11px 14px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.perm-item:last-child { border-bottom: 0; }
.perm-item input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--blue-deep); flex: 0 0 auto; }
.perm-item b { display: block; font-size: 12.5px; font-weight: 660; }
.perm-item span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.field-editor { display: grid; gap: 10px; }
.field-row {
  display: grid; grid-template-columns: 22px minmax(140px, 1.4fr) minmax(120px, 1fr) 120px 120px 92px 36px;
  gap: 9px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fdfdfb;
}
.field-row .drag { display: grid; gap: 2px; justify-items: center; }
.field-row .drag .move {
  width: 22px; height: 17px; padding: 0; line-height: 1; font-size: 8px;
  border: 1px solid var(--line); background: #fff; border-radius: 5px; color: #7d878c;
}
.field-row .drag .move:hover:not(:disabled) { background: var(--surface-soft); color: var(--blue-deep); }
.field-row .drag .move:disabled { opacity: .3; cursor: default; }
.field-row input, .field-row select { min-height: 38px; padding: 8px 10px; font-size: 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; outline: 0; width: 100%; }
.field-row .key { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.field-head { display: grid; grid-template-columns: 22px minmax(140px, 1.4fr) minmax(120px, 1fr) 120px 120px 92px 36px; gap: 9px; padding: 0 10px; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #7d878c; font-weight: 700; }
.suggest-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.suggest-chip {
  border: 1px dashed #bcd3de; background: #f2f9fb; color: var(--blue-deep); border-radius: 999px;
  padding: 7px 12px; font-size: 11px; font-weight: 650;
}
.suggest-chip:hover { background: #e6f2f6; }
.suggest-chip[disabled] { opacity: .45; cursor: default; }

.log-list { display: grid; gap: 8px; }
.log-item { display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; align-items: center; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-md); font-size: 12px; }
.log-item .when { color: var(--muted); font-size: 11px; }
.log-item.ok { border-left: 3px solid #73935e; }
.log-item.error { border-left: 3px solid #b8756f; }
.log-item.skipped { border-left: 3px solid #d7ad50; }

/* ─────────────────────────── Модалки ─────────────────────────── */

.modal { display: none; position: fixed; inset: 0; z-index: 200; align-items: center; justify-content: center; padding: 18px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 31, 37, .42); backdrop-filter: blur(4px); }
.modal-dialog {
  position: relative; width: min(720px, 96vw); max-height: 90vh; overflow: auto;
  background: #fff; border-radius: 24px; border: 1px solid rgba(255, 255, 255, .6);
  box-shadow: 0 30px 100px rgba(15, 29, 38, .28);
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 20px 22px 17px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 6px 0 0; font-size: 20px; letter-spacing: -.025em; }
.modal-body { padding: 20px 22px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 22px; flex-wrap: wrap; }
.icon-button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: #f8f8f5; font-size: 22px; line-height: 1; color: #677279; flex: 0 0 auto; }
.icon-button:hover { background: #f0f1ed; }

.archive-dialog { width: min(780px, 96vw); }
.archive-toolbar { padding: 14px 22px 4px; }
.archive-empty { padding: 32px 12px 36px; text-align: center; color: var(--muted); font-size: 12px; }
.archive-list { padding: 10px 12px 16px; }
.archive-item { width: 100%; border: 0; background: transparent; display: grid; grid-template-columns: 1fr auto; gap: 14px; text-align: left; padding: 14px 12px; border-radius: 14px; }
.archive-item:hover { background: #f6f7f3; }
.archive-item.active { background: #eef4f6; }
.archive-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.archive-badge { min-width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue-deep); font-weight: 760; font-size: 12px; flex: 0 0 auto; }
.archive-title { font-size: 13px; font-weight: 720; color: #2a373d; display: block; }
.archive-meta { margin-top: 4px; font-size: 10px; color: #849095; display: block; }
.archive-side { text-align: right; align-self: center; }
.archive-amount { font-size: 13px; font-weight: 730; display: block; }
.archive-state { margin-top: 4px; font-size: 10px; color: #748087; display: block; }

.invoice-dialog { width: min(760px, 96vw); }
.invoice-preview { padding: 22px 20px 26px; background: #f4f4ef; }
.invoice-paper { max-width: 620px; margin: 0 auto; background: #fff; box-shadow: 0 12px 40px rgba(25, 45, 55, .09); border: 1px solid #e7e8e4; padding: 30px 28px; }
.invoice-paper-head { display: flex; justify-content: space-between; gap: 18px; padding-bottom: 20px; border-bottom: 2px solid #21333c; flex-wrap: wrap; }
.invoice-paper-logo { font-size: 15px; font-weight: 800; color: var(--blue-deep); text-transform: uppercase; letter-spacing: .03em; }
.invoice-paper-head small { color: #7c888e; font-size: 10px; }
.invoice-paper h3 { margin: 24px 0 6px; font-size: 18px; }
.invoice-paper-date { color: #77838a; font-size: 11px; }
.invoice-parties { display: grid; gap: 12px; margin-top: 20px; }
.invoice-party { display: grid; grid-template-columns: 96px 1fr; gap: 12px; font-size: 11px; line-height: 1.45; }
.invoice-party span:first-child { color: #7f8b91; }
.invoice-party strong { font-weight: 650; overflow-wrap: anywhere; }
.invoice-lines { width: 100%; border-collapse: collapse; margin-top: 22px; }
.invoice-lines th, .invoice-lines td { border: 1px solid #dfe2de; padding: 9px 8px; font-size: 10px; text-align: left; }
.invoice-lines th { background: #f6f6f2; color: #6b777c; }
.invoice-lines th:last-child, .invoice-lines td:last-child { text-align: right; }
.invoice-total { display: flex; justify-content: flex-end; gap: 16px; align-items: baseline; margin-top: 16px; }
.invoice-total span { color: #7a868c; font-size: 11px; }
.invoice-total strong { font-size: 17px; }
.invoice-foot { margin-top: 34px; padding-top: 14px; border-top: 1px solid #e5e6e2; color: #889297; font-size: 10px; line-height: 1.45; }

.confirm-dialog { width: min(460px, 96vw); padding: 26px; text-align: center; overflow: visible; }
.confirm-icon { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; margin: 0 auto 14px; background: var(--blue-soft); color: var(--blue-deep); font-size: 20px; font-weight: 800; }
.confirm-dialog h2 { margin: 0; font-size: 19px; }
.confirm-dialog p { margin: 9px auto 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; max-width: 360px; }
.confirm-comment { margin-top: 18px; text-align: left; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }

.toast-stack { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 300; max-width: calc(100vw - 36px); }
.toast { min-width: 260px; max-width: 390px; padding: 13px 15px; border-radius: 13px; background: #21343e; color: #fff; box-shadow: 0 16px 40px rgba(15, 29, 38, .24); font-size: 11.5px; line-height: 1.4; animation: toastIn .22s ease both; }
.toast strong { display: block; font-size: 12.5px; margin-bottom: 3px; }
.toast.success { background: #496642; }
.toast.warning { background: #8d6821; }
.toast.error { background: #8e4944; }
@keyframes toastIn { from { transform: translateY(7px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.loading-veil { padding: 60px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.spinner { width: 22px; height: 22px; border: 2.5px solid #d8e2e6; border-top-color: var(--blue-deep); border-radius: 50%; margin: 0 auto 12px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────── Адаптив ─────────────────────────── */

@media (max-width: 1280px) {
  .topbar { padding: 12px 20px; }
  .main-content { padding-left: 18px; padding-right: 18px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .field-row, .field-head { grid-template-columns: 22px minmax(120px, 1fr) 108px 104px 78px 36px; }
  .field-row .key-cell, .field-head .key-cell { display: none; }
}

@media (max-width: 900px) {
  .table-wrap { display: none; }
  .invoice-cards { display: grid; }
  .hero-panel { align-items: stretch; }
  .hero-toolbar { width: 100%; }
  .search-box { flex: 1 1 200px; width: auto; }
  .registry-bulk-actions button { flex: 1 1 160px; min-width: 0; }
  .summary-head { align-items: flex-start; }
  .summary-total { text-align: left; }
}

@media (max-width: 720px) {
  .topbar { min-height: 0; gap: 10px; padding: 10px 14px; }
  .brand-logo { height: 40px; }
  .top-nav { order: 3; width: 100%; margin-left: 0; }
  .top-nav button { flex: 1; text-align: center; }
  .topbar-actions { gap: 8px; }
  .logout-button span { display: none; }
  .logout-button { padding: 9px 11px; }
  .main-content { padding: 18px 14px 32px; }
  h1 { font-size: 24px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 19px; }
  .registry-card, .summary-card, .panel { border-radius: var(--radius-lg); }
  .registry-card-head, .panel-head, .summary-head, .registry-bulk-actions { padding-left: 16px; padding-right: 16px; }
  .panel-body { padding: 16px; }
  .modal { padding: 10px; }
  .modal-dialog { border-radius: 18px; max-height: 94vh; }
  .field-row, .field-head { grid-template-columns: 1fr 1fr; }
  .field-head { display: none; }
  .field-row .drag { display: none; }
  .data-table thead th, .data-table tbody td { padding: 10px 11px; }
}

@media (max-width: 460px) {
  .stats-grid { grid-template-columns: 1fr; }
  .card-actions { grid-template-columns: 1fr; }
  .confirm-actions { grid-template-columns: 1fr; }
  .detail-item, .card-line { grid-template-columns: 1fr; gap: 3px; }
  .invoice-party { grid-template-columns: 1fr; gap: 2px; }
}
