:root {
    --ink: #172027;
    --muted: #60707b;
    --line: #d9e0e4;
    --paper: #ffffff;
    --wash: #f3f6f7;
    --header: #18242b;
    --header-line: #33444d;
    --green: #18794e;
    --green-soft: #e8f5ed;
    --red: #b42318;
    --red-soft: #fcebea;
    --amber: #a15c00;
    --amber-soft: #fff2d8;
    --blue: #246b9c;
    --blue-soft: #e8f3fa;
    --purple: #6a4c93;
    --shadow: 0 8px 24px rgba(23, 32, 39, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--wash);
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--wash);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0;
}

a {
    color: #165f8e;
    text-underline-offset: 2px;
}

a:hover {
    color: #0f466a;
}

button,
input,
select,
textarea {
    font: inherit;
    letter-spacing: 0;
}

button,
.button {
    min-height: 42px;
}

.page-width {
    width: min(1180px, calc(100% - 32px));
    margin-inline: auto;
}

.site-header {
    position: relative;
    z-index: 1000;
    border-bottom: 1px solid var(--header-line);
    background: var(--header);
    color: #fff;
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(1180px, calc(100% - 32px));
    min-height: 72px;
    margin-inline: auto;
    gap: 28px;
}

.brand {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 14px;
    color: #fff;
    text-decoration: none;
}

.brand:hover {
    color: #fff;
}

.brand img {
    display: block;
    width: 126px;
    height: auto;
}

.brand span {
    border-left: 1px solid #53636b;
    padding-left: 14px;
    color: #cbd5da;
    font-size: 0.88rem;
    white-space: nowrap;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.site-nav a {
    border-radius: 4px;
    padding: 9px 11px;
    color: #dce4e8;
    font-size: 0.92rem;
    font-weight: 650;
    text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
    background: #2a3941;
    color: #fff;
}

.nav-toggle {
    display: none;
    width: 44px;
    min-height: 44px;
    border: 1px solid #52636c;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    margin: 4px auto;
    background: #fff;
}

.admin-banner {
    border-bottom: 1px solid #e9d29c;
    background: var(--amber-soft);
    color: #674000;
    font-size: 0.85rem;
    font-weight: 700;
}

.admin-banner .page-width {
    padding-block: 7px;
}

.page-heading {
    padding: 34px 0 24px;
}

.page-heading__row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--blue);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    margin-top: 0;
    line-height: 1.2;
    letter-spacing: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(2rem, 5vw, 3rem);
}

h2 {
    margin-bottom: 6px;
    font-size: 1.35rem;
}

h3 {
    font-size: 1.05rem;
}

.page-heading p,
.section-heading p {
    max-width: 760px;
    margin: 0;
    color: var(--muted);
}

.refresh-state {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

.refresh-state__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--green);
}

.refresh-state.is-error .refresh-state__dot {
    background: var(--red);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    padding-bottom: 30px;
}

.summary-item {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper);
    padding: 17px 18px;
    box-shadow: 0 3px 12px rgba(23, 32, 39, 0.04);
}

.summary-item span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.summary-item strong {
    display: block;
    margin-top: 2px;
    font-size: 1.8rem;
    line-height: 1.2;
}

.summary-item--link {
    display: block;
    color: var(--ink);
    text-decoration: none;
}

.summary-item--link:hover {
    border-color: #d5a09b;
    background: var(--red-soft);
    color: var(--ink);
}

.summary-item--link:focus-visible {
    border-color: var(--red);
    outline: 3px solid rgba(180, 35, 24, 0.18);
}

.summary-item--link small {
    display: block;
    margin-top: 6px;
    color: var(--red);
    font-size: 0.74rem;
    font-weight: 750;
}

.transmitting-panel {
    margin: -12px 0 30px;
    scroll-margin-top: 18px;
    border-block: 1px solid #e3b6b2;
    background: var(--red-soft);
    padding: 15px 18px 17px;
}

.transmitting-panel:target {
    border-color: var(--red);
}

.transmitting-panel--idle,
.transmitting-panel--idle:target {
    border-color: var(--line);
    background: var(--wash);
}

.transmitting-panel--idle .transmitting-panel__heading > span,
.transmitting-panel--idle .transmitting-list__empty {
    color: var(--muted);
}

.transmitting-panel--idle .transmitting-list__empty {
    border-top-color: var(--line);
}

.transmitting-panel__heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 10px;
}

.transmitting-panel__heading h2,
.transmitting-panel__heading p {
    margin-bottom: 0;
}

.transmitting-panel__heading > span {
    color: #7a2821;
    font-size: 0.8rem;
    font-weight: 800;
    white-space: nowrap;
}

.transmitting-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    margin: 0;
    border-top: 1px solid #e3b6b2;
    padding: 0;
    list-style: none;
}

.transmitting-list li {
    min-width: 0;
    border-bottom: 1px solid #e3b6b2;
}

.transmitting-list a {
    display: grid;
    grid-template-columns: 10px auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 10px 8px;
    color: var(--ink);
    text-decoration: none;
}

.transmitting-list a:hover,
.transmitting-list a:focus-visible {
    background: rgba(255, 255, 255, 0.58);
    color: var(--ink);
}

.transmitting-list__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}

.transmitting-list__station {
    overflow: hidden;
    color: #7a4540;
    font-size: 0.84rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.transmitting-list__empty {
    margin: 0;
    border-top: 1px solid #e3b6b2;
    padding: 11px 8px 0;
    color: #7a4540;
}

.info-band {
    border-block: 1px solid var(--line);
    background: #eaf0f2;
}

.info-band .page-width {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 24px;
    padding-block: 20px;
}

.info-band p {
    margin: 0;
}

.button,
button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #1d638f;
    border-radius: 4px;
    background: #246b9c;
    padding: 9px 15px;
    color: #fff;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
}

.button:hover,
button[type="submit"]:hover {
    background: #1c5a84;
    color: #fff;
}

.button--secondary {
    border-color: #aebbc2;
    background: #fff;
    color: var(--ink);
}

.button--secondary:hover {
    background: #eef2f4;
    color: var(--ink);
}

.button--danger {
    border-color: #a81d14;
    background: var(--red);
}

.node-lists {
    padding-block: 32px 48px;
}

.node-section + .node-section {
    margin-top: 34px;
}

.section-heading {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 12px;
}

.section-count {
    min-width: 36px;
    border-radius: 999px;
    background: #dfe8ec;
    padding: 5px 10px;
    color: #33434c;
    font-size: 0.82rem;
    font-weight: 800;
    text-align: center;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper);
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid #e7ecef;
    text-align: left;
    vertical-align: middle;
}

th {
    background: #eaf0f2;
    color: #41515a;
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover td {
    background: #f8fafb;
}

.node-state {
    display: inline-grid;
    grid-template-columns: 10px auto;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 8px;
    min-width: 110px;
}

.node-state__dot {
    grid-row: 1 / span 2;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--green);
}

.node-state strong {
    font-variant-numeric: tabular-nums;
}

.node-state span:last-child {
    color: var(--muted);
    font-size: 0.73rem;
}

.node-state--transmitting .node-state__dot {
    background: var(--red);
    box-shadow: 0 0 0 3px var(--red-soft);
}

.node-state--offline .node-state__dot {
    background: #84929a;
}

.empty-row td {
    padding: 22px;
    color: var(--muted);
    text-align: center;
}

.map-page {
    padding: 28px 0 44px;
}

.map-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 14px;
}

.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    color: var(--muted);
    font-size: 0.82rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--green);
}

.legend-dot--tx { background: var(--red); }
.legend-dot--restricted { background: var(--amber); }
.legend-dot--external { background: var(--blue); }
.legend-dot--offline { background: #7e8c94; }

#network-map {
    width: 100%;
    height: min(72vh, 820px);
    min-height: 520px;
    border: 1px solid #bfcbd1;
    border-radius: 6px;
    background: #dce5e9;
    box-shadow: var(--shadow);
}

.map-popup h3 {
    margin: 0 0 8px;
}

.map-popup p {
    margin: 4px 0;
}

.content-page {
    padding: 36px 0 56px;
}

.content-panel {
    max-width: 860px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper);
    padding: 26px;
    box-shadow: var(--shadow);
}

.notice {
    margin-bottom: 18px;
    border-left: 4px solid var(--blue);
    background: var(--blue-soft);
    padding: 12px 14px;
}

.notice--success {
    border-color: var(--green);
    background: var(--green-soft);
}

.notice--error {
    border-color: var(--red);
    background: var(--red-soft);
}

.find-results {
    margin-top: 24px;
}

.site-footer {
    border-top: 1px solid var(--header-line);
    background: var(--header);
    color: #cbd5da;
    font-size: 0.84rem;
}

.site-footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
    gap: 20px;
}

.site-footer a {
    color: #fff;
}

.admin-page {
    padding-top: 30px;
}

.admin-title-row {
    align-items: center;
    margin-bottom: 24px;
}

.admin-section + .admin-section {
    margin-top: 32px;
}

.admin-section small {
    display: block;
    color: var(--muted);
    font-size: 0.76rem;
}

.admin-filters {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto;
    align-items: end;
    gap: 12px;
    margin: 22px 0 30px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper);
    padding: 14px;
}

label {
    display: grid;
    gap: 6px;
    color: #41515a;
    font-size: 0.82rem;
    font-weight: 750;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid #aebbc2;
    border-radius: 4px;
    background: #fff;
    padding: 8px 10px;
    color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    outline: 3px solid rgba(36, 107, 156, 0.15);
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.filter-tabs a {
    border-radius: 4px;
    padding: 8px 10px;
    color: #45555e;
    font-size: 0.82rem;
    font-weight: 750;
    text-decoration: none;
}

.filter-tabs a:hover,
.filter-tabs a[aria-current="page"] {
    background: #dfe8ec;
    color: var(--ink);
}

.filter-tabs span {
    color: var(--muted);
}

.admin-table {
    min-width: 1040px;
    font-size: 0.88rem;
}

.admin-table td:nth-child(2) {
    min-width: 220px;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px 10px;
}

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

.icon-action,
.text-action {
    min-height: auto;
    border: 0;
    border-radius: 0;
    background: none;
    padding: 0;
    color: #165f8e;
    font-size: 0.78rem;
    font-weight: 750;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.text-action:hover,
.icon-action:hover {
    background: none;
    color: #0f466a;
}

.text-action--danger {
    color: var(--red);
}

.fault-label {
    display: inline-block;
    margin-top: 4px;
    border-radius: 3px;
    background: var(--red-soft);
    padding: 2px 5px;
    color: var(--red);
    font-size: 0.68rem;
    font-weight: 800;
}

.allocate-panel {
    position: relative;
}

.allocate-panel > summary {
    list-style: none;
}

.allocate-panel > summary::-webkit-details-marker {
    display: none;
}

.allocate-form {
    position: absolute;
    z-index: 900;
    top: calc(100% + 8px);
    right: 0;
    width: min(390px, calc(100vw - 24px));
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 18px;
    box-shadow: var(--shadow);
}

.allocate-form label + label,
.allocate-form label + p,
.allocate-form p + button {
    margin-top: 12px;
}

.allocate-form p {
    color: var(--muted);
    font-size: 0.78rem;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.check-label input {
    width: 18px;
    min-height: 18px;
    margin: 0;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.metric-grid > div {
    min-width: 0;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 13px 14px;
}

.metric-grid > div:nth-child(4n) {
    border-right: 0;
}

.metric-grid span,
.metric-grid strong {
    display: block;
    overflow-wrap: anywhere;
}

.metric-grid span {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
}

.metric-grid strong {
    margin-top: 3px;
    font-size: 0.88rem;
}

.form-section {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 22px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.span-2 {
    grid-column: span 2;
}

fieldset {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    align-items: end;
    gap: 12px;
    min-width: 0;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 12px;
}

legend {
    padding: 0 5px;
    font-weight: 800;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.danger-zone {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-top: 1px solid var(--line);
    padding-top: 22px;
}

.danger-zone h2,
.danger-zone p {
    margin-bottom: 4px;
}

@media (max-width: 860px) {
    .nav-toggle {
        display: block;
    }

    .site-nav {
        position: absolute;
        top: 72px;
        right: 16px;
        left: 16px;
        display: none;
        align-items: stretch;
        border: 1px solid #43545d;
        border-radius: 4px;
        background: var(--header);
        padding: 8px;
        box-shadow: var(--shadow);
        flex-direction: column;
    }

    .site-nav.is-open {
        display: flex;
    }

    .site-nav a {
        padding: 11px 12px;
    }

    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .page-heading__row,
    .map-toolbar {
        align-items: start;
        flex-direction: column;
    }

    .admin-filters {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-grid > div:nth-child(4n) {
        border-right: 1px solid var(--line);
    }

    .metric-grid > div:nth-child(2n) {
        border-right: 0;
    }
}

@media (max-width: 640px) {
    .page-width,
    .site-header__inner {
        width: min(100% - 22px, 1180px);
    }

    .brand img {
        width: 108px;
    }

    .brand span {
        display: none;
    }

    .page-heading {
        padding-top: 26px;
    }

    h1 {
        font-size: 2rem;
    }

    .summary-grid {
        gap: 8px;
    }

    .summary-item {
        padding: 13px 14px;
    }

    .summary-item strong {
        font-size: 1.5rem;
    }

    .transmitting-panel {
        margin-top: -14px;
        padding-inline: 14px;
    }

    .transmitting-list {
        grid-template-columns: 1fr;
    }

    .transmitting-list a {
        grid-template-columns: 10px auto;
    }

    .transmitting-list__station {
        grid-column: 2;
        white-space: normal;
    }

    .info-band .page-width {
        grid-template-columns: 1fr;
    }

    .node-table thead {
        display: none;
    }

    .node-table,
    .node-table tbody,
    .node-table tr,
    .node-table td {
        display: block;
        width: 100%;
    }

    .node-table tr {
        padding: 10px 12px;
        border-bottom: 1px solid var(--line);
    }

    .node-table tr:last-child {
        border-bottom: 0;
    }

    .node-table td {
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 10px;
        padding: 5px 0;
        border: 0;
        overflow-wrap: anywhere;
    }

    .node-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.72rem;
        font-weight: 800;
        text-transform: uppercase;
    }

    .node-table td:first-child::before {
        align-self: center;
    }

    .admin-table {
        min-width: 0;
    }

    .admin-table thead {
        display: none;
    }

    .admin-table,
    .admin-table tbody,
    .admin-table tr,
    .admin-table td {
        display: block;
        width: 100%;
    }

    .admin-table tr {
        padding: 12px;
        border-bottom: 1px solid var(--line);
    }

    .admin-table tr:last-child {
        border-bottom: 0;
    }

    .admin-table td,
    .admin-table td:nth-child(2) {
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 10px;
        min-width: 0;
        padding: 6px 0;
        border: 0;
        overflow-wrap: anywhere;
    }

    .admin-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.7rem;
        font-weight: 800;
        text-transform: uppercase;
    }

    .admin-table .action-row {
        align-items: start;
    }

    .empty-row td {
        display: block;
        text-align: center;
    }

    .empty-row td::before {
        content: none;
    }

    #network-map {
        height: 68vh;
        min-height: 440px;
    }

    .content-panel {
        padding: 20px 16px;
    }

    .admin-title-row,
    .danger-zone {
        align-items: stretch;
        flex-direction: column;
    }

    .allocate-panel,
    .allocate-panel > summary {
        width: 100%;
    }

    .allocate-form {
        position: static;
        width: 100%;
        margin-top: 8px;
    }

    .form-section {
        padding: 18px 14px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }

    fieldset {
        grid-template-columns: 1fr;
    }

    .site-footer__inner {
        align-items: start;
        justify-content: center;
        padding-block: 18px;
        flex-direction: column;
    }
}
