:root {
  font-family: system-ui, sans-serif;
  color: #e8edf2;
  background: #111820;
}

body { margin: 0; }

main {
  max-width: 1100px;
  margin: auto;
  padding: 18px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid #34404c;
}

h1 { margin-bottom: 0; }

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar-item,
.toolbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  box-sizing: border-box;
  border: 1px solid #344b60;
  border-radius: 8px;
  background: #1a2834;
  color: #e8edf2;
  line-height: 1;
}

.toolbar-item { padding: 0 12px; }

.toolbar-button {
  min-width: 42px;
  padding: 0 12px;
  margin: 0;
  font-weight: 650;
  text-decoration: none;
}

.toolbar-button:hover {
  border-color: #5f7d98;
  background: #223647;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 1.25rem;
}

.signed-user {
  border-color: transparent;
  background: transparent;
  color: #b9c7d3;
}

.logout-form {
  display: inline-flex;
  margin: 0;
}

.badge,
.notice,
.call {
  border: 1px solid #34404c;
  border-radius: 8px;
  background: #19232d;
}

.badge { padding: 0 12px; }

.notice {
  padding: 10px;
  margin: 14px 0;
  color: #c8d2dc;
}

.ok { color: #76db9b; }
.bad { color: #ff8b8b; }
.status-line { display: inline-block; }

.calls {
  display: grid;
  gap: 5px;
}

.call { padding: 7px 10px; }

.call-row {
  display: grid;
  grid-template-columns: 75px minmax(130px, 1.2fr) 75px 110px 60px minmax(140px, 1fr);
  gap: 10px;
  align-items: center;
  font-size: .92rem;
}

.call-row time {
  font-variant-numeric: tabular-nums;
  color: #b9c7d3;
}

.lrrp-row {
  display: grid;
  grid-template-columns: 180px 160px 1fr 180px;
  gap: 10px;
  font-size: .9rem;
}

.lrrp-row a { color: #87c7ff; }

.channel {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.muted { color: #9aa9b7; }
.inferred { color: #ffd37a; }

details {
  margin-top: 4px;
  border-top: 1px solid #2c3945;
  padding-top: 3px;
}

summary {
  cursor: pointer;
  color: #9fb0bf;
  font-size: .82rem;
}

.edit-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
}

button {
  background: #263849;
  color: white;
  border: 1px solid #4b647b;
  border-radius: 6px;
  padding: 5px 8px;
  margin: 6px 5px 0 0;
}

.header-actions .toolbar-button {
  min-height: 38px;
  min-width: 42px;
  padding: 0 12px;
  margin: 0;
  border-color: #344b60;
  border-radius: 8px;
  background: #1a2834;
  font-weight: 650;
}

.header-actions .toolbar-button:hover {
  border-color: #5f7d98;
  background: #223647;
}

.header-actions .icon-button {
  width: 42px;
  padding: 0;
}

.danger {
  border-color: #884b51;
  color: #ffb5b5;
}

textarea,
input,
select {
  width: 100%;
  box-sizing: border-box;
  background: #111820;
  color: white;
  border: 1px solid #4b647b;
  border-radius: 4px;
  padding: 5px;
}

textarea {
  height: 34px;
  resize: vertical;
}

label {
  display: block;
  margin-top: 6px;
  font-size: .85rem;
}

dialog {
  width: min(960px, 92vw);
  max-height: 86vh;
  overflow: auto;
  color: #e8edf2;
  background: #111820;
  border: 1px solid #4b647b;
  border-radius: 10px;
  padding: 16px;
}

dialog::backdrop { background: #000a; }

.dialog-head,
.station-head,
.add-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dialog-head { justify-content: space-between; }
.dialog-head h2 { margin: 0; }

.service-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.service-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid #34404c;
  border-radius: 8px;
  background: #19232d;
  padding: 10px;
}

.service-item span { color: #b9c7d3; }

.service-meter {
  grid-column: 1 / -1;
  align-items: flex-start;
}

.service-meter > div { flex: 1; }

.service-meter meter {
  display: block;
  width: 100%;
  height: 18px;
  margin-bottom: 6px;
}

.receiver-controls {
  display: grid;
  grid-template-columns: repeat(4, max-content) minmax(220px, 1fr) max-content;
  gap: 8px;
  align-items: end;
  margin: 12px 0;
}

.receiver-controls button {
  min-height: 38px;
  margin: 0;
}

.receiver-controls label {
  margin-top: 0;
}

.receiver-map {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.receiver-zone {
  border: 1px solid #34404c;
  border-radius: 8px;
  background: #19232d;
  padding: 10px;
}

.receiver-zone h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.receiver-channel {
  display: grid;
  gap: 2px;
  padding: 5px 0;
  border-top: 1px solid #2c3945;
}

.receiver-channel small {
  color: #9aa9b7;
}

.station-card {
  border: 1px solid #34404c;
  border-radius: 8px;
  padding: 10px;
  margin: 10px 0;
  background: #19232d;
}

.station-head input { font-weight: 700; }

.members {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.member-row {
  display: grid;
  grid-template-columns: 100px 1fr 140px 70px minmax(180px, 1fr) 130px 70px 75px;
  gap: 6px;
  align-items: center;
}

.member-row small {
  color: #9aa9b7;
}

.add-member { margin-top: 8px; }
.add-row input { flex: 1; }

@media(max-width: 760px) {
  main { padding: 10px; }

  header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  header h1 {
    font-size: 1.55rem;
    margin-top: 10px;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .toolbar-item,
  .toolbar-button {
    min-height: 44px;
  }

  .signed-user {
    order: 5;
    flex-basis: 100%;
    justify-content: flex-start;
    min-height: auto;
    padding: 2px 0;
  }

  .badge,
  .notice {
    font-size: .85rem;
  }

  .notice {
    line-height: 1.35;
    margin: 10px 0;
  }

  h2 {
    font-size: 1.2rem;
    margin: 16px 0 8px;
  }

  .call { padding: 7px 8px; }

  .call-row {
    grid-template-columns: 64px minmax(0, 1fr) 64px;
    grid-template-areas:
      "time identity duration"
      "tg calltype duration";
    gap: 3px 8px;
    font-size: .86rem;
  }

  .call-row time { grid-area: time; }

  .identity {
    grid-area: identity;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tg { grid-area: tg; }
  .call-type { grid-area: calltype; }

  .duration {
    grid-area: duration;
    text-align: right;
  }

  .channel { display: none; }

  summary {
    min-height: 34px;
    display: flex;
    align-items: center;
  }

  .lrrp-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .edit-grid,
  .service-grid,
  .receiver-controls {
    grid-template-columns: 1fr;
  }

  .service-item { min-height: 44px; }

  .detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .detail-actions button {
    width: 100%;
    margin: 5px 0;
    min-height: 44px;
  }

  button,
  select,
  input {
    min-height: 44px;
    font-size: 16px;
  }

  textarea {
    min-height: 64px;
    font-size: 16px;
  }

  dialog {
    box-sizing: border-box;
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    margin: 0;
    padding: 12px;
  }

  .dialog-head {
    position: sticky;
    top: -12px;
    background: #111820;
    padding: 10px 0;
    z-index: 2;
  }

  .dialog-head button,
  .icon-button {
    width: 44px;
    min-width: 44px;
  }

  .add-row,
  .station-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .station-head button,
  .add-row button {
    width: 100%;
    margin: 0;
  }

  .member-row {
    grid-template-columns: 1fr;
    border-top: 1px solid #34404c;
    padding-top: 8px;
    margin-top: 6px;
  }

  .member-row button {
    width: 100%;
    margin: 0;
  }

  .add-member span { display: none; }
}
