/* Vendor Information Portal — интерфейс. Раздел 28 ТЗ.
   Плотная enterprise-таблица, контраст не ниже WCAG AA, видимый фокус. */

:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1a2028;
  --ink-soft: #4a5765;
  --line: #d3dae1;
  --accent: #14508c;
  --accent-soft: #e8f0f8;
  --warn: #8a5300;
  --warn-bg: #fff4e0;
  --danger: #a11b1b;
  --ok: #1c6b3a;
  --forecast: #6b4fa8;
  --forecast-bg: #f1ecfa;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #0b6bcb;
  outline-offset: 1px;
}

.hidden { display: none !important; }

/* --- вход --------------------------------------------------------- */
.login-screen {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 28px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { margin: 0 0 20px; color: var(--ink-soft); font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 4px; font-size: 13px; color: var(--ink-soft); }
.field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
.checkbox { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 13px; }
.checkbox input { width: auto; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 7px 14px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #0f3f70; }
button.link { border: none; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
button[disabled] { opacity: .6; cursor: default; }
button.wide { width: 100%; }

/* --- каркас ------------------------------------------------------- */
.app { display: none; min-height: 100%; grid-template-rows: auto 1fr; }
.app.visible { display: grid; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand { font-weight: 600; white-space: nowrap; }
.topbar .search { flex: 1; max-width: 460px; }
.topbar .search input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.topbar .meta { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: var(--ink-soft); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge.readonly { background: var(--warn-bg); color: var(--warn); border: 1px solid #e5c489; }
.badge.source { background: var(--accent-soft); color: var(--accent); border: 1px solid #b9d2ea; }
.badge.actual { background: #e7f2ea; color: var(--ok); border: 1px solid #a9cdb7; }
.badge.forecast { background: var(--forecast-bg); color: var(--forecast); border: 1px solid #c6b6e6; }
.badge.admin { background: #e6e2f7; color: #4a3b8c; border: 1px solid #b9adde; }
.badge.unmapped { background: #f2e7e7; color: var(--danger); border: 1px solid #d9b3b3; }

.body { display: grid; grid-template-columns: 210px 1fr; min-height: 0; }

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 14px 0;
}
.sidebar .group { padding: 6px 18px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7b8794; }
.sidebar button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 8px 18px;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar button:hover { background: #f0f3f6; }
.sidebar button.active { background: var(--accent-soft); border-left-color: var(--accent); font-weight: 600; color: var(--accent); }

.content { padding: 18px 20px 40px; min-width: 0; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 19px; }
.page-head .count { color: var(--ink-soft); font-size: 13px; }

/* --- фильтры ------------------------------------------------------ */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 12px;
  margin-bottom: 14px;
}
.filters .f { display: flex; flex-direction: column; gap: 3px; }
.filters label { font-size: 11.5px; color: var(--ink-soft); }
.filters input, .filters select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  min-width: 130px;
  background: #fff;
  color: var(--ink);
}

/* --- таблицы ------------------------------------------------------ */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 5px; overflow: auto; max-height: 70vh; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th {
  position: sticky;
  top: 0;
  background: #eef2f6;
  z-index: 2;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--ink-soft);
  border-bottom: 2px solid var(--line);
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--accent); }
tbody tr:hover { background: #f7f9fb; }
tbody tr.total-row { background: #eef2f6; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 240px; }
.na { color: #8a949e; font-style: italic; }

.rowlink { color: var(--accent); text-decoration: underline; cursor: pointer; background: none; border: none; padding: 0; font: inherit; }

.pager { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--ink-soft); }

/* --- карточки ----------------------------------------------------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 14px 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.summary-head { position: sticky; top: 52px; z-index: 10; }
.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 18px; }
.prop .k { font-size: 11.5px; color: var(--ink-soft); }
.prop .v { font-size: 13.5px; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs button { border: 1px solid transparent; border-bottom: none; border-radius: 4px 4px 0 0; padding: 7px 12px; }
.tabs button.active { background: var(--panel); border-color: var(--line); font-weight: 600; color: var(--accent); }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--ink-soft); align-items: center; }

.chart { background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 10px; margin-bottom: 12px; overflow-x: auto; }
.chart svg { display: block; }
.chart .bar-actual { fill: #2f7d4f; }
.chart .bar-forecast { fill: #7a5fc0; }
.chart .axis { stroke: #b9c3cc; stroke-width: 1; }
.chart .tick { font-size: 9px; fill: #64707c; }

.note { font-size: 12.5px; color: var(--warn); background: var(--warn-bg); border: 1px solid #e5c489; border-radius: 4px; padding: 8px 10px; margin-bottom: 12px; }
.state { padding: 26px; text-align: center; color: var(--ink-soft); }
.state.error { color: var(--danger); }
.corr { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; }

/* --- модалка (нативные confirm/alert не используем) ---------------- */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(16, 22, 30, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--panel);
  border-radius: 6px;
  padding: 20px 22px;
  max-width: 460px;
  width: 100%;
  border: 1px solid var(--line);
}
.modal h3 { margin: 0 0 8px; font-size: 16px; }
.modal p { margin: 0 0 14px; color: var(--ink-soft); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 900px) {
  .body { grid-template-columns: 1fr; }
  .sidebar { display: flex; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--line); }
  .sidebar .group { width: 100%; }
  .sidebar button { width: auto; border-left: none; border-bottom: 3px solid transparent; }
  .sidebar button.active { border-left: none; border-bottom-color: var(--accent); }
  .summary-head { position: static; }
}

/* --- открытый информационный режим (PUBLIC_READ_ONLY_MODE) ------------ */
.app.public { grid-template-rows: auto auto 1fr; }

.public-banner {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  padding: 9px 20px;
  background: var(--warn-bg);
  border-bottom: 2px solid #e5c489;
  color: var(--warn);
}

.public-banner .mark { font-weight: 700; font-size: 14px; }
.public-banner .sub { font-size: 12.5px; color: #6b4a12; }
