body {
    margin: 0;
    color: #202124;
    background: #f7f8fa;
    font-family: "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
    color: #fff;
    background: #1f2937;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 800;
    letter-spacing: 0;
    text-decoration: none;
}

.site-brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: #fff;
    object-fit: contain;
}

.site-title {
    flex: 1;
}

.site-header h1 {
    margin: 0;
    font-size: 1.35rem;
}

.site-main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 20px;
    border-bottom: 1px solid #cbd5e1;
}

.main-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 6px 6px 0 0;
    color: #0f766e;
    font-weight: 600;
    text-decoration: none;
}

.main-nav a.active {
    color: #202124;
    background: #fff;
    border-color: #cbd5e1;
    border-bottom-color: #fff;
}

.admin-menu {
    position: relative;
}

.admin-menu summary {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px 6px 0 0;
    color: #202124;
    background: #e5e7eb;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.admin-menu summary::-webkit-details-marker {
    display: none;
}

.admin-menu div {
    position: absolute;
    right: 0;
    z-index: 5;
    min-width: 180px;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 16px 40px rgb(15 23 42 / 0.16);
}

.admin-menu a {
    display: flex;
    min-height: 0;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
}

.admin-menu a:hover {
    background: #edf2f7;
}

.signout-form {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.form-panel {
    display: grid;
    gap: 14px;
    max-width: 360px;
    margin-bottom: 24px;
}

.wide-form {
    max-width: 720px;
}

.wide-form h3 {
    margin: 14px 0 0;
}

.form-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

label {
    display: grid;
    gap: 6px;
    font-weight: 600;
}

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

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    max-width: 100%;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
}

button {
    width: fit-content;
    padding: 8px 12px;
    border: 0;
    border-radius: 6px;
    color: #fff;
    background: #0f766e;
    font-weight: 700;
    cursor: pointer;
}

button.secondary {
    color: #202124;
    background: #e5e7eb;
}

button.danger {
    color: #fff;
    background: #b91c1c;
}

.button-link {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 8px 12px;
    border-radius: 6px;
    color: #fff;
    background: #0f766e;
    font-weight: 700;
    text-decoration: none;
}

.button-link.secondary {
    color: #202124;
    background: #e5e7eb;
}

.error {
    color: #b91c1c;
    font-weight: 700;
}

.ok {
    color: #047857;
    font-weight: 700;
}

.warning {
    color: #92400e;
    font-weight: 700;
}

.danger {
    color: #b91c1c;
    font-weight: 700;
}

.danger-text {
    display: block;
    margin-bottom: 4px;
    color: #b91c1c;
    font-weight: 700;
}

.notice {
    font-weight: 600;
}

.flash-message {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid #99f6e4;
    border-radius: 8px;
    color: #064e3b;
    background: #ecfdf5;
    font-weight: 700;
}

.flash-message.error {
    border-color: #fecaca;
    color: #991b1b;
    background: #fef2f2;
}

.form-note {
    margin: 0;
    color: #4b5563;
    font-size: 0.95rem;
}

.admin-landing {
    display: grid;
    gap: 22px;
}

.telemetry-hero-panel,
.maintenance-summary,
.maintenance-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px;
    border: 1px solid #d6dde6;
    border-radius: 8px;
    background: #fff;
}

.telemetry-hero-panel {
    border-color: #99f6e4;
    background: #ecfdf5;
}

.telemetry-hero-panel h2,
.maintenance-summary h2,
.maintenance-intro h2 {
    margin: 0 0 6px;
}

.telemetry-hero-panel p,
.maintenance-summary p,
.maintenance-intro p {
    margin: 0;
    color: #4b5563;
    line-height: 1.45;
}

.telemetry-primary-action {
    flex: 0 0 auto;
}

.maintenance-summary {
    align-items: flex-start;
}

.maintenance-intro {
    display: block;
}

.admin-scope {
    margin: 0;
    color: #374151;
    font-weight: 600;
}

.stat-grid,
.admin-action-grid,
.telemetry-summary-grid {
    display: grid;
    gap: 12px;
}

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

.stat-tile {
    display: grid;
    gap: 4px;
    min-height: 88px;
    padding: 14px;
    border: 1px solid #d6dde6;
    border-radius: 8px;
    background: #fff;
}

.stat-tile strong {
    font-size: 1.8rem;
    line-height: 1;
}

.stat-tile span {
    color: #4b5563;
    font-weight: 600;
}

.health-tile.ok {
    border-color: #99f6e4;
}

.health-tile.warning {
    border-color: #fcd34d;
}

.health-tile.danger {
    border-color: #fecaca;
}

.admin-action-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

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

.telemetry-summary-tile {
    display: grid;
    gap: 8px;
    min-height: 116px;
    padding: 14px;
    border: 1px solid #d6dde6;
    border-left: 5px solid #0f766e;
    border-radius: 8px;
    color: #202124;
    background: #fff;
    text-decoration: none;
}

.telemetry-summary-tile.warning {
    border-left-color: #b45309;
}

.telemetry-summary-tile.danger {
    border-left-color: #b91c1c;
}

.telemetry-summary-tile strong {
    color: #202124;
    line-height: 1.25;
}

.telemetry-summary-tile span {
    color: #4b5563;
    font-size: 0.95rem;
    line-height: 1.4;
}

.telemetry-summary-tile:hover,
.telemetry-summary-tile:focus {
    border-color: #0f766e;
    border-left-color: #0f766e;
    outline: none;
}

.telemetry-summary-tile.warning:hover,
.telemetry-summary-tile.warning:focus {
    border-color: #b45309;
}

.telemetry-summary-tile.danger:hover,
.telemetry-summary-tile.danger:focus {
    border-color: #b91c1c;
}

.admin-action {
    display: grid;
    gap: 8px;
    min-height: 128px;
    padding: 16px;
    border: 1px solid #d6dde6;
    border-radius: 8px;
    color: #202124;
    background: #fff;
    text-decoration: none;
    box-shadow: 0 10px 24px rgb(15 23 42 / 0.05);
}

.admin-action:hover,
.admin-action:focus {
    border-color: #0f766e;
    outline: none;
}

.admin-action strong {
    color: #0f766e;
    font-size: 1.05rem;
}

.admin-action span {
    color: #4b5563;
    line-height: 1.4;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #cbd5e1;
    background: #fff;
}

.table-scroll .data-table {
    border: 0;
}

.table-scroll .data-table th:first-child,
.table-scroll .data-table td:first-child {
    border-left: 0;
}

.table-scroll .data-table th:last-child,
.table-scroll .data-table td:last-child {
    border-right: 0;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    text-align: left;
    vertical-align: top;
}

.data-table th {
    background: #e9eef3;
}

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #202124;
    font-weight: 700;
    text-decoration: none;
}

.sort-link:hover,
.sort-link:focus {
    color: #0f766e;
    text-decoration: underline;
}

.sort-arrows {
    display: inline-flex;
    gap: 1px;
    min-width: 1.4em;
    color: #9ca3af;
    font-size: 0.75em;
    line-height: 1;
}

.sort-arrow {
    color: #9ca3af;
}

.sort-arrow.active {
    color: #202124;
}

.sort-arrow.hidden {
    display: none;
}

.sticky-columns-table {
    --sticky-col-1-width: 220px;
    --sticky-col-2-width: 140px;
}

.sticky-col {
    min-width: var(--sticky-col-1-width);
}

.sticky-col-2 {
    min-width: var(--sticky-col-2-width);
}

.inactive-row {
    color: #6b7280;
    background: #f3f4f6;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.row-actions form {
    margin: 0;
}

.plain-list {
    display: grid;
    gap: 8px;
    margin: 0 0 10px;
    padding: 0;
    list-style: none;
}

.plain-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.inline-form.compact {
    gap: 6px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 7px;
    border-radius: 6px;
    background: #f3f4f6;
    font-size: 0.82rem;
}

.status-pill.warning {
    color: #92400e;
    background: #fef3c7;
}

.status-pill.danger {
    color: #991b1b;
    background: #fee2e2;
}

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

.alert-summary-tile {
    padding: 14px;
    border: 1px solid #cbd5e1;
    border-left: 5px solid #0f766e;
    background: #fff;
    border-radius: 8px;
}

.alert-summary-tile.danger {
    border-left-color: #b91c1c;
}

.alert-summary-tile strong {
    display: block;
    color: #202124;
    font-size: 1.6rem;
}

.alert-summary-tile span {
    color: #4b5563;
}

.alert-history-table {
    min-width: 1120px;
}

.alert-ongoing-row {
    background: #fef2f2;
}

.alert-ongoing-row td {
    border-color: #fecaca;
}

.alert-message-preview {
    max-width: 360px;
    white-space: normal;
}

.muted {
    color: #6b7280;
}

.rotate-secret-action {
    display: grid;
    gap: 4px;
}

.nodes-table {
    min-width: 1180px;
}

.telemetry-table {
    min-width: 980px;
}

.telemetry-detail-table {
    min-width: 820px;
}

.alert-outbox-table {
    min-width: 1120px;
}

.diagnostics-table {
    min-width: 980px;
}

.outbox-error {
    max-width: 360px;
    white-space: normal;
}

.measurement-danger {
    color: #b91c1c;
    font-weight: 800;
}

.telemetry-filter {
    align-items: center;
}

.trend-grid-layout {
    display: grid;
    gap: 16px;
    margin: 0 0 26px;
}

.trend-panel {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #d6dde6;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 24px rgb(15 23 42 / 0.06);
}

.trend-panel svg {
    width: 100%;
    min-width: 760px;
    height: auto;
    display: block;
}

.trend-svg {
    --trend-stroke: #0f766e;
    --trend-fill: #ccfbf1;
}

.trend-background {
    fill: #fff;
}

.trend-grid {
    stroke: #e5e7eb;
    stroke-width: 1;
}

.trend-axis {
    stroke: #64748b;
    stroke-width: 1.2;
}

.trend-axis-label,
.trend-time-label {
    fill: #475569;
    font-size: 12px;
}

.trend-title {
    fill: #202124;
    font-size: 15px;
    font-weight: 700;
}

.trend-time-label-end {
    text-anchor: end;
}

.trend-area {
    fill: var(--trend-fill);
    opacity: 0.42;
}

.trend-line {
    fill: none;
    stroke: var(--trend-stroke);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.trend-point {
    fill: #fff;
    stroke: var(--trend-stroke);
    stroke-width: 2.4;
    pointer-events: none;
}

.trend-hit {
    fill: transparent;
    cursor: crosshair;
}

.trend-hit:focus {
    outline: none;
}

.trend-hit:hover,
.trend-hit:focus {
    stroke: var(--trend-stroke);
    stroke-width: 1.5;
    opacity: 0.35;
}

.trend-tooltip {
    position: fixed;
    z-index: 20;
    max-width: min(320px, calc(100% - 32px));
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: #fff;
    background: #202124;
    font-size: 0.9rem;
    line-height: 1.35;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 120ms ease, transform 120ms ease;
}

.trend-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.nodes-table input[type="number"] {
    width: 7rem;
}

.nodes-table input[name="capabilities"] {
    width: 8rem;
}

.nodes-table .sticky-col-1 input {
    width: 100%;
}

.password-entry {
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: 100%;
}

.password-entry input {
    flex: 1 1 auto;
    min-width: 0;
}

.password-toggle {
    flex: 0 0 auto;
    width: auto;
    min-width: 4.25rem;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 0;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin: 0 0 16px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 18px 0 20px;
    border-bottom: 1px solid #cbd5e1;
}

.tabs a {
    padding: 10px 12px;
    color: #0f766e;
    border: 1px solid transparent;
    border-radius: 6px 6px 0 0;
    font-weight: 700;
    text-decoration: none;
}

.tabs a.active {
    color: #202124;
    background: #fff;
    border-color: #cbd5e1;
    border-bottom-color: #fff;
}

.compact-tabs {
    margin-top: 8px;
}

.settings-section {
    max-width: 820px;
}

.settings-group {
    display: grid;
    gap: 14px;
    margin: 0;
    padding: 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
}

.settings-group legend {
    padding: 0 6px;
    font-weight: 800;
}

.selector-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    margin: 0 0 18px;
}

.selector-form label {
    min-width: min(100%, 340px);
}

.modal {
    width: min(420px, calc(100vw - 48px));
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgb(15 23 42 / 0.22);
}

.danger-modal {
    width: min(560px, calc(100vw - 48px));
}

.modal::backdrop {
    background: rgb(15 23 42 / 0.45);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
    margin: 0;
    font-size: 1rem;
}

.modal-body {
    padding: 18px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}

@media (max-width: 760px) {
    .site-header {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 16px;
    }

    .site-main {
        padding: 16px;
    }

    .main-nav {
        gap: 6px;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0;
    }

    .signout-form {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .page-actions {
        justify-content: flex-start;
    }

    .form-panel {
        max-width: none;
    }

    .inline-form {
        align-items: stretch;
        flex-direction: column;
    }

    .inline-form input,
    .inline-form select,
    .inline-form textarea {
        width: 100%;
    }

    .modal {
        width: min(520px, calc(100vw - 24px));
        max-height: calc(100vh - 24px);
        overflow: auto;
    }

    .modal-header,
    .modal-body {
        padding: 14px;
    }

    .modal-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .modal-actions button,
    .page-actions button,
    .page-actions .button-link,
    .signout-form button,
    .inline-form button {
        width: 100%;
    }

    .data-table {
        min-width: 640px;
    }

    .stat-grid,
    .admin-action-grid,
    .maintenance-action-grid,
    .telemetry-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .telemetry-hero-panel,
    .maintenance-summary {
        align-items: stretch;
        flex-direction: column;
    }

    .admin-menu {
        flex: 0 0 auto;
    }

    .admin-menu div {
        left: auto;
        right: 0;
    }

    .data-table th,
    .data-table td {
        padding: 9px 10px;
    }
}

@media (min-width: 900px) {
    .sticky-columns-table .sticky-col {
        position: sticky;
        z-index: 2;
        background: #fff;
        box-shadow: 1px 0 0 #cbd5e1;
    }

    .sticky-columns-table th.sticky-col {
        z-index: 3;
        background: #e9eef3;
    }

    .sticky-columns-table .sticky-col-1 {
        left: 0;
        width: var(--sticky-col-1-width);
        min-width: var(--sticky-col-1-width);
    }

    .sticky-columns-table .sticky-col-2 {
        left: var(--sticky-col-1-width);
        width: var(--sticky-col-2-width);
        min-width: var(--sticky-col-2-width);
    }

    .sticky-columns-table .inactive-row .sticky-col {
        background: #f3f4f6;
    }
}

@media (max-width: 520px) {
    .site-header h1 {
        font-size: 1.15rem;
    }

    .main-nav a {
        display: inline-flex;
        padding: 4px 0;
    }

    button {
        width: 100%;
    }

    .password-entry {
        display: grid;
        grid-template-columns: 1fr;
    }

    .password-entry .password-toggle {
        justify-self: start;
        width: auto;
        min-width: 0;
        padding: 6px 10px;
        font-size: 0.9rem;
    }

    .stat-grid,
    .admin-action-grid,
    .maintenance-action-grid,
    .telemetry-summary-grid {
        grid-template-columns: 1fr;
    }
}
