/* ==========================================================================
   Turboref Engineering — дизайн-система помощника оператора
   Палитра и типографика сняты с turboref.ru
   ========================================================================== */

:root {
  /* Фирменные цвета */
  --ink:          #080C1C;   /* основной тёмно-синий */
  --ink-2:        #0D1226;   /* поверхности на тёмном */
  --ink-3:        #161C33;   /* приподнятые блоки */
  --accent:       #E62E1F;   /* фирменный красный */
  --accent-hover: #C9261A;
  --accent-soft:  rgba(230, 46, 31, .12);

  --paper:        #F6F6F6;   /* фон светлой темы */
  --surface:      #FFFFFF;
  --surface-2:    #F0F1F3;
  --line:         #D9DADA;
  --line-soft:    rgba(8, 12, 28, .08);

  --text:         #080C1C;
  --text-2:       #4A4F5E;
  --text-3:       #606674;
  --text-muted:   #9AA0AB;

  --ok:      #12805C;
  --warn:    #89500B;
  --danger:  #E62E1F;

  --font: "IBM Plex Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: Manrope, "IBM Plex Sans", system-ui, sans-serif;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(8,12,28,.06), 0 1px 3px rgba(8,12,28,.04);
  --shadow:    0 4px 16px rgba(8,12,28,.08);
  --shadow-lg: 0 12px 40px rgba(8,12,28,.16);

  --header-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;              /* 16px: iOS не зумит поля ввода */
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Шапка ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  min-height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  background: rgba(8, 12, 28, .96);
  backdrop-filter: blur(10px);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.topbar a { color: #fff; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-family: var(--font-display); }
.brand img { height: 26px; width: auto; display: block; }
.brand-text { font-size: .95rem; letter-spacing: -.01em; }
.brand-text em { color: #FF7467; font-style: normal; }
.topbar .spacer { flex: 1; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--r-sm);
  background: transparent; border: 0; color: inherit; cursor: pointer;
  font-size: 1.1rem;
}
.icon-btn:hover { background: rgba(255,255,255,.1); }

/* ── Раскладка ─────────────────────────────────────────────────────── */
.wrap { max-width: 1180px; margin: 0 auto; padding: 18px 14px 32px; }
.wrap-narrow { max-width: 560px; margin: 0 auto; padding: 18px 14px 32px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}
.card + .card { margin-top: 14px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  margin: -16px -16px 14px; padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--r) var(--r) 0 0;
  font-weight: 600;
}

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ── Кнопки ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px;                       /* палец в перчатке */
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--accent-hover); color: #fff;
  font: inherit; font-weight: 600; font-size: .95rem;
  cursor: pointer; text-decoration: none;
  transition: background .15s, transform .05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-dark { background: var(--ink); }
.btn-dark:hover { background: var(--ink-3); }
.btn-danger { background: var(--danger); }
.btn-sm { min-height: 44px; padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; }

/* ── Формы ─────────────────────────────────────────────────────────── */
label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=email], input[type=search],
select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit; font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; line-height: 1.45; }
.field { margin-bottom: 14px; }
.hint { font-size: .8rem; color: var(--text-3); margin-top: 5px; }

.checks { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); }
.check {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--surface); cursor: pointer;
}
.check:hover { border-color: var(--text-3); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }

/* ── Плашки и бейджи ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
  background: var(--surface-2); color: var(--text-2);
}
.badge-accent { background: var(--accent-soft); color: #AB2117; }
.badge-ok     { background: rgba(18,128,92,.12);  color: var(--ok); }
.badge-warn   { background: rgba(180,105,14,.12); color: var(--warn); }

.alert {
  padding: 11px 14px; border-radius: var(--r-sm);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft); color: var(--text);
  font-size: .9rem; margin-bottom: 14px;
}
.alert-ok { border-left-color: var(--ok); background: rgba(18,128,92,.1); }

.eyebrow {
  display: flex; align-items: center; gap: 9px;
  font-size: .72rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--accent-hover); margin-bottom: 8px;
}
.eyebrow::before { content: ""; width: 22px; height: 2px; background: var(--accent); }

.empty { text-align: center; padding: 40px 18px; color: var(--text-3); }
.empty-icon { font-size: 2.2rem; opacity: .35; margin-bottom: 10px; }

/* ── Таблицы ───────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em;
     color: var(--text-3); font-weight: 700; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* ── Утилиты ───────────────────────────────────────────────────────── */
.muted { color: var(--text-3); }
.small { font-size: .82rem; }
.mono  { font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace; font-size: .85em; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }
@media (max-width: 720px) { .hide-mobile { display: none !important; } }

/* Общие ориентиры: видимый фокус, подписанная навигация, цели от 44px. */
:focus-visible { outline: 3px solid #2563EB; outline-offset: 3px; }
.topbar :focus-visible { outline-color: #A9C8FF; outline-offset: -3px; }
.app-main { min-width: 0; }
.app-main:focus { outline: none; }
.skip-link { position: fixed; left: 12px; top: 8px; z-index: 100;
  transform: translateY(-150%); padding: 12px 18px;
  background: #fff; color: var(--ink); border-radius: var(--r-sm); }
.skip-link:focus { transform: translateY(0); }
.brand { flex: none; min-height: 44px; }
.brand:hover { text-decoration: none; }
.primary-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; min-width: 0; }
.primary-nav a { display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 14px; border-radius: var(--r-sm);
  color: #CBD0DC; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.primary-nav a:hover { background: var(--ink-3); color: #fff; text-decoration: none; }
.primary-nav a[aria-current="page"] { background: var(--ink-3); color: #fff;
  box-shadow: inset 0 -2px var(--accent); }
.icon-btn { flex-shrink: 0; }
.icon-btn:hover { background: var(--line-soft); }
.topbar .icon-btn:hover { background: rgba(255,255,255,.1); }
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }
.empty h2, .empty h3 { color: var(--text); }
.empty p { max-width: 46ch; margin: 12px auto 20px; }
.wrap, .wrap-narrow { overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 0; padding: 4px 12px 0; }
  .topbar .brand { margin-right: auto; }
  .primary-nav { flex-basis: 100%; margin: 0; justify-content: space-between; flex-wrap: wrap; }
  .primary-nav a { padding: 8px; }
}
@media (max-width: 360px) {
  .primary-nav a { flex: 1 1 45%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important;
    scroll-behavior: auto !important; }
}
