:root {
    color-scheme: light;
    --bg: #f5f7f9;
    --surface: #ffffff;
    --line: #d9e1e8;
    --text: #14212b;
    --muted: #657484;
    --primary: #0b6b72;
    --primary-dark: #074f55;
    --danger-bg: #fff1f0;
    --danger-text: #9f2a1f;
    --shadow: 0 16px 40px rgba(20, 33, 43, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: inherit;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(100%, 440px);
}

.login-panel,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-panel {
    padding: 32px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 24px;
    font-size: clamp(1.7rem, 5vw, 2.2rem);
    line-height: 1.1;
}

h2 {
    margin-bottom: 16px;
    font-size: 1.15rem;
}

.form-stack {
    display: grid;
    gap: 12px;
}

label {
    font-weight: 650;
}

input {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    font: inherit;
}

textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    font: inherit;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(11, 107, 114, 0.16);
}

button {
    min-height: 44px;
    border: 0;
    border-radius: 6px;
    background: var(--primary);
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 10px 16px;
}

button:hover,
button:focus {
    background: var(--primary-dark);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.secondary-button {
    background: #e7edf2;
    color: var(--text);
}

.secondary-button:hover,
.secondary-button:focus {
    background: #d8e2ea;
}

.alert {
    border-radius: 6px;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.alert-success {
    background: #ecf8ef;
    color: #236b35;
}

.alert p {
    margin-bottom: 0;
}

.admin-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.admin-sidebar {
    background: #102b33;
    color: #ffffff;
    padding: 22px;
}

.brand {
    align-items: center;
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
}

.brand span {
    color: #b7c8ce;
    display: block;
}

.brand-mark {
    align-items: center;
    background: #d8f06f;
    border-radius: 8px;
    color: #102b33 !important;
    display: inline-flex !important;
    font-size: 0.85rem;
    font-weight: 800;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.admin-menu {
    display: grid;
    gap: 8px;
}

.admin-menu a {
    border-radius: 6px;
    color: #d9e6ea;
    padding: 10px 12px;
    text-decoration: none;
}

.admin-menu a.active,
.admin-menu a:hover,
.admin-menu a:focus {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.admin-main {
    padding: 28px;
}

.admin-topbar {
    align-items: center;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 24px;
}

.admin-topbar h1 {
    margin-bottom: 0;
}

.panel {
    margin-bottom: 18px;
    padding: 22px;
}

.panel p {
    color: var(--muted);
    margin-bottom: 0;
}

.panel-heading {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 16px;
}

.panel-heading h2 {
    margin-bottom: 0;
}

.muted {
    color: var(--muted);
}

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

.form-grid label:not(.checkbox-row) {
    padding-top: 10px;
}

.checkbox-row {
    align-items: center;
    display: flex;
    gap: 10px;
    grid-column: 2;
}

.checkbox-row input,
.parameter-row input {
    min-height: auto;
    width: auto;
}

.form-actions {
    grid-column: 2;
    margin-top: 4px;
}

.inline-form {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: 110px minmax(220px, 420px) auto;
}

.table-wrap {
    overflow-x: auto;
}

table {
    border-collapse: collapse;
    min-width: 820px;
    width: 100%;
}

.wide-table {
    min-width: 1320px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
}

.actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.actions form {
    margin: 0;
}

.text-link {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.text-link:hover,
.text-link:focus {
    text-decoration: underline;
}

.small-button {
    min-height: 34px;
    padding: 6px 10px;
}

.button-link {
    align-items: center;
    border-radius: 6px;
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    text-decoration: none;
}

.button-link:not(.secondary-button) {
    background: var(--primary);
    color: #ffffff;
}

.button-link:not(.secondary-button):hover,
.button-link:not(.secondary-button):focus {
    background: var(--primary-dark);
}

.checksum-cell {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

.status-pill {
    border-radius: 999px;
    display: inline-flex;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 4px 10px;
}

.status-on {
    background: #ecf8ef;
    color: #236b35;
}

.status-off {
    background: #eef2f5;
    color: #596977;
}

.parameter-list {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    overflow: hidden;
}

.parameter-row {
    align-items: center;
    display: flex;
    gap: 12px;
    padding: 13px 14px;
}

.parameter-row + .parameter-row {
    border-top: 1px solid var(--line);
}

.parameter-row small {
    color: var(--muted);
    display: block;
}

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

.details-grid div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.details-grid dt {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.details-grid dd {
    margin: 0;
    overflow-wrap: anywhere;
}

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

.metric-grid div {
    background: #f8fafb;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.metric-grid dt {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.metric-grid dd {
    font-size: 1.45rem;
    font-weight: 800;
    margin: 0;
    overflow-wrap: anywhere;
}

.pagination {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 16px;
}

.pagination a {
    align-items: center;
    display: inline-flex;
    text-decoration: none;
}

.manual-poll-form {
    margin-top: 18px;
}

.raw-preview {
    background: #101820;
    border-radius: 8px;
    color: #e7eef4;
    font-size: 0.86rem;
    line-height: 1.45;
    margin: 0;
    max-height: 520px;
    overflow: auto;
    padding: 16px;
    white-space: pre-wrap;
    word-break: break-word;
}

@media (max-width: 760px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        padding: 16px;
    }

    .admin-main {
        padding: 18px;
    }

    .admin-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

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

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

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

    .checkbox-row,
    .form-actions {
        grid-column: 1;
    }

    .form-grid label:not(.checkbox-row) {
        padding-top: 0;
    }
}
