:root {
    --bg: #f6f7f9;
    --fg: #1a1f2b;
    --muted: #6b7280;
    --border: #d8dde5;
    --card: #ffffff;
    --primary: #1f5fff;
    --primary-fg: #ffffff;
    --secondary: #e5e8ee;
    --up: #137a3f;
    --down: #c92a2a;
    --paused: #8a6d00;
    --shadow: 0 1px 2px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.4;
}

h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.1rem; margin-top: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.hidden { display: none; }
.inline { display: inline; }

/* ---------- Login ---------- */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    background: var(--card);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 360px;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.login-card label {
    font-weight: 600;
    margin-top: 0.5rem;
}

/* ---------- Topbar ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.topbar-left { display: flex; align-items: baseline; gap: 0.75rem; }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }

/* ---------- Buttons & inputs ---------- */

button, .button {
    font: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0.45rem 0.9rem;
    transition: filter 0.1s ease;
}

button.primary {
    background: var(--primary);
    color: var(--primary-fg);
}

button.secondary {
    background: var(--secondary);
    color: var(--fg);
    border-color: var(--border);
}

button.link {
    background: transparent;
    border: none;
    color: var(--primary);
    padding: 0.25rem 0.5rem;
    text-decoration: underline;
}

button.danger {
    background: transparent;
    color: var(--down);
    border-color: var(--border);
}

button:hover { filter: brightness(1.05); }
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

input[type=email],
input[type=password],
input[type=url],
input[type=text],
select {
    font: inherit;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    width: 100%;
}

/* ---------- Table ---------- */

main { padding: 1.5rem; }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

th, td {
    text-align: left;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    background: #f0f3f8;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

tbody tr:last-child td { border-bottom: none; }

.options-cell { display: flex; gap: 0.3rem; }

.status-pill {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}
.status-active { background: #e3f5ea; color: var(--up); }
.status-paused { background: #fff3cd; color: var(--paused); }

.uptime-up   { color: var(--up); font-weight: 600; }
.uptime-down { color: var(--down); font-weight: 600; }
.uptime-unknown { color: var(--muted); }

/* ---------- Dialogs ---------- */

dialog {
    border: none;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    max-width: 560px;
    width: 90%;
}

dialog::backdrop { background: rgba(0,0,0,0.35); }

dialog form { display: flex; flex-direction: column; gap: 0.5rem; }
dialog label { font-weight: 600; margin-top: 0.5rem; }
.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

pre {
    background: #f0f3f8;
    padding: 0.75rem;
    border-radius: 6px;
    overflow-x: auto;
    white-space: pre-wrap;
}

/* ---------- Alerts ---------- */

.alert {
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    margin: 0.75rem 0;
}
.alert.error { background: #fdecec; color: var(--down); border: 1px solid #f4c4c4; }

/* ---------- History list ---------- */

.history-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
    max-height: 360px;
    overflow-y: auto;
}

.history-list li {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}
.history-list li:last-child { border-bottom: none; }

.history-list .state-up   { color: var(--up); font-weight: 600; }
.history-list .state-down { color: var(--down); font-weight: 600; }
