/* ==========================================================================
   Fleet.Click design system
   Dark-first operations console. Light theme via [data-theme="light"].
   ========================================================================== */

:root {
  --bg: #0b0f14;
  --bg-raised: #11161d;
  --panel: #151b23;
  --panel-2: #1a222c;
  --panel-glass: rgba(21, 27, 35, 0.88);
  --text: #e8edf2;
  --text-strong: #f6f9fb;
  --muted: #8b96a3;
  --faint: #5c6672;
  --accent: #4c8dff;
  --accent-strong: #2f6fe4;
  --accent-soft: rgba(76, 141, 255, 0.14);
  --ok: #3fb950;
  --ok-soft: rgba(63, 185, 80, 0.14);
  --warn: #d29922;
  --warn-soft: rgba(210, 153, 34, 0.14);
  --danger: #e5534b;
  --danger-soft: rgba(229, 83, 75, 0.14);
  --critical: #f85149;
  --orange: #db6d28;
  --orange-soft: rgba(219, 109, 40, 0.14);
  --info: #54aeff;
  --info-soft: rgba(84, 174, 255, 0.13);
  --border: #262e38;
  --border-strong: #333d49;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --topbar-h: 56px;
  --sidebar-w: 232px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: "Cascadia Code", "SF Mono", Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #eef1f5;
  --bg-raised: #f7f9fb;
  --panel: #ffffff;
  --panel-2: #f2f5f8;
  --panel-glass: rgba(255, 255, 255, 0.9);
  --text: #1c2530;
  --text-strong: #0c131b;
  --muted: #5b6672;
  --faint: #8b96a3;
  --accent: #2f6fe4;
  --accent-strong: #2059c4;
  --accent-soft: rgba(47, 111, 228, 0.1);
  --ok-soft: rgba(35, 154, 59, 0.12);
  --warn-soft: rgba(191, 135, 18, 0.14);
  --danger-soft: rgba(210, 60, 52, 0.1);
  --orange-soft: rgba(209, 99, 32, 0.12);
  --info-soft: rgba(28, 126, 214, 0.1);
  --border: #dbe1e8;
  --border-strong: #c3ccd6;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.14);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
h1,
h2,
h3,
h4 {
  color: var(--text-strong);
  line-height: 1.25;
}
.muted {
  color: var(--muted);
}
.error {
  color: var(--danger);
}
.hidden {
  display: none !important;
}
.num {
  font-variant-numeric: tabular-nums;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-track {
  background: transparent;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 550;
  cursor: pointer;
  min-height: 38px;
  white-space: nowrap;
  transition:
    background 0.15s var(--ease),
    border-color 0.15s var(--ease),
    transform 0.1s var(--ease),
    box-shadow 0.15s var(--ease);
}
.btn:hover {
  background: var(--border);
  border-color: var(--faint);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.btn .ic {
  font-size: 16px;
  flex: none;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(47, 111, 228, 0.35);
}
.btn.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
.btn.danger {
  background: var(--danger-soft);
  border-color: rgba(229, 83, 75, 0.4);
  color: var(--danger);
}
.btn.danger:hover {
  background: rgba(229, 83, 75, 0.22);
  border-color: var(--danger);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn.ghost:hover {
  background: var(--panel-2);
  color: var(--text);
}
.btn.sm {
  min-height: 30px;
  padding: 0.25rem 0.65rem;
  font-size: 0.84rem;
}
.btn.block {
  width: 100%;
}
.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}
.btn.loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
  position: relative;
}
.btn-icon:hover {
  background: var(--panel-2);
  color: var(--text);
}
.btn-icon .ic {
  font-size: 18px;
}
.btn-icon .dot {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--panel);
}

/* ==========================================================================
   Badges / pills
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.14rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: transparent;
}
.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}
.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}
.badge.info {
  background: var(--info-soft);
  color: var(--info);
  border-color: transparent;
}
.badge.accent {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}
.badge.orange {
  background: var(--orange-soft);
  color: var(--orange);
  border-color: transparent;
}
.badge.plain::before {
  display: none;
}

/* ==========================================================================
   Auth pages
   ========================================================================== */
.auth-page {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 1rem;
  background:
    radial-gradient(60rem 30rem at 15% -10%, rgba(76, 141, 255, 0.16), transparent 60%),
    radial-gradient(50rem 28rem at 110% 110%, rgba(63, 185, 80, 0.1), transparent 55%), var(--bg);
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.25rem;
  width: 100%;
  max-width: 400px;
}
.auth-card .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}
.auth-card h1 {
  margin: 0;
  font-size: 1.45rem;
}
.auth-card .sub {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ==========================================================================
   App shell
   ========================================================================== */
.app-shell {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
}
.app-topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.9rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1200;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-strong);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  padding-right: 0.4rem;
}
.brand:hover {
  text-decoration: none;
}
.brand .ic {
  font-size: 26px;
  color: var(--accent);
}
.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.conn-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}
.conn-pill.live {
  color: var(--ok);
  border-color: rgba(63, 185, 80, 0.35);
}
.conn-pill.live::before {
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}
.conn-pill.warn {
  color: var(--warn);
  border-color: rgba(210, 153, 34, 0.35);
}
.conn-pill.warn::before {
  background: var(--warn);
}
.topbar-spacer {
  flex: 1;
}

.app-main {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 0;
}
.app-sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0.75rem 0.6rem;
}
.app-sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-section {
  margin-bottom: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-section-label {
  padding: 0.35rem 0.65rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
}
.app-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 520;
  transition:
    background 0.12s,
    color 0.12s;
}
.app-sidebar nav a .ic {
  font-size: 18px;
  flex: none;
  opacity: 0.85;
}
.app-sidebar nav a:hover {
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
}
.app-sidebar nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.app-sidebar nav a.active .ic {
  opacity: 1;
}
.app-content {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

/* ==========================================================================
   Dropdown menus + notification panel
   ========================================================================== */
.dropdown {
  position: relative;
}
.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 210px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.35rem;
  z-index: 1300;
  animation: menu-in 0.14s var(--ease);
}
@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}
.menu-item:hover {
  background: var(--panel-2);
  text-decoration: none;
}
.menu-item .ic {
  font-size: 16px;
  color: var(--muted);
}
.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0.2rem;
}
.menu-header {
  padding: 0.45rem 0.6rem 0.3rem;
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
}

.notif-panel {
  width: 380px;
  max-width: calc(100vw - 2rem);
  max-height: 480px;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
.notif-head h3 {
  margin: 0;
  font-size: 0.95rem;
}
.notif-list {
  overflow-y: auto;
  flex: 1;
}
.notif-item {
  display: flex;
  gap: 0.7rem;
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}
.notif-item:hover {
  background: var(--panel-2);
  text-decoration: none;
}
.notif-item.unread {
  background: var(--accent-soft);
}
.notif-item.unread:hover {
  background: rgba(76, 141, 255, 0.2);
}
.notif-sev {
  flex: none;
  width: 8px;
  border-radius: 4px;
  background: var(--info);
  margin: 3px 0;
}
.notif-sev.low {
  background: var(--muted);
}
.notif-sev.medium {
  background: var(--warn);
}
.notif-sev.high {
  background: var(--orange);
}
.notif-sev.critical {
  background: var(--critical);
}
.notif-body {
  min-width: 0;
  flex: 1;
}
.notif-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-strong);
  margin: 0 0 0.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notif-text {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-time {
  flex: none;
  font-size: 0.74rem;
  color: var(--faint);
  white-space: nowrap;
}
.notif-empty {
  padding: 2.2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ==========================================================================
   Content pages
   ========================================================================== */
.app-content.page {
  overflow-y: auto;
  padding: 1.4rem 1.6rem 3rem;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.page-head h1,
.page-head h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}
.page-head .sub {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.page-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.skip-link {
  position: fixed;
  z-index: 10000;
  top: 0.5rem;
  left: 0.5rem;
  transform: translateY(-200%);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--panel);
}
.skip-link:focus {
  transform: translateY(0);
}
.org-switcher {
  max-width: 13rem;
  min-height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  padding: 0 0.6rem;
}
.page-head.compact {
  align-items: center;
  margin-top: 1.5rem;
  margin-bottom: 0.65rem;
}
.admin-page {
  max-width: 1500px;
  margin: 0 auto;
  padding: 1.5rem 1.6rem 4rem;
}
.admin-tabs {
  margin-bottom: 1.25rem;
  overflow-x: auto;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  display: grid;
  gap: 0.3rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.stat-card strong {
  font-size: 1.55rem;
}
.stat-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.secret-once code,
#mfa-enrollment code {
  display: block;
  overflow-wrap: anywhere;
  user-select: all;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad {
  padding: 1rem 1.1rem;
}
.card + .card {
  margin-top: 1rem;
}
.card h3 {
  margin: 0 0 0.75rem;
  font-size: 1.02rem;
}

/* Toolbar (search / filters / actions above tables) */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}
.toolbar .spacer {
  flex: 1;
}
.search-box {
  position: relative;
  min-width: 220px;
  flex: 0 1 300px;
}
.search-box .ic {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  color: var(--faint);
  pointer-events: none;
}
.search-box input {
  padding-left: 2rem;
}

/* Segmented tabs */
.segmented {
  display: inline-flex;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.segmented button {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 550;
  padding: 0.3rem 0.75rem;
  border-radius: 5px;
  cursor: pointer;
  min-height: 30px;
}
.segmented button:hover {
  color: var(--text);
}
.segmented button.active {
  background: var(--panel);
  color: var(--text-strong);
  box-shadow: var(--shadow-sm);
}
.segmented button .count {
  margin-left: 0.35rem;
  font-size: 0.74rem;
  color: var(--faint);
}

/* ==========================================================================
   Forms
   ========================================================================== */
label,
.label {
  display: block;
  font-size: 0.86rem;
  font-weight: 550;
  color: var(--text);
}
input,
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  margin-top: 0.3rem;
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.94rem;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
input:hover,
select:hover,
textarea:hover {
  border-color: var(--faint);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder,
textarea::placeholder {
  color: var(--faint);
}
input[type="color"] {
  padding: 2px;
  height: 40px;
  cursor: pointer;
}
input[type="checkbox"] {
  width: auto;
  margin: 0;
}
textarea {
  resize: vertical;
  min-height: 70px;
}
.field {
  margin-bottom: 0.85rem;
}
.field .hint {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--faint);
}
.field .field-error {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--danger);
}
.field.invalid input,
.field.invalid select {
  border-color: var(--danger);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 0.9rem;
}
.form-grid .span-2 {
  grid-column: span 2;
}
.form-row {
  display: flex;
  gap: 0.9rem;
}
.form-row > * {
  flex: 1;
}

/* Switch */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.switch .track {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.18s var(--ease);
  position: relative;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s var(--ease);
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .track {
  background: var(--ok);
}
.switch input:checked + .track::after {
  transform: translateX(16px);
}
.switch input:focus-visible + .track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow-sm);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.data-table tbody tr {
  transition: background 0.1s;
}
.data-table tbody tr:hover {
  background: var(--panel-2);
}
.data-table tbody tr:last-child td {
  border-bottom: 0;
}
.data-table .cell-main {
  font-weight: 600;
  color: var(--text-strong);
}
.data-table .cell-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--faint);
  font-weight: 400;
}
.td-actions {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}
.td-actions .btn-icon {
  width: 30px;
  height: 30px;
  opacity: 0.65;
}
.td-actions .btn-icon:hover {
  opacity: 1;
}
.data-table tr:hover .td-actions .btn-icon {
  opacity: 1;
}
.color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 4px;
  vertical-align: -2px;
  margin-right: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 12, 0.6);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 1.25rem;
  z-index: 2000;
  animation: fade-in 0.15s var(--ease);
  overflow-y: auto;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 3rem);
  display: flex;
  flex-direction: column;
  animation: modal-in 0.18s var(--ease);
}
.modal.wide {
  max-width: 720px;
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  margin: 0;
  font-size: 1.08rem;
}
.modal-body {
  padding: 1rem 1.2rem;
  overflow-y: auto;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.2rem 1rem;
  border-top: 1px solid var(--border);
}
.modal-footer > div {
  display: flex;
  gap: 0.55rem;
}
.modal-overlay.closing {
  animation: fade-out 0.12s var(--ease) forwards;
}
.modal-overlay.closing .modal {
  animation: modal-out 0.12s var(--ease) forwards;
}
@keyframes fade-out {
  to {
    opacity: 0;
  }
}
@keyframes modal-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
  }
}

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-stack {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  right: 14px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 360px;
  max-width: calc(100vw - 2rem);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--info);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0.7rem 0.85rem;
  font-size: 0.88rem;
  animation: toast-in 0.2s var(--ease);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.toast.leaving {
  animation: toast-out 0.16s var(--ease) forwards;
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(14px);
  }
}
.toast.success {
  border-left-color: var(--ok);
}
.toast.error {
  border-left-color: var(--danger);
}
.toast.warning {
  border-left-color: var(--warn);
}
.toast .toast-icon {
  flex: none;
  font-size: 17px;
  margin-top: 1px;
}
.toast.success .toast-icon {
  color: var(--ok);
}
.toast.error .toast-icon {
  color: var(--danger);
}
.toast.warning .toast-icon {
  color: var(--warn);
}
.toast.info .toast-icon {
  color: var(--info);
}
.toast .toast-msg {
  flex: 1;
  min-width: 0;
}
.toast .toast-title {
  font-weight: 650;
  color: var(--text-strong);
  margin: 0;
}
.toast .toast-close {
  flex: none;
  background: none;
  border: 0;
  color: var(--faint);
  cursor: pointer;
  padding: 0;
  min-height: 0;
  line-height: 1;
}
.toast .toast-close:hover {
  color: var(--text);
}

/* ==========================================================================
   Empty states / skeletons
   ========================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3.2rem 1.5rem;
  background: var(--panel);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty-state .ic {
  font-size: 44px;
  color: var(--faint);
  margin-bottom: 0.8rem;
}
.empty-state h3 {
  margin: 0 0 0.3rem;
  font-size: 1.02rem;
}
.empty-state p {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 420px;
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  min-height: 1em;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}
.skel-row {
  height: 44px;
  margin-bottom: 2px;
  border-radius: 0;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading-block {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  padding: 1.4rem 0.4rem;
  font-size: 0.9rem;
}

/* ==========================================================================
   Detail lists, misc
   ========================================================================== */
.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1.1rem;
  margin: 0;
  font-size: 0.92rem;
  max-width: 640px;
}
.detail-list dt {
  color: var(--muted);
}
.detail-list dd {
  margin: 0;
  color: var(--text);
}

.app-content.page select {
  max-width: 320px;
}
.toolbar select,
.toolbar input {
  width: auto;
  margin-top: 0;
  min-height: 38px;
}
.toolbar .search-box input {
  width: 100%;
}

.report-output:empty {
  display: none;
}
.report-output {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem;
  overflow: auto;
  font-size: 0.84rem;
  font-family: var(--mono);
  max-height: 380px;
  white-space: pre;
}

/* ==========================================================================
   Map page
   ========================================================================== */
#map {
  position: absolute;
  inset: 0;
  background: var(--bg);
}
.map-wrap {
  position: absolute;
  inset: 0;
}
.map-side {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  bottom: 0.75rem;
  width: 320px;
  max-width: calc(100vw - 1.5rem);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--panel-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: transform 0.2s var(--ease);
}
.map-side.collapsed {
  transform: translateX(calc(-100% - 1rem));
}
.map-side-head {
  padding: 0.7rem 0.8rem 0.55rem;
  border-bottom: 1px solid var(--border);
}
.map-side-head .search-box {
  min-width: 0;
  flex: 1;
}
.map-side-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.35rem;
}
.asset-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.55rem;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}
.asset-row:hover {
  background: var(--panel-2);
}
.asset-row.selected {
  background: var(--accent-soft);
}
.asset-row .a-status {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--faint);
}
.asset-row .a-status.online {
  background: var(--ok);
  box-shadow: 0 0 5px rgba(63, 185, 80, 0.7);
}
.asset-row .a-status.moving {
  background: var(--ok);
  box-shadow: 0 0 5px rgba(63, 185, 80, 0.7);
}
.asset-row .a-status.idle {
  background: var(--warn);
}
.asset-row .a-main {
  flex: 1;
  min-width: 0;
}
.asset-row .a-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asset-row .a-sub {
  display: block;
  font-size: 0.76rem;
  color: var(--faint);
}
.asset-row .a-speed {
  flex: none;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.map-side-toggle {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1001;
  background: var(--panel-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
}
.map-side-toggle.hidden {
  display: none;
}

.map-panel {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1000;
  background: var(--panel-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 330px;
  max-width: calc(100vw - 1.5rem);
  max-height: calc(100% - 1.5rem);
  overflow-y: auto;
  animation: menu-in 0.16s var(--ease);
}
.asset-card {
  padding: 0.95rem 1rem;
}
.asset-card .ac-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}
.asset-card h2 {
  margin: 0;
  font-size: 1.05rem;
}
.asset-card .ac-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.1rem;
}
.asset-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.9rem;
  margin: 0.6rem 0;
  font-size: 0.88rem;
}
.asset-card dt {
  color: var(--muted);
}
.asset-card dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.asset-card .ac-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.map-fab-stack {
  position: absolute;
  right: 0.75rem;
  bottom: 1.4rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.map-fab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--panel-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
}
.map-fab:hover {
  background: var(--panel-2);
}
.map-fab.active {
  border-color: var(--accent);
  color: var(--accent);
}
.map-fab .ic {
  font-size: 16px;
}

/* Leaflet theme integration */
.leaflet-container {
  font: inherit;
  background: var(--bg);
}
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.leaflet-popup-content {
  margin: 0.7rem 0.9rem;
  font-size: 0.88rem;
}
.leaflet-popup-content b {
  color: var(--text-strong);
}
.leaflet-bar a {
  background: var(--panel);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.leaflet-bar a:hover {
  background: var(--panel-2);
}
.leaflet-control-attribution {
  background: var(--panel-glass) !important;
  color: var(--faint);
  font-size: 0.7rem;
}
.leaflet-control-attribution a {
  color: var(--muted);
}
.leaflet-tooltip.fc-tip {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  font-size: 0.8rem;
  padding: 0.25rem 0.55rem;
}
.leaflet-tooltip.fc-tip::before {
  display: none;
}

/* Asset markers (divIcon) */
.fc-marker {
  background: none;
  border: none;
}
.fc-marker .mk {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
}
.fc-marker .mk-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s var(--ease);
}
.fc-marker:hover .mk-dot {
  transform: scale(1.15);
}
.fc-marker .mk-heading {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 8px solid currentColor;
  transform-origin: 50% 19px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}
.fc-marker.selected .mk-dot {
  box-shadow:
    0 0 0 3px var(--accent-soft),
    0 0 0 5px var(--accent);
}
.fc-marker .mk-alert {
  position: absolute;
  top: -3px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--critical);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--bg);
  animation: pulse 1.4s infinite;
}
.asset-row .a-alert {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--critical);
  box-shadow: 0 0 5px rgba(248, 81, 73, 0.8);
}
.fc-cluster {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  border: 2.5px solid rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow-md);
  cursor: pointer;
}

/* Geofence draw hint bar */
.draw-bar {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--panel-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--accent);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  padding: 0.45rem 0.9rem;
  font-size: 0.86rem;
  animation: menu-in 0.16s var(--ease);
}
.draw-bar .pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}
.draw-bar .btn {
  min-height: 28px;
  padding: 0.15rem 0.6rem;
  font-size: 0.8rem;
}

/* Zones page split layout */
.zones-layout {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 340px 1fr;
}
.zones-list {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.zones-list .zones-head {
  padding: 0.9rem 0.95rem 0.7rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}
.zones-list .zones-head h2 {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
}
.zone-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.6rem 0.95rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.zone-item:hover {
  background: var(--panel-2);
}
.zone-item.selected {
  background: var(--accent-soft);
}
.zone-item .z-color {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.zone-item .z-main {
  flex: 1;
  min-width: 0;
}
.zone-item .z-name {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.zone-item .z-sub {
  display: block;
  font-size: 0.76rem;
  color: var(--faint);
}
.zone-item .z-actions {
  display: flex;
  gap: 0.1rem;
  flex: none;
}
.zones-map {
  position: relative;
  min-width: 0;
}
.zones-map #zones-map {
  position: absolute;
  inset: 0;
}
.zone-overlay-actions {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1000;
  display: flex;
  gap: 0.45rem;
}

/* ==========================================================================
   Timezone combobox (formModal "timezone" field type)
   ========================================================================== */
.tz-combo {
  position: relative;
}
.tz-combo input {
  padding-right: 2.3rem;
}
.tz-combo .tz-locate {
  position: absolute;
  right: 3px;
  top: calc(0.3rem + 3px);
  width: 30px;
  height: 30px;
}
.tz-combo .tz-locate .ic {
  font-size: 15px;
}
.tz-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 60;
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 0.25rem;
  animation: menu-in 0.12s var(--ease);
}
.tz-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  border-radius: 5px;
  cursor: pointer;
  text-align: left;
}
.tz-option:hover,
.tz-option.active {
  background: var(--accent-soft);
}
.tz-option .tz-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tz-option .tz-off {
  flex: none;
  color: var(--faint);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}
.tz-empty {
  padding: 0.7rem 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
.tz-hint {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Rule builder (automations)
   ========================================================================== */
.rb-gallery-intro {
  margin: 0.1rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.rb-templates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.rb-tpl {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.75rem 0.8rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.15s var(--ease),
    background 0.15s var(--ease),
    transform 0.1s var(--ease);
}
.rb-tpl:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.rb-tpl-icon {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
}
.rb-tpl-icon .ic {
  font-size: 18px;
}
.rb-tpl-main {
  min-width: 0;
}
.rb-tpl-label {
  display: block;
  font-weight: 650;
  font-size: 0.92rem;
  color: var(--text-strong);
}
.rb-tpl-desc {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.rb-back {
  margin: 0 0 0.7rem -0.4rem;
}
.rb-name {
  margin-bottom: 1rem;
}

.rb-flow {
  display: flex;
  flex-direction: column;
}
.rb-section {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
}
.rb-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.rb-head-text {
  font-size: 0.88rem;
  color: var(--text);
}
.rb-tag {
  flex: none;
  font-size: 0.7rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
}
.rb-tag.when {
  background: var(--info-soft);
  color: var(--info);
}
.rb-tag.if {
  background: var(--accent-soft);
  color: var(--accent);
}
.rb-tag.then {
  background: var(--warn-soft);
  color: var(--warn);
}
.rb-tag.scope {
  background: var(--ok-soft);
  color: var(--ok);
}
.rb-conn {
  width: 2px;
  height: 14px;
  margin-left: 1.6rem;
  background: var(--border-strong);
  position: relative;
}
.rb-conn::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--border-strong);
}

.rb-logic,
.rb-scope {
  padding: 2px;
}
.rb-logic button,
.rb-scope button {
  min-height: 26px;
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
}

.rb-conds {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.65rem;
}
.rb-conds:empty {
  margin-top: 0;
}
.rb-cond {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.6rem;
}
.rb-cond-idx {
  flex: none;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--faint);
  font-size: 0.7rem;
  font-weight: 700;
}
.rb-cond-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.rb-cond select,
.rb-cond input {
  width: auto;
  margin-top: 0;
  min-height: 34px;
  padding: 0.3rem 0.55rem;
  font-size: 0.88rem;
}
.rb-cond .rb-subject {
  font-weight: 600;
  color: var(--text-strong);
}
.rb-cond .rb-num {
  width: 110px;
}
.rb-cond .rb-cmetric {
  width: 190px;
  font-family: var(--mono);
  font-size: 0.82rem;
}
.rb-cond .rb-cvalue {
  width: 120px;
}
.rb-cond .rb-geo {
  min-width: 160px;
  max-width: 240px;
}
.rb-suffix {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}
.rb-cond .rb-del {
  flex: none;
  width: 30px;
  height: 30px;
  margin-left: auto;
}
.rb-cond-hint {
  flex-basis: 100%;
  margin: 0.1rem 0 0 1.75rem;
  font-size: 0.76rem;
  color: var(--faint);
}
.rb-add {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.6rem;
  padding: 0.45rem 0.8rem;
  width: 100%;
  justify-content: center;
  background: none;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 550;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s,
    background 0.15s;
}
.rb-add:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.rb-add .ic {
  font-size: 15px;
}

.rb-alert {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.65rem;
}
.rb-alert input {
  margin-top: 0;
}
.rb-sev {
  display: inline-flex;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
  align-self: flex-start;
  flex-wrap: wrap;
}
.rb-sev button {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 5px;
  cursor: pointer;
  min-height: 28px;
}
.rb-sev button:hover {
  color: var(--text);
}
.rb-sev button.active[data-sev="info"] {
  background: var(--info-soft);
  color: var(--info);
}
.rb-sev button.active[data-sev="low"] {
  background: var(--panel);
  color: var(--text-strong);
  box-shadow: var(--shadow-sm);
}
.rb-sev button.active[data-sev="medium"] {
  background: var(--warn-soft);
  color: var(--warn);
}
.rb-sev button.active[data-sev="high"] {
  background: var(--orange-soft);
  color: var(--orange);
}
.rb-sev button.active[data-sev="critical"] {
  background: var(--danger-soft);
  color: var(--critical);
}

.rb-scope-body {
  margin-top: 0.65rem;
}
.rb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.rb-chips:empty {
  display: none;
}
.rb-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.2rem 0.35rem 0.2rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 600;
}
.rb-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
}
.rb-chip-x:hover {
  background: rgba(255, 255, 255, 0.18);
}
.rb-chip-x .ic {
  font-size: 11px;
}
.rb-scope-add select {
  width: auto;
  margin-top: 0.5rem;
  min-height: 34px;
  font-size: 0.88rem;
}
.rb-chips + .rb-scope-add select {
  margin-top: 0.55rem;
}

.rb-summary {
  margin-top: 0.9rem;
  padding: 0.7rem 0.85rem;
  background: var(--accent-soft);
  border: 1px solid rgba(76, 141, 255, 0.3);
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}
.rb-summary b {
  color: var(--text-strong);
}
.rb-summary .rb-sev-info {
  color: var(--info);
}
.rb-summary .rb-sev-low {
  color: var(--muted);
}
.rb-summary .rb-sev-medium {
  color: var(--warn);
}
.rb-summary .rb-sev-high {
  color: var(--orange);
}
.rb-summary .rb-sev-critical {
  color: var(--critical);
}

.rb-json {
  margin-top: 0.7rem;
}
.rb-json summary {
  cursor: pointer;
  color: var(--faint);
  font-size: 0.82rem;
  font-weight: 550;
  user-select: none;
}
.rb-json summary:hover {
  color: var(--text);
}
.rb-json pre {
  margin: 0.5rem 0 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  overflow: auto;
  max-height: 260px;
  color: var(--muted);
}

.rb-legacy {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  background: var(--warn-soft);
  border: 1px solid rgba(210, 153, 34, 0.35);
  border-radius: var(--radius);
  padding: 0.65rem 0.8rem;
  margin-bottom: 0.9rem;
}
.rb-legacy .ic {
  flex: none;
  font-size: 17px;
  color: var(--warn);
  margin-top: 2px;
}
.rb-legacy p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text);
}

@media (max-width: 720px) {
  .rb-templates {
    grid-template-columns: 1fr;
  }
  .rb-cond .rb-num,
  .rb-cond .rb-cvalue {
    width: 90px;
  }
  .rb-cond .rb-cmetric {
    width: 100%;
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .zones-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 240px 1fr;
  }
  .zones-list {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}
#nav-toggle {
  display: none;
}

@media (max-width: 720px) {
  #nav-toggle {
    display: inline-flex;
  }
  .app-main {
    grid-template-columns: 1fr;
  }
  .app-sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: min(280px, 84vw);
    z-index: 1500;
    transform: translateX(-100%);
    transition: transform 0.2s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .app-sidebar.open {
    transform: none;
  }
  .map-panel {
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
  }
  .map-side {
    width: min(320px, calc(100vw - 1.5rem));
  }
  .app-content.page {
    padding: 1rem;
  }
  .data-table {
    font-size: 0.85rem;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .span-2 {
    grid-column: span 1;
  }
  .notif-panel {
    width: calc(100vw - 2rem);
  }
  .conn-pill {
    display: none;
  }
}
