:root {
  --primary: #1F364D;
  --accent: #F2A541;
  --bg: #F4F2EE;
  --surface: #FFFFFF;
  --text: #1A1A1A;
  --muted: #6B6F76;
  --line: #E2DFD8;
  --error: #B42318;
  --warn-bg: #FFF4E0;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 15px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
h1, h2 { color: var(--primary); line-height: 1.2; margin: 0; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; }
code { background: #ECE9E3; padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* верхняя панель */
.bar { background: var(--primary); color: #fff; }
.bar-inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.brand { color: #fff; text-decoration: none; font-family: "Space Grotesk", "Inter", sans-serif; font-weight: 700; font-size: 18px; }
.brand span { color: var(--accent); margin: 0 2px; }
.bar nav { display: flex; gap: 16px; flex: 1; }
.bar nav a { color: rgba(255,255,255,.75); text-decoration: none; font-weight: 500; }
.bar nav a.active, .bar nav a:hover { color: #fff; }
.mode { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.mode-mock { background: rgba(242,165,65,.18); color: var(--accent); }
.mode-live { background: rgba(255,255,255,.14); color: #fff; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 28px 16px 64px; }
.page-head { margin-bottom: 20px; }
.sub { color: var(--muted); margin: 6px 0 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* форма */
.form { padding: 24px; max-width: 820px; display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.grow { flex: 1 1 240px; }
.label { font-size: 13px; font-weight: 600; color: var(--primary); }
.label b { color: var(--accent); }
input, select, textarea {
  font: inherit; color: var(--text); background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.err { color: var(--error); font-size: 13px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; }
.seg span { display: block; padding: 9px 16px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg input:checked + span { background: var(--primary); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  border-radius: 8px; padding: 10px 18px; border: 1px solid transparent; display: inline-block;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #2A4866; }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--primary); }
.btn-ghost:hover { border-color: var(--primary); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.check input { width: auto; }
.hint { color: var(--muted); font-size: 14px; }
.inline { display: inline; margin: 0; }

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; background: #EAF0F6; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert-error { background: #FDECEA; color: var(--error); }
.alert-warn { background: var(--warn-bg); }

/* превью */
.preview-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.back { font-size: 14px; text-decoration: none; color: var(--muted); }
.preview-head h1 { margin-top: 6px; }
.preview-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.doc-frame { width: 100%; min-height: 900px; border: 0; border-radius: var(--radius); background: transparent; }
.side { padding: 18px; position: sticky; top: 16px; }
.side h2 { margin-bottom: 2px; }
table { border-collapse: collapse; width: 100%; }
.calc { font-size: 13.5px; margin: 12px 0; }
.calc th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 0 4px 6px; }
.calc td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.calc tfoot td { font-weight: 700; color: var(--primary); border-top: 2px solid var(--primary); }
.num { text-align: right; }
.tier { display: inline-block; min-width: 22px; text-align: center; font-size: 12px; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.tier-S { background: #E6F2EA; color: #2D6A3E; }
.tier-M { background: #FFF1D6; color: #8A5A00; }
.tier-L { background: #FBE3E1; color: #8E2A20; }
.facts { margin: 0; display: grid; gap: 8px; font-size: 13.5px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-weight: 500; }

/* история */
.table-card { overflow-x: auto; }
.history { font-size: 14px; }
.history th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.history td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.history tr:last-child td { border-bottom: 0; }
.history a { text-decoration: none; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 12px; background: #ECE9E3; color: var(--muted); }
.pill-warn { background: var(--warn-bg); color: #8A5A00; }
.empty { padding: 32px; text-align: center; }
.empty h1 { margin-bottom: 8px; }

@media (max-width: 900px) {
  .preview-grid { grid-template-columns: 1fr; }
  .side { position: static; order: -1; }
}
@media (max-width: 560px) {
  h1 { font-size: 22px; }
  .form { padding: 16px; }
  .bar nav { order: 3; flex-basis: 100%; }
}
