/* Portal — small stylesheet. System font, generous spacing, one accent color. */

:root {
    --bg: #f7f7f9;
    --card: #ffffff;
    --ink: #1c1c22;
    --muted: #6a6a75;
    --line: #e4e4ea;
    --accent: #315dd8;
    --accent-ink: #ffffff;
    --ok-bg: #e8f5e9;
    --ok-ink: #1b5e20;
    --err-bg: #fdecea;
    --err-ink: #a5001b;
    --danger: #b8362a;
    --hover: rgba(0,0,0,0.03);
    --warn-bg: #ffd84d;
    --warn-ink: #2b1d00;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #17181d;
        --card: #1f2028;
        --ink: #e7e7ec;
        --muted: #9092a0;
        --line: #2d2f39;
        --accent: #6d92ff;
        --accent-ink: #0b0f1c;
        --ok-bg: #163d21;
        --ok-ink: #b5e6c2;
        --err-bg: #3a1a1a;
        --err-ink: #f5b7b1;
        --danger: #e37769;
        --hover: rgba(255,255,255,0.04);
        --warn-bg: #f9c74f;
        --warn-ink: #2b1d00;
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

/* ---------------- top bar ---------------- */
header.top {
    display: flex; align-items: center; gap: 1.5rem;
    padding: 0.6rem 1.25rem; background: var(--card);
    border-bottom: 1px solid var(--line);
}
header.top .brand { font-weight: 600; text-decoration: none; color: var(--ink); }
header.top nav { display: flex; gap: 1rem; margin-left: 1rem; }
header.top nav a { color: var(--muted); text-decoration: none; padding: 0.25rem 0.5rem; border-radius: 6px; }
header.top nav a.on { background: var(--accent); color: var(--accent-ink); }
header.top .me { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; color: var(--muted); }
header.top .me .name { color: var(--ink); }
header.top .me a { color: var(--accent); text-decoration: none; margin-left: 0.25rem; }
header.top .me .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    object-fit: cover; display: inline-block;
    background: var(--bg); border: 1px solid var(--line);
    font-size: 0.75rem; font-weight: 600;
    color: var(--accent-ink); text-align: center; line-height: 32px;
    text-transform: uppercase; letter-spacing: 0.02em;
}
header.top .me .avatar.initials {
    background: var(--accent); color: var(--accent-ink); border-color: transparent;
}

main { max-width: 780px; margin: 1.5rem auto; padding: 0 1.25rem 3rem; }
main h1 { margin-top: 0.5rem; }
main h2 { margin-top: 2.5rem; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.5rem; }
.page-heading h1 { margin: 0; }
.lede { color: var(--muted); }
.muted { color: var(--muted); }
.hint { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }

.flash { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash.err { background: var(--err-bg); color: var(--err-ink); }

/* collapsible box: neutral by default (certificate install steps),
   .warn = warning banner (orphan devices) */
.alert {
    border-radius: 8px; margin-bottom: 1.25rem;
    background: var(--card); color: var(--ink); border: 1px solid var(--line);
}
.alert.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-ink); }
.card code { word-break: break-all; }
.alert > summary { cursor: pointer; padding: 0.7rem 1rem; list-style: none; }
.alert > summary::-webkit-details-marker { display: none; }
.alert > summary::before {
    content: "▸"; margin-right: 0.4rem; display: inline-block; width: 0.75rem;
    transition: transform 0.15s ease-out;
}
.alert[open] > summary::before { transform: rotate(90deg); }
.alert a { color: inherit; text-decoration: underline; }
.alert-body { padding: 0 1rem 0.8rem 2.4rem; }
.alert-body ul { margin: 0.4rem 0 0.6rem 1rem; padding: 0; }
.alert-body li { margin-bottom: 0.25rem; }
.alert-body code { background: rgba(0,0,0,0.08); }
@media (prefers-color-scheme: dark) {
    .alert-body code { background: rgba(255,255,255,0.06); }
}

/* ---------------- device rows (collapsed by default) ---------------- */
details.device {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 10px; margin-bottom: 0.75rem; overflow: hidden;
}
details.device > summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.75rem 1rem;
}
details.device > summary::-webkit-details-marker { display: none; }
details.device > summary::before {
    content: "▸"; color: var(--muted); font-size: 0.75rem;
    transition: transform 0.15s ease-out;
    display: inline-block; width: 0.75rem;
}
details.device[open] > summary::before { transform: rotate(90deg); }
details.device > summary:hover { background: var(--hover); }
details.device .device-name { font-weight: 500; }
details.device .meta { color: var(--muted); font-size: 0.85rem; display: flex; gap: 0.75rem; margin-left: auto; }
details.device .meta > span { white-space: nowrap; }

.device-body {
    padding: 0.5rem 1rem 1rem;
    border-top: 1px solid var(--line);
}
.device-body section { padding: 0.65rem 0; border-bottom: 1px solid var(--line); }
.device-body section:last-of-type { border-bottom: 0; }
.device-body h3 { margin: 0 0 0.4rem; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.device-body details.danger { padding: 0.65rem 0 0.25rem; border-top: 1px solid var(--line); }
.device-body details.danger > summary { cursor: pointer; color: var(--danger); font-weight: 500; }
.device-body .checkbox { display: flex; align-items: center; gap: 0.5rem; margin: 0.25rem 0; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot.green { background: #38b957; }
.dot.grey  { background: var(--muted); }

/* ---------------- prefixed input (username-…) ---------------- */
.prefixed {
    display: inline-flex; align-items: stretch; margin-top: 0.35rem;
    border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
    background: var(--bg);
}
.prefixed .prefix {
    padding: 0.4rem 0.6rem; background: var(--line); color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9rem;
}
.prefixed input[type=text] {
    border: 0; background: transparent; color: var(--ink);
    padding: 0.4rem 0.6rem; font: inherit; min-width: 12ch;
    outline: none;
}
.prefixed + button { margin-left: 0.5rem; }

/* ---------------- forms / cards / commands ---------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; }
.card label { display: block; margin-bottom: 1rem; }
.card label input[type=text], .card label input[type=email] {
    display: block; width: 100%; padding: 0.5rem 0.65rem; margin-top: 0.25rem;
    border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink);
    font-size: 0.95rem;
}

button, .button {
    display: inline-block;
    background: var(--accent); color: var(--accent-ink); border: 0;
    padding: 0.5rem 1rem; border-radius: 6px; font: inherit; cursor: pointer;
    text-decoration: none;
}
button:hover, .button:hover { filter: brightness(1.05); }
button.danger { background: var(--danger); }
button.small { padding: 0.2rem 0.6rem; font-size: 0.85rem; }

/* shared groups: one card per group, member list with remove buttons */
section.card + section.card { margin-top: 1.25rem; }
.card select { display: block; margin-top: 0.25rem; padding: 0.45rem 0.6rem; border: 1px solid var(--line);
               border-radius: 6px; background: var(--bg); color: var(--ink); font: inherit; }
ul.members { list-style: none; padding: 0; margin: 0.5rem 0 0; }
ul.members li { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
                padding: 0.45rem 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
ul.members li form { margin-left: auto; }

/* meetings: list of cards, inline renew/delete forms */
.card + section.card, form.card + section.card { margin-top: 1.25rem; }
.card input[type=datetime-local] { display: block; margin-top: 0.25rem; padding: 0.45rem 0.6rem; border: 1px solid var(--line);
                                   border-radius: 6px; background: var(--bg); color: var(--ink); font: inherit; }
form.inline { display: inline-flex; align-items: flex-end; gap: 0.5rem; margin: 0.5rem 0.75rem 0 0; flex-wrap: wrap; }
form.inline label { margin: 0; }
section.meeting.over { opacity: 0.75; }

.cmdbox {
    display: flex; align-items: stretch; gap: 0.5rem;
    background: #0e0f14; color: #e7ecff;
    padding: 0.75rem 1rem; border-radius: 8px; margin: 0.5rem 0 1rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
/* only the command scrolls — the Copy button always stays visible */
.cmdbox code { display: block; white-space: nowrap; flex: 1 1 auto; min-width: 0;
               overflow-x: auto; padding-bottom: 0.3rem; word-break: normal; }
.cmdbox button { background: #2f3242; color: #e7ecff; flex: none; align-self: center; }

code { background: var(--bg); padding: 0.05rem 0.35rem; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 2rem 1rem 3rem; }
footer a { color: var(--muted); }

.empty { padding: 2rem; text-align: center; background: var(--card); border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); }

pre.trace { background: #0e0f14; color: #e7ecff; padding: 1rem; border-radius: 8px; overflow-x: auto; font-size: 0.8rem; }

/* ---------------- add-device dialog ---------------- */
dialog.add-dialog {
    max-width: 640px; width: 92vw;
    background: var(--card); color: var(--ink);
    border: 1px solid var(--line); border-radius: 12px;
    padding: 0;
    box-shadow: 0 20px 60px -20px rgba(0,0,0,0.35);
}
dialog.add-dialog::backdrop {
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
}
dialog.add-dialog .dlg-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.9rem 1.25rem; border-bottom: 1px solid var(--line);
    margin: 0;
}
dialog.add-dialog .dlg-head h2 { margin: 0; font-size: 1.1rem; }
dialog.add-dialog .dlg-close {
    background: transparent; color: var(--muted); border: 0;
    font-size: 1.4rem; line-height: 1; padding: 0 0.3rem; cursor: pointer;
}
dialog.add-dialog .dlg-close:hover { color: var(--ink); }
dialog.add-dialog ol { padding: 1rem 1.25rem 0.5rem 2.5rem; }
dialog.add-dialog ol li { margin-bottom: 1rem; }
dialog.add-dialog .dlg-foot {
    display: flex; justify-content: flex-end; gap: 0.5rem;
    padding: 0.9rem 1.25rem; border-top: 1px solid var(--line);
    margin: 0;
}

/* ---------- recovery page ---------- */
.rec-explain p { margin: 0.4em 0; }
ol.codes { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.1em; line-height: 1.8; }
code.secret { font-size: 1.1em; padding: 0.2em 0.5em; user-select: all; }
.secret-row { display: flex; gap: 0.5em; align-items: center; flex-wrap: wrap; }
.warn-text { color: #b45309; }
.history { margin: 0.5em 0 0; padding-left: 1.2em; font-size: 0.9em; }
button.secondary { opacity: 0.8; }
.print-only { display: none; }
@media print {
    body * { visibility: hidden; }
    .print-only, .print-only * { visibility: visible; }
    .print-only { display: block; position: absolute; top: 0; left: 0; }
}

/* logo in the top bar (white SVG — meant for the dark per-server themes) */
header.top .brand { display: inline-flex; align-items: center; gap: 0.5rem; }
header.top .brand .logo { width: 28px; height: 28px; }
@media (prefers-color-scheme: light) { header.top .brand .logo { filter: invert(1); } }

/* recovery: re-hide countdown */
.countdown-warn {
    display: flex; align-items: center; gap: 0.6rem;
    background: var(--warn-bg); color: var(--warn-ink);
    border: 1px solid var(--warn-ink); border-radius: 8px;
    padding: 0.6rem 0.9rem; font-weight: 600;
}
.countdown-warn .warn-icon { font-size: 1.5em; line-height: 1; }
.countdown-warn strong { font-size: 1.2em; font-variant-numeric: tabular-nums; }

/* recovery: progress bar for the deliberately slow steps */
.rec-progress { margin: 0.8rem 0; padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.rec-progress progress { width: 100%; height: 0.9rem; accent-color: var(--accent); }
.rec-progress #prog-label { display: block; margin-top: 0.3rem; font-weight: 600; }
.rec-progress p { margin: 0.3rem 0 0; }

/* devices: personal DNS names */
.dns-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.25rem 0; }
.dns-row code { font-size: 1em; }

/* info wizard: OS tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0 1rem; }
.tabs .tab { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.tabs .tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tab-panel h2:first-child { margin-top: 0.2rem; }
#wiz-status { margin-top: 1.5rem; }
.flash.connected p { margin: 0.3rem 0; }
.flash.connected .button { margin: 0.3rem 0; }

/* info wizard: OS choice + one-step-at-a-time accordion */
.os-pick { margin: 1rem 0 0.5rem; }
.os-pick > span { font-weight: 600; margin-right: 0.4rem; }
.step { border: 1px solid var(--line); border-radius: 8px; margin: 0.6rem 0; background: var(--card); }
.step-head { display: flex; align-items: center; gap: 0.5rem; width: 100%; text-align: left;
             background: transparent; color: var(--ink); border: 0; padding: 0.8rem 1rem; font-size: 1.05rem; font-weight: 600; cursor: pointer; }
.step-head .num { color: var(--muted); min-width: 1.4rem; }
.step-head .opt { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.step-head .tick { margin-left: auto; color: var(--accent); visibility: hidden; }
.step.done .step-head .tick { visibility: visible; }
.step-body { display: none; padding: 0 1rem 1rem; }
.step.open .step-body { display: block; }
.step.open .step-head { border-bottom: 1px solid var(--line); margin-bottom: 0.6rem; }
.step-body h3 { margin: 1rem 0 0.4rem; font-size: 1rem; }
.step-nav { display: flex; gap: 0.5rem; margin-top: 1rem; }
.waiting { font-weight: 600; }
header.top nav.langs { display: flex; gap: 0.35rem; margin-left: auto; margin-right: 1rem; }
header.top nav.langs a { opacity: 0.6; text-decoration: none; font-size: 0.85rem; }
header.top nav.langs a.on { opacity: 1; font-weight: 700; }

/* info pages: simple tables */
main.info table { border-collapse: collapse; margin: 0.5rem 0 1rem; width: 100%; }
main.info th, main.info td { text-align: left; vertical-align: top; padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--line); }
main.info th { white-space: nowrap; width: 1%; }
