@font-face { font-family: 'UI'; font-weight: 400; src: url(/fonts/GoogleSans-Regular.ttf) format('truetype'); font-display: swap; }
@font-face { font-family: 'UI'; font-weight: 500; src: url(/fonts/GoogleSans-Medium.ttf) format('truetype'); font-display: swap; }
/* шрифты сертификата — те же файлы, что рисуют PDF на сервере */
@font-face { font-family: 'CertPlayfair'; src: url(/fonts/Playfair-MediumItalic-opsz12.ttf) format('truetype'); }
@font-face { font-family: 'CertGoogleSans'; font-style: italic; src: url(/fonts/GoogleSans-Italic.ttf) format('truetype'); }

:root {
  --bg: #FEFCF8;
  --card: #FFFFFF;
  --ink: #170500;
  --ink-2: #8A7D72;
  --line: #EADFD2;
  --line-strong: #D9C8B4;
  --gold: #E2AA6C;
  --gold-ink: #A8713A;
  --soft: #F6EEE4;
  --warn: #B4541E;
  --warn-bg: #FBEDE3;
  --ok: #3D7A4A;
  --radius: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 400 16px/1.4 'UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }

/* шапка */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 32px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 16px; }
.brand .logo { display: block; height: 36px; width: auto; }
.brand span { color: var(--ink-2); font-size: 14px; }
.link { background: none; border: 0; padding: 8px 0; color: var(--ink-2); font-size: 14px; cursor: pointer; text-decoration: none; }
.link:hover { color: var(--ink); }

/* сетка */
.wrap { max-width: 1600px; margin: 0 auto; padding: 32px; display: grid; grid-template-columns: 400px 1fr; gap: 32px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; }
h1 { font-size: 24px; font-weight: 500; margin: 0 0 24px; }
h2 { font-size: 20px; font-weight: 500; margin: 0 0 16px; }

/* поля */
.field { margin-bottom: 24px; }
.label { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 8px; }
.input {
  display: flex; align-items: center; height: 48px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 12px; background: var(--card);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus-within { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(226, 170, 108, .2); }
.input.bad { border-color: var(--warn); }
.input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; font-size: 16px; padding: 0; }
.input input::placeholder { color: #C4B6A8; }
.prefix { color: var(--ink-2); margin-right: 1px; }
.row { display: flex; gap: 8px; align-items: center; }
.row .input { flex: 1; }
.hint { font-size: 14px; color: var(--ink-2); margin-top: 8px; }
.hint:empty { display: none; }
.hint button { padding: 0; border: 0; background: none; color: var(--gold-ink); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.hint.warn { color: var(--warn); }

/* чипы (вместо системных селектов) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 40px; padding: 0 16px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--card); font-size: 14px;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--gold); }
.chip[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #fff; }
.chip.small { height: 48px; border-radius: 12px; flex: none; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 4px; border-radius: 24px; background: var(--soft); }
.seg .chip { border: 0; background: none; height: 40px; font-size: 16px; }
.seg .chip[aria-pressed="true"] { background: var(--gold); color: #fff; }

/* комбобокс с поиском (менеджер) */
.combo { position: relative; }
.combo-toggle { flex: none; width: 32px; height: 32px; margin-right: -8px; border: 0; background: none; color: var(--ink-2); cursor: pointer; display: grid; place-items: center; border-radius: 8px; }
.combo-toggle:hover { color: var(--ink); background: var(--soft); }
.combo-add {
  flex: none; height: 32px; margin-right: -8px; padding: 0 12px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--gold); color: #fff; font-size: 14px; font-weight: 500;
}
.combo-add:hover { filter: brightness(.96); }
.combo-add[disabled] { opacity: .6; cursor: default; }
.combo-list li.add { color: var(--gold-ink); font-weight: 500; }
.combo-list {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px; list-style: none; max-height: 240px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(23, 5, 0, .12);
}
.combo-list li { padding: 10px 12px; border-radius: 8px; font-size: 16px; cursor: pointer; }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: var(--soft); }
.combo-list li mark { background: none; color: var(--gold-ink); font-weight: 500; }
.combo-list li.note { cursor: default; color: var(--ink-2); font-size: 14px; }
.combo-list li.note:hover { background: none; }

/* кнопки */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.btn {
  height: 48px; border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  font-size: 16px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: filter .15s, background .15s;
}
.btn-primary { background: var(--gold); color: #fff; }
.btn-primary:hover { filter: brightness(.96); }
.btn-ghost { background: var(--soft); color: var(--ink); }
.btn-ghost:hover { background: #F0E4D6; }
.btn[disabled] { opacity: .5; cursor: default; filter: none; }
.status { font-size: 14px; color: var(--ink-2); margin-top: 16px; min-height: 20px; }
.status.err { color: var(--warn); }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: s .7s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }

/* превью */

.sheet { background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 4px rgba(23, 5, 0, .06), 0 16px 48px rgba(23, 5, 0, .12); }
.sheet svg { display: block; width: 100%; height: auto; aspect-ratio: 2380 / 1684; }
.preview-note { font-size: 14px; color: var(--ink-2); margin-top: 16px; text-align: center; }

/* журнал */
.issued { grid-column: 1 / -1; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 400; color: var(--ink-2); padding: 8px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); }
.table td:nth-child(2), .table td:nth-child(4) { white-space: nowrap; }
.table td:nth-child(6) { color: var(--ink-2); }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--soft); }
.empty { color: var(--ink-2); font-size: 14px; }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .panel { width: 100%; max-width: 400px; }
.login .brand { flex-direction: column; text-align: center; gap: 16px; margin-bottom: 32px; }
.login .brand .logo { height: 48px; }
.login .brand span { display: block; font-size: 16px; }
.login .btn { width: 100%; margin-top: 8px; }

@media (max-width: 1100px) {
  .wrap { grid-template-columns: 1fr; }
  .preview { order: -1; }
}
@media (max-width: 600px) {
  .top { padding: 8px 16px; }
  .brand span { display: none; }
  .wrap { padding: 16px; gap: 16px; }
  .panel { padding: 20px; }
  .table th:nth-child(1), .table td:nth-child(1), .table th:nth-child(5), .table td:nth-child(5), .table th:nth-child(6), .table td:nth-child(6) { display: none; }
}
