/* Vantyx — Vantyx Admin UI (Uncodixify) */
:root {
  --primary: #212529;
  --primary-dark: #0d0f10;
  --primary-light: rgba(33, 37, 41, 0.08);
  --success: #059669;
  --success-light: rgba(5, 150, 105, 0.1);
  --danger: #dc2626;
  --danger-light: rgba(220, 38, 38, 0.08);
  --warning: #d97706;
  --warning-light: rgba(217, 119, 6, 0.1);
  --info: #525252;

  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --border: #e5e7eb;
  --border-light: #eceef1;

  --text: #525252;
  --heading: #171717;
  --muted: #737373;

  --sidebar-w: 252px;
  --nav-h: 52px;
  --touch-min: 44px;
  --sidebar-z: 160;
  --sidebar-overlay-z: 150;
  --radius: 6px;
  --radius-lg: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  --font: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
}

[data-theme="dark"] {
  --primary: #00d4aa;
  --primary-dark: #00b894;
  --primary-light: rgba(0, 212, 170, 0.12);
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-2: #222222;
  --border: #333333;
  --border-light: #2a2a2a;
  --text: #a3a3a3;
  --heading: #f5f5f5;
  --muted: #737373;
  --success-light: rgba(5, 150, 105, 0.15);
  --danger-light: rgba(220, 38, 38, 0.12);
  --warning-light: rgba(217, 119, 6, 0.12);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.47;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  overflow-x: hidden;
}

body.sidebar-open { overflow: hidden; }

.mobile-only { display: none; }

h1, h2, h3, strong { color: var(--heading); font-weight: 600; }

.hidden { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Login ───────────────────────────────────────────── */
.screen { min-height: 100dvh; }

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: var(--bg);
}

.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2rem;
  border: 1px solid var(--border-light);
}

.logo-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--heading);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-light);
}

.logo-mark.sm { width: 36px; height: 36px; }

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.login-brand-title {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.1;
}

.login-brand-sub {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.3;
}

.login-box-head { margin-bottom: 1.5rem; }

.login-box-head h2 {
  font-size: 1.375rem;
  margin-bottom: 0.35rem;
}

.login-box-head p { color: var(--muted); font-size: 0.9375rem; }

.field { margin-bottom: 1.25rem; }

.field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 0.4rem;
}

.field input,
.input-select,
.search-field input,
.navbar-search input {
  width: 100%;
  height: 38px;
  padding: 0 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--heading);
  font: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.input-select:focus,
.search-field input:focus,
.navbar-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.form-error {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--danger-light);
  color: var(--danger);
  border-radius: var(--radius);
  font-size: 0.8125rem;
}

.form-success {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--success-light, rgba(40, 199, 111, 0.12));
  color: var(--success, #28c76f);
  border-radius: var(--radius);
  font-size: 0.8125rem;
}

.form-hint {
  margin: 0.5rem 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.inline-field {
  display: flex;
  gap: 0.5rem;
}

.inline-field input { flex: 1; }

.detail-label-field { margin: 1rem 0; }

.password-form .field:last-of-type { margin-bottom: 1rem; }

.detail-sms {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

.detail-sms .sms-cmd {
  display: block;
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  background: var(--surface-alt, rgba(0, 0, 0, 0.04));
  border-radius: var(--radius);
  font-size: 0.8125rem;
  word-break: break-all;
}


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

/* ── Shell ───────────────────────────────────────────── */
.shell {
  display: flex;
  min-height: 100dvh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1.25rem 1.375rem;
  text-decoration: none;
  color: var(--heading);
  font-weight: 700;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.logo-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.1;
}

.logo-sub {
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-menu {
  flex: 1;
  padding: 0 0.75rem;
  overflow-y: auto;
}

.menu-section {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0.875rem 0.75rem 0.25rem;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5625rem 0.75rem;
  margin-bottom: 2px;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.menu-link.unavailable {
  opacity: 0.5;
  cursor: not-allowed;
}

.menu-dl-badge {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface-2);
  padding: 0.125rem 0.375rem;
  border-radius: 6px;
  white-space: nowrap;
}

.menu-download:not(.unavailable) .menu-dl-badge {
  color: var(--success, #28c76f);
  background: rgba(40, 199, 111, 0.12);
}

.menu-dl-badge.coming-soon {
  color: var(--muted);
  background: var(--bg);
  font-size: 0.625rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.coming-soon-label {
  margin-left: 0.35rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.menu-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.85;
}

.menu-link:hover {
  background: var(--bg);
  color: var(--heading);
}

.menu-link.active {
  background: var(--surface-2);
  color: var(--heading);
  font-weight: 600;
}

.menu-link.active svg { opacity: 1; }

.menu-badge {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.375rem;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--heading);
  border: 1px solid var(--border);
}

.menu-link.logout { color: var(--muted); }
.menu-link.logout:hover { color: var(--danger); background: var(--danger-light); }

.sidebar-bottom {
  padding: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--sidebar-overlay-z);
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.sidebar-backdrop.visible {
  display: block;
  opacity: 1;
}

.sidebar-toggle { display: none; }

.sidebar-toggle .icon-close { display: none; }
.sidebar-toggle[aria-expanded="true"] .icon-menu { display: none; }
.sidebar-toggle[aria-expanded="true"] .icon-close { display: block; }

.navbar-start {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

.navbar-brand-mobile {
  display: none;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--heading);
  font-size: 0.9375rem;
}

.server-status {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  margin-bottom: 0.375rem;
  background: var(--success-light);
  border-radius: var(--radius);
}

.server-status strong {
  display: block;
  font-size: 0.8125rem;
  color: var(--success);
}

.server-status small,
.server-status-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

/* ── Content area ────────────────────────────────────── */
.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  max-height: 100dvh;
}

.navbar {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  gap: 1rem;
}

.navbar-search {
  position: relative;
  flex: 1;
  max-width: 380px;
}

.navbar-search svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

.navbar-search input {
  padding-left: 2.375rem;
  background: var(--bg);
  border-color: transparent;
}

.navbar-search input:focus {
  background: var(--surface);
  border-color: var(--border);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-time {
  font-size: 0.8125rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding: 0 0.5rem;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.icon-btn:hover { background: var(--bg); }
.icon-btn svg { width: 20px; height: 20px; }

#theme-toggle .icon-moon { display: none; }
[data-theme="dark"] #theme-toggle .icon-sun { display: none; }
[data-theme="dark"] #theme-toggle .icon-moon { display: block; }

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.page-head {
  margin-bottom: 1.25rem;
}

.page-head h1 {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.page-head p {
  color: var(--muted);
  font-size: 0.9375rem;
  margin-top: 0.125rem;
}

/* ── Stats bar (overview) ───────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}

.stat-item {
  background: var(--surface);
  padding: 1rem 1.125rem;
}

.stat-label {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  display: block;
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--heading);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.125rem;
}

.overview-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

/* ── Main layout ─────────────────────────────────────── */
.layout-main {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.25rem;
  align-items: start;
}

.layout-primary,
.layout-secondary {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Panels ──────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: 1.25rem;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.panel-head h3 {
  font-size: 1rem;
  font-weight: 600;
}

.panel-desc {
  color: var(--muted);
  font-size: 0.9375rem;
  margin-bottom: 0.875rem;
}

.panel-alert {
  border-color: rgba(220, 38, 38, 0.35);
  background: var(--surface);
}

.panel-alert p {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 0.875rem;
}

.panel-table { padding: 0; overflow: hidden; }

/* ── Charts ──────────────────────────────────────────── */
.chart-box {
  position: relative;
  width: 100%;
}

.chart-box.lg { height: 260px; }
.chart-box.md { height: 220px; }

.chart-box.donut {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 160px;
}

.chart-box.donut canvas {
  width: 130px !important;
  height: 130px !important;
  flex-shrink: 0;
}

.chart-box.gauge {
  width: 110px;
  height: 110px;
  flex-shrink: 0;
}

.chart-box.gauge canvas {
  width: 110px !important;
  height: 110px !important;
}

.gauge-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--heading);
  pointer-events: none;
}

.legend-list {
  list-style: none;
  flex: 1;
}

.legend-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  padding: 0.375rem 0;
}

.legend-list b { margin-left: auto; font-variant-numeric: tabular-nums; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.purple { background: var(--primary); }
.dot.orange { background: var(--warning); }

.security-block {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.check-list {
  list-style: none;
  font-size: 0.8125rem;
}

.check-list li {
  padding: 0.3125rem 0;
  padding-left: 1.25rem;
  position: relative;
  color: var(--muted);
}

.check-list li.ok { color: var(--heading); }

.check-list li.ok::before,
.check-list li.warn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55rem;
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.check-list li.ok::before {
  background: var(--success-light);
  box-shadow: inset 0 0 0 2px var(--success);
}

.check-list li.warn::before {
  background: var(--warning-light);
  box-shadow: inset 0 0 0 2px var(--warning);
}

/* ── Devices ─────────────────────────────────────────── */
.device-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.device-item {
  padding: 0.875rem 1rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.device-item:hover {
  border-color: var(--border);
  background: var(--surface-2);
}

.device-item .name {
  font-weight: 600;
  color: var(--heading);
  font-size: 0.9375rem;
  margin-bottom: 0.375rem;
}

.device-item .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  align-items: center;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Feed / Activity ─────────────────────────────────── */
.feed {
  display: flex;
  flex-direction: column;
  max-height: 280px;
  overflow-y: auto;
}

.feed.tall { max-height: 480px; }

.feed-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
}

.feed-item:last-child { border-bottom: none; }

.feed-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.feed-icon svg { width: 16px; height: 16px; }
.feed-icon.trigger { background: var(--danger-light); color: var(--danger); }
.feed-icon.register { background: var(--success-light); color: var(--success); }
.feed-icon.offline { background: var(--warning-light); color: var(--warning); }
.feed-icon.delete { background: var(--bg); color: var(--muted); }

.feed-body { flex: 1; min-width: 0; }

.feed-msg {
  font-size: 0.875rem;
  color: var(--heading);
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-time {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.125rem;
}

.feed-tag {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.feed-tag.trigger { background: var(--danger-light); color: var(--danger); }
.feed-tag.register { background: var(--success-light); color: var(--success); }
.feed-tag.offline { background: var(--warning-light); color: var(--warning); }
.feed-tag.delete { background: var(--bg); color: var(--muted); }

/* ── Tags & badges ───────────────────────────────────── */
.tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
}

.tag-green { background: var(--success-light); color: var(--success); }

.badge {
  display: inline-flex;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge.online { background: var(--success-light); color: var(--success); }
.badge.offline { background: var(--danger-light); color: var(--danger); }
.badge.android { background: var(--primary-light); color: var(--primary); }
.badge.ios { background: var(--warning-light); color: #cc7a00; }
.badge.update-needed { background: var(--warning-light); color: #cc7a00; margin-left: 0.35rem; }

.device-map {
  height: 420px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-top: 0.75rem;
}

.map-hint { margin: 0 0 0.25rem; }

.version-cell { font-size: 0.8125rem; white-space: nowrap; }

.wear-report {
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--surface-2);
  border-radius: var(--radius);
  font-size: 0.8125rem;
}

.wear-report pre {
  margin: 0.5rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.75rem;
  max-height: 160px;
  overflow: auto;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 38px;
  padding: 0 1.125rem;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-sm { height: 32px; padding: 0 0.875rem; font-size: 0.8125rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) { background: #d44a4b; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) { background: var(--bg); }

.danger-text { color: var(--danger) !important; border-color: rgba(234,84,85,0.35) !important; }
.danger-text:hover { background: var(--danger-light) !important; }

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.link-btn:hover { text-decoration: underline; }

/* ── Filter & Table ──────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.search-field {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-field svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

.search-field input { padding-left: 2.375rem; }

.input-select {
  width: auto;
  min-width: 140px;
  cursor: pointer;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table { min-width: 640px; }

.table-wrap.cards-only table { min-width: 0; }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 0.875rem 1.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-light);
}

tbody td {
  padding: 0.875rem 1.25rem;
  font-size: 0.9375rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tbody tr:hover td { background: var(--bg); }
tbody tr:last-child td { border-bottom: none; }

.device-cell strong {
  display: block;
  font-weight: 600;
  color: var(--heading);
}

.device-cell small {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

.actions { display: flex; gap: 0.375rem; justify-content: flex-end; }

.empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
}

.empty p { font-weight: 600; color: var(--heading); margin-bottom: 0.25rem; }

/* ── Settings ────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.settings-grid .span-full { grid-column: 1 / -1; }

.team-hint {
  flex: 1;
  margin: 0;
  font-size: 0.9375rem;
  color: var(--muted);
}

.filter-bar .btn { margin-left: auto; }

.perm-fieldset {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.75rem 1rem 1rem;
  margin: 0 0 1rem;
}

.perm-fieldset legend {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--heading);
  padding: 0 0.25rem;
}

.perm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
}

.perm-grid label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.perm-grid input { accent-color: var(--primary); }

.perm-summary {
  font-size: 0.8125rem;
  color: var(--muted);
  max-width: 280px;
}

.role-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.role-badge.owner { background: var(--primary-light); color: var(--primary); }
.role-badge.admin { background: var(--info-light, rgba(0,207,232,.15)); color: var(--info); }
.role-badge.viewer { background: var(--surface-2); color: var(--muted); }

.dialog-form { text-align: left; max-width: 420px; }
.dialog-form h3 { text-align: center; margin-bottom: 1rem; }
.field-hint { display: block; margin-top: 0.25rem; font-size: 0.75rem; color: var(--muted); }

@media (max-width: 640px) {
  .perm-grid { grid-template-columns: 1fr; }
}

.info-list div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9375rem;
}

.info-list div:last-child { border-bottom: none; }
.info-list dt { color: var(--muted); }
.info-list dd { font-weight: 600; color: var(--heading); }

.theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.theme-row p {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 0.125rem;
}

.code-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.code-row.mt { margin-top: 0.75rem; }

.code-row code,
.info-list code {
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem;
  color: var(--heading);
}

.code-label {
  width: 100%;
  font-size: 0.75rem;
  color: var(--muted);
}

.code-block {
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem;
  line-height: 1.7;
  color: var(--text);
  overflow-x: auto;
}

.split-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

/* ── Modal & Drawer ──────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.overlay-bg {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.dialog {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
}

.dialog-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.875rem;
}

.dialog-icon.warn { background: var(--danger-light); color: var(--danger); }
.dialog-icon svg { width: 22px; height: 22px; }

.dialog h3 {
  font-size: 1.0625rem;
  margin-bottom: 0.375rem;
}

.dialog > p {
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.55;
  margin-bottom: 1rem;
}

.dialog-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.drawer-overlay { justify-content: flex-end; padding: 0; }

.drawer {
  position: relative;
  width: 400px;
  max-width: 100%;
  height: 100%;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(47, 43, 61, 0.15);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
}

.drawer-head h3 { font-size: 1rem; }

.drawer-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.detail-grid { margin-bottom: 1rem; }

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9375rem;
}

.detail-row span:first-child { color: var(--muted); }

.detail-log h4 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 1rem 0 0.5rem;
}

.detail-log-item {
  font-size: 0.875rem;
  padding: 0.4375rem 0;
  border-bottom: 1px solid var(--border-light);
}

.muted { color: var(--muted); font-size: 0.875rem; }

/* ── Toast & Loading ─────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.625rem 1.125rem;
  background: var(--heading);
  color: #fff;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 300;
}

.toast.error { background: var(--danger); }

.loading {
  position: fixed;
  inset: 0;
  background: rgba(248, 249, 250, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 250;
}

[data-theme="dark"] .loading { background: rgba(15, 15, 15, 0.85); }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 1440px) {
  .layout-main { grid-template-columns: 1fr 320px; }
}

@media (max-width: 1280px) {
  .layout-main { grid-template-columns: 1fr; }
  .layout-secondary {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1025px) {
  .navbar-start { display: none; }
}

@media (max-width: 1024px) {
  .sidebar-toggle { display: inline-flex; }
  .mobile-only { display: inline-flex; }
  .navbar-brand-mobile { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(var(--sidebar-w), 85vw);
    height: 100dvh;
    z-index: var(--sidebar-z);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.22);
  }

  .sidebar-menu {
    display: block;
    overflow-x: visible;
    overflow-y: auto;
    padding: 0 0.75rem;
    gap: 0;
  }

  .menu-label,
  .sidebar-bottom .server-status { display: block; }

  .sidebar-bottom .logout { display: flex; }

  .menu-link {
    white-space: normal;
    width: 100%;
    min-height: var(--touch-min);
    padding-top: 0.6875rem;
    padding-bottom: 0.6875rem;
  }

  .content {
    flex: 1;
    width: 100%;
    max-height: none;
  }

  .navbar {
    padding: 0 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .navbar-search {
    flex: 1;
    max-width: none;
  }

  .icon-btn {
    width: var(--touch-min);
    height: var(--touch-min);
  }

  .btn,
  .menu-link {
    min-height: var(--touch-min);
  }

  .btn-sm {
    min-height: var(--touch-min);
    height: auto;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .field input,
  .input-select,
  .search-field input,
  .navbar-search input {
    min-height: var(--touch-min);
    height: auto;
  }

  .user-avatar {
    width: var(--touch-min);
    height: var(--touch-min);
  }
}

@media (max-width: 992px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .layout-secondary { grid-template-columns: 1fr; }
  .split-panels { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .navbar-search { display: none; }
  .navbar-time { display: none; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .page-content {
    padding: 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  .page-head h1 { font-size: clamp(1.125rem, 4.5vw, 1.375rem); }
  .page-head p { font-size: clamp(0.8125rem, 3.5vw, 0.9375rem); }
  .stat-value { font-size: clamp(1.125rem, 5vw, 1.375rem); }
  .overview-toolbar { flex-direction: column; }
  .overview-toolbar .btn { width: 100%; }
  .filter-bar { gap: 0.625rem; }
  .device-map {
    height: min(65dvh, 520px);
    min-height: 260px;
    width: 100%;
  }
  #page-map .panel-head { flex-wrap: wrap; gap: 0.5rem; }
  .drawer { width: 100%; max-width: 100%; }
  .drawer-overlay { justify-content: stretch; }
  .drawer-head {
    padding-top: max(1.125rem, env(safe-area-inset-top));
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
  }
  .drawer-body {
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  }
  .security-block { flex-direction: column; align-items: flex-start; }
  .chart-box.donut { flex-direction: column; align-items: flex-start; }
  .theme-row { flex-direction: column; align-items: flex-start; }
  .theme-row .input-select { width: 100%; }
  .info-list div { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
  .toast {
    left: 1rem;
    right: 1rem;
    transform: none;
    bottom: max(1.5rem, env(safe-area-inset-bottom));
    text-align: center;
  }
}

@media (max-width: 640px) {
  .stats-bar { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .search-field,
  .filter-bar .input-select { width: 100%; min-width: 0; }
  .filter-bar .btn { margin-left: 0; width: 100%; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .btn { width: 100%; min-height: var(--touch-min); }
  .perm-grid { grid-template-columns: 1fr; }

  .table-wrap.cards-only { overflow-x: visible; }
  .table-wrap.cards-only table { min-width: 0; width: 100%; }
  .table-wrap.cards-only thead { display: none; }
  .table-wrap.cards-only tbody tr {
    display: block;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
  }
  .table-wrap.cards-only tbody tr:hover td { background: transparent; }
  .table-wrap.cards-only tbody tr:last-child { border-bottom: none; }
  .table-wrap.cards-only tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4375rem 0;
    border-bottom: none;
    font-size: 0.875rem;
  }
  .table-wrap.cards-only tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    flex-shrink: 0;
  }
  .table-wrap.cards-only tbody td.device-cell {
    flex-direction: column;
    align-items: flex-start;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0.375rem;
  }
  .table-wrap.cards-only tbody td.device-cell::before { display: none; }
  .table-wrap.cards-only tbody td.actions {
    flex-direction: column;
    align-items: stretch;
    padding-top: 0.75rem;
  }
  .table-wrap.cards-only tbody td.actions::before { display: none; }
  .table-wrap.cards-only tbody td.actions .btn { width: 100%; }
}

@media (max-width: 480px) {
  .login-screen { align-items: center; }
  .login-box { padding: 1.5rem; }
  .login-brand-title { font-size: clamp(1.25rem, 5vw, 1.5rem); }
  .login-box-head h2 { font-size: clamp(1.125rem, 4.5vw, 1.375rem); }
  .panel { padding: 1rem; }
  .panel-table { padding: 0; }
  .navbar-actions { gap: 0.25rem; }
  .user-avatar { display: none; }
  .device-list { grid-template-columns: 1fr; }
  .feed-msg { white-space: normal; }
  .code-block { font-size: 0.75rem; }
}

@media (max-width: 375px) {
  .navbar { gap: 0.5rem; }
  .page-content { padding: 0.875rem; }
  .stat-item { padding: 0.875rem 1rem; }
}

@media (max-width: 320px) {
  .login-box { padding: 1.25rem; }
  .login-brand { gap: 0.625rem; margin-bottom: 1.25rem; padding-bottom: 1rem; }
  .logo-mark { width: 40px; height: 40px; }
  .page-head { margin-bottom: 1rem; }
  .filter-bar { margin-bottom: 1rem; }
  thead th,
  tbody td { padding-left: 0.875rem; padding-right: 0.875rem; }
  .table-wrap.cards-only tbody tr { padding: 0.875rem 1rem; }
  .device-map { min-height: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
