/* Страницы входа и управления. Только токены из /app/tokens.css — никаких hex.
   Базовые элементы (кнопки, поля, сообщения, метки) — в /app/base.css. */

/* ================================================================ вход */
body.bw-auth {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, var(--bw-100), transparent 45%),
    var(--bw-bg);
  background-attachment: fixed;
}
.auth {
  max-width: 420px;
  margin: 0 auto;
  padding: var(--bw-space-10) var(--bw-space-4) var(--bw-space-8);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--bw-space-3);
  margin-bottom: var(--bw-space-6);
}
.auth-brand .bw-logo { width: 40px; height: 40px; }
.auth-brand .bw-logo .bw-icon { width: 22px; height: 22px; }
.auth-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.auth-brand-text strong { font-size: 18px; color: var(--bw-900); font-weight: 600; }
.auth-brand-text span { font-size: 12px; color: var(--bw-muted); }

.auth-card {
  padding: var(--bw-space-8) var(--bw-space-6);
  box-shadow: var(--bw-shadow-md);
}
.auth-card h1 { font-size: 20px; margin-bottom: var(--bw-space-2); }
.auth-lead { color: var(--bw-muted); margin-bottom: var(--bw-space-5); }
.auth-card form { margin-top: var(--bw-space-2); }
.auth-card .bw-btn-block { margin-top: var(--bw-space-2); }
.auth-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--bw-space-4);
  border-radius: var(--bw-radius-lg);
  background: var(--bw-100);
  color: var(--bw-700);
}
.auth-icon .bw-icon { width: 22px; height: 22px; }
.auth-icon-danger { background: var(--bw-danger-soft); color: var(--bw-danger); }
.auth-note {
  display: flex;
  gap: var(--bw-space-2);
  margin: var(--bw-space-5) 0 0;
  color: var(--bw-muted);
  font-size: 12px;
}
.auth-note .bw-icon { margin-top: 2px; }
.auth-links { margin: var(--bw-space-4) 0 0; font-size: 13px; }
.auth-links a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.auth-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: var(--bw-space-5) 0 0;
  color: var(--bw-muted);
  font-size: 12px;
}

.code-input {
  font-family: var(--bw-font-mono);
  font-size: 24px;
  letter-spacing: 0.3em;
  text-align: center;
  padding: 10px;
}

.auth-steps {
  margin: 0 0 var(--bw-space-4);
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.auth-steps li {
  position: relative;
  padding: 0 0 var(--bw-space-3) 34px;
  counter-increment: step;
}
.auth-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bw-100);
  color: var(--bw-700);
  font-size: 12px;
  font-weight: 600;
  line-height: 22px;
  text-align: center;
}
.qr {
  display: flex;
  justify-content: center;
  margin: 0 0 var(--bw-space-4);
  padding: var(--bw-space-4);
  border: 1px solid var(--bw-border);
  border-radius: var(--bw-radius-md);
  background: var(--bw-surface);
}
.qr img { display: block; }
.manual {
  margin: 0 0 var(--bw-space-4);
  padding: var(--bw-space-3) var(--bw-space-4);
  border-radius: var(--bw-radius-md);
  background: var(--bw-bg);
}
.manual summary {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--bw-700);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}
.manual summary::-webkit-details-marker { display: none; }
.manual[open] .manual-chevron { transform: rotate(90deg); }
.manual p { margin: var(--bw-space-3) 0 0; }
.secret {
  padding: var(--bw-space-2) var(--bw-space-3);
  border: 1px dashed var(--bw-300);
  border-radius: var(--bw-radius-sm);
  background: var(--bw-surface);
  font-size: 15px;
  letter-spacing: 0.08em;
  word-break: break-all;
}
.codes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--bw-space-2);
  margin: 0 0 var(--bw-space-5);
  padding: 0;
  list-style: none;
}
.codes li {
  padding: var(--bw-space-2);
  border: 1px dashed var(--bw-300);
  border-radius: var(--bw-radius-sm);
  background: var(--bw-bg);
  font-size: 15px;
  text-align: center;
}

/* ================================================================ каркас управления */
.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: var(--bw-space-4) var(--bw-space-3);
  background: var(--bw-surface);
  border-right: 1px solid var(--bw-border);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--bw-space-3);
  padding: var(--bw-space-2) var(--bw-space-2) var(--bw-space-5);
  text-decoration: none;
}
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-brand-text strong { color: var(--bw-900); font-size: 15px; font-weight: 600; }
.sidebar-brand-text span { color: var(--bw-muted); font-size: 12px; }

.sidenav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidenav a {
  display: flex;
  align-items: center;
  gap: var(--bw-space-3);
  padding: var(--bw-space-2) var(--bw-space-3);
  border-radius: var(--bw-radius-md);
  color: var(--bw-700);
  text-decoration: none;
  font-weight: 500;
}
.sidenav a .bw-icon { width: 18px; height: 18px; color: var(--bw-500); }
.sidenav a:hover { background: var(--bw-hover); color: var(--bw-900); }
.sidenav a[aria-current="page"] { background: var(--bw-selected); color: var(--bw-900); }
.sidenav a[aria-current="page"] .bw-icon { color: var(--bw-900); }
.sidenav .sidenav-app {
  margin-top: var(--bw-space-3);
  border: 1px dashed var(--bw-300);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--bw-space-2);
  padding: var(--bw-space-3) var(--bw-space-1) 0;
  border-top: 1px solid var(--bw-border);
}
.sidebar-user form { margin: 0; }
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: var(--bw-100);
  color: var(--bw-700);
  font-weight: 600;
}
.sidebar-user-name {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}
.sidebar-user-name strong,
.sidebar-user-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user-name strong { font-weight: 500; color: var(--bw-900); font-size: 13px; }
.sidebar-user-name span { color: var(--bw-muted); font-size: 12px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--bw-radius-md);
  background: none;
  color: var(--bw-muted);
}
.icon-btn:hover { background: var(--bw-hover); color: var(--bw-900); }
.icon-btn .bw-icon { width: 18px; height: 18px; }

.page {
  width: 100%;
  max-width: 1200px;
  padding: var(--bw-space-8) var(--bw-space-8) var(--bw-space-10);
}

/* ================================================================ заголовки страниц */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--bw-space-4);
  margin-bottom: var(--bw-space-6);
}
.page-sub { margin: var(--bw-space-1) 0 0; color: var(--bw-muted); }
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--bw-space-3);
  color: var(--bw-muted);
  font-size: 13px;
  text-decoration: none;
}
.back:hover { color: var(--bw-900); }

.section { margin-top: var(--bw-space-8); }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bw-space-3);
  margin-bottom: var(--bw-space-3);
}
.icon-after { margin: 0 0 0 4px; }

/* ================================================================ плитки обзора */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--bw-space-4);
}
.tile {
  display: flex;
  flex-direction: column;
  gap: var(--bw-space-1);
  padding: var(--bw-space-5);
  color: var(--bw-muted);
  text-decoration: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.tile:hover { border-color: var(--bw-300); box-shadow: var(--bw-shadow-md); color: var(--bw-muted); }
.tile strong { color: var(--bw-900); font-size: 15px; font-weight: 600; }
.tile span:last-child { font-size: 13px; }
.tile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-bottom: var(--bw-space-3);
  border-radius: var(--bw-radius-md);
  background: var(--bw-100);
  color: var(--bw-700);
}
.tile-icon .bw-icon { width: 20px; height: 20px; }

/* ================================================================ панель поиска */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--bw-space-2) var(--bw-space-3);
  margin-bottom: var(--bw-space-4);
}
.search-input {
  position: relative;
  flex: 0 1 360px;
  min-width: 220px;
}
.search-input .bw-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bw-muted);
  pointer-events: none;
}
.search-input input { width: 100%; padding-left: 32px; min-height: var(--bw-control-h); }
.toolbar-count { margin-left: auto; color: var(--bw-muted); font-size: 13px; }

/* ================================================================ таблицы */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  padding: 10px var(--bw-space-4);
  border-bottom: 1px solid var(--bw-border);
  text-align: left;
  vertical-align: middle;
}
.table th {
  background: var(--bw-bg);
  color: var(--bw-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.table thead th:first-child { border-top-left-radius: var(--bw-radius-lg); }
.table thead th:last-child { border-top-right-radius: var(--bw-radius-lg); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bw-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .bw-badge { margin: 2px 0; }
.row-link { color: var(--bw-900); font-weight: 500; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.row-danger { background: var(--bw-danger-soft); }
.row-danger:hover { background: var(--bw-danger-soft); }
.status-cell { width: 1%; padding-right: 0; }
.status-ok { color: var(--bw-success); }
.status-bad { color: var(--bw-danger); }
.status-ok .bw-icon, .status-bad .bw-icon { width: 16px; height: 16px; display: block; }
.cell-muted { color: var(--bw-muted); }
.cell-small { font-size: 12px; }
.nowrap { white-space: nowrap; }

.barcode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px 6px 2px 0;
  padding: 1px 8px 1px 6px;
  border: 1px solid var(--bw-border);
  border-radius: var(--bw-radius-sm);
  background: var(--bw-bg);
  font-size: 12px;
  white-space: nowrap;
}
.barcode-pack { color: var(--bw-muted); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--bw-space-3);
  padding: var(--bw-space-10) var(--bw-space-4);
  color: var(--bw-muted);
  text-align: center;
}
.empty p { margin: 0; }
.empty-icon { width: 32px; height: 32px; color: var(--bw-300); }

/* ================================================================ формы и панели */
.cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--bw-space-6);
  align-items: start;
}
.panel { padding: var(--bw-space-6); }
.panel-narrow { max-width: 720px; }
.panel-title {
  display: flex;
  align-items: center;
  gap: var(--bw-space-2);
  margin-bottom: var(--bw-space-4);
  font-size: 15px;
}
.panel-title .bw-icon { color: var(--bw-500); }
.panel-title-sep {
  margin-top: var(--bw-space-6);
  padding-top: var(--bw-space-5);
  border-top: 1px solid var(--bw-border);
}
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bw-space-2);
  margin-top: var(--bw-space-6);
  padding-top: var(--bw-space-5);
  border-top: 1px solid var(--bw-border);
}
.panel-actions .bw-btn-danger { margin-left: auto; }
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 var(--bw-space-4);
}
.field-short input { max-width: 120px; }
.check-group .bw-check { padding: 6px var(--bw-space-2); margin: 0; border-radius: var(--bw-radius-sm); }
.check-group .bw-check:hover { background: var(--bw-hover); }
.switch-row {
  padding: var(--bw-space-3);
  border: 1px solid var(--bw-border);
  border-radius: var(--bw-radius-md);
  background: var(--bw-bg);
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--bw-space-3) var(--bw-space-4);
  margin: 0 0 var(--bw-space-5);
}
.facts dt { color: var(--bw-muted); }
.facts dd { margin: 0; }
.action-list { display: flex; flex-direction: column; gap: var(--bw-space-2); margin: 0; }
.action-list > button { justify-content: flex-start; width: 100%; }

.sessions { margin: 0; padding: 0; list-style: none; }
.sessions li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--bw-space-3) 0;
  border-bottom: 1px solid var(--bw-border);
}
.sessions li:last-child { border-bottom: 0; }
.session-when { display: flex; align-items: center; gap: var(--bw-space-2); font-weight: 500; }
.session-when .bw-icon { color: var(--bw-muted); }
.session-when .bw-mono { margin-left: auto; font-weight: 400; font-size: 12px; }
.session-ua { color: var(--bw-muted); font-size: 12px; overflow-wrap: anywhere; }

/* ================================================================ временный пароль */
.slip {
  max-width: 480px;
  margin-bottom: var(--bw-space-4);
  overflow: hidden;
}
.slip-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--bw-space-4) var(--bw-space-5);
}
.slip-row + .slip-row { border-top: 1px dashed var(--bw-border); }
.slip-label { color: var(--bw-muted); font-size: 12px; }
.slip-value { color: var(--bw-900); font-size: 20px; font-weight: 600; word-break: break-all; }
.slip-note { max-width: 640px; }

/* ================================================================ адаптив */
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar {
    align-content: flex-start;
    position: sticky;
    z-index: 10;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--bw-space-2);
    padding: var(--bw-space-2) var(--bw-space-4);
    border-right: 0;
    border-bottom: 1px solid var(--bw-border);
  }
  .sidebar-brand { padding: var(--bw-space-1) 0; }
  .sidebar-brand-text span { display: none; }
  .sidebar-user { order: 2; margin-left: auto; padding: 0; border: 0; }
  .sidebar-user-name { display: none; }
  .sidenav {
    order: 3;
    flex: 1 0 100%;
    flex-direction: row;
    gap: var(--bw-space-1);
    overflow-x: auto;
    margin: 0 calc(var(--bw-space-4) * -1);
    padding: 0 var(--bw-space-4) var(--bw-space-1);
  }
  .sidenav a { flex: none; padding: 6px 10px; }
  .sidenav .sidenav-app { margin-top: 0; }
  .page { padding: var(--bw-space-5) var(--bw-space-4) var(--bw-space-8); }
  .cols, .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .auth { padding-top: var(--bw-space-6); }
  .auth-card { padding: var(--bw-space-6) var(--bw-space-4); }
  .panel { padding: var(--bw-space-4); }
  .panel-actions .bw-btn-danger { margin-left: 0; }
}
