:root,
:root[data-theme="original"],
body[data-theme="original"] {
  color-scheme: dark;
  --bg: #050806;
  --panel: rgba(9, 22, 15, .82);
  --panel-strong: rgba(10, 32, 22, .94);
  --panel-border: rgba(79, 255, 141, .48);
  --line: rgba(79, 255, 141, .48);
  --line-soft: rgba(79, 255, 141, .18);
  --accent: #41ff8d;
  --accent-soft: rgba(65, 255, 141, .14);
  --green: #41ff8d;
  --warning: #f4c542;
  --amber: #f4c542;
  --red: #ff4b4b;
  --text: #d9ffe8;
  --muted: #7ebd95;
  --hud-grid: rgba(65, 255, 141, .035);
  --theme-shadow: 0 0 24px rgba(65, 255, 141, .09);
  --map-tile-filter: brightness(.87) contrast(1.12) saturate(.88);
  --boundary-play-halo: #f8fafc;
  --boundary-play-core: #0b1220;
  --boundary-play-barb: #fbbf24;
  --boundary-play-shadow: rgba(0, 0, 0, .35);
}

:root[data-theme="frontline-hud"],
body[data-theme="frontline-hud"] {
  color-scheme: dark;
  --bg: #07111b;
  --panel: rgba(9, 24, 38, .86);
  --panel-strong: rgba(10, 31, 50, .94);
  --panel-border: rgba(0, 200, 255, .24);
  --line: rgba(0, 200, 255, .42);
  --line-soft: rgba(0, 200, 255, .18);
  --accent: #35d6ff;
  --accent-soft: rgba(53, 214, 255, .18);
  --green: #35d6ff;
  --warning: #ff9d3b;
  --amber: #ff9d3b;
  --red: #ff655f;
  --text: #e7f7ff;
  --muted: #87a6ba;
  --hud-grid: rgba(53, 214, 255, .055);
  --theme-shadow: 0 18px 54px rgba(0, 12, 24, .48), 0 0 28px rgba(53, 214, 255, .08);
  --map-tile-filter: brightness(.84) contrast(1.16) saturate(.86);
  --boundary-play-halo: #d8f8ff;
  --boundary-play-core: #071423;
  --boundary-play-barb: #35d6ff;
  --boundary-play-shadow: rgba(0, 0, 0, .42);
}

:root[data-theme="urban-ops"],
body[data-theme="urban-ops"] {
  color-scheme: dark;
  --bg: #090807;
  --panel: rgba(18, 18, 16, .88);
  --panel-strong: rgba(24, 23, 19, .95);
  --panel-border: rgba(190, 150, 80, .18);
  --line: rgba(190, 150, 80, .38);
  --line-soft: rgba(190, 150, 80, .16);
  --accent: #c6a15b;
  --accent-soft: rgba(198, 161, 91, .16);
  --green: #c6a15b;
  --warning: #ffb347;
  --amber: #ffb347;
  --red: #e65d48;
  --text: #f2eadc;
  --muted: #9f9789;
  --hud-grid: rgba(198, 161, 91, .045);
  --theme-shadow: 0 20px 58px rgba(0, 0, 0, .48), inset 0 1px 0 rgba(255, 255, 255, .045);
  --map-tile-filter: brightness(.82) contrast(1.14) saturate(.80);
  --boundary-play-halo: #2a2a2a;
  --boundary-play-core: #050505;
  --boundary-play-barb: #6f6f6f;
  --boundary-play-shadow: rgba(0, 0, 0, .60);
}

html[data-theme="frontline-hud"] body,
body[data-theme="frontline-hud"] {
  background:
    radial-gradient(circle at 18% 14%, rgba(53, 214, 255, .12), transparent 30%),
    radial-gradient(circle at 82% 18%, rgba(255, 157, 59, .09), transparent 26%),
    linear-gradient(rgba(53, 214, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(53, 214, 255, .035) 1px, transparent 1px),
    linear-gradient(180deg, #07111b 0%, #06101a 55%, #03070d 100%) !important;
  background-size: auto, auto, 46px 46px, 46px 46px, auto !important;
}

html[data-theme="urban-ops"] body,
body[data-theme="urban-ops"] {
  background:
    linear-gradient(135deg, rgba(255, 179, 71, .09), transparent 28%),
    radial-gradient(circle at 78% 16%, rgba(124, 145, 72, .13), transparent 34%),
    linear-gradient(rgba(198, 161, 91, .028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(198, 161, 91, .022) 1px, transparent 1px),
    linear-gradient(180deg, #090807 0%, #0d0d0a 52%, #060605 100%) !important;
  background-size: auto, auto, 42px 42px, 42px 42px, auto !important;
}

body[data-theme] header,
body[data-theme] .topbar,
body[data-theme] .bottombar,
body[data-theme] .toolbar,
body[data-theme] .panel,
body[data-theme] dialog,
body[data-theme] .network,
body[data-theme] .user-card,
body[data-theme] .device-card,
body[data-theme] .perm-group,
body[data-theme] .row,
body[data-theme] .chip,
body[data-theme] .mobile-info-bar,
body[data-theme] .compass {
  border-color: var(--line-soft);
  background-color: var(--panel);
  box-shadow: var(--theme-shadow);
}

body[data-theme] h1,
body[data-theme] h2,
body[data-theme] h3,
body[data-theme] .panel-title,
body[data-theme] .value,
body[data-theme] .chip strong,
body[data-theme] .eyebrow,
body[data-theme] .pill {
  color: var(--accent);
}

body[data-theme] .warn,
body[data-theme] .warn-text {
  color: var(--warning);
}

body[data-theme] input,
body[data-theme] select,
body[data-theme] button,
body[data-theme] a.button-link {
  border-color: var(--line);
  background-color: var(--accent-soft);
  color: var(--text);
}

body[data-theme] button.ui-button,
body[data-theme] a.button-link.ui-button {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  justify-content: center;
  min-height: 34px;
  padding: 6px 10px;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 800;
  background-color: var(--accent-soft);
  color: var(--text);
}

body[data-theme] button.ui-button--secondary,
body[data-theme] a.button-link.ui-button--secondary {
  background-color: rgba(255,255,255,.05);
}

body[data-theme] button.ui-button--ghost,
body[data-theme] a.button-link.ui-button--ghost {
  background-color: rgba(255,255,255,.04);
}

body[data-theme] button.ui-button--danger,
body[data-theme] a.button-link.ui-button--danger {
  border-color: rgba(255,75,75,.55);
  background-color: rgba(255,75,75,.12);
}

body[data-theme] button.ui-button--warn,
body[data-theme] a.button-link.ui-button--warn {
  border-color: rgba(244,197,66,.55);
  background-color: rgba(244,197,66,.12);
}

body[data-theme] button.ui-button.icon-button,
body[data-theme] a.button-link.ui-button.icon-button {
  padding-inline: 12px;
}

body[data-theme] button.ui-button svg,
body[data-theme] a.button-link.ui-button svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

body[data-theme] select,
body[data-theme] option,
body[data-theme] optgroup {
  background-color: color-mix(in srgb, var(--panel-strong) 92%, #020404);
  color: var(--text);
}

body[data-theme] select:disabled,
body[data-theme] input:disabled,
body[data-theme] button:disabled {
  opacity: .56;
  cursor: not-allowed;
}

body[data-theme] select:focus-visible,
body[data-theme] input:focus-visible,
body[data-theme] button:focus-visible,
body[data-theme] a.button-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body[data-theme] button:hover,
body[data-theme] a.button-link:hover {
  background-color: color-mix(in srgb, var(--accent) 22%, transparent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 20%, transparent);
}

body[data-theme] #map,
body[data-theme] #commandMap {
  filter: none !important;
}

body[data-theme] .leaflet-container,
body[data-theme] .leaflet-tile {
  background: #050b08 !important;
}

body[data-theme] .leaflet-tile {
  filter: var(--map-tile-filter, none) !important;
}

body[data-theme] .hud {
  background:
    linear-gradient(var(--hud-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--hud-grid) 1px, transparent 1px),
    radial-gradient(circle at center, transparent 35%, rgba(0, 0, 0, .34));
  background-size: 48px 48px, 48px 48px, auto;
}

body[data-theme="frontline-hud"] .brand img,
body[data-theme="frontline-hud"] .brand-mark,
body[data-theme="frontline-hud"] .radar-logo {
  filter: drop-shadow(0 0 13px rgba(53, 214, 255, .26));
}

body[data-theme="urban-ops"] .brand img,
body[data-theme="urban-ops"] .brand-mark,
body[data-theme="urban-ops"] .radar-logo {
  filter: drop-shadow(0 0 10px rgba(198, 161, 91, .16)) saturate(.9);
}

body.bve-login-page {
  position: relative;
  overflow: hidden;
}

body.bve-login-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: rgba(0, 0, 0, .16);
}

body.bve-login-page[data-theme="frontline-hud"],
html[data-theme="frontline-hud"] body.bve-login-page {
  background:
    radial-gradient(circle at 22% 18%, rgba(53, 214, 255, .18), transparent 28%),
    radial-gradient(circle at 86% 78%, rgba(255, 157, 59, .13), transparent 30%),
    linear-gradient(rgba(53, 214, 255, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(53, 214, 255, .045) 1px, transparent 1px),
    #07111b !important;
  background-size: auto, auto, 48px 48px, 48px 48px, auto !important;
}

body.bve-login-page[data-theme="urban-ops"],
html[data-theme="urban-ops"] body.bve-login-page {
  background:
    linear-gradient(135deg, rgba(255, 179, 71, .14), transparent 32%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, .028) 0 1px, transparent 1px 17px),
    #090807 !important;
}

body.bve-login-page .login-panel {
  position: relative;
  z-index: 1;
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel-strong) 86%, transparent);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .54), inset 0 1px 0 rgba(255, 255, 255, .055);
}

body.bve-login-page .login-logo {
  display: block;
  width: clamp(62px, 18vw, 92px);
  height: clamp(62px, 18vw, 92px);
  margin: 0 auto 12px;
  object-fit: contain;
  filter: drop-shadow(0 0 14px color-mix(in srgb, var(--accent) 24%, transparent));
}

.theme-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 8px;
}

.theme-preview-card {
  border: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, .22);
  padding: 8px;
}

.theme-preview-card strong {
  display: block;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: .08em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.theme-preview-card small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  line-height: 1.35;
  margin-top: 6px;
}

.theme-mini {
  border: 1px solid rgba(255, 255, 255, .10);
  display: grid;
  grid-template-columns: 1fr .65fr;
  gap: 5px;
  min-height: 74px;
  padding: 6px;
}

.theme-mini span {
  border: 1px solid rgba(255, 255, 255, .12);
  display: block;
}

.theme-mini span:first-child {
  grid-row: span 2;
}

.theme-mini.original {
  background: #030604;
}

.theme-mini.original span:first-child {
  background: linear-gradient(135deg, rgba(65, 255, 141, .12), rgba(5, 16, 10, .9));
}

.theme-mini.original span {
  border-color: rgba(65, 255, 141, .28);
  background: rgba(65, 255, 141, .09);
}

.theme-mini.frontline-hud {
  background: #07111b;
}

.theme-mini.frontline-hud span:first-child {
  background: linear-gradient(135deg, rgba(53, 214, 255, .18), rgba(9, 24, 38, .92));
}

.theme-mini.frontline-hud span {
  border-color: rgba(53, 214, 255, .32);
  background: rgba(53, 214, 255, .11);
}

.theme-mini.frontline-hud span:last-child {
  background: rgba(255, 157, 59, .16);
}

.theme-mini.urban-ops {
  background: #090807;
}

.theme-mini.urban-ops span:first-child {
  background: linear-gradient(135deg, rgba(198, 161, 91, .18), rgba(18, 18, 16, .94));
}

.theme-mini.urban-ops span {
  border-color: rgba(198, 161, 91, .30);
  background: rgba(198, 161, 91, .11);
}

.theme-mini.urban-ops span:last-child {
  background: rgba(255, 179, 71, .14);
}

#bve-admin-menu-root .bve-theme-select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-soft, rgba(65,255,141,.22));
  background: rgba(0, 0, 0, .28);
  color: var(--text, #dfffe8);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 9px;
  text-transform: uppercase;
}

@media (max-width: 860px) {
  .theme-preview-grid {
    grid-template-columns: 1fr;
  }
}
