/* Mu97 admin panel - dark theme, no external resources. */
:root {
  --bg: #0f1216; --panel: #161b22; --panel2: #1c232c; --line: #2a333f; --text: #d8dee6; --muted: #8b96a5;
  --accent: #4f9cf9; --accent2: #2f7de1; --ok: #3fb67b; --warn: #e0a83a; --bad: #e5534b; --code: #0b0e12;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 14px; font-weight: 600; }
h2 { font-size: 16px; margin: 18px 0 10px; font-weight: 600; }
h3 { font-size: 14px; margin: 14px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
code, pre, textarea.code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace; font-size: 12.5px; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.side { width: 210px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 14px; }
.brand small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.nav a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); margin-bottom: 2px; }
.nav a:hover { background: var(--panel2); text-decoration: none; }
.nav a.active { background: var(--accent2); color: #fff; }
.side .who { margin-top: 18px; padding: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.main { flex: 1; min-width: 0; padding: 20px 24px 60px; }
.topbar { display: none; }
@media (max-width: 860px) {
  .layout { display: block; }
  .side { display: none; position: fixed; z-index: 20; height: 100vh; }
  .side.open { display: block; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
  .main { padding: 14px; }
}

/* blocks */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); }
.badge.ok { border-color: var(--ok); } .badge.bad { border-color: var(--bad); } .badge.warn { border-color: var(--warn); }
.hidden { display: none !important; }
.stat { font-size: 22px; font-weight: 600; }
.bar { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--accent); }

/* forms */
input, select, textarea, button { font: inherit; color: var(--text); }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], input[type=datetime-local], select, textarea {
  background: var(--code); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input.changed, textarea.changed { border-color: var(--warn); }
input.invalid { border-color: var(--bad); }
label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 12.5px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--text); font-size: 14px; }
button, .btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
button.danger { border-color: var(--bad); color: #ffb4ae; }
button.danger:hover { background: #3a1d1b; }
button.small, .btn.small { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .45; cursor: default; }
textarea.code { width: 100%; min-height: 60vh; resize: vertical; tab-size: 4; white-space: pre; overflow: auto; line-height: 1.45; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; white-space: nowrap; }
tr:hover td { background: #1a2029; }
.table-wrap { overflow-x: auto; }
td.num, th.num { text-align: right; }
tr.off td { opacity: .5; }

/* log / diff */
.log { background: var(--code); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; max-height: 60vh; overflow: auto; font-family: ui-monospace, Consolas, monospace; font-size: 12px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.log .hl { background: #3b3214; }
.diff .add { color: #7ee2a8; background: #12261b; display: block; }
.diff .del { color: #ffa7a1; background: #2b1615; display: block; }
.diff .hunk { color: var(--accent); display: block; }

/* editor with line numbers */
.editor { display: flex; border: 1px solid var(--line); border-radius: 6px; background: var(--code); overflow: hidden; }
.editor .gutter { flex: none; padding: 8px 6px 8px 8px; color: #56606d; text-align: right; user-select: none; overflow: hidden; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.45; white-space: pre; border-right: 1px solid var(--line); }
.editor textarea.code { border: 0; border-radius: 0; min-height: 65vh; padding: 8px; }

/* file tree */
.split { display: grid; grid-template-columns: 300px 1fr; gap: 14px; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
.tree { max-height: 75vh; overflow: auto; font-size: 13px; }
.tree .item { padding: 3px 6px; border-radius: 4px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree .item:hover { background: var(--panel2); }
.tree .item.sel { background: var(--accent2); color: #fff; }
.tree .dir::before { content: "▸ "; color: var(--muted); }
.tree .dir.open::before { content: "▾ "; }
.tree .file::before { content: "  "; white-space: pre; }
.tree .children { padding-left: 14px; }

/* settings form */
.field { display: grid; grid-template-columns: minmax(180px, 280px) minmax(120px, 260px) 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: start; }
.field .key { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; padding-top: 7px; word-break: break-all; }
.field .help { color: var(--muted); font-size: 12.5px; white-space: pre-wrap; padding-top: 6px; }
.field .help.shared { opacity: .55; }
.field input { width: 100%; }
@media (max-width: 760px) { .field { grid-template-columns: 1fr; gap: 4px; } }
.group-title { margin-top: 18px; font-weight: 600; color: var(--accent); }
.group-desc { color: var(--muted); font-size: 12.5px; white-space: pre-wrap; margin: 4px 0 6px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); margin-top: 10px; z-index: 5; }

/* dialog */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; width: min(760px, 94vw); max-height: 90vh; overflow: auto; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin-top: 0; }
.toast-box { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(460px, 90vw); }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.4); white-space: pre-wrap; }
.toast.bad { border-left-color: var(--bad); } .toast.ok { border-left-color: var(--ok); }

/* auth pages */
.auth { max-width: 440px; margin: 8vh auto; padding: 0 16px; }
.auth .card { padding: 24px; }
.auth input { width: 100%; }
.qr { background: #fff; padding: 10px; border-radius: 8px; display: inline-block; }
.qr svg { display: block; }
.steps-list .step { display: flex; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.steps-list .step select { max-width: 280px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; }
.kv div:nth-child(odd) { color: var(--muted); }
