:root {
    --bg: #0f1420;
    --surface: #ffffff;
    --ink: #1a2233;
    --muted: #6b7686;
    --line: #e3e8f0;
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --green: #15803d;
    --green-bg: #dcfce7;
    --red: #b91c1c;
    --red-bg: #fee2e2;
    --amber-bg: #fef3c7;
    --amber-ink: #92400e;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--ink);
    background: #f4f6fb;
}

/* ---- Top bar ---- */
.topbar {
    background: var(--bg);
    color: #fff;
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.brand-mark {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    background: var(--brand);
    border-radius: 8px;
    font-weight: 800;
}
.brand-text { font-size: 1.05rem; letter-spacing: .3px; }
.brand-text strong { color: #c7d2fe; }
.topbar-user { display: flex; align-items: center; gap: 16px; font-size: .9rem; }
.inline-form { display: inline; margin: 0; }
.link-button {
    background: none; border: none; color: #c7d2fe; cursor: pointer;
    font-size: .9rem; padding: 0; text-decoration: underline;
}

/* ---- Page ---- */
.page { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0 0 4px; font-size: 1.6rem; }
.page-head p { margin: 0; color: var(--muted); }

/* ---- Cards / grid ---- */
.grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; align-items: start; }
@@media (max-width: 880px) { .grid { grid-template-columns: 1fr; } }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.card h2 { margin: 0 0 4px; font-size: 1.15rem; }
.card .hint { margin: 0 0 18px; color: var(--muted); font-size: .88rem; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
tr:last-child td { border-bottom: none; }
.key-chip {
    font-family: "Cascadia Mono", Consolas, monospace;
    background: #eef2ff; color: var(--brand-dark);
    padding: 3px 9px; border-radius: 6px; font-weight: 700; letter-spacing: 1px;
}
.db-name { color: var(--muted); font-size: .82rem; }

.status { font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.status.on { background: var(--green-bg); color: var(--green); }
.status.off { background: var(--red-bg); color: var(--red); }

/* ---- Forms ---- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.field input {
    width: 100%; padding: 10px 12px; font-size: .95rem;
    border: 1px solid var(--line); border-radius: 9px; background: #fbfcfe;
}
.field input:focus { outline: none; border-color: var(--brand); background: #fff; }
.field-error { color: var(--red); font-size: .8rem; display: block; margin-top: 5px; }

.btn {
    display: inline-block; cursor: pointer; border: none;
    padding: 10px 18px; border-radius: 9px; font-size: .92rem; font-weight: 600;
    text-decoration: none;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: 7px; }
.btn-ghost { background: #eef2f7; color: var(--ink); }
.btn-ghost:hover { background: #e2e8f0; }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #fecaca; }
.btn-block { width: 100%; text-align: center; }

/* ---- Alerts ---- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: .9rem; }
.alert-success { background: var(--green-bg); color: var(--green); }
.alert-error { background: var(--red-bg); color: var(--red); }
.validation-summary { color: var(--red); font-size: .88rem; margin-bottom: 12px; }
.validation-summary ul { margin: 0; padding-left: 18px; }

/* ---- Auth screen ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
    width: 100%; max-width: 380px; background: var(--surface);
    border: 1px solid var(--line); border-radius: 16px; padding: 34px 30px;
    box-shadow: 0 10px 40px rgba(16, 24, 40, .12);
}
.auth-card .brand { color: var(--ink); margin-bottom: 22px; justify-content: center; }
.auth-card .brand-text strong { color: var(--brand); }
.auth-card h1 { font-size: 1.3rem; margin: 0 0 4px; text-align: center; }
.auth-card .sub { color: var(--muted); font-size: .88rem; text-align: center; margin: 0 0 24px; }

details.reset-tool { margin-top: 14px; }
details.reset-tool summary { cursor: pointer; color: var(--brand-dark); font-size: .85rem; font-weight: 600; }
details.reset-tool .reset-body { margin-top: 14px; }
.muted-row td { color: var(--muted); text-align: center; padding: 26px; }
