:root {
    --bg: #f0f4f7;
    --panel: #ffffff;
    --ink: #1d2a35;
    --muted: #526474;
    --accent: #0f9d8a;
    --border: #d5e0e7;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
    color: var(--ink);
    background: linear-gradient(140deg, #ecf4f9 0%, #f5faf7 100%);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: #13384c;
    color: #f2fbff;
}

.topbar .brand { font-weight: 700; letter-spacing: 0.6px; }
.topbar .links a {
    color: #f2fbff;
    margin-left: 12px;
    text-decoration: none;
}

.content { padding: 20px; }

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

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

.field { margin-bottom: 10px; }
.field label {
    display: block;
    color: var(--muted);
    margin-bottom: 4px;
}
.field input,
.field select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
}

.field input.input-invalid,
.field select.input-invalid {
    border-color: #d03045;
    box-shadow: 0 0 0 1px rgba(208, 48, 69, 0.15);
}

.validation-hint {
    color: #b21f35;
    margin: 6px 0 0 0;
    font-size: 13px;
}

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

button {
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: 8px;
    padding: 9px 12px;
    cursor: pointer;
}

.metrics {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.metrics div {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
}
.metrics span { display: block; color: var(--muted); }

.history {
    max-height: 320px;
    overflow: auto;
    font-size: 12px;
}
.history-row {
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
}
.history-row pre {
    white-space: pre-wrap;
    margin: 6px 0 0 0;
}

.table {
    margin-top: 12px;
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: #fff;
}
.table th,
.table td {
    border: 1px solid var(--border);
    padding: 8px;
    text-align: left;
    font-size: 13px;
    vertical-align: top;
}

.table .col-select {
    width: 36px;
}

.table .col-name {
    width: 24%;
}

.table .col-endpoint {
    width: auto;
}

.table .col-actions {
    width: 120px;
    text-align: right;
    white-space: nowrap;
}

.table .endpoint-value {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.table .col-actions button {
    white-space: nowrap;
}

.run-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #9fd1c9;
    border-radius: 8px;
    background: #eefaf7;
}

.run-spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #9fd1c9;
    border-top-color: var(--accent);
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

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

.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dialog-panel {
    background: var(--panel);
    border-radius: 10px;
    padding: 20px;
    min-width: 600px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
}

.row-fail td { background: #fff5f5; }

.error-cell {
    color: #b21f35;
    font-size: 0.85em;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gauge-track {
    width: 100%;
    height: 18px;
    border-radius: 999px;
    background: #e8eff4;
    border: 1px solid var(--border);
    overflow: hidden;
    margin: 8px 0;
}

.gauge-fill {
    height: 100%;
    background: linear-gradient(90deg, #0f9d8a 0%, #2db39e 100%);
    transition: width 0.4s ease;
}

.gauge-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

.queue-visual {
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: 14px;
    align-items: center;
    margin-top: 8px;
}

.queue-ring {
    position: relative;
    width: 150px;
    height: 150px;
    display: grid;
    place-items: center;
}

.queue-ring-svg {
    width: 150px;
    height: 150px;
    position: absolute;
}

.queue-ring-track,
.queue-ring-progress {
    fill: none;
    stroke-width: 12;
}

.queue-ring-track {
    stroke: #e8eff4;
}

.queue-ring-progress {
    stroke: #0f9d8a;
    transform: rotate(-90deg);
    transform-origin: 70px 70px;
    transition: stroke-dashoffset 0.45s ease;
    stroke-linecap: round;
}

.queue-ring-center {
    position: relative;
    text-align: center;
    z-index: 1;
}

.queue-ring-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
}

.queue-ring-label {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.queue-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.queue-meta-row {
    display: flex;
    justify-content: space-between;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
}

.queue-trend {
    display: flex;
    justify-content: space-between;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid transparent;
}

.queue-trend.trend-up {
    background: #eefaf7;
    border-color: #b7e5db;
    color: #176f62;
}

.queue-trend.trend-down {
    background: #fff5f5;
    border-color: #f2c2c2;
    color: #9d1c2f;
}

.queue-trend.trend-flat {
    background: #f3f6f9;
    border-color: #dbe4ec;
    color: #526474;
}

@media (max-width: 640px) {
    .queue-visual {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .queue-meta {
        width: 100%;
    }
}
