/* RemoteLog support UI — plain CSS, no framework. */
:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #dfe3e8;
    --text: #1d232b;
    --muted: #5d6875;
    --accent: #1f6feb;
    --accent-text: #ffffff;
    --danger: #c62828;
    --ok: #1b7f3b;
    --warn: #a15c00;
    --radius: 8px;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1216;
        --surface: #171b21;
        --surface-2: #1f252d;
        --border: #2c333d;
        --text: #e6e9ee;
        --muted: #98a2ae;
        --accent: #4c8dff;
        --danger: #ff6b6b;
        --ok: #4cc27a;
        --warn: #f0a33a;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .75rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1rem .75rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}
.content { padding: 1.25rem 1.75rem 3rem; min-width: 0; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand.big { font-size: 1.35rem; margin-bottom: 1rem; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: var(--accent); display: inline-block; }
.instance {
    align-self: flex-start;
    background: var(--warn);
    color: #fff;
    border-radius: 4px;
    padding: 0 .4rem;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}
nav { display: flex; flex-direction: column; gap: 2px; margin-top: .75rem; }
nav a { color: var(--text); padding: .4rem .6rem; border-radius: 6px; }
nav a:hover { background: var(--surface-2); text-decoration: none; }
nav a.active { background: var(--accent); color: var(--accent-text); }
.nav-section { margin: .9rem .6rem .2rem; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.userbox { margin-top: auto; border-top: 1px solid var(--border); padding-top: .75rem; display: flex; flex-direction: column; gap: .15rem; }
.userbox .user { color: var(--text); font-weight: 600; }
.userbox .role { color: var(--muted); font-size: .85em; }
.sidebar .build { font-family: var(--mono); padding-top: .4rem; }

@media (max-width: 800px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .content { padding: 1rem; }
}

/* ---------- auth ---------- */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.75rem; width: min(420px, 100%); }
.qr svg { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 8px; }
.secret { display: inline-block; padding: .3rem .5rem; background: var(--surface-2); border-radius: 6px; word-break: break-all; user-select: all; }

/* ---------- forms ---------- */
input, select, textarea, button {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .4rem .55rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { width: 100%; resize: vertical; }
label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .4rem; color: var(--text); }
label input, label select, label textarea { color: var(--text); font-size: .95rem; }
button { cursor: pointer; background: var(--surface-2); }
button:hover { border-color: var(--muted); }
button:disabled { opacity: .55; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.small { padding: .15rem .45rem; font-size: .8rem; }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
.button { display: inline-block; padding: .4rem .7rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text); }
.button:hover { text-decoration: none; border-color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: .75rem; }
form.inline { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: .6rem .8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .9rem;
    margin-bottom: 1rem;
    align-items: end;
}
.filters .wide { grid-column: span 2; }
.filters .actions { display: flex; gap: .5rem; }
.actions-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ---------- cards & tables ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card.narrow { max-width: 560px; }
dl.grid { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; }
dl.grid dt { color: var(--muted); }
dl.grid dd { margin: 0; word-break: break-word; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
th.num { text-align: right; }
tr:last-child td { border-bottom: none; }
.card table th { position: static; }
table.logs tbody tr:not(.details) { cursor: pointer; }
table.logs tbody tr:not(.details):hover, tr.open { background: var(--surface-2); }
td.msg { word-break: break-word; max-width: 70ch; white-space: pre-wrap; }
table.logs td.msg { max-height: 4.4em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
tr.details td { background: var(--surface-2); }
pre.message-full, pre.stack {
    font-family: var(--mono);
    font-size: .85rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .6rem .75rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 480px;
    overflow: auto;
}
button.more { margin-top: .75rem; }

/* ---------- badges ---------- */
.lvl { display: inline-block; min-width: 4.6em; text-align: center; padding: 0 .35rem; border-radius: 4px; font-size: .78rem; font-weight: 600; }
.lvl-trace, .lvl-debug { background: var(--surface-2); color: var(--muted); }
.lvl-info { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.lvl-warning { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.lvl-error, .lvl-fatal { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.pill { display: inline-block; padding: 0 .45rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.pill.on { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.off { background: var(--surface-2); color: var(--muted); }
.toggle-group { display: inline-flex; gap: .3rem; align-items: center; flex-wrap: wrap; }
.status { display: inline-block; padding: 0 .45rem; border-radius: 4px; font-size: .78rem; font-weight: 600; }
.status-open { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.status-resolved { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.status-ignored { background: var(--surface-2); color: var(--muted); }

.notice { padding: .6rem .8rem; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); margin: .5rem 0; }
.notice.error { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.notice.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); }

/* ---------- live view ---------- */
.live-controls { display: flex; gap: 1rem; align-items: end; margin-bottom: .5rem; }
.live {
    background: #0d1117;
    color: #d6dde6;
    border-radius: var(--radius);
    padding: .6rem .8rem;
    font-family: var(--mono);
    font-size: .83rem;
    height: calc(100vh - 260px);
    min-height: 300px;
    overflow: auto;
    display: flex;
    flex-direction: column-reverse;
}
.live .line { word-break: break-word; padding: 1px 0; }
.live .msg { white-space: pre-wrap; }
.live .lvl { min-width: 5.2em; margin-left: .4rem; }
.live .tag { color: #8fb4ff; margin: 0 .4rem; }
.live .muted { color: #7d8794; }

/* ---------- blazor error ui ---------- */
#blazor-error-ui {
    background: #ffefc2;
    color: #3d2b00;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ---------- context attributes & field editor ---------- */
.attrs { display: inline-flex; flex-wrap: wrap; gap: .25rem; }
.attr { font-size: .78rem; padding: 0 .4rem; border-radius: 4px; background: var(--surface-2); color: var(--muted); }
.card.inset { background: var(--surface-2); margin-top: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; }
.row > label { flex: 1 1 160px; }
.row.checks > label { flex: 0 1 auto; }
ul.plain { list-style: none; padding: 0; margin: .3rem 0 0; display: flex; flex-direction: column; gap: .3rem; }
