@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500&display=swap");

:root {
  --bg: #12161c;
  --bg-2: #181e27;
  --panel: #1c2430;
  --panel-2: #232d3b;
  --line: #334155;
  --text: #eef3f8;
  --muted: #93a1b1;
  --accent: #f0a202;
  --accent-dim: #b77906;
  --accent-ink: #16120a;
  --danger: #dc2626;
  --ok: #16a34a;
  --nav-w: 240px;
  --rail-w: 320px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 480px at 0% 0%, rgba(240, 162, 2, 0.08), transparent 55%),
    radial-gradient(800px 500px at 100% 100%, rgba(56, 96, 140, 0.12), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent), #c2410c);
  display: grid;
  place-items: center;
  color: var(--accent-ink);
  font-weight: 700;
  margin-bottom: 16px;
}

.brand {
  margin: 0 0 6px;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sub {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.45;
}

label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: #0f141b;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  margin-bottom: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(240, 162, 2, 0.35);
  border-color: var(--accent-dim);
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}

.btn.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.btn:hover { filter: brightness(1.05); }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }

.error {
  color: #fecaca;
  background: rgba(220, 38, 38, 0.14);
  border: 1px solid rgba(220, 38, 38, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

.ok {
  color: #bbf7d0;
  background: rgba(22, 163, 74, 0.14);
  border: 1px solid rgba(22, 163, 74, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  min-height: 100vh;
}

.app-shell.with-rail {
  grid-template-columns: var(--nav-w) 1fr var(--rail-w);
}

.nav {
  background: linear-gradient(180deg, #161c25, #10141a);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.nav-brand strong {
  display: block;
  font-size: 0.98rem;
}

.nav-brand span {
  color: var(--muted);
  font-size: 0.78rem;
}

.nav-link {
  border: 0;
  text-align: left;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 11px 12px;
  font-weight: 550;
}

.nav-link.active,
.nav-link:hover {
  background: rgba(240, 162, 2, 0.12);
  color: var(--text);
}

.nav-spacer { flex: 1; }

.nav-user {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 8px;
}

.nav-user .name {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0 8px 2px;
}

.nav-user .meta {
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0 8px 10px;
}

.main {
  padding: 28px 32px 40px;
  min-width: 0;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}

.page-head h1 {
  margin: 0 0 4px;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.page-head p {
  margin: 0;
  color: var(--muted);
}

.page-meta {
  color: var(--muted);
  font-size: 0.85rem;
  padding-bottom: 4px;
}

.rail {
  background: linear-gradient(180deg, #161c25, #10141a);
  border-left: 1px solid var(--line);
  padding: 28px 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.main-map {
  padding: 0;
  position: relative;
  min-height: 100vh;
}

.map-page {
  position: relative;
  height: 100vh;
  width: 100%;
}

#fleet-map {
  height: 100%;
  width: 100%;
  background: #0d1218;
}

.map-legend {
  position: absolute;
  left: 14px;
  bottom: 18px;
  z-index: 500;
  display: flex;
  gap: 14px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(16, 20, 26, 0.88);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

.map-legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.map-legend .dot.online { background: #22c55e; }
.map-legend .dot.offline { background: #f59e0b; }

.map-pin-wrap {
  background: transparent;
  border: 0;
}

.map-pin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--pin, #22c55e);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.rail-map {
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
}

.map-rail {
  min-height: 0;
  height: calc(100vh - 36px);
}

.map-search {
  width: 100%;
  margin-bottom: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0d1218;
  color: var(--text);
  padding: 10px 12px;
}

.map-user-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  padding-right: 2px;
}

.map-user-item {
  text-align: left;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.map-user-item:hover:not(:disabled),
.map-user-item.selected {
  border-color: rgba(240, 162, 2, 0.45);
  background: rgba(240, 162, 2, 0.1);
}

.map-user-item:disabled {
  opacity: 0.55;
  cursor: default;
}

.map-user-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.map-user-meta {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 2px;
}

.map-user-status {
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.map-user-status.live { color: #34d399; }
.map-user-status.last { color: #fbbf24; }
.map-user-status.none { color: var(--muted); }


.rail-block {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 56px);
}

.rail-head {
  text-align: center;
  margin-bottom: 22px;
}

.rail-block h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.rail-block .hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.rail-form {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.rail-form .field {
  margin-bottom: 16px;
}

.rail-form .field-centered {
  text-align: center;
}

.rail-form .field-centered label {
  text-align: center;
}

.rail-form .field-centered input,
.rail-form .field-centered textarea {
  text-align: center;
}

.rail-form label {
  margin-bottom: 8px;
}

.rail-form input,
.rail-form select,
.rail-form textarea {
  margin-bottom: 0;
}

.rail-form textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  background: #0f141b;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  line-height: 1.45;
}

.rail-form textarea:focus {
  outline: 2px solid rgba(240, 162, 2, 0.35);
  border-color: var(--accent-dim);
}

.rail-form .field-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-family: var(--mono);
}

.rail-form .field-centered .field-meta {
  text-align: center;
}

.rail-submit {
  margin-top: 28px;
}

.rail-cancel {
  margin-top: 10px;
}

.channel-table {
  border-top: 1px solid var(--line);
  width: 100%;
}

.channel-table-head,
.channel-table-row {
  display: grid;
  grid-template-columns: 15% 62% 23%;
  column-gap: 0;
  align-items: center;
  width: 100%;
  padding: 9px 0;
  box-sizing: border-box;
}

.channel-table-head {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line);
  padding-top: 6px;
  padding-bottom: 6px;
}

.channel-table-head span:nth-child(1),
.channel-table-head span:nth-child(2) {
  text-align: left;
  padding-right: 12px;
}

.channel-table-head span:nth-child(3) {
  text-align: center;
}

.channel-table-row {
  border-bottom: 1px solid rgba(51, 65, 85, 0.55);
  min-height: 42px;
}

.channel-table-row:hover,
.channel-table-row.is-editing {
  background: rgba(255, 255, 255, 0.025);
}

.channel-name-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  width: 100%;
  text-align: left;
  padding-right: 12px;
}

.channel-name-cell .channel-num {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.channel-name-cell strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 650;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-desc-cell {
  color: var(--muted);
  font-size: 0.9rem;
  min-width: 0;
  width: 100%;
  text-align: left;
  padding-right: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.channel-actions .btn {
  width: 72px;
  padding: 7px 0;
  font-size: 0.78rem;
  text-align: center;
}

.user-table {
  border-top: 1px solid var(--line);
  width: 100%;
}

.user-table-head,
.user-table-row {
  display: grid;
  grid-template-columns: 18% 12% 35% 35%;
  align-items: center;
  width: 100%;
  padding: 9px 0;
  box-sizing: border-box;
}

.user-table-head {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line);
  padding-top: 6px;
  padding-bottom: 6px;
}

.user-table-head span:nth-child(1),
.user-table-head span:nth-child(2),
.user-table-head span:nth-child(3) {
  text-align: left;
  padding-right: 10px;
}

.user-table-head span:nth-child(4) {
  text-align: center;
}

.user-table-row {
  border-bottom: 1px solid rgba(51, 65, 85, 0.55);
  min-height: 44px;
}

.user-table-row:hover,
.user-table-row.is-editing {
  background: rgba(255, 255, 255, 0.025);
}

.user-name-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  text-align: left;
  padding-right: 10px;
}

.user-name-cell strong {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-name-cell .mono {
  font-size: 0.78rem;
}

.user-type-cell,
.user-channels-cell {
  text-align: left;
  font-size: 0.9rem;
  min-width: 0;
  padding-right: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}

.user-actions .btn {
  width: 72px;
  padding: 7px 0;
  font-size: 0.72rem;
  text-align: center;
}

.check-inline {
  display: flex !important;
  align-items: center;
  gap: 8px;
  color: var(--text) !important;
  margin: 0 !important;
}

.check-inline input {
  width: auto;
  margin: 0;
}

.modal-checks {
  max-height: 240px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(6, 10, 14, 0.62);
  display: grid;
  place-items: center;
  padding: 24px;
}

.members-modal {
  width: min(420px, 100%);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.members-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.members-modal-head h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.members-modal-head .hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.members-table {
  border-top: 1px solid var(--line);
}

.members-table-head,
.members-table-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.8fr;
  gap: 8px;
  align-items: center;
  padding: 7px 2px;
}

.members-table-head {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
}

.members-table-row {
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
  font-size: 0.86rem;
}

.members-table-row span {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.members-empty {
  padding: 18px 4px;
  font-size: 0.88rem;
}

.empty-state {
  padding: 48px 12px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  color: var(--text);
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.empty-state p {
  margin: 0;
  font-size: 0.92rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.card .k {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.card .v {
  font-size: 1.7rem;
  font-weight: 700;
  font-family: var(--mono);
}

.panel {
  background: color-mix(in srgb, var(--panel) 96%, black);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
}

.panel + .panel { margin-top: 16px; }

.panel h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.panel .hint {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: 0.9rem;
}

.split {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 16px;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.85);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #334155;
}

.pill.admin { background: #7c2d12; color: #ffedd5; }
.pill.radio { background: #14532d; color: #dcfce7; }
.pill.both { background: #1e3a8a; color: #dbeafe; }
.pill.off { background: #3f3f46; color: #d4d4d8; }

.checks {
  display: grid;
  gap: 8px;
  margin: 4px 0 14px;
  max-height: 180px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #121820;
}

.checks label {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  color: var(--text);
}

.role-picks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.role-pick {
  border: 1px solid var(--line);
  background: #121820;
  color: var(--muted);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
}

.role-pick.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(240, 162, 2, 0.12);
}

.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

.radio-layout { align-items: start; }

.channel-list {
  display: grid;
  gap: 8px;
}

.channel-item {
  display: grid;
  gap: 4px;
  text-align: left;
  width: 100%;
  border: 1px solid var(--line);
  background: #121820;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
}

.channel-item span {
  color: var(--muted);
  font-size: 0.85rem;
}

.channel-item.active,
.channel-item:hover {
  border-color: var(--accent);
  background: rgba(240, 162, 2, 0.1);
}

.radio-deck {
  min-height: 320px;
}

.radio-status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.radio-idle {
  margin-top: 24px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.85rem;
}

.talker-line {
  margin: 18px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: #121820;
  border: 1px solid var(--line);
  color: var(--muted);
}

.talker-line.hot {
  border-color: #b91c1c;
  background: rgba(185, 28, 28, 0.18);
  color: #fecaca;
}

.ptt-btn {
  width: 100%;
  min-height: 140px;
  border: 0;
  border-radius: 18px;
  background: #334155;
  color: white;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.ptt-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ptt-btn.tx,
.ptt-btn:not(:disabled):active {
  background: #b91c1c;
}

@media (max-width: 1100px) {
  .app-shell.with-rail {
    grid-template-columns: var(--nav-w) 1fr;
  }
  .rail {
    position: static;
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  .app-shell,
  .app-shell.with-rail { grid-template-columns: 1fr; }
  .nav {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .nav-brand { border: 0; margin: 0; padding: 0 8px 0 0; }
  .nav-spacer, .nav-user .meta { display: none; }
  .nav-user { border: 0; margin: 0; padding: 0; margin-left: auto; display: flex; gap: 8px; align-items: center; }
  .cards, .split, .role-picks { grid-template-columns: 1fr; }
  .channel-table-head,
  .channel-table-row {
    grid-template-columns: 15% 55% 30%;
    padding: 8px 0;
  }
  .channel-actions .btn { width: 64px; font-size: 0.72rem; }
  .user-table-head,
  .user-table-row {
    grid-template-columns: 20% 12% 28% 40%;
    padding: 8px 0;
  }
  .user-actions .btn { width: 64px; }
  .main { padding: 18px; }
}
