/* Тёмная тема интерфейса.

   Печатные формы к этим стилям не подключены: документы уходят клиенту
   и печатаются на бумаге, там своя светлая вёрстка. */
:root {
  --bg: #0a1017;           /* фон страницы */
  --panel: #111a24;        /* карточки */
  --panel-2: #0d151d;      /* боковое меню */
  --panel-hi: #16202c;     /* подсветка строк и наведение */
  --line: #1e2a37;         /* границы */
  --line-soft: #17212c;

  --ink: #e8eef4;          /* основной текст */
  --ink-dim: #c3cedb;      /* текст в таблицах */
  --muted: #8593a4;        /* подписи и второстепенное */

  --accent: #2dd4bf;       /* бирюзовый акцент */
  --accent-ink: #04262b;   /* текст на бирюзовом */
  --accent-soft: rgba(45, 212, 191, 0.13);
  --accent-line: rgba(45, 212, 191, 0.35);

  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --violet: #a78bfa;

  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Fira Sans Condensed", "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--accent-soft); }

/* ---------- каркас ---------- */
.layout { display: flex; min-height: 100vh; }

.side {
  width: 252px;
  flex: 0 0 252px;
  background: var(--panel-2);
  border-right: 1px solid var(--line);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
}
.side .brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.02em;
  padding: 0 18px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
  color: var(--ink);
}
.side .brand::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 9px;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--accent), var(--ok));
  vertical-align: middle;
}
.side nav > a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 18px;
  color: var(--ink-dim);
  border-left: 3px solid transparent;
}
.side nav > a:hover { background: var(--panel-hi); color: var(--ink); text-decoration: none; }
.side nav > a.on {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.ic { width: 17px; height: 17px; flex: 0 0 17px; opacity: 0.85; }

/* ---------- цепочка документов в меню ---------- */
.flow {
  margin: 8px 12px;
  padding: 6px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(45, 212, 191, 0.04);
}
.flow .step {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 7px 12px;
  color: var(--ink-dim);
}
.flow .step:hover { color: var(--ink); text-decoration: none; }
.flow .step .num {
  position: relative;
  z-index: 1;
  flex: 0 0 22px;
  width: 22px; height: 22px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1.5px solid var(--accent-line);
  background: var(--panel-2);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
/* соединительная линия между шагами */
.flow .step:not(.last)::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 26px;
  bottom: -4px;
  width: 1.5px;
  background: var(--accent-line);
}
.flow .step .txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.flow .step .txt b { font-weight: 600; font-size: 14px; white-space: nowrap; }
.flow .step .txt i {
  font-style: normal;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
}
.flow .step.on { color: var(--accent); }
.flow .step.on .num { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.flow .step.on .txt b { color: var(--accent); }

.flow .step-row { display: flex; align-items: flex-start; }
.flow .step-row .step { flex: 1; min-width: 0; }
.flow .chev {
  flex: 0 0 30px;
  margin: 9px 8px 0 0;
  padding: 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
}
.flow .chev:hover { color: var(--ink); background: var(--panel-hi); }
.flow .chev .ic { transition: transform 0.15s; }
.flow.cn-open .chev .ic { transform: rotate(180deg); }

.flow .substep {
  display: none;
  padding: 6px 12px 8px 45px;
  font-size: 13.5px;
  color: var(--muted);
}
.flow.cn-open .substep { display: block; }
.flow .substep:hover { color: var(--ink); text-decoration: none; }
.flow .substep.on { color: var(--accent); font-weight: 600; }
.flow .substep::before {
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  margin-right: 9px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
}

/* ---------- раскрывающийся раздел меню ---------- */
.group-head {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 8px 18px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.group-head span { flex: 1; }
.group-head:hover { background: var(--panel-hi); color: var(--ink); }
.group-head.on {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.group-head .ic:last-child { transition: transform 0.15s; opacity: 0.6; }
.group.open .group-head .ic:last-child { transform: rotate(180deg); }

.group .subitem {
  display: none;
  padding: 6px 18px 6px 48px;
  font-size: 13.5px;
  color: var(--muted);
}
.group.open .subitem { display: block; }
.group .subitem:hover { color: var(--ink); text-decoration: none; background: var(--panel-hi); }
.group .subitem.on { color: var(--accent); font-weight: 600; }
.group .subitem::before {
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  margin-right: 9px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
}

.side .sep { height: 1px; background: var(--line); margin: 10px 14px; }
.side .foot { margin-top: auto; padding: 12px 18px; font-size: 13px; color: var(--muted); }

.main { flex: 1; padding: 22px 26px 60px; min-width: 0; }

.head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin-bottom: 16px;
}
h1 { font-size: 23px; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 22px 0 10px; font-weight: 600; }

/* ---------- элементы ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}

table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line-soft); }
th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
td { color: var(--ink-dim); }
td.r, th.r { text-align: right; }
td.c, th.c { text-align: center; }
tbody tr:hover { background: var(--panel-hi); }
tfoot th { border-top: 1px solid var(--line); color: var(--ink); font-size: 13px; }
.nums { font-variant-numeric: tabular-nums; white-space: nowrap; }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c141d;
  width: 100%;
}
input::placeholder, textarea::placeholder { color: #5b6878; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input:disabled, select:disabled { color: var(--muted); background: #0a1119; }
textarea { min-height: 62px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.7); }
select option { background: var(--panel); color: var(--ink); }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: 1fr 1fr 1fr; }
.g4 { grid-template-columns: repeat(4, 1fr); }

.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #131d28;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}
.btn:hover { background: var(--panel-hi); border-color: #2a3949; text-decoration: none; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.35); }
.btn.danger:hover { background: rgba(248, 113, 113, 0.1); }
.btn.sm { padding: 3px 9px; font-size: 13px; }
.row-actions { display: flex; gap: 8px; align-items: center; }

.tag {
  display: inline-block; padding: 1px 9px; border-radius: 20px;
  font-size: 12px; background: var(--panel-hi);
  border: 1px solid var(--line); color: var(--ink-dim);
}
.tag.draft { color: var(--muted); }
.tag.issued, .tag.sent {
  color: #67e8f9; border-color: rgba(103, 232, 249, 0.3); background: rgba(103, 232, 249, 0.1);
}
.tag.partial { color: var(--warn); border-color: rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.1); }
.tag.paid, .tag.accepted {
  color: var(--ok); border-color: rgba(52, 211, 153, 0.3); background: rgba(52, 211, 153, 0.1);
}
.tag.shipped { color: var(--violet); border-color: rgba(167, 139, 250, 0.32); background: rgba(167, 139, 250, 0.1); }
.tag.cancelled, .tag.rejected, .tag.expired {
  color: var(--danger); border-color: rgba(248, 113, 113, 0.3); background: rgba(248, 113, 113, 0.1);
}

.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.err {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fca5a5;
  padding: 9px 12px; border-radius: 7px; margin-bottom: 14px;
}
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }

/* ---------- итоги документа ---------- */
.totals { margin-left: auto; width: 360px; }
.totals td { border: none; padding: 5px 0; color: var(--muted); }
.totals td.r { font-variant-numeric: tabular-nums; color: var(--ink-dim); }
.totals tr.grand td {
  font-weight: 700; color: var(--ink);
  border-top: 1px solid var(--line); padding-top: 9px;
}

/* ---------- вход ---------- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { width: 340px; }

/* ---------- проверка пароля ---------- */
.pwlist {
  list-style: none;
  margin: 7px 0 0;
  padding: 0;
  font-size: 12px;
  color: var(--muted);
}
.pwlist li { display: flex; gap: 8px; align-items: baseline; line-height: 1.8; }
.pwlist li::before {
  content: "○";
  width: 12px;
  flex: 0 0 12px;
  color: #4a5866;
}
.pwlist li.ok { color: var(--ok); }
.pwlist li.ok::before { content: "✓"; color: var(--ok); font-weight: 700; }
.pwlist .title { color: var(--muted); margin-bottom: 2px; }
.pwlist .title::before { content: ""; width: 0; flex: 0; }
.pwlist.collapsed { display: none; }
