/* Общие стили: тёмная тема, крупные элементы под палец, высокий контраст.
   Сканером пользуются в полумраке аудитории — светлый фон слепит. */

:root {
  --bg: #0f1216;
  --bg-elev: #171c22;
  --bg-elev-2: #1f262e;
  --line: #2b333d;
  --text: #e9eef4;
  --muted: #9aa7b4;
  --accent: #4c9ffe;
  --ok: #2ea86a;
  --ok-dim: #11331f;
  --warn: #e0a326;
  --warn-dim: #33290d;
  --err: #e05252;
  --err-dim: #331414;
  --radius: 14px;
  --tap: 52px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body { min-height: 100dvh; }

h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; font-weight: 650; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }
.wrap-wide { max-width: 1180px; margin: 0 auto; padding: 16px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-tight { display: flex; gap: 6px; align-items: center; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* ------------------------------- карточки -------------------------------- */

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.card-tight { padding: 12px; }

/* -------------------------------- формы ---------------------------------- */

label { display: block; margin: 0 0 4px; font-size: .85rem; color: var(--muted); }

input, select, textarea, button {
  font: inherit;
  color: inherit;
  font-family: inherit;
}

input[type="text"], input[type="password"], input[type="date"],
input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

textarea { min-height: 120px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; }

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.field { margin-bottom: 12px; }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; }

/* -------------------------------- кнопки --------------------------------- */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 18px;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #06121f; }
.btn-danger { background: transparent; border-color: var(--err); color: var(--err); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: .85rem; font-weight: 500; }

/* ------------------------------- бейджики -------------------------------- */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--muted);
}
.badge-ok { background: var(--ok-dim); color: #7ee0a8; border-color: transparent; }
.badge-warn { background: var(--warn-dim); color: #f2ca72; border-color: transparent; }
.badge-err { background: var(--err-dim); color: #f2a0a0; border-color: transparent; }

/* -------------------------------- таблицы -------------------------------- */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: var(--bg-elev-2); }

/* ------------------------------ уведомления ------------------------------ */

.notice {
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
}
.notice-err { background: var(--err-dim); border-color: #5c2626; }
.notice-ok { background: var(--ok-dim); border-color: #1f5c3a; }
.notice-warn { background: var(--warn-dim); border-color: #5c4a1a; }

#toasts {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
  width: min(560px, calc(100vw - 24px));
}
.toast {
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
  animation: toast-in .16s ease-out;
}
.toast-err { background: #40191a; border-color: #6b2a2a; }
.toast-ok { background: #143324; border-color: #245c3c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------- служебное ------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(15, 18, 22, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar strong { font-size: .95rem; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; }
.tab {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  cursor: pointer;
  white-space: nowrap;
  font-size: .9rem;
  min-height: 40px;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 650; }

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev-2);
  margin-bottom: 8px;
  cursor: pointer;
}
.list-item:active { border-color: var(--accent); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }
.list-item .sub { font-size: .82rem; color: var(--muted); }
