:root {
  color-scheme: light dark;
  --bg: light-dark(#f7f9fb, #151c24);
  --paper: light-dark(#fff, #1b2530);
  --bar: light-dark(#edf1f5, #202b37);
  --edge: light-dark(#ccd5de, #394b5c);
  --ink: light-dark(#192b3b, #e5edf6);
  --muted: light-dark(#506579, #aabacc);
  --blue: light-dark(#155a99, #9aceff);
  --title: light-dark(#164b7d, #193f64);
  --selection: light-dark(#dcecfb, #243f59);
  --green: light-dark(#087157, #68d4a7);
  --error: light-dark(#a02626, #ff9c9c);
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bar);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, summary { cursor: pointer; }
button {
  font: inherit;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 4px 10px;
  min-height: 30px;
}
button:hover:not(:disabled), summary:hover { background: var(--selection); }
button:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.cps { display: flex; flex-direction: column; height: 100dvh; background: var(--bg); }
.cps > :not(.workspace) { flex: none; }
.title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  min-height: 47px;
  padding: 8px 14px;
  background: var(--title);
  color: #fff;
}
.title img { filter: brightness(0) invert(1); }
.title h1 { font-size: 16px; font-weight: 650; }
.edition { border: 1px solid #ffffff66; border-radius: 3px; padding: 2px 6px; font-size: 11px; letter-spacing: .08em; }
.title-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.utility { font-size: 12px; }
.support-button { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 5px 12px; border: 1px solid #ffffff55; border-radius: 5px; background: #323842; color: #fff; font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.support-button:hover { background: #424955; }
.menu { display: flex; padding: 0 7px; background: var(--bar); border-bottom: 1px solid var(--edge); }
.menu details { position: relative; }
.menu summary { list-style: none; padding: 5px 11px; }
.menu summary::-webkit-details-marker { display: none; }
.menu details[open] summary { background: var(--selection); }
.menu-items {
  position: absolute;
  z-index: 1;
  min-width: 180px;
  padding: 4px;
  border: 1px solid var(--edge);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 0 5px 12px #0002;
}
.menu-items button { width: 100%; border: 0; text-align: left; }
.toolbar { display: flex; flex-wrap: wrap; align-items: stretch; gap: 4px; padding: 6px 9px; background: var(--paper); border-bottom: 1px solid var(--edge); }
.toolbar button { display: grid; justify-items: center; gap: 3px; min-width: 57px; border-color: transparent; padding: 3px 7px; font-size: 12px; }
.toolbar svg { width: 21px; height: 21px; fill: none; stroke: var(--green); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.divider { width: 1px; background: var(--edge); margin: 3px 4px; }
.connection { display: flex; align-items: center; gap: 6px; margin-left: auto; align-self: center; color: var(--muted); font-size: 12px; }
.led { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.led.online { background: var(--green); }
.path { display: flex; gap: 8px; flex-wrap: wrap; padding: 7px 13px; border-bottom: 1px solid var(--edge); background: var(--bar); color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.path b { color: var(--ink); }
.workspace { display: grid; grid-template-columns: clamp(185px, 23%, 270px) minmax(0, 1fr); flex: 1; min-height: 5rem; }
.workspace > * { overflow: auto; }
.sidebar { background: var(--paper); border-right: 1px solid var(--edge); }
.caption { margin: 0; padding: 6px 11px; border-bottom: 1px solid var(--edge); background: var(--bar); font-size: 12px; font-weight: 650; }
.tree { padding: 5px; }
.tree summary { padding: 4px 6px; font-size: 12px; color: var(--muted); font-weight: 650; }
.branch { padding-left: 12px; margin-left: 10px; border-left: 1px solid var(--edge); }
.branch button { border: 1px solid transparent; background: transparent; text-align: left; width: 100%; }
.branch button[aria-current="page"] { background: var(--selection); border-color: var(--edge); color: var(--blue); font-weight: 650; }
.heading { padding: 12px 14px 10px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.heading h2 { font-size: 18px; letter-spacing: -.015em; }
.sub { margin-top: 3px; font-size: 12px; color: var(--muted); }
.chip { border: 1px solid var(--edge); color: var(--blue); background: var(--selection); border-radius: 4px; padding: 2px 6px; font-size: 11px; white-space: nowrap; }
.content { display: grid; gap: 10px; padding: 0 14px 14px; }
.pane { min-width: 0; border: 1px solid var(--edge); border-radius: 4px; background: var(--paper); }
.pane > .caption { border-radius: 3px 3px 0 0; }
.properties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin: 0; padding: 10px 11px; font-size: 13px; }
.properties div { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(0, 1.3fr); gap: 7px; }
.properties .wide { grid-column: 1 / -1; grid-template-columns: minmax(100px, 1fr) minmax(0, 3.7fr); }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.pane-actions, .dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pane-actions { padding: 0 11px 10px; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
th, td { padding: 5px 9px; border-bottom: 1px solid var(--edge); }
th { background: var(--bg); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td button { border: 0; padding-left: 0; color: var(--blue); text-align: left; }
.guide { margin: 12px 10px; padding-left: 25px; }
.guide li + li { margin-top: 7px; }
#usage-dialog { width: min(calc(100% - 32px), 680px); max-height: calc(100dvh - 32px); overflow: auto; }
.information { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--edge); background: var(--paper); }
.information section + section { border-left: 1px solid var(--edge); }
.information p { min-height: 36px; padding: 7px 11px; font-size: 12px; overflow-wrap: anywhere; }
#validation.valid { color: var(--green); }
#error { color: var(--error); padding-top: 0; }
.progress-area { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border-top: 1px solid var(--edge); padding: 7px 11px; font-size: 12px; }
progress { width: min(180px, 100%); accent-color: var(--green); }
.status { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; border-top: 1px solid var(--edge); background: var(--bar); padding: 6px 11px; font-size: 11px; color: var(--muted); }
dialog { width: min(calc(100% - 32px), 440px); padding: 0; color: var(--ink); background: var(--paper); border: 1px solid var(--edge); border-radius: 6px; }
dialog::backdrop { background: #070f2070; }
dialog h2 { padding: 9px 13px; background: var(--title); color: #fff; font-size: 15px; }
.dialog-body { display: grid; gap: 14px; padding: 13px; }
.dialog-body p { overflow-wrap: anywhere; }
.dialog-actions { justify-content: flex-end; }
.primary { background: var(--title); color: #fff; border-color: var(--title); }
.primary:hover:not(:disabled) { background: light-dark(#216399, #285a86); }
@media (max-width: 780px) {
  .properties { grid-template-columns: 1fr; }
  .properties .wide { grid-template-columns: minmax(100px, 1fr) minmax(0, 1.3fr); }
}
@media (max-width: 530px) {
  .workspace { display: block; overflow: auto; }
  .workspace > * { overflow: visible; }
  .information { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--edge); }
  .information section + section { border-left: 0; border-top: 1px solid var(--edge); }
  .connection { margin-left: 4px; }
}
@media (pointer: coarse) {
  button, summary { min-height: 44px; }
}
#set-list td:last-child { font-variant-numeric: tabular-nums; }
#record-categories { padding-left: 9px; }
#talkgroup-system-filter { padding: 6px 11px; border-bottom: 1px solid var(--edge); }
#talkgroup-system-filter:not([hidden]) { display: flex; align-items: center; gap: 8px; }
.table-wrap { overflow-x: auto; }
#record-grid { width: max-content; min-width: 100%; user-select: none; }
#record-grid th, #record-grid td { min-width: 84px; white-space: pre; }
#record-grid td { border-right: 1px solid var(--edge); }
#record-grid td[aria-readonly="true"] { color: var(--muted); background: var(--bg); }
#record-grid td[aria-selected="true"] { background: var(--selection); }
#record-grid .append-row td { color: var(--blue); }
.record-actions { display: flex; gap: 6px; flex-wrap: wrap; }
#new-record-fields { display: grid; gap: 7px; }
#new-record-fields label { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px; align-items: center; }
#new-record-fields input, #new-record-fields select, #membership select, #iden-rows input, #talkgroup-system {
  min-width: 0;
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--edge);
  border-radius: 3px;
  padding: 4px 6px;
}
#talkgroup-system { width: auto; max-width: 75%; }
#new-record-error, #membership-error, #iden-error { color: var(--error); }
#iden-editor { width: min(calc(100% - 32px), 570px); }
.iden-table { overflow: auto; max-height: min(50dvh, 430px); }
.iden-table th { position: sticky; top: 0; }
.iden-table th, .iden-table td { padding: 4px; }
#membership { width: min(calc(100% - 32px), 615px); }
#membership-destination { display: grid; gap: 6px; }
#membership-count { color: var(--muted); }
.membership-lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.membership-lists > div { display: grid; gap: 6px; align-content: start; }
@media (max-width: 530px) {
  .membership-lists { grid-template-columns: 1fr; }
}
#record-grid td[tabindex="0"] { outline: 2px solid var(--blue); outline-offset: -2px; }
#record-grid td[aria-invalid="true"] {
  background: light-dark(#ffe1df, #552a2b);
  outline: 2px solid var(--error);
  outline-offset: -2px;
}
#record-grid .reference-picker {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  min-height: 0;
  padding: 0;
  margin-left: 7px;
  vertical-align: middle;
  color: var(--blue);
}
#record-grid .reference-picker::after {
  content: "";
  border: 4px solid transparent;
  border-top-color: currentColor;
  transform: translateY(2px);
}
#record-grid input, #record-grid select {
  width: 100%;
  min-width: 75px;
  border: 1px solid var(--blue);
  border-radius: 2px;
  padding: 1px 3px;
  color: var(--ink);
  background: var(--paper);
  font: inherit;
}

#usage-description { display: grid; gap: 12px; font-size: 13px; }
#usage-description h3 { font-size: 14px; }
#usage-description ul { margin: 0; padding-left: 20px; }
#usage-description li + li { margin-top: 10px; }
#usage-description a { color: var(--blue); text-underline-offset: 2px; }
