/* ─── WebSSM — Мобильная адаптивная тема (Русский интерфейс) ────────────────── */

:root {
  --bg-base: #090a0f;
  --bg-surface: #10121a;
  --bg-elevated: #161824;
  --bg-panel: #1b1e2c;
  --bg-card: #202436;
  --bg-input: #12141d;

  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.22);

  --text-primary: #f3f4f8;
  --text-secondary: #a3a6c2;
  --text-muted: #626580;
  --text-accent: #818cf8;

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #a855f7;
  --accent-glow: rgba(99, 102, 241, 0.35);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info: #38bdf8;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 32px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 24px var(--accent-glow);

  --header-h: 60px;
  --sidebar-w: 320px;
  --statusbar-h: 34px;
  --bottomnav-h: 62px;
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

/* ─── SCROLLBAR ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); }

/* ─── ШАПКА ПРИЛОЖЕНИЯ ────────────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(13, 15, 23, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 1000;
}

.header-content {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  max-width: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Кнопка гамбургера для мобильных */
.sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 8px;
  transition: var(--transition);
}

.sidebar-toggle:active {
  transform: scale(0.94);
  background: var(--bg-elevated);
}

.sidebar-toggle .bar {
  width: 100%;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: var(--transition);
}

.logo-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.logo-brand {
  font-size: 19px;
  font-weight: 800;
  background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.4px;
}

.logo-sub {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.conn-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 12.5px;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
}

.indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: var(--transition);
}

.conn-indicator.connected {
  border-color: rgba(16, 185, 129, 0.4);
  background: var(--success-bg);
  color: #34d399;
}
.conn-indicator.connected .indicator-dot {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.conn-indicator.disconnected {
  color: var(--text-muted);
}

.conn-indicator.connecting {
  border-color: rgba(245, 158, 11, 0.4);
  background: var(--warning-bg);
  color: #fbbf24;
}
.conn-indicator.connecting .indicator-dot {
  background: #f59e0b;
  animation: pulseDot 1s infinite alternate;
}

@keyframes pulseDot {
  from { opacity: 0.3; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1.15); }
}

.ecu-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── ОСНОВНОЙ МАКЕТ ─────────────────────────────────────────── */
.app-main {
  position: fixed;
  top: var(--header-h);
  bottom: var(--statusbar-h);
  left: 0; right: 0;
  display: flex;
  overflow: hidden;
}

/* ─── САЙДБАР (ПАНЕЛЬ УПРАВЛЕНИЯ) ─────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1050;
  display: flex;
  flex-direction: column;
}

.sidebar-overlay {
  display: none;
}

.sidebar-inner {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.sidebar-mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-mobile-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
}

.sidebar-close-btn {
  width: 34px;
  height: 34px;
  font-size: 16px;
}

/* Панели в сайдбаре */
.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
}

.panel-title svg {
  width: 16px;
  height: 16px;
  color: var(--accent-primary);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

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

select, input[type="text"], input[type="search"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239a9bb5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

select:focus, input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  touch-action: manipulation;
  user-select: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-block {
  width: 100%;
}

.btn-large {
  padding: 12px 22px;
  font-size: 14.5px;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #7174f7 0%, #5d55e8 100%);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-strong);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  touch-action: manipulation;
}

.icon-btn:hover {
  background: var(--bg-card);
  border-color: var(--border-strong);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.btn-row {
  display: flex;
  gap: 8px;
}

/* Паспорт ЭБУ */
.ecu-info-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  color: var(--text-muted);
}

.info-value {
  font-weight: 500;
  color: var(--text-primary);
}

/* Десктопная навигация */
.app-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.nav-btn svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: var(--transition);
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.nav-btn.active {
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.25);
  font-weight: 600;
}

.nav-btn.active svg {
  color: var(--accent-primary);
}

/* ─── ОБЛАСТЬ КОНТЕНТА ────────────────────────────────────────── */
.content-area {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  background: var(--bg-base);
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.tab-pane {
  display: none;
  animation: fadeIn 200ms ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.tab-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.tab-title-wrap h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.tab-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.tab-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── ЭКРАН ПРИВЕТСТВИЯ ────────────────────────────────────────── */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 16px;
  max-width: 680px;
  margin: 0 auto;
}

.welcome-icon {
  width: 90px;
  height: 90px;
  margin-bottom: 16px;
}

.welcome-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.8px;
  background: linear-gradient(135deg, #ffffff 0%, #c7d2fe 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
}

.welcome-desc {
  font-size: 14.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

.welcome-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
  margin-bottom: 28px;
}

.feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.feature-card:hover {
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-2px);
}

.feature-icon {
  font-size: 26px;
  margin-bottom: 2px;
}

.feature-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.feature-sub {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

.welcome-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ─── ПРИБОРНЫЕ ШКАЛЫ (GAUGES) ─────────────────────────────────── */
.gauges-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.gauge-widget {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.gauge-canvas {
  width: 140px;
  height: 140px;
  max-width: 100%;
}

.gauge-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
}

.gauge-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

/* ─── КАРТОЧКИ ПАРАМЕТРОВ ─────────────────────────────────────── */
.live-data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.mb-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.mb-card:hover {
  border-color: var(--border-strong);
}

.mb-card-title {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1.35;
  min-height: 32px;
}

.mb-card-val-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.mb-card-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  transition: color 150ms ease, transform 150ms ease;
  letter-spacing: -0.5px;
}

.mb-card-value.updated {
  color: #818cf8;
  transform: scale(1.03);
}

.mb-card-unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.mb-progress {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  margin-top: auto;
}

.mb-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  border-radius: 2px;
  transition: width 200ms ease;
}

/* ─── КОДЫ ОШИБОК (DTC) ────────────────────────────────────────── */
.dtc-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dtc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
}

.dtc-card.current {
  border-left: 4px solid var(--danger);
}

.dtc-card.historic {
  border-left: 4px solid var(--warning);
}

.dtc-code {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-elevated);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
  letter-spacing: 0.5px;
}

.dtc-desc {
  flex: 1;
  font-size: 13.5px;
  color: var(--text-primary);
  line-height: 1.4;
}

.dtc-type {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.dtc-type.current {
  background: var(--danger-bg);
  color: #f87171;
}

.dtc-type.historic {
  background: var(--warning-bg);
  color: #fbbf24;
}

/* ─── ТЕСТЫ МЕХАНИЗМОВ ────────────────────────────────────────── */
.actuator-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-md);
  font-size: 12.5px;
  color: #fbbf24;
  margin-bottom: 16px;
  line-height: 1.45;
}

.actuator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.actuator-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: var(--transition);
}

.actuator-card.active {
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(99, 102, 241, 0.06);
}

.actuator-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.35;
}

.actuator-btn {
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  touch-action: manipulation;
  white-space: nowrap;
}

.actuator-btn:hover {
  background: var(--bg-card);
}

.actuator-btn.active {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: pulseButton 1.5s infinite;
}

@keyframes pulseButton {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ─── МОДАЛЬНОЕ ОКНО ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 16px;
  animation: fadeIn 150ms ease;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title-wrap h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-counter {
  font-size: 11.5px;
  padding: 2px 8px;
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border-radius: var(--radius-full);
}

.modal-search {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-panel);
}

.search-input {
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  padding: 9px 12px;
}

.modal-body {
  padding: 12px 20px;
  overflow-y: auto;
  flex: 1;
}

.mb-checklist {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mb-check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  min-height: 44px;
}

.mb-check-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.mb-check-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.mb-check-label {
  flex: 1;
  font-size: 13.5px;
  color: var(--text-primary);
  line-height: 1.3;
}

.mb-check-unit {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.modal-footer {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  gap: 10px;
  flex-wrap: wrap;
}

.modal-footer-actions {
  display: flex;
  gap: 8px;
}

/* ─── СТРОКА СОСТОЯНИЯ (СТАТУС-БАР) ─────────────────────────── */
.status-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--statusbar-h);
  background: rgba(10, 11, 16, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 12px;
  z-index: 1000;
}

.status-msg {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-weight: 500;
}

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

.hz-display {
  font-family: var(--font-mono);
  color: #38bdf8;
  font-weight: 600;
  font-size: 11.5px;
}

.status-version {
  color: var(--text-muted);
  font-size: 11px;
}

/* ─── МОБИЛЬНАЯ НИЖНЯЯ ПАНЕЛЬ (BOTTOM NAV) ───────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  background: rgba(13, 15, 23, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  z-index: 1200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  padding: 6px 2px;
  touch-action: manipulation;
}

.bottom-nav-btn svg {
  width: 20px;
  height: 20px;
  transition: var(--transition);
}

.bottom-nav-btn.active {
  color: #818cf8;
  font-weight: 600;
}

.bottom-nav-btn.active svg {
  color: var(--accent-primary);
  transform: translateY(-1px);
}

/* ─── УВЕДОМЛЕНИЯ (TOASTS) ────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  right: 16px;
  z-index: 4000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 360px;
  width: calc(100% - 32px);
}

.toast {
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastSlide 200ms ease;
  line-height: 1.4;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }

@keyframes toastSlide {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Пустое состояние */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 42px;
  margin-bottom: 12px;
}

/* Вспомогательные классы */
.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }

/* Анимация загрузки */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn.loading {
  position: relative;
  pointer-events: none;
}

.btn.loading span {
  visibility: hidden;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ══════════════════════════════════════════════════════════════════
   АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ И ПЛАНШЕТОВ (< 768px)
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root {
    --header-h: 56px;
    --statusbar-h: 28px;
    --bottomnav-h: 58px;
  }

  /* Гамбургер в шапке виден */
  .sidebar-toggle {
    display: flex;
  }

  .logo-sub {
    display: none;
  }

  .logo-brand {
    font-size: 18px;
  }

  .conn-indicator {
    padding: 4px 10px;
    font-size: 12px;
  }

  .ecu-badge {
    display: none !important;
  }

  /* Сайдбар превращается в плавную выезжающую шторку (drawer) */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 310px;
    max-width: 86vw;
    height: 100vh;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.75);
    background: #11131c !important;
    transform: translateX(-100%) translateZ(0);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 2200;
    border-right: 1px solid var(--border-medium);
    isolation: isolate;
  }

  .sidebar.open {
    transform: translateX(0) translateZ(0);
  }

  .sidebar-inner {
    position: relative;
    z-index: 2;
    background: #11131c;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 2150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .sidebar.open + .sidebar-overlay,
  .sidebar-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-mobile-header {
    display: flex;
  }

  /* Скрываем десктопную навигацию в сайдбаре на мобильных */
  .app-nav {
    display: none !important;
  }

  /* Включаем нижнюю панель навигации */
  .bottom-nav {
    display: flex;
  }

  /* Область контента получает отступ под статус-бар и нижнюю панель */
  .app-main {
    top: var(--header-h);
    bottom: calc(var(--bottomnav-h) + var(--statusbar-h) + env(safe-area-inset-bottom, 0px));
  }

  .content-area {
    padding: 16px 14px;
  }

  /* Статус-бар висит строго над нижней панелью навигации */
  .status-bar {
    bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
    height: var(--statusbar-h);
    padding: 0 12px;
    font-size: 11px;
    border-top: 1px solid var(--border-subtle);
    background: rgba(10, 11, 16, 0.98);
  }

  .status-version {
    display: none;
  }

  /* Приветственный экран на смартфонах */
  .welcome {
    padding: 16px 8px;
  }

  .welcome-title {
    font-size: 26px;
  }

  .welcome-desc {
    font-size: 13.5px;
    margin-bottom: 20px;
  }

  .welcome-features {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 20px;
  }

  .feature-card {
    flex-direction: row;
    text-align: left;
    padding: 12px 14px;
    gap: 12px;
  }

  .feature-icon {
    margin-bottom: 0;
    font-size: 24px;
  }

  .welcome-cta {
    flex-direction: column;
    width: 100%;
  }

  .welcome-cta .btn {
    width: 100%;
  }

  /* Шкалы приборов 2x2 на смартфонах */
  .gauges-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }

  .gauge-widget {
    padding: 10px 6px;
  }

  .gauge-canvas {
    width: 120px;
    height: 120px;
  }

  .gauge-label {
    font-size: 11px;
  }

  .gauge-value {
    font-size: 14.5px;
  }

  /* Сетка параметров 2 колонки на смартфонах */
  .live-data-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  .mb-card {
    padding: 10px;
    gap: 6px;
  }

  .mb-card-title {
    font-size: 11.5px;
    min-height: 28px;
  }

  .mb-card-value {
    font-size: 20px;
  }

  /* Шапка вкладок и кнопки */
  .tab-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }

  .tab-title-wrap h2 {
    font-size: 18px;
  }

  .tab-actions {
    display: flex;
    width: 100%;
  }

  .tab-actions .btn {
    flex: 1;
    padding: 10px;
    font-size: 13px;
  }

  /* Тесты механизмов */
  .actuator-grid {
    grid-template-columns: 1fr;
  }

  /* Модальное окно как Bottom Sheet на мобильных */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: 100%;
    max-height: 88vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none;
    animation: slideUp 250ms cubic-bezier(0.32, 0.72, 0, 1);
  }

  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .modal-footer {
    padding: 12px 16px;
    flex-direction: column-reverse;
  }

  .modal-footer-actions {
    width: 100%;
  }

  .modal-footer-actions .btn {
    flex: 1;
  }

  .btn-apply {
    width: 100%;
  }

  /* Уведомления сверху по центру */
  .toast-container {
    top: calc(var(--header-h) + 8px);
    right: 12px;
    left: 12px;
    width: auto;
  }
}

/* ══════════════════════════════════════════════════════════════════
   ОСОБО УЗКИЕ СМАРТФОНЫ (< 380px)
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
  .live-data-grid {
    grid-template-columns: 1fr;
  }

  .gauge-canvas {
    width: 100px;
    height: 100px;
  }
}
