:root {
  --ink: #1b2430;
  --muted: #7b8794;
  --soft: #4a5563;
  --line: #e4e8ee;
  --paper: #ffffff;
  --page: #ffffff;
  --side: #fbfcfd;
  --accent: #0b84f3;
  --accent-dark: #0a6fcd;
  --accent-soft: #e8f3fe;
  --red: #b3261e;
  --red-soft: #fcecea;
  --yellow: #7a5a00;
  --yellow-soft: #fdf6dd;
  --green: #1d6b3a;
  --green-soft: #e8f5ec;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 Inter, Roboto, "Segoe UI", Arial, "Liberation Sans", sans-serif;
}

[hidden] { display: none !important; }

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

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon .fill { fill: currentColor; stroke: none; }
.icon .fill-white { fill: #fff; stroke: none; }
.icon .on-fill { stroke: #fff; }

/* Каркас */
body.app { display: flex; min-height: 100vh; }
.side { width: 200px; flex: none; background: var(--side); border-right: 1px solid var(--line); padding: 14px 8px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: block; color: var(--accent); font-weight: 800; font-size: 19px; letter-spacing: -.2px; padding: 6px 12px 18px; }
.brand:hover { text-decoration: none; }
.side a:not(.brand), .side button { display: flex; align-items: center; justify-content: flex-start; gap: 9px; font-weight: 400; width: 100%; padding: 6px 12px; border: 0; background: none; border-radius: 6px; color: var(--soft); font: inherit; text-align: left; cursor: pointer; margin-bottom: 2px; }
.side a:not(.brand):hover, .side button:hover { background: #f0f3f6; text-decoration: none; }
.side a.active { background: var(--accent-soft); color: var(--ink); }
.side a.active .icon { color: var(--accent); }
.side .icon { width: 16px; height: 16px; }
.side-bottom { margin-top: auto; }
.body { flex: 1; min-width: 0; }
.top { height: 54px; display: flex; align-items: center; padding: 0 40px; border-bottom: 1px solid var(--line); font-weight: 500; color: var(--soft); font-size: 14px; }
main { max-width: 1320px; padding: 22px 40px 64px; }

/* Заголовок страницы */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.pagehead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 22px; }
.pagetitle { display: flex; align-items: center; gap: 14px; min-width: 0; }
.docmark { width: 42px; height: 54px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex: none; }
.docmark .icon { width: 28px; height: 28px; }
h1 { font-size: 24px; line-height: 1.25; font-weight: 600; margin: 0; overflow-wrap: anywhere; }
.pagetitle p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 10px; }
h3 { font-size: 15px; font-weight: 600; margin: 14px 0 6px; }
.note, .muted { color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

/* Этапы */
.steps { display: flex; align-items: center; list-style: none; margin: 0 0 26px; padding: 0; gap: 12px; }
.steps li { display: flex; align-items: center; gap: 10px; flex: 1; font-weight: 500; white-space: nowrap; }
.steps li:last-child { flex: none; }
.steps li:not(:last-child)::after { content: ""; flex: 1; height: 1px; background: #8c97a3; min-width: 16px; }
.steps li.now:not(:last-child)::after { background: none; border-top: 1px dashed #8c97a3; }
.steps .num { width: 32px; height: 32px; flex: none; border: 1px solid #5f6b78; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.steps .now .num, .steps .done .num { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps .done .label { color: var(--muted); }

/* Карточки */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.narrow { max-width: 520px; }

/* Поля */
label { display: block; font-weight: 500; margin: 12px 0 4px; font-size: 14px; }
label.first { margin-top: 0; }
input:not([type=radio]):not([type=checkbox]):not([type=file]) { width: 100%; max-width: 420px; padding: 8px 10px; border: 1px solid #cfd6de; border-radius: 6px; font: inherit; color: inherit; background: #fff; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
input:focus-visible, button:focus-visible, a:focus-visible, .help:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Кнопки */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
button:disabled { cursor: not-allowed; opacity: .55; }
.primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(11, 132, 243, .35); }
.primary:hover:not(:disabled) { background: var(--accent-dark); text-decoration: none; }
.primary.small { padding: 5px 11px; font-size: 13px; }
.primary.small .icon { width: 14px; height: 14px; }
.primary.wide { width: 100%; margin-top: 14px; }
.secondary { background: #fff; color: var(--ink); border-color: var(--line); box-shadow: 0 1px 2px rgba(20, 30, 45, .06); }
.secondary:hover { background: #f5f7f9; text-decoration: none; }
.tool { background: none; color: var(--accent); padding: 4px 6px; font-size: 13px; font-weight: 500; }
.tool:hover:not(:disabled) { background: var(--accent-soft); }
.tool .icon { width: 14px; height: 14px; }
button.link { background: none; border: none; padding: 4px 0; color: var(--accent); font-weight: 400; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; align-items: center; }
.actions.end { justify-content: flex-end; }

/* Загрузка */
.upload-grid { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: 24px; align-items: start; }
.company-list { list-style: none; margin: 0; padding: 0; }
.company-list li { display: flex; align-items: stretch; border-radius: 6px; margin-bottom: 2px; }
.company-list li.active { background: var(--accent-soft); }
.company-select { flex: 1; min-width: 0; justify-content: space-between; background: none; font-weight: 500; padding: 8px 10px; }
.company-select small { color: var(--muted); font-weight: 400; }
.company-remove { background: none; color: var(--muted); padding: 0 10px; font-size: 16px; font-weight: 400; }
.company-remove:hover { color: var(--red); }
.company-name { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 14px; }
.docs { padding: 14px 16px 6px; transition: border-color .15s; }
.docs.over { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.doc-row { border-top: 1px solid var(--line); padding: 14px 0; }
.docs .card-head { margin-bottom: 14px; }
.doc-row-head { display: flex; align-items: center; gap: 12px; padding: 0 14px; }
.doc-row-head h3 { flex: 1; min-width: 0; margin: 0; font-weight: 500; font-size: 15px; }
.folder { color: var(--accent); display: flex; }
.folder .icon { width: 22px; height: 22px; }
.formats { color: var(--muted); font-weight: 400; }
.help { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: #eef1f4; color: var(--muted); font-size: 10px; font-weight: 500; cursor: help; vertical-align: 1px; }
.round { width: 28px; height: 28px; padding: 0; border-radius: 50%; background: var(--accent); color: #fff; flex: none; }
.round:hover { background: var(--accent-dark); }
.round .icon { width: 14px; height: 14px; }
.fold { width: 28px; height: 28px; padding: 0; background: none; color: var(--soft); flex: none; }
.fold .icon { transition: transform .15s; }
.folded .fold .icon { transform: rotate(180deg); }
.folded .file-list { display: none; }
.file-list { list-style: none; margin: 8px 0 0; padding: 0 14px; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 5px 4px 5px 34px; font-size: 14px; }
.file-list li + li { border-top: 1px solid #f1f3f6; }
.file-list .empty { justify-content: center; color: var(--muted); font-size: 13px; padding: 4px; }
.file-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file-list small { color: var(--muted); white-space: nowrap; }
.file-list button { background: none; color: var(--muted); padding: 0 6px; font-size: 16px; font-weight: 400; }
.file-list button:hover { color: var(--red); }

/* Окно документов */
dialog { width: min(1100px, calc(100vw - 32px)); height: min(680px, calc(100vh - 48px)); border: 0; border-radius: 10px; padding: 26px; color: inherit; }
dialog::backdrop { background: rgba(35, 45, 60, .35); }
dialog h2 { font-size: 22px; margin: 0 0 22px; padding-right: 40px; }
.dialog-close { position: absolute; top: 16px; right: 16px; width: 28px; height: 28px; padding: 0; border-radius: 50%; background: #fff; border: 1px solid var(--line); color: var(--soft); }
.dialog-close .icon { width: 14px; height: 14px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px 28px; margin-bottom: 22px; }
.tabs button { background: none; padding: 0 2px 6px; border-radius: 0; border-bottom: 2px solid transparent; color: var(--ink); font-size: 14px; }
.tabs button.selected { color: var(--accent); border-bottom-color: var(--accent); }
.dialog-tools { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.search { position: relative; margin: 0; font-weight: 400; width: min(280px, 100%); color: var(--muted); }
.search .icon { position: absolute; left: 10px; top: 10px; width: 16px; height: 16px; }
.search input { padding-left: 34px !important; }
.tool-group { display: flex; gap: 12px; }
.dialog-table { border: 1px solid var(--line); border-radius: var(--radius); border-collapse: separate; border-spacing: 0; }
.dialog-table th { background: #fff; font-weight: 500; font-size: 15px; color: var(--soft); padding: 12px 10px; }
.dialog-table td { padding: 9px 10px; overflow-wrap: anywhere; }
.dialog-table tr:last-child td { border-bottom: 0; }
.dialog-table .empty { text-align: center; color: var(--muted); padding: 16px; }
.dialog-table .check { width: 44px; text-align: center; }
.num-col { text-align: right !important; white-space: nowrap; }

/* Вход */
body.plain { background: #f5f7fa; }
.login { max-width: 400px; margin: 0 auto; padding: 12vh 16px 32px; }
.brand-big { color: var(--accent); font-weight: 800; font-size: 22px; margin: 0 0 18px; }
.login h1 { font-size: 20px; margin-bottom: 8px; }
.login input { max-width: none !important; }

/* Сообщения */
.alert { padding: 9px 12px; border-radius: 6px; margin: 8px 0 14px; font-size: 14px; }
.alert.red { background: var(--red-soft); color: var(--red); }
.alert.yellow { background: var(--yellow-soft); color: var(--yellow); }
.alert.green { background: var(--green-soft); color: var(--green); }

.field { margin-bottom: 12px; }
.suffix { display: flex; align-items: center; gap: 8px; }
.suffix input { max-width: 120px !important; }
.revenue { border-top: 1px solid var(--line); padding: 4px 0 14px; }
.revenue:first-of-type { border-top: 0; }
.choice { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 6px 0; }

.issues { list-style: none; margin: 0; padding: 0; }
.issues li { padding: 8px 10px; border-left: 3px solid var(--line); margin-bottom: 6px; font-size: 14px; overflow-wrap: anywhere; border-radius: 0 6px 6px 0; }
.issues .tag { font-size: 12px; font-weight: 600; display: block; }
.issues .red { border-color: var(--red); background: var(--red-soft); }
.issues .red .tag { color: var(--red); }
.issues .yellow { border-color: #c9a227; background: var(--yellow-soft); }
.issues .yellow .tag { color: var(--yellow); }
.issues .info { background: #f7f9fb; }
.issues .info .tag { color: var(--muted); }

/* Результат */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 0 0 12px; }
.kpis > div { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpis dt { color: var(--muted); font-size: 13px; }
.kpis dd { margin: 2px 0 0; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f7f9fb; font-weight: 600; color: var(--soft); font-size: 13px; }
.numbers td, .numbers th { white-space: nowrap; }
.numbers td:nth-child(2) { white-space: normal; min-width: 180px; }
.numbers td { font-variant-numeric: tabular-nums; }
tr.section td { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
tr.sub td { background: #f7f9fb; font-weight: 600; }
tr.total td { font-weight: 600; border-top: 1px solid #8c97a3; }

.status { font-weight: 600; }
.status.green { color: var(--green); }
.status.red { color: var(--red); }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: 4px 0; }

/* Узкий экран */
@media (max-width: 860px) {
  body.app { display: block; }
  .side { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 4px 8px 4px 0; width: 100%; }
  .side nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; }
  .side a:not(.brand), .side button { width: auto; padding: 5px 8px; font-size: 13px; margin: 0; }
  .side-bottom { margin: 0; }
  .top { display: none; }
  main { padding: 16px 16px 48px; }
  .upload-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .steps { gap: 6px; }
  .steps .label { display: none; }
  .steps .now .label { display: inline; white-space: normal; }
  .doc-row-head { padding: 0 2px; gap: 8px; }
  .file-list { padding: 0 2px; }
  .file-list li { padding-left: 4px; }
  dialog { padding: 18px; }
  h1 { font-size: 21px; }
}
