/* Мобильная тёмная тема PWA 7pda Board — оптимизирована под управление одной рукой */

:root {
  --bg-deep: #090d16;
  --bg-panel: #111827;
  --bg-card: #162033;
  --bg-elevated: #1e293b;
  --border: #283548;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #10b981;
  --accent-hover: #059669;
  --blue: #38bdf8;
  --danger: #ef4444;
  --warn: #f59e0b;
  --yellow: #facc15;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  padding-top: var(--safe-top);
}

.hidden {
  display: none !important;
}

/* Шапка */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  min-height: 52px;
  flex-shrink: 0;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  flex-shrink: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.2px;
}

.brand-title .accent {
  color: var(--accent);
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.bug-btn {
  border-color: rgba(245, 158, 11, 0.4);
}

.pill-btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.14);
  color: #a7f3d0;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Тулбар переключения режима */
.mode-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: #0d1320;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}

.seg-group {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px;
  flex-shrink: 0;
}

.seg-group.full-w {
  display: flex;
  width: 100%;
}

.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.seg-btn.active {
  background: var(--bg-elevated);
  color: var(--text-main);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.action-chip {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--accent);
  color: #042f2e;
  font-weight: 700;
  font-size: 12.5px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.action-chip.secondary {
  background: var(--bg-card);
  color: var(--blue);
  border: 1px solid var(--border);
}

/* Основная рабочая область */
.workspace {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.tab-view {
  display: none;
  width: 100%;
  height: 100%;
}

.tab-view.active {
  display: block;
}

.tab-view.scrollable {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at center, rgba(30, 41, 59, 0.35) 1px, transparent 1px),
    var(--bg-deep);
  background-size: 22px 22px;
  overflow: hidden;
}

#boardCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
}

/* Пустое состояние на Canvas */
.empty-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: none;
}

.empty-card {
  pointer-events: auto;
  max-width: 340px;
  width: 100%;
  background: rgba(17, 24, 39, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 18px;
  text-align: center;
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.empty-card h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.empty-card p {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.empty-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Спиннер парсера */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 13, 22, 0.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 15;
  font-weight: 600;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(56, 189, 248, 0.25);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Плашка выбранной цепи */
.net-banner {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 60px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.5);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12.5px;
  color: #e0f2fe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 8;
}

.mini-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
}

/* Плавающие кнопки зума под правый палец */
.canvas-fab-stack {
  position: absolute;
  right: 10px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 8;
}

.fab-mini {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.9);
  color: var(--text-main);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.danger-text {
  color: #fca5a5;
}

/* Панель диагностики и карточки */
.panel-pad {
  padding: 12px;
  padding-bottom: 32px;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-banner {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #bae6fd;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.highlight-card {
  border-color: rgba(16, 185, 129, 0.5);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.09), var(--bg-card));
}

.next-probe-card {
  border-color: rgba(250, 204, 21, 0.55);
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.08), var(--bg-card));
}

.card-title {
  font-weight: 700;
  font-size: 14.5px;
  margin-bottom: 10px;
}

.card-header-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.card-header-line .card-title {
  margin-bottom: 0;
}

.yellow-text {
  color: var(--yellow);
}

.field-row {
  margin-bottom: 10px;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 5px;
  font-weight: 600;
}

.text-input {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-main);
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
}

.text-input:focus {
  border-color: var(--accent);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 520px) {
  .grid-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.primary-btn {
  height: 46px;
  padding: 0 16px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #022c22;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ghost-btn {
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.danger-outline-btn {
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.small-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.yellow-btn {
  background: rgba(250, 204, 21, 0.2);
  border-color: rgba(250, 204, 21, 0.6);
  color: #fef08a;
}

.danger-btn {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.full-w {
  width: 100%;
}

.flex-1 {
  flex: 1;
}

.ai-cta {
  margin-top: 4px;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.25);
}

.summary-p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.5;
}

.tiny-badge {
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--bg-deep);
  color: var(--text-muted);
}

.probe-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 13px;
}

.probe-cell {
  background: rgba(9, 13, 22, 0.65);
  padding: 8px 10px;
  border-radius: 8px;
}

.probe-cell span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.suspect-list, .meas-list, .admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suspect-item {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.suspect-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  color: #fecaca;
  margin-bottom: 4px;
}

.prob-pill {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.25);
}

.steps-ol {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
}

.meas-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}

.meas-row.is-suspect {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
}

.meas-badge {
  min-width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #022c22;
  font-weight: 800;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.meas-row.is-suspect .meas-badge {
  background: var(--danger);
  color: #fff;
}

.meas-info {
  flex: 1;
  min-width: 0;
}

.meas-title {
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meas-meta {
  font-size: 11.5px;
  color: var(--text-muted);
}

.meas-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
  font-size: 15px;
  color: #a7f3d0;
}

.muted-empty {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 12px 4px;
}

/* Нижняя навигация */
.bottom-nav {
  display: flex;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  min-height: calc(56px + var(--safe-bottom));
  flex-shrink: 0;
}

.nav-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.nav-tab.active {
  color: var(--accent);
}

.nav-ico {
  font-size: 18px;
}

.counter-pill {
  display: inline-block;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--bg-elevated);
  font-size: 10.5px;
  color: var(--text-main);
}

/* Выдвижная нижняя шторка замера */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 30;
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 8px 14px calc(14px + var(--safe-bottom));
  z-index: 35;
  max-height: 88dvh;
  overflow-y: auto;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.65);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 4px;
  background: var(--border);
  margin: 2px auto 10px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.sheet-title {
  font-weight: 800;
  font-size: 16px;
}

.sheet-sub {
  font-size: 12px;
  color: var(--blue);
}

.value-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.giant-value-input {
  flex: 1;
  min-width: 0;
  height: 54px;
  border-radius: 12px;
  border: 2px solid var(--accent);
  background: var(--bg-deep);
  color: #ecfdf5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 24px;
  font-weight: 800;
  padding: 0 14px;
  outline: none;
}

.quick-val-btn {
  width: 68px;
  height: 54px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-weight: 800;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.quick-val-btn small {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.85;
}

.quick-val-btn.warn {
  border-color: rgba(245, 158, 11, 0.5);
  color: #fde68a;
}

.quick-val-btn.danger {
  border-color: rgba(239, 68, 68, 0.5);
  color: #fecaca;
}

.chip-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.chip-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.chip-row-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 10px;
  padding-bottom: 2px;
}

.choice-chip {
  padding: 8px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
}

.choice-chip.active {
  border-color: var(--accent);
  background: rgba(16, 185, 129, 0.16);
  color: #d1fae5;
}

.compact-top {
  margin-top: 4px;
}

.sheet-footer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* Модалки (Auth, Bug) */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 45;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
}

.error-box {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fecaca;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  margin-bottom: 10px;
}

.tiny-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 10px 0 0;
}

.mt-0 { margin-top: 0; margin-bottom: 10px; }
.mt-12 { margin-top: 12px; }
.mb-12 { margin-bottom: 12px; }

.col-gap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row-gap {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.profile-summary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Админка */
.admin-user-row {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-user-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.status-tag {
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.status-tag.pending { background: rgba(245, 158, 11, 0.2); color: #fde68a; }
.status-tag.active { background: rgba(16, 185, 129, 0.2); color: #a7f3d0; }
.status-tag.banned { background: rgba(239, 68, 68, 0.2); color: #fecaca; }

.log-pre {
  background: #060911;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 11.5px;
  line-height: 1.45;
  color: #cbd5e1;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* Toast уведомления */
.toast-stack {
  position: fixed;
  top: calc(58px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 60;
  width: calc(100% - 28px);
  max-width: 380px;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--accent);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.toast.err {
  border-color: var(--danger);
  color: #fecaca;
}
