:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --panel: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --line: #d7dde8;
    --accent: #2563eb;
    --good: #16a34a;
    --bad: #dc2626;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
    font: inherit;
}

button,
.button {
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    min-height: 40px;
    padding: 0 14px;
    text-decoration: none;
}

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

button.danger {
    background: var(--bad);
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 6px;
    min-height: 40px;
    padding: 0 10px;
}

textarea {
    line-height: 1.4;
    padding: 10px;
    resize: vertical;
}

.layout {
    margin: 0 auto;
    max-width: 1320px;
    padding: 24px;
}

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

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

h1 {
    font-size: 34px;
    margin-bottom: 4px;
}

.brand {
    align-items: center;
    color: var(--text);
    display: inline-flex;
    font-size: 34px;
    font-weight: 800;
    gap: 10px;
    margin-bottom: 4px;
    text-decoration: none;
}

.brand-mark {
    align-items: end;
    background: #0f172a;
    border-radius: 8px;
    display: inline-flex;
    height: 34px;
    justify-content: center;
    padding: 7px;
    position: relative;
    width: 34px;
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span {
    background: #ffffff;
    border-radius: 999px;
    content: "";
    display: block;
    width: 4px;
}

.brand-mark::before {
    height: 10px;
}

.brand-mark span {
    height: 16px;
    margin: 0 4px;
}

.brand-mark::after {
    background: #38bdf8;
    height: 20px;
}

h2 {
    font-size: 22px;
    margin-bottom: 8px;
}

h3 {
    font-size: 17px;
}

p,
small {
    color: var(--muted);
}

.add-form {
    display: grid;
    gap: 8px;
    grid-template-columns: 140px minmax(260px, 1fr) 120px 100px;
}

.grid {
    display: grid;
    gap: 20px;
    grid-template-columns: 320px minmax(0, 1fr);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.site-list {
    align-self: start;
}

.site-list-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.site-list-head h2 {
    margin-bottom: 0;
}

.icon-button {
    border-radius: 999px;
    font-size: 18px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    width: 28px;
}

.site-items {
    display: grid;
    gap: 2px;
    margin-top: 14px;
}

.site {
    align-items: center;
    border-radius: 6px;
    color: inherit;
    display: grid;
    gap: 10px;
    grid-template-columns: 16px 12px minmax(0, 1fr);
    padding: 10px;
    text-decoration: none;
}

.site.active,
.site:hover {
    background: #eef4ff;
}

.site.dragging {
    opacity: 0.45;
}

.site strong,
.site small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drag-handle {
    color: var(--muted);
    cursor: grab;
    font-weight: 700;
    line-height: 1;
}

.sort-error .site {
    outline: 1px solid var(--bad);
}

.status {
    border-radius: 999px;
    height: 10px;
    width: 10px;
}

.status.ok {
    background: var(--good);
}

.status.warning {
    background: #f59e0b;
}

.status.bad {
    background: var(--bad);
}

.status.disabled,
.status.unknown {
    background: #94a3b8;
}

.dashboard-head {
    align-items: start;
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

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

.edit-site {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 18px 0;
    padding: 18px;
}

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

.edit-form label,
.delete-form label {
    display: grid;
    gap: 6px;
}

.edit-form label span,
.delete-form label span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.edit-form .checkbox-line {
    align-items: center;
    display: flex;
    gap: 8px;
}

.edit-form .checkbox-line input {
    min-height: auto;
}

.edit-form .actions {
    grid-column: 1 / -1;
}

.delete-modal,
.form-modal {
    border: 0;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
    max-width: 460px;
    padding: 22px;
    width: calc(100% - 32px);
}

.delete-modal::backdrop,
.form-modal::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.delete-modal form,
.delete-modal .modal-content,
.form-modal form {
    display: grid;
    gap: 14px;
}

.delete-modal label,
.form-modal label {
    display: grid;
    gap: 6px;
}

.delete-modal label span,
.form-modal label span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

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

.metrics {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin: 18px 0;
}

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

.metrics span {
    color: var(--muted);
    display: block;
    font-size: 13px;
    margin-bottom: 8px;
}

.metrics strong {
    font-size: 24px;
}

.home-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.8fr);
    margin-top: 20px;
}

.step-breakdown {
    margin-top: 18px;
}

.site-summary-list {
    display: grid;
    gap: 6px;
}

.summary-row {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: inherit;
    display: grid;
    gap: 12px;
    grid-template-columns: 12px minmax(0, 1fr) auto auto;
    padding: 12px;
    text-decoration: none;
}

.summary-row:hover {
    background: #f8fbff;
}

.summary-row strong,
.summary-row small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.summary-state {
    color: var(--muted);
    font-weight: 700;
}

.graph-head {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin: 22px 0 10px;
}

.graph-head h3 {
    margin-bottom: 0;
}

.period-switch {
    align-items: center;
    display: inline-flex;
    gap: 6px;
}

.period-button {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    display: inline-flex;
    font-size: 13px;
    font-weight: 800;
    height: 30px;
    justify-content: center;
    min-width: 42px;
    padding: 0 10px;
    text-decoration: none;
}

.period-button:hover,
.period-button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

canvas {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: block;
    height: auto;
    max-width: 100%;
    width: 100%;
}

.details {
    display: grid;
    gap: 24px;
    margin-top: 20px;
}

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

table {
    border-collapse: collapse;
    font-size: 14px;
    min-width: 860px;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 9px 6px;
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-weight: 700;
}

.alert {
    border-left: 4px solid var(--bad);
    padding: 4px 0 8px 12px;
}

.alert-slow {
    border-left-color: #f59e0b;
}

.alert-down {
    border-left-color: var(--bad);
}

.alerts-list {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.alert span {
    color: var(--muted);
    display: block;
    font-size: 13px;
    margin: 3px 0;
}

.incidents-list {
    display: grid;
    gap: 12px;
}

.incident {
    border: 1px solid var(--line);
    border-left: 4px solid var(--bad);
    border-radius: 8px;
    display: grid;
    gap: 8px;
    padding: 12px;
}

.incident-slow {
    border-left-color: #f59e0b;
}

.incident-down {
    border-left-color: var(--bad);
}

.incident strong,
.incident span {
    display: block;
}

.incident span {
    color: var(--muted);
    font-size: 13px;
    margin-top: 3px;
}

.incident p {
    margin-bottom: 0;
}

.incident-open:not(.is-acknowledged) {
    background: #fffaf0;
}

.incident-open.incident-down:not(.is-acknowledged) {
    background: #fff5f5;
}

.incident.is-acknowledged {
    background: #f8fafc;
}

.incident-resolved,
.muted-list .incident {
    background: #f8fafc;
    opacity: 0.72;
}

.empty,
.welcome {
    color: var(--muted);
}

@media (max-width: 960px) {
    .topbar,
    .dashboard-head {
        align-items: stretch;
        flex-direction: column;
    }

    .add-form,
    .grid,
    .metrics,
    .edit-form,
    .home-grid {
        grid-template-columns: 1fr;
    }

    .summary-row {
        grid-template-columns: 12px minmax(0, 1fr);
    }

    .summary-state {
        grid-column: 2;
    }
}
