:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --ink: #1f2933;
    --muted: #6b7280;
    --line: #e2e8f0;
    --brand: #128c7e; /* WhatsApp-ish teal */
    --brand-ink: #ffffff;
    --danger: #b91c1c;
    --ok: #067647;
    --err: #b91c1c;
    --radius: 8px;
}

* { box-sizing: border-box; }

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

.topnav {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--brand);
    color: var(--brand-ink);
    padding: 0 1.25rem;
    height: 52px;
}
.topnav .brand { font-weight: 700; margin-right: 1rem; }
.topnav a { color: var(--brand-ink); text-decoration: none; opacity: 0.85; padding: 0.25rem 0; }
.topnav a:hover, .topnav a.active { opacity: 1; border-bottom: 2px solid var(--brand-ink); }
.topnav .logout { margin-left: auto; }
.topnav .logout button {
    background: transparent; color: var(--brand-ink); border: 1px solid rgba(255,255,255,0.6);
    border-radius: var(--radius); padding: 0.3rem 0.7rem; cursor: pointer;
}

.page { max-width: 1000px; margin: 1.5rem auto; padding: 0 1.25rem; }
.page.narrow { max-width: 560px; }
.page-head { display: flex; align-items: center; justify-content: space-between; }

h1 { font-size: 1.4rem; }
.muted { color: var(--muted); }
code { background: #eef2f5; padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.85em; word-break: break-all; }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8fafc; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
tr:last-child td { border-bottom: none; }

.actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.actions form { display: inline; margin: 0; }

button, .btn {
    display: inline-block; background: var(--brand); color: var(--brand-ink);
    border: none; border-radius: var(--radius); padding: 0.45rem 0.8rem;
    font-size: 0.9rem; cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { filter: brightness(0.95); }
button.danger, .btn.danger { background: var(--danger); }
.btn.secondary, button.secondary { background: #e2e8f0; color: var(--ink); }

form.secondary { margin-top: 1rem; }

label { display: block; margin: 0.75rem 0; font-weight: 600; }
label.checkbox { font-weight: 400; }
input[type=text], input[type=password], input[type=url], input[type=number], select {
    display: block; width: 100%; margin-top: 0.25rem; padding: 0.5rem;
    border: 1px solid var(--line); border-radius: var(--radius); font-size: 0.95rem;
    font-weight: 400;
}
label.checkbox input { display: inline; width: auto; margin-right: 0.4rem; }
.form-actions { margin-top: 1.25rem; display: flex; gap: 0.75rem; align-items: center; }

.flash { padding: 0.6rem 0.85rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash.ok { background: #ecfdf3; color: var(--ok); border: 1px solid #abefc6; }
.flash.err { background: #fef3f2; color: var(--err); border: 1px solid #fecdca; }

.badge { padding: 0.1rem 0.45rem; border-radius: 999px; font-size: 0.8rem; }
.badge.ok { background: #ecfdf3; color: var(--ok); }
.badge.err { background: #fef3f2; color: var(--err); }
.badge.warn { background: #fff7ed; color: #b45309; cursor: help; }
.test-result { margin: 0 0.25rem; }

/* Dashboard */
.tiles { display: flex; gap: 1rem; margin: 1rem 0; }
.tile { background: var(--card); border-radius: var(--radius); padding: 1rem 1.5rem; box-shadow: 0 1px 2px rgba(0,0,0,0.05); min-width: 160px; }
.tile .num { font-size: 2rem; font-weight: 700; }
.tile .lbl { color: var(--muted); font-size: 0.85rem; }
.tile.alert { background: #fef3f2; }
.tile.alert .num { color: var(--danger); }
table.counters { max-width: 420px; }
table.counters td:not(:first-child), table.counters th:not(:first-child) { text-align: right; }

.filters { display: flex; gap: 0.5rem; margin: 0.75rem 0; }
.filters select, .filters input { width: auto; margin: 0; }
table.log td { font-size: 0.85rem; padding: 0.35rem 0.6rem; }

.bulk { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.bulk select { width: auto; margin: 0; }

pre.body {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1rem; overflow-x: auto; white-space: pre-wrap; word-break: break-word; font-size: 0.85rem;
}

.centered { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.card { background: var(--card); padding: 2rem; border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); width: 340px; }
.card h1 { margin-top: 0; font-size: 1.3rem; }
