/* ScaffCase Ops — hand-written CSS borrowing the nuxt-app theme:
   Nuxt UI primary "blue" + neutral "slate", Open Sans, rounded-lg cards on a slate-100 canvas,
   inputs on #fafafa with a slate-300 ring. No build step, no JS. */

:root {
    color-scheme: light dark;

    --font-sans: 'Open Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

    --bg: #f1f5f9;          /* slate-100 */
    --surface: #ffffff;
    --surface-2: #f8fafc;   /* slate-50 */
    --fg: #0f172a;          /* slate-900 */
    --fg-soft: #334155;     /* slate-700 */
    --muted: #64748b;       /* slate-500 */
    --line: #e2e8f0;        /* slate-200 */
    --line-strong: #cbd5e1; /* slate-300 */

    --primary: #2563eb;     /* blue-600 */
    --primary-hover: #1d4ed8;
    --primary-soft: #eff6ff;
    --on-primary: #ffffff;
    --ring: #3b82f6;        /* blue-500 */

    --input-bg: #fafafa;

    --ok: #15803d;      --ok-soft: #f0fdf4;   --ok-line: #bbf7d0;
    --warn: #b45309;    --warn-soft: #fffbeb; --warn-line: #fde68a;
    --info: #1d4ed8;    --info-soft: #eff6ff; --info-line: #bfdbfe;
    --bad: #b91c1c;     --bad-soft: #fef2f2;  --bad-line: #fecaca;
    --off: #475569;     --off-soft: #f1f5f9;  --off-line: #e2e8f0;

    --radius: .375rem;
    --radius-lg: .5rem;
    --shadow: 0 1px 2px rgb(15 23 42 / .05);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1e293b;          /* slate-800 */
        --surface: #0f172a;     /* slate-900 */
        --surface-2: #162032;
        --fg: #f1f5f9;
        --fg-soft: #cbd5e1;
        --muted: #94a3b8;
        --line: #334155;
        --line-strong: #475569;

        --primary: #3b82f6;
        --primary-hover: #60a5fa;
        --primary-soft: rgb(59 130 246 / .14);
        --on-primary: #ffffff;
        --ring: #60a5fa;

        --input-bg: #0f172a;

        --ok: #4ade80;   --ok-soft: rgb(34 197 94 / .12);  --ok-line: rgb(34 197 94 / .35);
        --warn: #fbbf24; --warn-soft: rgb(245 158 11 / .12); --warn-line: rgb(245 158 11 / .35);
        --info: #60a5fa; --info-soft: rgb(59 130 246 / .14); --info-line: rgb(59 130 246 / .4);
        --bad: #f87171;  --bad-soft: rgb(239 68 68 / .12);  --bad-line: rgb(239 68 68 / .4);
        --off: #94a3b8;  --off-soft: rgb(148 163 184 / .12); --off-line: rgb(148 163 184 / .3);

        --shadow: none;
    }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font: 15px/1.55 var(--font-sans);
    color: var(--fg);
    background: var(--bg);
}

h1, h2, h3 { line-height: 1.25; color: var(--fg); }
h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .75rem; }

p { margin: 0 0 .85rem; }

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

code, .mono { font-family: var(--font-mono); font-size: .86em; }
code {
    padding: .1em .35em;
    border-radius: .25rem;
    background: var(--surface-2);
    border: 1px solid var(--line);
    white-space: nowrap;
}

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* ---------- Top bar ---------- */

header.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-inner {
    max-width: 80rem;
    margin: 0 auto;
    padding: 0 1rem;
    min-height: 3.5rem;
    display: flex;
    align-items: center;
    gap: .5rem 1.5rem;
    flex-wrap: wrap;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    font-weight: 700;
    font-size: .95rem;
    letter-spacing: -.01em;
    color: var(--fg);
    text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 1.6rem; height: 1.6rem; color: var(--primary); flex: none; }
.brand-sub { font-weight: 500; color: var(--muted); }

header.topbar nav { display: flex; gap: .25rem; }
header.topbar nav a {
    padding: .4rem .7rem;
    border-radius: var(--radius);
    color: var(--fg-soft);
    font-weight: 500;
    font-size: .9rem;
    text-decoration: none;
}
header.topbar nav a:hover { background: var(--surface-2); color: var(--fg); }
header.topbar nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }

header.topbar .logout {
    margin-left: auto;
    display: flex;
    gap: .75rem;
    align-items: center;
    font-size: .875rem;
}
header.topbar .logout .user { color: var(--muted); }

/* ---------- Layout ---------- */

main {
    flex: 1;
    width: 100%;
    max-width: 80rem;
    margin: 0 auto;
    padding: 1.5rem 1rem 2rem;
}

footer {
    max-width: 80rem;
    width: 100%;
    margin: 0 auto;
    padding: 1rem;
    font-size: .8rem;
    text-align: center;
}

.page-head { margin-bottom: 1.25rem; }
.page-head h1 { margin-bottom: .2rem; }
.page-head p { margin: 0; }

/* ---------- Cards ---------- */

.card, section.cell {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin: 0 0 1.25rem;
}
.card { padding: 1.25rem; }
.card:has(> .table-wrap:only-child) { padding: 0; overflow: hidden; }

section.cell { overflow: hidden; }
section.cell > :not(.cell-head):not(.table-wrap) { margin-left: 1.25rem; margin-right: 1.25rem; }
section.cell > .cell-meta, section.cell > p { margin-top: .9rem; }
section.cell > :last-child:not(.table-wrap) { margin-bottom: 1.1rem; }
section.cell > .table-wrap { border-top: 1px solid var(--line); margin-top: .9rem; }

.cell-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .85rem 1.25rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}
.cell-head h2 { margin: 0; }
.cell-head + .table-wrap { border-top: 0; margin-top: 0; }

section.cell.attention { border-color: var(--bad-line); box-shadow: 0 0 0 1px var(--bad-line); }
section.cell.attention .cell-head { background: var(--bad-soft); border-bottom-color: var(--bad-line); }
section.cell.attention .cell-head h2::after {
    content: "Kræver opmærksomhed";
    margin-left: .6rem;
    font-size: .72rem;
    font-weight: 600;
    color: var(--bad);
    vertical-align: middle;
}

.cell-meta { color: var(--fg-soft); }
.cell-meta strong.badge { margin: 0 .15rem; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td {
    text-align: left;
    padding: .6rem 1rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
thead th {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    background: var(--surface-2);
    white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }

tr.attention td { background: var(--bad-soft); }
tr.attention td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
tbody tr.attention:hover td { background: var(--bad-soft); }

table.tenants td:first-child { min-width: 12rem; }
table.tenants td:last-child { min-width: 14rem; }
table.audit td:last-child { color: var(--fg-soft); }

td.actions { white-space: nowrap; }
td.actions form + form { margin-left: .35rem; }

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .1rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    color: var(--off);
    background: var(--off-soft);
    border: 1px solid var(--off-line);
}
.badge::before {
    content: "";
    width: .4rem;
    height: .4rem;
    border-radius: 50%;
    background: currentColor;
}

.state-active, .state-ready, .state-running {
    color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line);
}
.state-pending, .state-created, .state-locked {
    color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line);
}
.state-provisioning, .state-deploying, .state-upgrading, .state-creating {
    color: var(--info); background: var(--info-soft); border-color: var(--info-line);
}
.state-unavailable, .state-error, .state-failed {
    color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line);
}
.state-disabled, .state-deleting {
    color: var(--off); background: var(--off-soft); border-color: var(--off-line);
}

/* Tenant booted on another version than its cell runs */
.mismatch {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .05rem .45rem;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--warn);
    background: var(--warn-soft);
    border: 1px solid var(--warn-line);
    white-space: nowrap;
}
.mismatch::before { content: "⚠"; font-family: var(--font-sans); }
.mismatch::after { content: "≠ celle"; font-family: var(--font-sans); font-weight: 500; font-size: .8em; opacity: .85; }

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

.error { color: var(--bad); }
.message { color: var(--ok); }

p.error, p.message {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    padding: .7rem .9rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--bad-line);
    background: var(--bad-soft);
    font-size: .9rem;
    font-weight: 500;
}
p.error::before { content: "!"; flex: none; display: inline-grid; place-items: center; width: 1.25rem; height: 1.25rem; border-radius: 50%; background: var(--bad); color: var(--surface); font-weight: 700; font-size: .8rem; }
p.message { border-color: var(--ok-line); background: var(--ok-soft); }
p.message::before { content: "✓"; flex: none; font-weight: 700; }

td .error { font-size: .85rem; }

/* ---------- Forms ---------- */

form.inline { display: inline-flex; gap: .35rem; align-items: center; }

label {
    display: block;
    margin: .9rem 0 .3rem;
    font-size: .875rem;
    font-weight: 600;
    color: var(--fg-soft);
}
label.check {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    margin: 0 0 1rem;
    font-weight: 500;
    cursor: pointer;
}

input[type=text], input[type=password], select {
    font: inherit;
    font-size: .925rem;
    color: var(--fg);
    background: var(--input-bg);
    border: 0;
    box-shadow: inset 0 0 0 1px var(--line-strong);
    border-radius: var(--radius);
    padding: .5rem .7rem;
    min-width: 16rem;
    max-width: 100%;
    transition: box-shadow .12s ease;
}
input[type=text]:hover, input[type=password]:hover, select:hover { box-shadow: inset 0 0 0 1px var(--muted); }
input[type=text]:focus, input[type=password]:focus, select:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--ring);
}
select { padding-right: 1.8rem; cursor: pointer; }
select:disabled { opacity: .6; cursor: not-allowed; }
td select { min-width: 0; padding: .3rem 1.6rem .3rem .5rem; font-size: .85rem; }
input[type=checkbox] { width: 1rem; height: 1rem; accent-color: var(--primary); margin: 0; }

button, a.button {
    font: inherit;
    display: inline-block;
    text-decoration: none;
    font-size: .875rem;
    font-weight: 600;
    line-height: 1.25rem;
    padding: .5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: var(--primary);
    color: var(--on-primary);
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease;
}
button:hover, a.button:hover { background: var(--primary-hover); }
button.secondary, button.ghost, a.button.secondary {
    background: var(--surface);
    color: var(--fg-soft);
    border-color: var(--line-strong);
}
button.secondary:hover, button.ghost:hover, a.button.secondary:hover { background: var(--surface-2); color: var(--fg); }
button.ghost { border-color: transparent; background: transparent; }
button.small, a.button.small { padding: .25rem .6rem; font-size: .8rem; }
/* Breathing room between a form's last field and its submit button (the button sits in a <p>). */
form > p:has(> button[type=submit]:only-child) { margin-top: 1.1rem; }

.form-card { max-width: 32rem; }
.form-card input[type=text], .form-card input[type=password], .form-card select,
.auth-card input[type=text], .auth-card input[type=password] { width: 100%; min-width: 0; }
.form-card h2 { margin-bottom: .25rem; }
form p:last-child { margin: 1.25rem 0 0; }

.filter { margin-bottom: .25rem; }

.pager { display: flex; gap: .5rem; flex-wrap: wrap; }
.pager a {
    padding: .4rem .8rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--fg-soft);
    font-size: .875rem;
    font-weight: 500;
}
.pager a:hover { text-decoration: none; background: var(--surface-2); }

/* ---------- Account pages (centred card) ---------- */

body.account main { display: flex; justify-content: center; align-items: flex-start; padding-top: 3rem; }
.auth-card { width: 100%; max-width: 28rem; padding: 1.75rem; }
.auth-card h1 { font-size: 1.3rem; }
.auth-card form button[type=submit] { width: 100%; padding: .6rem 1rem; }
.auth-card ol { padding-left: 1.2rem; }
.auth-card ol li { margin-bottom: .4rem; }
.auth-card svg { display: block; width: 100%; max-width: 12rem; height: auto; margin: .5rem auto 1rem; background: #fff; padding: .5rem; border-radius: var(--radius-lg); }
.auth-card code { white-space: normal; word-break: break-all; }

.codes {
    list-style: none;
    padding: .75rem;
    margin: 0 0 1rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .4rem;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
}
.codes li {
    font-family: var(--font-mono);
    font-size: .9rem;
    text-align: center;
    padding: .3rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
    .topbar-inner { padding: .5rem .75rem; }
    header.topbar nav { order: 3; width: 100%; margin: 0 -.35rem; }
    header.topbar .logout .user { display: none; }
    main { padding: 1rem .75rem 1.5rem; }
    body.account main { padding-top: 1.25rem; }
    .card { padding: 1rem; }
    .auth-card { padding: 1.25rem; }
    section.cell > :not(.cell-head):not(.table-wrap) { margin-left: 1rem; margin-right: 1rem; }
    .cell-head { padding: .75rem 1rem; }
    th, td { padding: .5rem .75rem; }
    input[type=text], input[type=password], select { min-width: 0; width: 100%; }
    td select { width: auto; }
    .codes { grid-template-columns: 1fr; }
}

/* Restart cell (cell header) and retry tenant (under the state badge) — phase 3a. */
.cell-head form.inline { margin: 0; }
td a.button.retry { display: table; margin-top: .4rem; padding: .2rem .65rem; }
section.cell > .cell-body { margin-top: 1.1rem; }
.confirm-actions { display: flex; gap: .6rem; align-items: center; margin-top: 1.25rem; }
