/* ═══════════════════════════════════════════════════════════
   PANELS.CSS — Panel chrome, analytics, chat, layers, forms
   ═══════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════
   PANEL BASE
   ═══════════════════════════════════════ */
body.theme-hud .panel {
  background: linear-gradient(180deg, var(--ui-surface), var(--ui-surface-2));
  border: 1px solid var(--ui-border);
  border-radius: var(--r-lg);
  box-shadow: var(--ui-shadow);
  backdrop-filter: var(--ui-blur);
  -webkit-backdrop-filter: var(--ui-blur);
  position: relative;
  overflow: hidden;
}

body.theme-hud .panel > * {
  position: relative;
  z-index: 1;
}

/* ── Head ── */
body.theme-hud .panel__head {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  min-height: 52px;
  padding: 10px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--ui-border) 80%, transparent);
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--ui-accent) 10%, transparent),
    transparent 72%
  );
}

body.theme-hud .panel__title {
  grid-column: 2;
  justify-self: center;
  margin: 0;
  font-family: var(--font-title);
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ui-accent) 88%, transparent);
  line-height: 1;
}

body.theme-hud .panel__titleText {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
}

body.theme-hud .panel__headRight {
  grid-column: 3;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* ── Body ── */
body.theme-hud .panel__body {
  padding: 14px;
}

/* ── Label ── */
body.theme-hud .panel__label {
  font-family: var(--font-title);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ui-accent) 88%, transparent);
}

/* ── Group ── */
body.theme-hud .panel__group {
  background: color-mix(in srgb, var(--ui-surface) 65%, transparent);
  border: 1px solid var(--ui-border);
  border-left: 2px solid color-mix(in srgb, var(--ui-accent) 85%, transparent);
  border-radius: var(--r-md);
  padding: 14px;
}

/* ── Chip group grid ── */
body.theme-hud #filters-panel .chip-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* ═══════════════════════════════════════
   ANALYTICS
   ═══════════════════════════════════════ */
body.theme-hud .analytics {
  display: grid;
  gap: 12px;
}

body.theme-hud .analytics__row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

body.theme-hud .analytics__row--full {
  grid-template-columns: 1fr;
}

body.theme-hud .analytics__metric {
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--ui-surface) 78%, transparent);
  border: 1px solid var(--ui-border);
  padding: 12px;
  display: grid;
  gap: 6px;
  color: var(--ui-text);
}

body.theme-hud .analytics__metric--alert {
  border-color: color-mix(in srgb, var(--c-amber) 25%, var(--ui-border));
  background: color-mix(in srgb, var(--c-amber) 8%, var(--ui-surface));
}

body.theme-hud .analytics__metric-label {
  font-family: var(--font-title);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ui-accent) 70%, var(--ui-text));
  opacity: .92;
}

body.theme-hud .analytics__metric-value {
  font-family: var(--font-mono);
  font-size: 22px;
  letter-spacing: .06em;
  color: var(--ui-text);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

body.theme-hud .analytics__metric-sub {
  font-size: 12px;
  color: var(--ui-text-dim);
}

/* ── Top categories ── */
body.theme-hud .analytics__top {
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--ui-surface) 78%, transparent);
  border: 1px solid var(--ui-border);
  padding: 12px;
}

body.theme-hud .analytics__top-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--ui-border) 75%, transparent);
  margin-bottom: 10px;
}

body.theme-hud .analytics__top-title {
  font-family: var(--font-title);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ui-accent) 78%, transparent);
}

body.theme-hud .analytics__top-sub {
  font-size: 12px;
  color: var(--ui-text-dim);
}

body.theme-hud .analytics__top-list {
  display: grid;
  gap: 8px;
}

/* ═══════════════════════════════════════
   CHAT
   ═══════════════════════════════════════ */

/* ── Collapsible details ── */
details.panel.is-collapsible {
  overflow: hidden;
}

details.panel.is-collapsible > summary.panel__head {
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

details.panel.is-collapsible > summary.panel__head::-webkit-details-marker {
  display: none;
}

details.panel.is-collapsible > summary.panel__head::after {
  content: "▾";
  opacity: .75;
  font-size: 14px;
  margin-left: 10px;
}

details.panel.is-collapsible[open] > summary.panel__head::after {
  content: "▴";
}

/* ── Chat body ── */
body.theme-hud #chat-panel .panel__body.chat {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

body.theme-hud #chat-panel .chat__messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--ui-surface) 70%, transparent);
  border: 1px solid color-mix(in srgb, var(--ui-border) 90%, transparent);
}

body.theme-hud #chat-panel .chat__controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--ui-surface) 78%, transparent);
  border: 1px solid var(--ui-border);
  backdrop-filter: var(--ui-blur);
  -webkit-backdrop-filter: var(--ui-blur);
}

body.theme-hud #chat-panel .chat__input {
  height: 38px;
  border-radius: var(--r-pill);
  padding: 0 12px;
  background: color-mix(in srgb, var(--ui-surface) 86%, transparent);
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
}

body.theme-hud #chat-panel .chat__input::placeholder {
  color: var(--ui-text-dim);
}

body.theme-hud #chat-panel .chat__input:focus {
  border-color: var(--ui-border-strong);
  box-shadow: var(--ui-focus);
}

body.theme-hud #chat-panel #chat-send-btn {
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r-pill);
}

/* ── Chat messages ── */
body.theme-hud .chatMsg {
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: color-mix(in srgb, var(--ui-surface) 78%, transparent);
  color: var(--ui-text);
  line-height: 1.35;
  word-break: break-word;
}

body.theme-hud .chatMsg--me {
  margin-left: auto;
  border-color: color-mix(in srgb, var(--ui-accent) 35%, var(--ui-border));
  background: color-mix(in srgb, var(--ui-accent) 10%, var(--ui-surface));
}

body.theme-hud .chatMsg__meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--ui-text-dim);
  letter-spacing: .04em;
}

/* ── Chat action buttons ── */
body.theme-hud .chat__btn-edit,
body.theme-hud .chat__btn-del {
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--ui-border);
  background: color-mix(in srgb, var(--ui-surface) 82%, transparent);
  color: var(--ui-text-2);
  font-family: var(--font-title);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform var(--dur-fast) ease, box-shadow var(--dur-normal) ease,
              background var(--dur-normal) ease, border-color var(--dur-normal) ease;
}

body.theme-hud .chat__btn-edit::before { content: "✎"; margin-right: 6px; }
body.theme-hud .chat__btn-del::before  { content: "×"; margin-right: 6px; font-size: 14px; }

body.theme-hud .chat__btn-edit:hover {
  border-color: color-mix(in srgb, var(--ui-accent) 45%, var(--ui-border));
  background: color-mix(in srgb, var(--ui-accent) 10%, var(--ui-surface));
}

body.theme-hud .chat__btn-del {
  border-color: color-mix(in srgb, var(--c-red) 22%, var(--ui-border));
}

body.theme-hud .chat__btn-del:hover {
  border-color: color-mix(in srgb, var(--c-red) 55%, var(--ui-border));
  background: color-mix(in srgb, var(--c-red) 10%, var(--ui-surface));
}

/* ═══════════════════════════════════════
   CATEGORY MULTISELECT
   ═══════════════════════════════════════ */

/* Allow overflow */
body.theme-hud section[aria-label="Управление"].panel,
body.theme-hud section[aria-label="Управление"] .panel__body {
  overflow: visible !important;
}

body.theme-hud section[aria-label="Управление"].panel {
  position: relative;
  z-index: 50;
}

body.theme-hud #category-filter {
  position: relative !important;
  display: block !important;
  width: 100% !important;
  overflow: visible !important;
}

body.theme-hud #category-filter[open] {
  z-index: 200;
}

/* ── Summary as select ── */
body.theme-hud details.msel > summary.select {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 0 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.theme-hud details.msel > summary.select::-webkit-details-marker {
  display: none;
}

/* Caret */
body.theme-hud details.msel > summary.select::after {
  content: "";
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-right: 2px solid color-mix(in srgb, var(--ui-text-2) 80%, transparent);
  border-bottom: 2px solid color-mix(in srgb, var(--ui-text-2) 80%, transparent);
  transform: rotate(45deg);
  transition: transform .16s ease;
}

body.theme-hud details.msel[open] > summary.select::after {
  transform: rotate(-135deg);
}

body.theme-hud details.msel[open] > summary.select {
  border-color: var(--ui-border-strong);
  box-shadow: var(--ui-focus);
}

/* ── Dropdown ── */
body.theme-hud #categoryFilterBox {
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  top: calc(100% + 8px) !important;
  z-index: 9999 !important;
  max-height: min(380px, 52vh);
  overflow: auto;
  margin: 0 !important;
  padding: 10px;
  border-radius: var(--r-lg);
  border: 1px solid var(--ui-border-strong);
  background: color-mix(in srgb, var(--ui-surface-solid) 92%, transparent);
  box-shadow: var(--ui-shadow);
  backdrop-filter: var(--ui-blur);
  -webkit-backdrop-filter: var(--ui-blur);
  transform-origin: top;
  animation: mselIn .14s ease-out;
}

body.theme-hud #category-filter:not([open]) > #categoryFilterBox {
  display: none !important;
}

@keyframes mselIn {
  from { opacity: 0; transform: translateY(-4px) scale(.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Items ── */
body.theme-hud .msel__list .msel__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  user-select: none;
  color: var(--ui-text-2);
  border: 1px solid transparent;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}

body.theme-hud .msel__list .msel__item + .msel__item {
  margin-top: 4px;
}

body.theme-hud .msel__list .msel__item:hover {
  background: color-mix(in srgb, var(--ui-accent) 10%, transparent);
  border-color: color-mix(in srgb, var(--ui-accent) 16%, transparent);
  color: var(--ui-text);
}

body.theme-hud .msel__list .msel__item:has(input:checked) {
  background: color-mix(in srgb, var(--ui-accent) 8%, transparent);
  border-color: color-mix(in srgb, var(--ui-accent) 18%, transparent);
}

body.theme-hud .msel__list .msel__item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  accent-color: var(--ui-accent);
}

/* ═══════════════════════════════════════
   PERSONAL LAYERS
   ═══════════════════════════════════════ */
body.theme-hud details#pl-panel.panel__group {
  padding: 14px;
}

body.theme-hud details#pl-panel > summary.panel__label {
  margin: 0;
  list-style: none;
  user-select: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

body.theme-hud details#pl-panel > summary.panel__label::-webkit-details-marker {
  display: none;
}

body.theme-hud details#pl-panel > summary.panel__label::after {
  content: "";
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-right: 2px solid color-mix(in srgb, var(--ui-text-2) 80%, transparent);
  border-bottom: 2px solid color-mix(in srgb, var(--ui-text-2) 80%, transparent);
  transform: rotate(45deg);
  transition: transform .16s ease;
}

body.theme-hud details#pl-panel[open] > summary.panel__label::after {
  transform: rotate(-135deg);
}

body.theme-hud #pl-hint {
  margin-top: 8px;
  color: var(--ui-text-dim);
  font-size: 12px;
  line-height: 1.35;
}

body.theme-hud #pl-hint b {
  color: var(--ui-text);
}

/* ── Layer rows ── */
body.theme-hud #pl-list .pl-row.hud-pill {
  background: color-mix(in srgb, var(--ui-surface) 78%, transparent) !important;
  border: 1px solid var(--ui-border) !important;
  border-radius: var(--r-md) !important;
  padding: 10px !important;
  gap: 12px !important;
  flex-wrap: wrap !important;
}

body.theme-hud #pl-list .pl-left {
  flex: 1 1 100% !important;
  min-width: 0 !important;
}

body.theme-hud #pl-list .pl-right {
  flex: 0 0 100% !important;
  justify-content: flex-end !important;
}

body.theme-hud #pl-list .pl-title {
  font-family: var(--font-title) !important;
  font-size: 11px !important;
  letter-spacing: .12em !important;
  text-transform: uppercase !important;
  color: var(--ui-text) !important;
}

body.theme-hud #pl-list .pl-iconbtn {
  width: 36px !important;
  height: 36px !important;
  border-radius: var(--r-pill) !important;
  background: color-mix(in srgb, var(--ui-surface) 82%, transparent) !important;
  border: 1px solid var(--ui-border) !important;
  color: var(--ui-text) !important;
}

body.theme-hud #pl-list .pl-iconbtn:hover {
  border-color: var(--ui-border-strong) !important;
  box-shadow: var(--ui-shadow-soft) !important;
}

/* ── Status chips ── */
body.theme-hud #pl-list .pl-status--processing {
  border-color: color-mix(in srgb, var(--c-amber) 35%, var(--ui-border));
  background: color-mix(in srgb, var(--c-amber) 10%, var(--ui-surface));
  color: color-mix(in srgb, var(--c-amber) 55%, var(--ui-text));
}

body.theme-hud #pl-list .pl-status--ready {
  border-color: color-mix(in srgb, var(--c-green) 35%, var(--ui-border));
  background: color-mix(in srgb, var(--c-green) 10%, var(--ui-surface));
  color: color-mix(in srgb, var(--c-green) 55%, var(--ui-text));
}

body.theme-hud #pl-list .pl-status--error {
  border-color: color-mix(in srgb, var(--c-red) 35%, var(--ui-border));
  background: color-mix(in srgb, var(--c-red) 10%, var(--ui-surface));
  color: color-mix(in srgb, var(--c-red) 55%, var(--ui-text));
}

/* ═══════════════════════════════════════
   ADD POINT FORM
   ═══════════════════════════════════════ */
body.theme-hud .panel--addPoint {
  max-width: 520px;
  position: relative;
  z-index: 2;
}

body.theme-hud .addPoint__body {
  display: grid;
  gap: 12px;
}

body.theme-hud .addPoint__coords {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
}

body.theme-hud .addPoint__coordsLabel {
  font-family: var(--font-title);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ui-accent) 70%, var(--ui-text));
}

body.theme-hud .addPoint__coordsValue {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--ui-text);
  white-space: nowrap;
}

body.theme-hud .addPoint__textarea {
  min-height: 86px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  resize: vertical;
}

body.theme-hud .addPoint__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Callsign mobile ── */
#hud-callsign-mobile { display: none !important; }