/* ============================================================
   alert-combiner — UI theme
   ============================================================ */
:root {
    --bg: #0b0f14;
    --bg-grad: radial-gradient(1200px 600px at 80% -10%, #16202e 0%, transparent 60%),
               radial-gradient(900px 500px at -10% 10%, #122019 0%, transparent 55%);
    --panel: #121821;
    --panel-2: #1a2230;
    --border: #243044;
    --border-soft: #1c2533;
    --text: #e6edf3;
    --muted: #8b97a7;
    --accent: #3b82f6;
    --accent-2: #22d3ee;
    --green: #22c55e;
    --red: #ef4444;
    --amber: #f59e0b;
    --radius: 12px;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { background-color: var(--bg); }

body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    /* NOTE: keep these as separate properties. In the `background` shorthand a
       background-color is only valid on the LAST layer, so combining the color
       with the multi-layer gradient there makes the whole declaration invalid
       (the page then renders white). */
    background-color: var(--bg);
    background-image: var(--bg-grad);
    background-attachment: fixed;
    background-repeat: no-repeat;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h2 { font-size: 22px; font-weight: 650; letter-spacing: 0.2px; margin: 4px 0 18px; }
h3 { font-size: 15px; font-weight: 600; color: var(--text); margin: 22px 0 10px; }
h4 { font-size: 14px; margin: 0 0 8px; }

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-soft);
    border-radius: 5px;
    padding: 1px 6px;
    font-size: 0.88em;
    color: #cfe8ff;
}

/* ---------- Top nav ---------- */
nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
    background: rgba(12, 17, 24, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
nav h1 {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(90deg, #fff, #9fd0ff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}
nav > div { display: flex; flex-wrap: wrap; gap: 4px; }
nav a {
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 500;
    padding: 7px 12px;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); text-decoration: none; }

/* ---------- Layout ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }

.helper-text { color: var(--muted); font-size: 13px; margin: 6px 0; }

/* ---------- Stat cards ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 26px;
}
.stat-card {
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.stat-card h3 {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted);
}
.stat-number { margin: 0; font-size: 26px; font-weight: 700; color: var(--text); }
.stat-card .helper-text { margin-top: 4px; }

/* ---------- Tables ---------- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
thead th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted);
    background: var(--panel-2);
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }

/* ---------- Badges / direction ---------- */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.badge-long, .direction-long { color: var(--green); }
.badge-short, .direction-short { color: var(--red); }
.badge-long { background: rgba(34, 197, 94, 0.12); }
.badge-short { background: rgba(239, 68, 68, 0.12); }
.direction-long, .direction-short { font-weight: 700; text-transform: uppercase; }

.aggregated-indicator {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent-2);
    margin-right: 6px;
    box-shadow: 0 0 8px rgba(34, 211, 238, 0.6);
}

/* ---------- Buttons ---------- */
button, .btn-filter, .btn-secondary, .btn-row-remove {
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 9px;
    padding: 9px 16px;
    border: 1px solid transparent;
    transition: filter 0.15s, background 0.15s, border-color 0.15s;
}
.btn-filter, form button[type="submit"], .login-container button {
    color: #fff;
    background: linear-gradient(180deg, #4b8ef7, var(--accent));
    border-color: #2f6fd6;
}
.btn-filter:hover, form button[type="submit"]:hover, .login-container button:hover { filter: brightness(1.08); }
.btn-secondary {
    color: var(--text);
    background: var(--panel-2);
    border-color: var(--border);
}
.btn-secondary:hover { background: #222c3c; text-decoration: none; }
.btn-row-remove {
    color: #ffb4b4;
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.35);
}
.btn-row-remove:hover { background: rgba(239, 68, 68, 0.16); }
button:disabled { opacity: 0.55; cursor: default; filter: none; }

/* ---------- Forms / panels ---------- */
.filters {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    margin-bottom: 8px;
}
input[type="text"], input[type="url"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"],
select, textarea {
    font: inherit;
    font-size: 13.5px;
    color: var(--text);
    background: #0e141d;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}
::placeholder { color: #5c6a7d; }
label { font-size: 13px; color: var(--muted); }

.filter-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; max-width: 420px; }
.settings-checkboxes { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 14px; }
.checkbox-line { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13.5px; }
.checkbox-line input { accent-color: var(--accent); width: 16px; height: 16px; }

.window-rows { display: flex; flex-direction: column; gap: 10px; }
.window-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--panel-2);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
}
.settings-actions { display: flex; gap: 10px; margin-top: 16px; }

/* Filter bar (alerts page) */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

/* Copy row (dashboard webhook URL) */
.copy-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; flex-wrap: wrap; }
.copy-row input { flex: 1; min-width: 280px; font-family: ui-monospace, monospace; }

.test-result { font-size: 12.5px; font-weight: 600; }

/* ---------- Webhook help cards ---------- */
.webhook-help { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.webhook-help-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.webhook-help-card p { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.webhook-help-card pre {
    background: #0a0e14;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 12px;
    overflow-x: auto;
    margin: 0 0 8px;
}
.webhook-help-card code { background: none; border: none; padding: 0; color: #cfe8ff; font-size: 12px; }

/* ---------- Flash messages ---------- */
.alert {
    padding: 11px 14px;
    border-radius: 9px;
    margin-bottom: 14px;
    font-size: 13.5px;
    border: 1px solid transparent;
}
.alert-success { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.4); color: #b6f0c8; }
.alert-error { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.4); color: #ffc2c2; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: 14px; margin-top: 16px; color: var(--muted); font-size: 13px; }
.pagination a {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--text);
}
.pagination a:hover { background: #222c3c; text-decoration: none; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    max-width: 520px;
    width: 90%;
    box-shadow: var(--shadow);
    position: relative;
}
.close { position: absolute; top: 12px; right: 16px; cursor: pointer; font-size: 22px; color: var(--muted); }
.close:hover { color: var(--text); }

/* ---------- Login ---------- */
.login-container {
    max-width: 360px;
    margin: 12vh auto 0;
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px 28px;
    box-shadow: var(--shadow);
}
.login-container h1 {
    font-size: 18px;
    text-align: center;
    margin: 0 0 22px;
    background: linear-gradient(90deg, #fff, #9fd0ff);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.login-container button { width: 100%; padding: 11px; margin-top: 4px; }
