/* Шрифт лежит внутри программы, в static/fonts/ (Golos Text, лицензия
   SIL OFL — файл OFL-GolosText.txt рядом), интернет для него не нужен.
   Golos Text — вариативный: один файл на набор символов покрывает начертания
   400–600. Наборы символов (unicode-range) взяты из Google Fonts.
   Если файла нет — используется системный Segoe UI. */
@font-face {
  font-family: "Golos Text";
  src: url("/fonts/GolosText-cyrillic-ext.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "Golos Text";
  src: url("/fonts/GolosText-cyrillic.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text";
  src: url("/fonts/GolosText-latin-ext.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Golos Text";
  src: url("/fonts/GolosText-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --accent: #1f4e8c;
  --accent-hover: #173b6a;
  --accent-ring: rgba(31, 78, 140, 0.18);
  --accent-tint: #f2f6fb;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-alt: #fafbfc;
  --text: #16191d;
  --text-muted: #5b6470;
  --border: #e3e6ea;
  --border-input: #cbd2d9;
  --border-row: #eef0f2;
  --radius: 8px;
  --radius-card: 16px;
  --font: "Golos Text", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted { color: var(--text-muted); }

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.01em;
}

p { margin: 0; }

/* Каркас страницы */

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

.test-banner {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 10px 24px;
  background: #fff6e0;
  border-bottom: 1px solid #f1d9a0;
  color: #5c3f00;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.test-banner strong { font-weight: 600; }
.test-banner .icon { width: 16px; height: 16px; }

/* Логотип стоит прямо на фоне страницы — поэтому он должен быть PNG с
   прозрачным фоном. */
.org-header .container {
  padding-top: 24px;
  padding-bottom: 0;
}

#org-logo {
  display: block;
  width: auto;
  height: auto;
  max-height: 120px;
  max-width: min(360px, 100%);
}

.main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  padding-top: 24px;
  padding-bottom: 48px;
}

/* Экраны */

.view-center {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.card-narrow {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-head .muted { font-size: 14px; }

.page-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 24px;
}

.page-head h1 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }

/* Поля */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
}

input[type="text"], input[type="password"], input[type="number"], select {
  height: 44px;
  padding: 0 12px;
  font: inherit;
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

input:disabled {
  background: var(--bg);
  color: #8a929c;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

input[type="checkbox"]:disabled { cursor: not-allowed; }

.field-select { max-width: 480px; }

.select-wrap { position: relative; display: block; }

.select-wrap select {
  width: 100%;
  padding-right: 40px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.select-chevron {
  position: absolute;
  right: 12px;
  top: 13px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Кнопки */

.btn {
  min-height: 44px;
  padding: 10px 24px;
  line-height: 1.25;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 78, 140, 0.28);
}

.btn:disabled { cursor: not-allowed; }

.btn-primary {
  color: #fff;
  background: var(--accent);
  border: none;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.45; }
.btn-primary.is-busy:disabled { opacity: 0.75; cursor: default; }

.btn-secondary {
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border-input);
}

.btn-secondary:hover { border-color: var(--accent); }

.btn-block {
  width: 100%;
  padding-left: 16px;
  padding-right: 16px;
}

.btn-label { white-space: nowrap; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Сообщения об ошибке */

.alert {
  padding: 10px 12px;
  background: #fdecec;
  border: 1px solid #f5c2c2;
  border-radius: var(--radius);
  color: #8a1c1c;
  font-size: 14px;
  line-height: 1.4;
}

/* Доступ закрыт администратором */

.notice {
  padding: 14px 16px;
  background: #eef3fa;
  border: 1px solid #c9d8ec;
  border-radius: var(--radius);
  color: #173b6a;
  font-size: 15px;
  line-height: 1.5;
}

/* Таблица бумаг */

.card-table { overflow: hidden; }

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th {
  height: 44px;
  padding: 0 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--border-row);
  vertical-align: middle;
}

th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }

.col-check { width: 44px; }

tbody tr.is-selected { background: var(--accent-tint); }

.sec-issuer { font-weight: 500; }

.sec-name {
  font-size: 13px;
  color: var(--text-muted);
}

/* ISIN — основным шрифтом с цифрами одинаковой ширины: столбец ровный,
   а ноль обычный (в моноширинном шрифте был с точкой внутри). */
.isin {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: #3a424c;
  white-space: nowrap;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.num input {
  width: 128px;
  height: 40px;
  padding: 0 10px;
  font-size: 15px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  background: var(--surface-alt);
}

.confirm {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 560px;
  line-height: 1.45;
  cursor: pointer;
}

.confirm input { margin-top: 1px; flex-shrink: 0; }

.actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.actions .muted { font-size: 14px; }

/* Узкий экран (телефон): строки таблицы — карточками, чтобы поле
   количества было видно без прокрутки вбок. */
@media (max-width: 640px) {
  .container { padding-left: 16px; padding-right: 16px; }
  #org-logo { max-height: 80px; }
  .card-narrow { padding: 24px; }
  .btn-label { white-space: normal; }
  .page-head h1 { font-size: 24px; }

  table { min-width: 0; }
  thead { display: none; }

  tbody tr {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    grid-template-areas:
      "check issue issue"
      ".     isin  isin"
      ".     avail qty";
    gap: 6px 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-row);
  }

  td, td:first-child, td:last-child {
    padding: 0;
    border: none;
  }

  td.col-check { grid-area: check; padding-top: 2px; }
  td.sec-cell { grid-area: issue; }
  td.isin { grid-area: isin; }
  td.avail { grid-area: avail; align-self: center; text-align: left; color: var(--text-muted); font-size: 14px; }
  td.avail::before { content: "Доступно: "; }
  td.qty { grid-area: qty; }

  .card-footer { padding: 16px; }
  .actions { width: 100%; justify-content: space-between; }
}

/* Результат */

.card-result {
  max-width: 480px;
  padding: 40px 32px 32px;
  align-items: center;
  text-align: center;
  gap: 20px;
}

.card-result .card-head { gap: 8px; }
.card-result .muted { font-size: 15px; line-height: 1.55; }

.result-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-icon .icon { width: 28px; height: 28px; stroke-width: 2.5; }
.result-icon.is-success { background: #e7f4ec; color: #1e7f4f; }
.result-icon.is-error { background: #fdecec; color: #b42318; }
.result-icon.is-success .icon-error, .result-icon.is-error .icon-success { display: none; }
