:root {
    /* Light mode — crisp, high-contrast, easy to read. */
    --bg: #eef2f7;
    --bg-2: #e7edf5;
    --bg-3: #eef2f7;

    --surface: #ffffff;
    --surface-strong: #ffffff;
    --surface-soft: #f4f7fb;

    --text: #15202e;
    --text-soft: #475467;
    --muted: #64748b;

    --line: #e3e8ef;
    --line-strong: #cdd6e2;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;

    --secondary: #eef2f8;
    --secondary-hover: #e1e8f2;

    --ghost: transparent;
    --ghost-hover: #eef2f8;

    --accent-cyan: #0e93b0;
    --accent-indigo: #4f5fd0;
    --accent-sky: #2f7df1;
    --accent-lavender: #7c6fd6;

    --success: #15803d;
    --warning: #b45309;
    --danger: #dc2626;
    --danger-strong: #dc2626;
    --danger-strong-hover: #b91c1c;

    --success-soft: rgba(21, 128, 61, 0.1);
    --warning-soft: rgba(180, 83, 9, 0.1);
    --danger-soft: rgba(220, 38, 38, 0.09);
    --primary-soft: rgba(37, 99, 235, 0.1);

    --shadow: 0 6px 22px rgba(15, 23, 42, 0.08);
    --blur: blur(14px);
    --radius: 16px;

    /* Status badge colours — dark ink on tinted background for light mode. */
    --status-queued: #475467;
    --status-queued-soft: rgba(100, 116, 139, 0.14);
    --status-running: #1d4ed8;
    --status-running-soft: rgba(37, 99, 235, 0.12);
    --status-cooldown: #7e22ce;
    --status-cooldown-soft: rgba(147, 51, 234, 0.12);
    --status-neutral: #64748b;
    --status-neutral-soft: rgba(100, 116, 139, 0.12);
}

body.theme-dark {
    /* Dark mode — calm slate, solid elevated panels, strong text contrast. */
    --bg: #0b1220;
    --bg-2: #0d1626;
    --bg-3: #0b1220;

    --surface: #141d2e;
    --surface-strong: #1a2438;
    --surface-soft: #101a2b;

    --text: #eef4fc;
    --text-soft: #b7c5d8;
    --muted: #8494a8;

    --line: rgba(148, 163, 184, 0.16);
    --line-strong: rgba(148, 163, 184, 0.3);

    --primary: #3b82f6;
    --primary-hover: #60a5fa;

    --secondary: #243044;
    --secondary-hover: #2d3b52;

    --ghost: transparent;
    --ghost-hover: #223047;

    --accent-cyan: #22b8cf;
    --accent-indigo: #8ba2ff;
    --accent-sky: #60a5fa;
    --accent-lavender: #a78bfa;

    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #fb7185;
    --danger-strong: #dc2626;
    --danger-strong-hover: #b91c1c;

    --success-soft: rgba(74, 222, 128, 0.14);
    --warning-soft: rgba(251, 191, 36, 0.15);
    --danger-soft: rgba(251, 113, 133, 0.14);
    --primary-soft: rgba(59, 130, 246, 0.18);

    --shadow: 0 16px 44px rgba(0, 0, 0, 0.42);

    /* Status badge colours — light ink on tinted background for dark mode. */
    --status-queued: #cbd5e1;
    --status-queued-soft: rgba(148, 163, 184, 0.20);
    --status-running: #93c5fd;
    --status-running-soft: rgba(59, 130, 246, 0.22);
    --status-cooldown: #d8b4fe;
    --status-cooldown-soft: rgba(168, 85, 247, 0.22);
    --status-neutral: #94a3b8;
    --status-neutral-soft: rgba(100, 116, 139, 0.18);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(1100px 460px at 50% -12%, rgba(47, 125, 241, 0.06), transparent 62%),
        linear-gradient(180deg, var(--bg), var(--bg-2));
    background-attachment: fixed;
}

a {
    color: inherit;
}

h1,
h2,
h3 {
    color: var(--text);
}

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

.card {
    background: linear-gradient(145deg, var(--surface), var(--surface-soft));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    margin-bottom: 16px;
}

.btn,
button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    border: 0;
    border-radius: 10px;
    padding: 11px 18px;
    /* Default = PRIMARY */
    background: var(--primary);
    color: #fff;
    border: 1px solid transparent;
    text-decoration: none;
    font-weight: 800;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.22);
    min-height: 42px;
    transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.btn:hover,
button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* SECONDARY — filled neutral surface with a clear border (medium emphasis). */
.btn.secondary,
button.secondary {
    background: var(--secondary);
    color: var(--text);
    border: 1px solid var(--line-strong);
    box-shadow: none;
}

.btn.secondary:hover,
button.secondary:hover {
    background: var(--secondary-hover);
    transform: translateY(-1px);
}

/* GHOST — transparent, outlined (lowest emphasis). */
.btn.ghost,
button.ghost {
    background: transparent;
    color: var(--text-soft);
    border: 1px solid var(--line-strong);
    box-shadow: none;
}

.btn.ghost:hover,
button.ghost:hover {
    background: var(--ghost-hover);
    color: var(--text);
}

/* DANGER — solid red, white text (destructive). */
.btn.danger,
button.danger {
    background: var(--danger-strong);
    color: #fff;
    border: 1px solid transparent;
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.22);
}

.btn.danger:hover,
button.danger:hover {
    background: var(--danger-strong-hover);
}

.btn.small {
    min-height: 34px;
    padding: 7px 12px;
    font-size: 13px;
    border-radius: 9px;
}

/* Named CTAs — treated as primary, aligned to the primary token. */
.btn.sos-new-task,
.btn.monitor-primary-btn,
.monitor-run-task {
    background: var(--primary);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.22);
}

.btn.sos-new-task:hover,
.btn.monitor-primary-btn:hover,
.monitor-run-task:hover {
    background: var(--primary-hover);
}

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

.sos-icon-btn,
.btn.sos-icon-btn,
button.sos-icon-btn {
    min-width: 36px;
    width: 36px;
    min-height: 34px;
    height: 34px;
    padding: 0;
    border-radius: 9px;
    font-size: 17px;
    line-height: 1;
}

.task-actions,
.checker-detail-actions,
.sos-history-actions,
.monitor-log-actions,
.monitor-row-actions,
.sos-detail-actions,
.indexation-toolbar-actions {
    align-items: center;
    gap: 8px;
}

.sos-task-log-link,
.monitor-text-link {
    color: var(--text);
    font-weight: 800;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

.sos-task-log-link:hover,
.monitor-text-link:hover {
    color: var(--primary-hover);
}

.flash {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    color: var(--text);
    box-shadow: var(--shadow);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.flash.warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.flash.error {
    background: var(--danger-soft);
    color: var(--danger);
}

label {
    display: block;
    font-weight: 800;
    margin-bottom: 7px;
    color: var(--text-soft);
}

input,
select,
textarea {
    width: 100%;
    padding: 13px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 15px;
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

select option {
    background: #ffffff;
    color: #1e2c3d;
}

body.theme-dark select option {
    background: #111d31;
    color: #eef6ff;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid var(--primary-soft);
    border-color: var(--primary);
}

textarea {
    min-height: 160px;
    resize: vertical;
    line-height: 1.6;
}

.field-block {
    margin-top: 16px;
}

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

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

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

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

th {
    color: var(--text-soft);
    background: var(--surface-soft);
    font-size: 13px;
}

td {
    color: var(--text);
    font-size: 14px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
    background: var(--primary-soft);
    color: var(--primary);
}

.status-pill,
.status-badge,
.simple-health-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-height: 28px;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
}

.badge.warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.badge.good {
    background: var(--success-soft);
    color: var(--success);
}

.badge.bad {
    background: var(--danger-soft);
    color: var(--danger);
}

/* Distinct colours for each ranking progress status. */
.badge.queued {
    background: var(--status-queued-soft);
    color: var(--status-queued);
}

.badge.running {
    background: var(--status-running-soft);
    color: var(--status-running);
}

.badge.cooldown {
    background: var(--status-cooldown-soft);
    color: var(--status-cooldown);
}

.badge.neutral {
    background: var(--status-neutral-soft);
    color: var(--status-neutral);
}

.logs {
    background: rgba(4, 12, 24, 0.82);
    color: #dbeafe;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    font-family: Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
    max-height: 300px;
    overflow: auto;
}

@media (max-width: 900px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}
/* Shared flag/search country selector used by checker forms. */
.sos-country-select {
    position: relative;
    min-width: 0;
}

.sos-country-trigger {
    display: inline-flex;
    width: 100%;
    min-height: 42px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--line-strong, var(--line));
    border-radius: 12px;
    padding: 10px 13px;
    background: var(--surface-soft);
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
    box-shadow: none;
}

.sos-country-display {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.sos-country-display img,
.sos-country-option img {
    width: 22px;
    height: 16px;
    flex: 0 0 auto;
    border-radius: 3px;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.sos-country-caret {
    flex: 0 0 auto;
    color: var(--text-soft, var(--muted));
    line-height: 1;
}

.sos-country-current {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sos-country-menu {
    position: absolute;
    z-index: 30;
    top: calc(100% + 8px);
    left: 0;
    width: min(360px, 92vw);
    border: 1px solid var(--line-strong, var(--line));
    border-radius: 12px;
    padding: 8px;
    background: var(--surface-strong);
    box-shadow: var(--shadow);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

body.theme-light .sos-country-trigger {
    background: rgba(255, 255, 255, 0.72);
    border-color: rgba(94, 121, 153, 0.26);
    color: #1e2c3d;
}

body.theme-light .sos-country-menu {
    background: rgba(248, 251, 255, 0.98);
    border-color: rgba(94, 121, 153, 0.24);
    box-shadow: 0 18px 42px rgba(48, 71, 100, 0.16);
}

.sos-country-menu input[type="search"] {
    width: 100%;
    min-height: 40px;
    margin-bottom: 8px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--text);
    border: 1px solid var(--line-strong);
}

body.theme-light .sos-country-menu input[type="search"] {
    background: #ffffff;
    border-color: rgba(94, 121, 153, 0.26);
    color: #1e2c3d;
}

.sos-country-options {
    display: grid;
    gap: 3px;
    max-height: 250px;
    overflow-y: auto;
}

.sos-country-option {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 34px;
    border: 0;
    border-radius: 7px;
    padding: 7px 8px;
    background: rgba(255, 255, 255, 0.26);
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
    text-align: left;
}

body.theme-light .sos-country-option {
    background: rgba(232, 239, 249, 0.82);
    color: #1e2c3d;
}

body.theme-light .sos-country-option:hover,
body.theme-light .sos-country-option:focus {
    background: rgba(47, 111, 237, 0.12);
}

.sos-country-option span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sos-country-option:hover,
.sos-country-option:focus {
    background: var(--primary-soft);
    outline: none;
}

.sos-country-option[hidden] {
    display: none !important;
}

body.theme-dark .sos-country-menu {
    background: rgba(7, 10, 18, 0.96);
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.42);
}

body.theme-dark .sos-country-menu input[type="search"] {
    background: rgba(10, 24, 42, 0.92);
}

body.theme-dark .sos-country-option {
    background: transparent;
}

body.theme-dark .sos-country-option:hover,
body.theme-dark .sos-country-option:focus {
    background: rgba(255, 255, 255, 0.12);
}
