/* ===== Тема ===== */
:root {
  --bg: #fbfbfd;
  --panel: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --active: #1ba14f;
  --warn: #c77700;
  --danger: #d70015;
  --unknown: #9a9a9e;
  --hover: rgba(0, 0, 0, 0.04);
  --soft: rgba(0, 0, 0, 0.025);
  --topbar-bg: rgba(251, 251, 253, 0.8);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 6px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.08);
  --overlay: rgba(0, 0, 0, 0.25);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 0px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #121214;
  --panel: #1c1c1f;
  --border: rgba(255, 255, 255, 0.1);
  --text: #f2f2f4;
  --muted: #a1a1a8;
  --accent: #3b9bff;
  --accent-hover: #5aaaff;
  --active: #34c46a;
  --warn: #f0a030;
  --danger: #ff5b6b;
  --unknown: #85858c;
  --hover: rgba(255, 255, 255, 0.07);
  --soft: rgba(255, 255, 255, 0.04);
  --topbar-bg: rgba(18, 18, 20, 0.8);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.5);
  --overlay: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214; --panel: #1c1c1f; --border: rgba(255, 255, 255, 0.1); --text: #f2f2f4; --muted: #a1a1a8;
    --accent: #3b9bff; --accent-hover: #5aaaff; --active: #34c46a; --warn: #f0a030; --danger: #ff5b6b;
    --unknown: #85858c; --hover: rgba(255, 255, 255, 0.07); --soft: rgba(255, 255, 255, 0.04);
    --topbar-bg: rgba(18, 18, 20, 0.8); --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.5); --overlay: rgba(0, 0, 0, 0.55); color-scheme: dark;
  }
}
/* логотип чёрный на прозрачном - в тёмной теме инвертируем */
:root[data-theme="dark"] .logo { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo { filter: invert(1); } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
input, select, textarea, button { font-family: inherit; color: var(--text); }
input, select, textarea { background: var(--panel); }
a { color: var(--accent); }

/* ===== Шапка ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 32px;
}
.logo { height: 28px; display: block; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab-btn {
  border: none; background: transparent; padding: 8px 18px; border-radius: 980px; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease; white-space: nowrap;
}
.tab-btn.active { background: var(--text); color: var(--bg); }
.tab-btn:not(.active):hover { background: var(--hover); color: var(--text); }

.user-menu { display: flex; align-items: center; gap: 8px; }
.user-name { font-size: 13px; color: var(--muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu .btn-ghost { text-decoration: none; display: inline-block; }

/* ===== Раскладка ===== */
main { max-width: 1180px; margin: 0 auto; padding: 0 24px 64px; }
.tab { display: none; }
.tab.active { display: block; animation: fade-in 0.35s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.hero { padding: 48px 0 24px; text-align: center; }
.hero h1 { font-size: 40px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 8px; }
.hero p { font-size: 17px; color: var(--muted); margin: 0; }
.muted { color: var(--muted); font-size: 13px; margin: 10px 2px; text-align: center; }
.muted-inline { color: var(--muted); font-size: 12px; font-weight: 400; }
.spacer { flex: 1; }

/* ===== Кнопки и поля ===== */
.btn-ghost {
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 980px; background: var(--panel);
  color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background 0.2s ease; min-height: 36px;
}
.btn-ghost:hover:not(:disabled) { background: var(--hover); }
.btn-ghost:disabled { opacity: 0.4; cursor: default; }
.btn-danger { color: var(--danger); border-color: rgba(215, 0, 21, 0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(215, 0, 21, 0.08); }
.btn-primary {
  display: inline-block; margin-top: 20px; padding: 12px 26px; background: var(--accent); color: #fff;
  border: none; border-radius: 980px; font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background 0.2s ease, transform 0.1s ease; min-height: 44px;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }

/* ===== Поиск ===== */
.search-panel { max-width: 760px; margin: 0 auto 16px; }
.search-bar { position: relative; margin-bottom: 12px; }
.search-icon { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search-bar input {
  width: 100%; padding: 14px 44px 14px 46px; font-size: 17px; border: 1px solid var(--border);
  border-radius: 980px; outline: none; background: var(--panel); box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.search-bar input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.14); }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px;
  border: none; background: transparent; color: var(--muted); font-size: 20px; cursor: pointer; border-radius: 50%;
}
.search-clear:hover { background: var(--hover); }

.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 15; background: var(--panel);
  border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-md); overflow: hidden;
  max-height: 60vh; overflow-y: auto;
}
.suggest-title { padding: 10px 18px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.suggest-item { display: flex; justify-content: space-between; gap: 12px; padding: 11px 18px; cursor: pointer; font-size: 15px; }
.suggest-item small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-item:hover, .suggest-item.active { background: var(--hover); }

.filters-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters-row select {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 980px; background: var(--panel);
  font-size: 13px; cursor: pointer; max-width: 180px; text-overflow: ellipsis; min-height: 36px;
}
.bulk-panel { margin-top: 14px; padding: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.bulk-panel textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 14px;
  resize: vertical; outline: none; margin-bottom: 12px; background: var(--panel);
}
.bulk-panel textarea:focus { border-color: var(--accent); }
.bulk-panel .btn-primary { margin-top: 0; }

.examples { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.empty-state { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty-state h3 { color: var(--text); margin: 0 0 6px; font-size: 18px; }
.empty-state p { margin: 4px 0; font-size: 14px; }

.wake-banner {
  position: sticky; top: 0; z-index: 25; background: var(--warn); color: #111; text-align: center;
  padding: 8px 16px; font-size: 13px; font-weight: 500;
}

/* ===== Чипы и сводка ===== */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--border);
  border-radius: 980px; background: var(--panel); font-size: 13px; cursor: pointer; color: var(--text);
  min-height: 34px; transition: background 0.15s ease, border-color 0.15s ease; white-space: nowrap;
}
.chip:hover { background: var(--hover); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { font-variant-numeric: tabular-nums; opacity: 0.7; font-size: 12px; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--unknown); }
.chip .dot.Active { background: var(--active); }
.chip .dot.NRND { background: var(--warn); }
.chip .dot.EOL, .chip .dot.Obsolete { background: var(--danger); }
.chip-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.chip-reset { border-style: dashed; color: var(--muted); }

.results-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.results-count { font-size: 13px; color: var(--muted); }

.col-picker { position: relative; }
.col-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 12; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-md); padding: 8px; min-width: 200px;
}
.col-menu label { display: flex; align-items: center; gap: 10px; padding: 8px 10px; font-size: 14px; cursor: pointer; border-radius: 8px; }
.col-menu label:hover { background: var(--hover); }

.sum-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 16px 0 6px; }
.sum-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px;
  box-shadow: var(--shadow-sm); cursor: pointer; text-align: left; transition: transform 0.1s ease, border-color 0.15s ease;
}
.sum-card:hover { border-color: var(--accent); }
.sum-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.sum-card .num { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.sum-card .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ===== Таблица результатов ===== */
.table-wrap { overflow: auto; border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border); max-height: 72vh; background: var(--panel); }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); }
.data-table th, .data-table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; white-space: nowrap; }
.data-table th {
  color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--panel); position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -1px 0 var(--border);
}
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--text); }
.data-table th .arrow { display: inline-block; width: 10px; margin-left: 4px; opacity: 0.8; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr { cursor: pointer; transition: background 0.15s ease; }
.data-table tbody tr:hover { background: rgba(0, 113, 227, 0.07); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table td.select-cell, .data-table th.select-cell { padding-right: 4px; width: 36px; }
.data-table td.notes-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.data-table input[type="checkbox"], .rc input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 980px; font-size: 12px; font-weight: 600; color: #fff; }
.badge.Active { background: var(--active); }
.badge.NRND { background: var(--warn); }
.badge.EOL, .badge.Obsolete { background: var(--danger); }
.badge.Unknown, .badge.not_in_db, .badge.not_found { background: var(--unknown); }
.badge.st-active { background: var(--active); }
.badge.st-pending { background: var(--warn); }
.badge.st-blocked { background: var(--danger); }
.conflict-flag, .ambiguous-flag { cursor: help; }

/* карточки результатов (телефон) */
.result-cards { list-style: none; margin: 0; padding: 0; display: none; flex-direction: column; gap: 10px; }
.rc {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px;
  box-shadow: var(--shadow-sm); cursor: pointer;
}
.rc:active { background: var(--hover); }
.rc-top { display: flex; align-items: center; gap: 10px; }
.rc-top b { flex: 1; font-size: 16px; word-break: break-all; }
.rc-mid { color: var(--muted); font-size: 13px; margin-top: 6px; }
.rc-bot { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; align-items: center; }
.rc-bot a { font-weight: 500; }

/* скелетон загрузки */
.skeleton { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.skeleton i {
  display: block; height: 46px; border-radius: 12px;
  background: linear-gradient(90deg, var(--soft) 25%, var(--hover) 50%, var(--soft) 75%); background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.error-banner {
  background: rgba(215, 0, 21, 0.08); color: var(--danger); border: 1px solid rgba(215, 0, 21, 0.25);
  border-radius: 12px; padding: 10px 14px; font-size: 13px; font-weight: 500; margin: 10px 0;
}
.info-banner {
  background: rgba(27, 161, 79, 0.1); color: var(--active); border: 1px solid rgba(27, 161, 79, 0.25);
  border-radius: 12px; padding: 10px 14px; font-size: 13px; font-weight: 500; margin: 10px 0;
}
.conflict-banner {
  background: rgba(199, 119, 0, 0.12); color: var(--warn); border: 1px solid rgba(199, 119, 0, 0.3);
  border-radius: 12px; padding: 10px 14px; font-size: 13px; font-weight: 500; margin: 14px 0;
}
#progress-errors { color: var(--danger); font-weight: 500; }

/* ===== Карточка компонента ===== */
.detail-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 29; animation: fade-in 0.25s ease; }
.detail-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 92vw; background: var(--panel);
  box-shadow: var(--shadow-md); padding: 28px; overflow-y: auto; z-index: 30;
  animation: slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1); overscroll-behavior: contain;
}
@keyframes slide-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.close-btn {
  position: absolute; top: 18px; right: 18px; border: none; background: var(--hover); width: 36px; height: 36px;
  border-radius: 50%; font-size: 20px; cursor: pointer; color: var(--muted); display: flex; align-items: center; justify-content: center;
}
.close-btn:hover { background: var(--border); }
.detail-panel h3 { margin: 0 44px 4px 0; font-size: 22px; letter-spacing: -0.01em; word-break: break-all; }
.detail-panel h3.section-title { font-size: 15px; margin: 28px 0 4px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.detail-panel table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.detail-panel td { padding: 7px 0; font-size: 13.5px; border-bottom: 1px solid var(--border); vertical-align: top; }
.detail-panel td:first-child { color: var(--muted); width: 42%; padding-right: 10px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }

.datasheet-list { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.datasheet-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; flex-wrap: wrap; }
.datasheet-row .ds-source { color: var(--muted); min-width: 60px; text-transform: capitalize; }
.datasheet-row a { flex: 1; }
.datasheet-row a.ds-copy { flex: none; font-size: 12px; color: var(--muted); }
.ds-icon-btn { border: none; background: transparent; cursor: pointer; font-size: 14px; color: var(--muted); padding: 6px 8px; border-radius: 6px; }
.ds-icon-btn:hover { background: var(--hover); color: var(--text); }
.datasheet-editing { gap: 6px; }
.datasheet-editing .ds-edit-input, .datasheet-add input {
  flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; outline: none; min-width: 0;
}
.datasheet-editing .ds-edit-input:focus, .datasheet-add input:focus { border-color: var(--accent); }
.datasheet-add { display: flex; gap: 8px; margin-top: 10px; }

/* сравнение */
.compare-modal {
  position: fixed; inset: 3vh 3vw; z-index: 40; background: var(--panel); border-radius: 20px; box-shadow: var(--shadow-md);
  padding: 22px; overflow: auto; animation: fade-in 0.2s ease;
}
.compare-modal h3 { margin: 0 44px 12px 0; }
.compare-table { border-collapse: collapse; min-width: 100%; }
.compare-table th, .compare-table td { padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; text-align: left; vertical-align: top; min-width: 160px; }
.compare-table th:first-child, .compare-table td:first-child { color: var(--muted); min-width: 150px; position: sticky; left: 0; background: var(--panel); }
.compare-table tr.diff td:not(:first-child) { background: rgba(199, 119, 0, 0.1); }
.compare-table .group td { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--soft); font-weight: 600; }

/* ===== Проверка BOM ===== */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 32px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.step-label { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.card h2 { font-size: 20px; margin: 0 0 6px; letter-spacing: -0.01em; }
.card label { display: block; margin: 16px 0 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.card select { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); font-size: 14px; min-height: 44px; }
.file-drop {
  display: flex; align-items: center; justify-content: center; margin-top: 16px; padding: 32px; text-align: center;
  border: 2px dashed var(--border); border-radius: 12px; cursor: pointer; color: var(--muted); font-size: 14px;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.file-drop:hover, .file-drop.drag { border-color: var(--accent); background: rgba(0, 113, 227, 0.05); }
.progress-bar { height: 8px; background: var(--hover); border-radius: 999px; overflow: hidden; margin: 16px 0 8px; }
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.3s ease; }
#progress-counts span { margin-right: 18px; font-size: 14px; font-weight: 500; }
.count-found { color: var(--active); }
.count-not-found { color: var(--danger); }
.done-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.done-actions .btn-primary { margin-top: 12px; }

/* ===== Авторизация ===== */
.auth-body { min-height: 100vh; min-height: 100dvh; display: flex; }
.auth-main { margin: auto; width: 100%; max-width: 400px; padding: 24px; }
.auth-logo { margin: 0 auto 28px; height: 36px; }
.auth-card { padding: 28px; }
.auth-card input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; font-size: 16px; background: var(--panel); outline: none; min-height: 46px;
}
.auth-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.14); }
.auth-sub { text-align: left; margin: 0 0 4px; }
.auth-submit { width: 100%; margin-top: 18px; }
.auth-submit:disabled { opacity: 0.6; cursor: default; }
.auth-switch { text-align: center; margin-top: 18px; }
.auth-switch a { color: var(--accent); text-decoration: none; }

/* ===== Админка ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat-num { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.admin-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.admin-cols .card { padding: 22px 24px; margin-bottom: 20px; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mini-table td { padding: 6px 0; border-bottom: 1px solid var(--border); }
.mini-table td.num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.chart-card { margin-bottom: 20px; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-svg { width: 100%; height: 220px; display: block; }
.chart-svg text { fill: var(--muted); font-size: 10px; }
.chart-svg .grid { stroke: var(--border); stroke-width: 1; }
.chart-svg .bar { fill: var(--accent); opacity: 0.85; }
.chart-svg .bar:hover { opacity: 1; }
.chart-svg .line { fill: none; stroke: var(--active); stroke-width: 2; }
.chart-svg .pt { fill: var(--active); }
.inline-select { padding: 6px 12px; border: 1px solid var(--border); border-radius: 980px; background: var(--panel); font-size: 14px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.inline-form input, .inline-form select { padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; font-size: 14px; background: var(--panel); flex: 1 1 140px; }
.inline-form .btn-primary { margin-top: 0; }
.actions-cell { white-space: normal !important; }
.actions-cell .btn-ghost { padding: 4px 10px; font-size: 12px; margin: 2px 2px 2px 0; min-height: 30px; }
.tab-actions { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 10px; }
.tab-actions a { text-decoration: none; }
#users-table tbody tr, #events-table tbody tr, #jobs-table tbody tr { cursor: default; }
.key-card label { display: block; }
.key-card input[type="text"], .key-card input[type="password"] { width: 100%; margin-top: 6px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; font-size: 14px; background: var(--panel); }
.key-actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.key-actions .btn-primary { margin-top: 0; }
.key-reset { margin-top: 6px; padding: 4px 10px; font-size: 12px; }
.toggle-row { display: flex !important; align-items: center; gap: 10px; margin-top: 18px !important; color: var(--text) !important; font-size: 14px !important; }
.key-card .toggle-row input { width: auto; margin: 0; }
.ds-copy { font-size: 12px; margin-left: 8px; color: var(--muted); }

/* ===== Приложение на телефоне ===== */
.bottom-nav { display: none; }
.sheet-menu { display: none; }
.ios-tip {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + var(--safe-bottom) + 10px); z-index: 28;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow-md);
  font-size: 13px; display: flex; gap: 10px; align-items: center;
}
.ios-tip button { flex: none; }

@media (max-width: 900px) {
  .admin-cols { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  :root { --nav-h: 62px; }
  body { font-size: 16px; }
  .topbar-inner { padding: 10px 16px; gap: 12px; }
  .logo { height: 26px; }
  /* вкладки уезжают вниз, как в мобильном приложении (отдельный элемент: у шапки backdrop-filter ломает position:fixed) */
  .topbar .tabs { display: none; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; gap: 0; justify-content: space-around;
    background: var(--topbar-bg); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--border); padding: 6px 6px calc(6px + var(--safe-bottom));
  }
  .tab-btn { flex: 1; border-radius: 12px; padding: 8px 4px; font-size: 12px; min-height: 48px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
  .tab-btn .ico { font-size: 20px; line-height: 1; }
  .tab-btn.active { background: var(--hover); color: var(--accent); }
  main { padding: 0 14px calc(var(--nav-h) + var(--safe-bottom) + 28px); }
  .hero { padding: 24px 0 14px; }
  .hero h1 { font-size: 28px; }
  .hero p { font-size: 15px; }
  .user-menu .desktop-only, .user-menu .user-name { display: none !important; }
  .user-menu { margin-left: auto; }
  .search-bar input { font-size: 16px; padding: 14px 44px 14px 44px; }
  .filters-row select { flex: 1 1 calc(50% - 6px); min-width: 0; max-width: none; min-height: 44px; font-size: 15px; }
  .filters-row .spacer { display: none; }
  #bulk-toggle-btn { flex: 1 1 100%; }
  .filters-row .btn-ghost { min-height: 44px; padding: 8px 14px; font-size: 14px; }
  .results-bar { gap: 8px; }
  .results-bar .btn-ghost { min-height: 40px; padding: 6px 12px; font-size: 13px; }
  .results-bar .spacer { display: none; }
  .results-count { flex: 1 1 100%; margin: 0; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 12px -14px 6px; padding: 0 14px 6px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { min-height: 40px; flex: none; }
  .table-wrap.has-cards { display: none; }
  .result-cards { display: flex; }
  .sum-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 20px; }
  .btn-primary { width: 100%; min-height: 48px; font-size: 16px; }
  .done-actions .btn-primary { width: auto; flex: 1; }
  /* карточка компонента - шторка на весь экран */
  .detail-panel {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-width: none; height: 94dvh; max-height: 94dvh;
    border-radius: 22px 22px 0 0; padding: 22px 18px calc(24px + var(--safe-bottom)); animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .detail-panel::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: -10px auto 14px; }
  .close-btn { width: 40px; height: 40px; top: 14px; right: 14px; }
  .compare-modal { inset: 0; border-radius: 0; padding: calc(16px + var(--safe-top)) 12px calc(16px + var(--safe-bottom)); }
  .datasheet-add { flex-direction: column; }
  .datasheet-add .btn-ghost { min-height: 44px; }
  .inline-form input, .inline-form select, .inline-form .btn-primary { flex: 1 1 100%; }
  /* меню «Ещё» */
  .sheet-menu {
    display: block; position: fixed; right: 12px; top: calc(var(--safe-top) + 56px); z-index: 35; background: var(--panel);
    border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-md); padding: 6px; min-width: 220px;
  }
  .sheet-menu[hidden] { display: none !important; }
  .sheet-menu a, .sheet-menu button {
    display: block; width: 100%; text-align: left; border: none; background: transparent; padding: 13px 14px; font-size: 16px;
    border-radius: 10px; color: var(--text); text-decoration: none; cursor: pointer;
  }
  .sheet-menu a:active, .sheet-menu button:active { background: var(--hover); }
  .admin-tabs-scroll { overflow-x: auto; }
  .table-wrap { max-height: none; }
  .data-table th, .data-table td { padding: 10px 12px; }
}
@media (min-width: 761px) {
  .user-menu .menu-toggle { display: none; }
  .sheet-menu { display: none !important; }
}

/* PWA: в режиме приложения без полей браузера */
@media (display-mode: standalone) {
  body { overscroll-behavior-y: contain; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; display: none; }

/* Диалоги */
.ui-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade-in 0.15s ease; }
.ui-dialog { background: var(--panel); border-radius: 20px; padding: 24px; width: 100%; max-width: 380px; box-shadow: var(--shadow-md); }
.ui-dialog h3 { margin: 0 0 8px; font-size: 18px; }
.ui-dialog p { margin: 0 0 8px; font-size: 15px; color: var(--text); line-height: 1.4; }
.ui-dialog label { display: block; margin: 12px 0 0; font-size: 13px; color: var(--muted); font-weight: 500; }
.ui-dialog input { width: 100%; margin-top: 6px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; font-size: 16px; min-height: 46px; outline: none; }
.ui-dialog input:focus { border-color: var(--accent); }
.ui-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.ui-actions .btn-ghost { min-height: 44px; padding: 8px 20px; font-size: 15px; }
.ui-actions .ui-ok { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Линейные иконки */
svg { flex: none; }
.tab-btn .ico { display: none; }
.tab-btn .ico svg, .sheet-menu svg, .theme-toggle svg {
  width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.theme-toggle svg { margin-right: 6px; vertical-align: -3px; }
.sheet-menu svg { margin-right: 12px; vertical-align: -4px; width: 22px; height: 22px; }
@media (max-width: 760px) {
  .tab-btn .ico { display: block; line-height: 0; }
  .tab-btn .ico svg { width: 26px; height: 26px; stroke-width: 1.7; }
  .tab-btn { gap: 4px; }
  .tab-btn.active .ico svg { stroke-width: 2.1; }
}

/* ---- Кабинет, сканер, слежение ---- */
.tab-badge, .seg-badge {
  display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; vertical-align: 1px;
}
.bottom-nav .tab-btn { position: relative; }
.bottom-nav .tab-badge { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; }
.seg { display: flex; gap: 4px; background: var(--hover); border-radius: 14px; padding: 4px; margin: 0 auto 18px; max-width: 640px; overflow-x: auto; }
.seg-btn { flex: 1; border: none; background: transparent; padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; min-height: 40px; }
.seg-btn.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.cab-sec { max-width: 1180px; margin: 0 auto; }
.notes-list, .jobs-list { display: flex; flex-direction: column; gap: 10px; }
.note, .job-row { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow-sm); }
.note[data-mpn] { cursor: pointer; }
.note.unread { border-left: 4px solid var(--accent); }
.note.sec { border-left-color: var(--danger); }
.note-title { font-weight: 600; font-size: 15px; }
.note-body { font-size: 14px; margin-top: 4px; color: var(--text); }
.note-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.job-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: space-between; }
.job-actions { display: flex; gap: 8px; align-items: center; }
.job-actions a { text-decoration: none; }
.job-counts { font-variant-numeric: tabular-nums; font-size: 15px; }
.watch-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; margin-right: 6px; vertical-align: -3px; }
.watch-btn.on { background: rgba(240, 160, 48, 0.16); border-color: var(--warn); color: var(--warn); }
.watch-btn.on svg { fill: currentColor; }
.ds-by { display: block; font-size: 11px; color: var(--muted); text-transform: none; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.scan-btn {
  position: absolute; right: 44px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: none; background: transparent;
  color: var(--muted); border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.scan-btn:hover { background: var(--hover); color: var(--accent); }
.scan-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.search-bar input { padding-right: 84px !important; }
.scan-modal { position: fixed; inset: 0; z-index: 50; background: var(--bg); padding: calc(20px + var(--safe-top)) 18px 24px; overflow-y: auto; }
.scan-modal h3 { margin: 0 44px 12px 0; font-size: 20px; }
#scan-video { width: 100%; max-height: 52vh; border-radius: 18px; background: #000; object-fit: cover; }
.scan-photo { display: block; text-align: center; cursor: pointer; }
@media (max-width: 760px) { .bottom-nav .tab-btn { padding: 8px 2px; } }
