/* Спокойная служебная палитра: серо-синий акцент, белые карточки, без градиентов */
:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --text: #22272b;
  --muted: #66707a;
  --border: #d8dde2;
  --accent: #34618c;
  --accent-dark: #2a4f73;
  --ok: #2f7d4f;
  --warn: #9c6b1f;
  --err: #a63d3d;
  --radius: 8px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* Каркас: шапка на всю ширину (название слева, «Выйти» справа), под ней
   центрированная область: колонка меню + содержимое */
.top { background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topwrap {
  max-width: 1280px; margin: 0 auto; padding: 8px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px;
}
.layout {
  max-width: 1280px; margin: 0 auto; padding: 8px 20px 0;
  display: flex; gap: 28px; align-items: flex-start;
}
.content { flex: 1; min-width: 0; }

a { color: var(--accent); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--accent-dark); text-decoration: underline; }

h1 { font-size: 24px; margin: 24px 0 12px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 16px 0 6px; }

.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }
.hint { color: var(--muted); font-size: 13.5px; }
.opt { color: var(--muted); font-weight: 400; font-size: 12.5px; }

/* Шапка и колонка меню */
.brand { font-weight: 650; font-size: 16px; color: var(--text); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 9px; }
.brand img { display: block; border-radius: 5px; }
.brand:hover { text-decoration: none; color: var(--text); }
.brand-sub { display: block; font-weight: 400; font-size: 11px; color: var(--muted); margin-top: -3px; }
.mainnav {
  width: 188px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 76px; margin-top: 16px;
}
.mainnav a {
  padding: 8px 12px; border-radius: 6px; color: var(--text); white-space: nowrap;
  font-size: 14px; transition: background .15s ease;
}
.mainnav a:hover { background: #e9ecef; text-decoration: none; }
.mainnav a.active { background: var(--accent); color: #fff; }
.logout { margin-left: auto; }

/* Кнопка-бургер: видна только на телефоне */
.burger { display: none; background: none; border: none; cursor: pointer; padding: 10px 6px; }
.burger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 1px; margin: 4px 0; transition: transform .2s ease, opacity .2s ease; }
.top.open .burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.top.open .burger span:nth-child(2) { opacity: 0; }
.top.open .burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.foot { max-width: 1280px; margin: 0 auto; color: var(--muted); font-size: 13px; padding: 24px 20px 32px; }

/* Карточки */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin: 0 0 16px;
}
.cards .card { margin: 0; }
.cards .card.wide { grid-column: 1 / -1; }

/* Сообщения */
.msg { border-radius: var(--radius); padding: 10px 14px; margin: 16px 0; border: 1px solid; animation: appear .25s ease; }
.msg-ok { background: #eef6f0; border-color: #bcd9c6; color: var(--ok); }
.msg-err { background: #f9eeee; border-color: #e0bcbc; color: var(--err); }
.msg-warn { background: #f9f3e8; border-color: #e2d2ae; color: var(--warn); }
@keyframes appear { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Вкладки редактора манифеста: разделы вместо одной длинной страницы */
.tabbar { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 14px; border-bottom: 1px solid var(--border); position: sticky; top: 104px; background: var(--bg); z-index: 4; padding-top: 2px; }
.tab { appearance: none; border: 1px solid transparent; border-bottom: none; background: none; color: var(--muted); font: inherit; font-size: 13px; padding: 8px 14px; border-radius: var(--radius) var(--radius) 0 0; cursor: pointer; margin-bottom: -1px; }
.tab:hover { color: var(--text); background: var(--card); }
.tab.active { color: var(--text); font-weight: 600; background: var(--card); border-color: var(--border); border-bottom: 1px solid var(--card); }
@media (max-width: 700px) {
  .tabbar { top: 96px; gap: 2px; }
  .tab { padding: 7px 10px; font-size: 12px; }
}

/* Перечень аккредитованных УЦ */
.tsl-authority { padding: 0; }
.tsl-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.tsl-head:hover { background: var(--bg); }
.tsl-head-text { flex: 1; min-width: 0; }
.tsl-head-text .title { font-weight: 600; }
.tsl-head-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tsl-certs { border-top: 1px solid var(--border); }
.tsl-cert { display: flex; align-items: center; gap: 12px; padding: 8px 14px 8px 40px; border-bottom: 1px solid var(--border); cursor: pointer; }
.tsl-cert:last-child { border-bottom: none; }
.tsl-cert:hover { background: var(--bg); }
.tsl-cert-text { flex: 1; min-width: 0; }
.tsl-cert-text > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsl-cert-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
#tsl-messages { position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: min(460px, calc(100vw - 40px)); }
#tsl-messages .msg { margin: 0; padding-right: 34px; position: relative; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); max-height: 50vh; overflow-y: auto; }
#tsl-messages .msg ul { margin: 0; padding-left: 18px; }
@media (max-width: 700px) {
  .tsl-cert { padding-left: 14px; flex-wrap: wrap; }
  .tsl-head-tags, .tsl-cert-tags { justify-content: flex-start; }
  #tsl-messages { right: 10px; left: 10px; bottom: 10px; max-width: none; }
}

/* Сообщения редактора манифеста - всплывающие поверх страницы: прокрутка
   к ним уводила менеджера в начало документа при работе с нижними карточками */
#ed-messages { position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: min(460px, calc(100vw - 40px)); }
#ed-messages .msg { margin: 0; padding-right: 34px; position: relative; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); max-height: 50vh; overflow-y: auto; }
#ed-messages .msg ul { margin: 0; padding-left: 18px; }
.msg-close { position: absolute; top: 4px; right: 6px; border: none; background: none; color: inherit; font-size: 18px; line-height: 1; padding: 2px 6px; cursor: pointer; opacity: .6; }
.msg-close:hover { opacity: 1; }
@media (max-width: 700px) {
  #ed-messages { right: 10px; left: 10px; bottom: 10px; max-width: none; }
}

.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--bg); color: var(--muted); }
.tag-ok { background: #eef6f0; color: var(--ok); }
.tag-warn { background: #f9f3e8; color: var(--warn); }
.tag-err { background: #f9eeee; color: var(--err); }

/* Таблицы */
.kv { border-collapse: collapse; width: 100%; table-layout: fixed; }
.kv td { padding: 4px 0; vertical-align: top; overflow-wrap: anywhere; }
.kv td:first-child { color: var(--muted); width: 38%; padding-right: 12px; }

.table-scroll { overflow-x: auto; }
.list { border-collapse: collapse; width: 100%; font-size: 14px; }
.list th { text-align: left; color: var(--muted); font-weight: 500; font-size: 13px; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
.list td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.list tr:last-child td { border-bottom: none; }
.list td.nowrap, .list td.mono { white-space: nowrap; }
.list .tag, .list a { white-space: nowrap; }
/* Действия в реестре: каждое на своей строке, поле причины рядом с кнопкой */
.actions { min-width: 200px; }
/* Формы действий переносятся по словам: с колонкой «Компьютер» таблица лицензий иначе шире карточки */
.actions form.inline { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 3px 0; white-space: normal; }
.list td.machine { min-width: 150px; max-width: 200px; }
.list td.machine .hint { font-size: 12.5px; }

/* Формы */
label { display: block; font-size: 13.5px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=url], select, textarea {
  width: 100%; margin-top: 3px; padding: 7px 10px; font: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(52, 97, 140, .15);
}
input.slim { width: 110px; display: inline-block; padding: 3px 8px; font-size: 13px; }
input.slim.mono { width: 170px; } /* идентификатор компьютера M-XXXXXXXXXXXXXXXX целиком */
.keybox { resize: vertical; }

button { font: inherit; cursor: pointer; }
button.primary, .btn {
  display: inline-block; background: var(--accent); color: #fff; border: none;
  padding: 8px 18px; border-radius: 6px; transition: background .15s ease;
}
button.primary:hover, .btn:hover { background: var(--accent-dark); color: #fff; text-decoration: none; }
button.secondary {
  background: #fff; color: var(--text); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 6px; transition: border-color .15s ease, background .15s ease;
}
button.secondary:hover { border-color: var(--accent); }
button.linklike { background: none; border: none; color: var(--accent); padding: 0; font-size: 14px; }
button.linklike:hover { color: var(--accent-dark); text-decoration: underline; }
button.linklike.danger { color: var(--err); }
button[disabled] { opacity: .55; cursor: default; }

.stack { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: end; }
.form-actions { display: flex; gap: 8px; align-items: end; }
.row-form { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.row-form input { flex: 1; min-width: 220px; width: auto; margin: 0; }
.inline { display: inline; }

.btn.secondary-btn { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary-btn:hover { border-color: var(--accent); background: #fff; }

/* Пагинация логов */
.pager { display: flex; gap: 16px; align-items: center; justify-content: center; margin-top: 14px; font-size: 14px; }
.page-link { padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; transition: border-color .15s ease; }
.page-link:hover { border-color: var(--accent); text-decoration: none; }

/* Вход */
body.centered { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 28px 30px; width: 100%; max-width: 400px; animation: appear .3s ease;
}
.auth-card h1 { margin-top: 0; }

/* Редактор манифеста */
.editor-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 14px 0; position: sticky; top: 52px; z-index: 5; background: var(--bg); padding: 8px 0; }
.editor-head .spacer { flex: 1; }
.fieldrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 14px; margin-bottom: 8px; }
.fieldrow .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin-top: 20px; }
.check input { width: auto; margin: 0; }
.subactions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.subactions .note { color: var(--muted); font-size: 12.5px; }
.cert-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; transition: border-color .15s ease; }
.cert-item:hover { border-color: #c2cad2; }
.cert-head { display: flex; align-items: baseline; gap: 10px; cursor: pointer; }
.cert-head .title { font-weight: 600; }
.cert-head .meta { color: var(--muted); font-size: 12.5px; flex: 1; }
.cert-body { margin-top: 10px; }
.collapsed .cert-body { display: none; }
pre.preview {
  background: #f7f8f9; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; overflow-x: auto; font-size: 12.5px; max-height: 480px;
}
.progress { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 6px; display: none; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }

/* Телефон: меню сворачивается в бургер в шапке, раскрывается столбиком над содержимым */
@media (max-width: 860px) {
  .topwrap { min-height: 46px; padding: 6px 14px; }
  .burger { display: block; margin-left: auto; }
  .logout { margin-left: 0; }
  .layout { display: block; padding: 4px 14px 0; }
  /* Меню - выпадающее поверх содержимого, закреплено под шапкой:
     видно при любой прокрутке страницы */
  .mainnav {
    display: none; width: auto; margin: 0;
    position: fixed; top: 54px; left: 12px; right: 12px; z-index: 30;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 6px; box-shadow: 0 10px 28px rgba(0, 0, 0, .14);
    max-height: calc(100vh - 70px); overflow-y: auto;
  }
  .top.open ~ .layout .mainnav { display: flex; }
  .mainnav a { padding: 11px 12px; }
  .editor-head { top: 46px; }
}

@media (max-width: 700px) {
  h1 { font-size: 20px; }
  .card { padding: 14px; }

  /* Таблицы-реестры превращаются в карточки: строка - блок, у ячеек подписи из data-l */
  .list thead { display: none; }
  .list, .list tbody, .list tr, .list td { display: block; width: 100%; }
  .list tr { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
  .list tr:last-child td { border-bottom: none; }
  .list td { border-bottom: none; padding: 3px 0; }
  .list td.nowrap, .list td.mono { white-space: normal; }
  .list td[data-l]::before {
    content: attr(data-l); display: inline-block; min-width: 108px;
    color: var(--muted); font-size: 12.5px;
  }
  .list td:empty { display: none; }
  .actions { min-width: 0; }
}
