/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #6B3FF6;
  --accent-hover: #5A32D4;
  --accent-light: #EDE9FE;
  --accent-mid: #C4B5FD;

  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #F3F4F6;
  --surface-3: #EAECF0;
  --border: #E5E7EB;
  --border-focus: #6B3FF6;

  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;

  --success: #10B981;
  --success-bg: #ECFDF5;
  --danger: #EF4444;
  --danger-bg: #FEF2F2;
  --warning: #F59E0B;

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

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.06);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 150ms ease;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); background: var(--bg); color: var(--text-primary); min-height: 100vh; }

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ─── Top bar ───────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: 60px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 24px;
  padding: 0 32px;
}

.topbar-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
}
.brand-logo {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.brand-name { color: var(--text-primary); }

.topbar-nav { flex: 1; display: flex; gap: 4px; }
.nav-link {
  padding: 6px 12px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
  transition: all var(--transition);
}
.nav-link:hover, .nav-link.active { color: var(--accent); background: var(--accent-light); }

.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 30px; height: 30px; border-radius: var(--radius-full); object-fit: cover; }
.user-name { font-size: 14px; font-weight: 500; color: var(--text-secondary); }

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.main-content { max-width: 1200px; margin: 0 auto; padding: 40px 32px; }

/* ─── Page header ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 32px; gap: 16px;
}
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.page-subtitle { margin-top: 6px; font-size: 15px; color: var(--text-secondary); }
.page-back { margin-bottom: 24px; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
  transition: color var(--transition);
}
.back-link:hover { color: var(--accent); }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-google, .btn-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-md); border: none; cursor: pointer;
  font-family: var(--font); font-size: 14px; font-weight: 600;
  transition: all var(--transition); white-space: nowrap;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(107,63,246,.3); }
.btn-secondary { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-ghost     { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger    { background: var(--danger-bg); color: var(--danger); border: 1px solid #FECACA; }
.btn-danger:hover { background: #FEE2E2; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-toggle { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border); padding: 8px 20px; }
.btn-toggle:hover { background: var(--accent-light); color: var(--accent); }
.btn-toggle-on { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-toggle-on:hover { background: var(--accent-hover); }

/* Google auth button */
.btn-google {
  background: var(--surface); color: var(--text-primary);
  border: 1.5px solid var(--border); padding: 12px 24px;
  border-radius: var(--radius-md); font-size: 15px; font-weight: 500;
  width: 100%; justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.btn-google:hover { background: var(--surface-2); box-shadow: var(--shadow-md); }
.google-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ─── Badges ────────────────────────────────────────────────────────────────── */
.device-type-badge {
  display: inline-block; padding: 3px 9px; border-radius: var(--radius-full);
  background: var(--surface-2); color: var(--text-secondary);
  font-size: 12px; font-weight: 500;
}
.device-virtual-badge {
  display: inline-block; padding: 3px 9px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600;
}
.device-virtual-counter { background: #EFF6FF; color: #2563EB; }
.device-virtual-switch  { background: #F0FDF4; color: #16A34A; }

/* ─── Device grid ───────────────────────────────────────────────────────────── */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.device-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
  transition: all var(--transition); cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.device-card:hover {
  border-color: var(--accent-mid); box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.device-card-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.device-card-body { display: flex; align-items: flex-start; gap: 14px; flex: 1; }

.device-icon-circle {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  background: var(--surface-2); display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); flex-shrink: 0; transition: all var(--transition);
}
.device-icon-circle.icon-on { background: var(--accent-light); color: var(--accent); }
.device-type-img { width: 28px; height: 28px; object-fit: contain; }

.device-info { flex: 1; min-width: 0; }
.device-name { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-room { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.device-state { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.state-chip {
  display: inline-block; padding: 3px 8px; border-radius: var(--radius-full);
  background: var(--surface-2); color: var(--text-primary); font-size: 12px; font-weight: 500;
}
.state-chip-prop { background: var(--accent-light); color: var(--accent); }

.device-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--border); padding-top: 12px;
}
.device-updated { font-size: 12px; color: var(--text-muted); }
.device-arrow { color: var(--text-muted); font-size: 14px; transition: transform var(--transition); }
.device-card:hover .device-arrow { transform: translateX(3px); color: var(--accent); }

/* ─── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 80px 40px; gap: 16px;
}
.empty-state-icon { opacity: 0.5; }
.empty-state-title { font-size: 20px; font-weight: 600; }
.empty-state-text { font-size: 15px; color: var(--text-secondary); max-width: 400px; }

/* ─── Detail layout ─────────────────────────────────────────────────────────── */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) { .detail-layout { grid-template-columns: 1fr; } }

.detail-card, .logs-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-sm);
}

.detail-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 28px;
}
.detail-header-left { display: flex; align-items: flex-start; gap: 20px; }
.detail-device-icon {
  width: 80px; height: 80px; border-radius: var(--radius-lg);
  background: var(--surface-2); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.detail-device-icon img { width: 52px; height: 52px; object-fit: contain; }
.detail-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.detail-name { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.detail-room { font-size: 15px; color: var(--text-secondary); margin-top: 4px; }
.detail-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

.section-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 16px; }

/* ─── State cards ───────────────────────────────────────────────────────────── */
.state-section { margin-bottom: 28px; }
.state-cards { display: flex; flex-wrap: wrap; gap: 14px; }
.state-card {
  flex: 1; min-width: 220px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 18px; display: flex; flex-direction: column; gap: 10px;
}
.state-card-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.state-card-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); }
.state-card-value.value-on  { color: var(--success); }
.state-card-value.value-off { color: var(--text-muted); }
.state-card-action { display: flex; }
.state-card-actions-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ─── Inline form ───────────────────────────────────────────────────────────── */
.inline-form { display: flex; gap: 6px; align-items: center; }
.input-inline {
  flex: 1; min-width: 0; padding: 6px 10px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13px; color: var(--text-primary);
  background: var(--surface); outline: none; transition: border-color var(--transition);
}
.input-inline:focus { border-color: var(--accent); }
.mt-8 { margin-top: 8px; }

/* ─── Device meta ───────────────────────────────────────────────────────────── */
.device-meta { border-top: 1px solid var(--border); padding-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.meta-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.meta-label { font-size: 13px; color: var(--text-muted); flex-shrink: 0; }
.meta-value { font-size: 13px; color: var(--text-secondary); text-align: right; }
.meta-value.mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 11px; word-break: break-all; }

/* ─── Logs ──────────────────────────────────────────────────────────────────── */
.logs-list { display: flex; flex-direction: column; gap: 0; }
.log-item {
  padding: 14px 0; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.log-item:last-child { border-bottom: none; }
.log-item-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.log-source {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: var(--radius-full);
}
.log-source-yandex { background: #EFF6FF; color: #2563EB; }
.log-source-manual  { background: #FFF7ED; color: #C2410C; }
.log-time { font-size: 12px; color: var(--text-muted); }
.log-description { font-size: 13px; color: var(--text-secondary); }
.log-values { font-size: 12px; color: var(--text-muted); }
.log-value-new { color: var(--accent); font-weight: 500; }
.logs-empty { padding: 32px 0; text-align: center; color: var(--text-muted); font-size: 14px; }

/* ─── Login page ────────────────────────────────────────────────────────────── */
.login-body { background: linear-gradient(135deg, #F0EEFF 0%, #EFF6FF 50%, #F0FDF4 100%); }
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: rgba(255,255,255,0.9); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: var(--radius-xl); padding: 48px 40px;
  width: 100%; max-width: 400px; text-align: center;
  box-shadow: var(--shadow-lg);
}
.login-logo { margin-bottom: 12px; }
.login-logo-icon { font-size: 40px; display: block; }
.login-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 8px; }
.login-subtitle { font-size: 15px; color: var(--text-secondary); margin-bottom: 32px; }
.login-hint { font-size: 12px; color: var(--text-muted); margin-top: 20px; line-height: 1.6; }
.oauth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 16px; }
.oauth-arrow { flex-shrink: 0; }
.oauth-yandex-logo { height: 28px; width: auto; }
.oauth-brand-logo {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.admin-login-form { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.login-field { width: 100%; }
.login-input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-md);
  font-family: var(--font); font-size: 15px; color: var(--text-primary);
  background: var(--surface); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.login-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(107,63,246,.1); }
.login-submit { width: 100%; justify-content: center; padding: 12px; font-size: 15px; margin-top: 2px; }
.login-error {
  background: var(--danger-bg); color: var(--danger);
  border: 1px solid #FECACA; border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13px; font-weight: 500; text-align: left;
}
.login-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0; color: var(--text-muted); font-size: 13px;
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ─── Form page ─────────────────────────────────────────────────────────────── */
.form-page { max-width: 560px; }
.form-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 36px; box-shadow: var(--shadow-sm);
}
.form-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 6px; }
.form-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 28px; }
.device-form { display: flex; flex-direction: column; gap: 20px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.form-input, .form-select {
  padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-md);
  font-family: var(--font); font-size: 15px; color: var(--text-primary);
  background: var(--surface); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(107,63,246,0.1);
}
.form-input.input-invalid { border-color: var(--danger); }
.form-hint { font-size: 12px; color: var(--text-muted); }
.form-error { font-size: 12px; color: var(--danger); font-weight: 500; }
.has-error .form-input, .has-error .form-select { border-color: var(--danger); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 8px; }

/* ─── Type selector ─────────────────────────────────────────────────────────── */
.type-selector { display: flex; flex-direction: column; gap: 10px; }
.type-option { cursor: pointer; }
.type-option input { display: none; }
.type-option-body {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px; border-radius: var(--radius-md);
  border: 1.5px solid var(--border); background: var(--surface);
  transition: all var(--transition);
}
.type-option:hover .type-option-body { border-color: var(--accent-mid); background: var(--accent-light); }
.type-option input:checked + .type-option-body { border-color: var(--accent); background: var(--accent-light); }
.type-option-icon {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--surface-2); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--text-secondary);
}
.type-option input:checked + .type-option-body .type-option-icon { background: var(--accent); color: #fff; }
.type-option-label { font-size: 15px; font-weight: 600; display: block; margin-bottom: 2px; }
.type-option-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.4; }

/* ─── Device type trigger button ────────────────────────────────────────────── */
.dt-trigger {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius-md);
  font-family: var(--font); cursor: pointer; text-align: left;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.dt-trigger:hover   { border-color: var(--accent-mid); }
.dt-trigger:focus   { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(107,63,246,.1); }
.dt-trigger-img     { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; border-radius: 6px; }
.dt-trigger-text    { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dt-trigger-name    { font-size: 15px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dt-trigger-id      { font-size: 11px; color: var(--text-muted); font-family: 'SF Mono','Fira Code',monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dt-trigger-chevron { flex-shrink: 0; color: var(--text-muted); }

/* ─── Bottom sheet overlay ──────────────────────────────────────────────────── */
.bs-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,0);
  transition: background 280ms ease;
}
.bs-overlay-visible { background: rgba(0,0,0,0.4); }

/* ─── Bottom sheet ──────────────────────────────────────────────────────────── */
.bs-sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 401;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.12);
  display: flex; flex-direction: column;
  height: 88vh;          /* фиксированная высота — не прыгает при фильтрации */
  transform: translateY(100%);
  transition: transform 280ms cubic-bezier(0.32, 0.72, 0, 1);
}
.bs-sheet-open { transform: translateY(0); }

.bs-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 12px auto 0; flex-shrink: 0;
}

.bs-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; flex-shrink: 0;
}
.bs-title  { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.bs-close  {
  width: 32px; height: 32px; border-radius: var(--radius-full);
  background: var(--surface-2); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: background var(--transition);
}
.bs-close:hover { background: var(--surface-3); }

/* ─── Search ─────────────────────────────────────────────────────────────────── */
.bs-search-wrap {
  display: flex; align-items: center; gap: 8px;
  margin: 0 16px 0; padding: 9px 12px;
  background: var(--surface-2); border-radius: var(--radius-md);
  flex-shrink: 0;
  color: var(--text-muted);
}
.bs-search {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: var(--font); font-size: 15px; color: var(--text-primary);
}
.bs-search::placeholder { color: var(--text-muted); }
.bs-search-clear {
  border: none; background: transparent; cursor: pointer; padding: 0;
  color: var(--text-muted); display: flex; align-items: center;
  transition: color var(--transition);
}
.bs-search-clear:hover { color: var(--text-primary); }

/* ─── Category chips ─────────────────────────────────────────────────────────── */
.bs-chips {
  display: flex; gap: 8px; padding: 12px 16px;
  overflow-x: auto; flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.bs-chips::-webkit-scrollbar { display: none; }
.bs-chip {
  flex-shrink: 0; padding: 6px 14px; border-radius: var(--radius-full);
  border: 1.5px solid var(--border); background: var(--surface);
  font-family: var(--font); font-size: 13px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; white-space: nowrap;
  transition: all var(--transition);
}
.bs-chip:hover    { border-color: var(--accent-mid); color: var(--accent); background: var(--accent-light); }
.bs-chip-active   { background: var(--accent); border-color: var(--accent); color: #fff; }
.bs-chip-active:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

/* ─── Items list ─────────────────────────────────────────────────────────────── */
.bs-list { overflow-y: auto; flex: 1; padding: 0 12px 24px; }
.bs-list::-webkit-scrollbar { width: 4px; }
.bs-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.bs-group { margin-bottom: 4px; }
.bs-group-label {
  padding: 14px 8px 8px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}

.bs-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.bs-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 14px 10px 12px;
  background: var(--surface-2); border: 1.5px solid transparent;
  border-radius: var(--radius-md); cursor: pointer;
  font-family: var(--font); text-align: center;
  transition: all var(--transition);
}
.bs-item:hover { background: var(--accent-light); border-color: var(--accent-mid); }
.bs-item-selected { background: var(--accent-light); border-color: var(--accent); }
.bs-item-icon { width: 44px; height: 44px; object-fit: contain; }
.bs-item-name {
  font-size: 13px; font-weight: 500; color: var(--text-primary);
  line-height: 1.3;
}
.bs-item-id {
  font-size: 10px; color: var(--text-muted);
  font-family: 'SF Mono','Fira Code',monospace;
  word-break: break-all; line-height: 1.3;
}

/* ─── Utilities ─────────────────────────────────────────────────────────────── */
.mt-8 { margin-top: 8px; }

/* ─── Dark theme ────────────────────────────────────────────────────────────── */
html[data-theme="dark"] {
  --bg: #0D0F17;
  --surface: #161925;
  --surface-2: #1E2132;
  --surface-3: #252939;
  --border: #2A2E42;
  --border-focus: #8B5CF6;

  --text-primary: #EDF0F8;
  --text-secondary: #8A90A8;
  --text-muted: #545970;

  --accent: #8B5CF6;
  --accent-hover: #7C3AED;
  --accent-light: rgba(139, 92, 246, 0.14);
  --accent-mid: rgba(196, 181, 253, 0.22);

  --success: #34D399;
  --success-bg: #0C2419;
  --danger: #F87171;
  --danger-bg: #260E0E;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.30), 0 1px 2px rgba(0,0,0,.20);
  --shadow-md: 0 4px 16px rgba(0,0,0,.40), 0 1px 4px rgba(0,0,0,.25);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.50), 0 2px 8px rgba(0,0,0,.30);
}

html[data-theme="dark"] .topbar {
  background: rgba(22, 25, 37, 0.90);
}

html[data-theme="dark"] .login-body {
  background: var(--bg);
}

html[data-theme="dark"] .login-card {
  background: var(--surface);
  border-color: var(--border);
}

html[data-theme="dark"] .oauth-yandex-logo {
  filter: brightness(0.9);
}

html[data-theme="dark"] .bs-sheet,
html[data-theme="dark"] .bs-sheet * {
  color-scheme: dark;
}

/* Theme toggle button */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--surface-3); color: var(--text-primary); }
.theme-toggle svg { display: block; }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
html[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .main-content { padding: 24px 16px; }
  .topbar { padding: 0 16px; }
  .page-header { flex-direction: column; }
  .detail-card-header { flex-direction: column; }
  .detail-actions { width: 100%; }
}
