/* tgkvm 2026-10-18: the admin site (admin.html, docs/16 section 23). Dark warm ground with a violet accent, so it is
   never mistaken for the console. The components (list + detail, dialogs, fields) are the console's (console.css),
   on the admin site's tokens. */
:root {
    color-scheme: dark;
    --bg: #17131a; --panel: #211b25; --panel2: #2a2230; --side: #1c1720; --line: #342b3b; --line2: #43384b;
    --text: #efe8f2; --text2: #b3a7ba; --text3: #7f7386; --hover: #2c2433; --sel: #31263d; --tip: #3d3146;
    --accent: #8f63e8; --accent-bg: rgba(167, 123, 243, .16); --link: #c9a8ff;
    --ok: #5fc48a; --warn: #e6b450; --bad: #f07070; --info: #6aa8f0;
    --warn-bg: rgba(230, 180, 80, .1); --warn-line: rgba(230, 180, 80, .4); --warn-text: #f0cf88;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans", "Noto Sans CJK SC", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--panel); }
.boot { color: var(--text3); padding: 40px; }
.mono { font-variant-numeric: tabular-nums; } code, pre, .mono.small { font-family: var(--mono); }
.muted { color: var(--text2); } .small { font-size: 12.5px; } .bad-text { color: var(--bad); font-weight: 600; }
h4 { margin: 16px 0 8px; font-size: 13px; color: var(--text2); }

/* ---------------------------------------------------------------- the shell */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50; display: flex; align-items: center; gap: 12px;
    padding: 9px 18px; background: #120f15; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .02em; }
.brand svg { color: var(--link); }
.brand em { font-style: normal; font-weight: 600; color: var(--link); background: var(--accent-bg); padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.top .sp { flex: 1; }
.top .who { color: var(--text2); font-size: 13px; }
.top .menu-btn { display: none; }
.layout { display: grid; grid-template-columns: 210px 1fr; min-height: calc(100vh - 51px); }
.side { border-right: 1px solid var(--line); padding: 12px 8px; background: var(--side); }
.side a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text2); text-decoration: none; margin-bottom: 1px; }
.side a:hover { background: var(--hover); color: var(--text); }
.side a.on { background: var(--accent-bg); color: var(--link); font-weight: 600; }
.side .grp { margin: 16px 10px 4px; font-size: 11px; color: var(--text3); letter-spacing: .08em; }
main { padding: 18px 22px 40px; min-width: 0; }
main > h1 { font-size: 20px; margin: 0 0 4px; }
.lead { color: var(--text2); margin: 0 0 14px; font-size: 13px; }

/* ---------------------------------------------------------------- cards, overview */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.card h3 { margin: 0 0 8px; font-size: 13px; color: var(--text2); font-weight: 600; }
.card b { display: block; font-size: 20px; margin-bottom: 6px; }
.card b.small { font-size: 15px; }
.card em { display: block; font-style: normal; color: var(--text2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.card em:empty { display: none; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; }
.panel h2 { font-size: 14px; margin: 0 0 10px; }
.todo { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.todo li { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--c, var(--warn)); border-radius: 8px; padding: 10px 14px; }
.todo li.ok { --c: var(--ok); color: var(--text2); } .todo li.bad { --c: var(--bad); }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 6px; }
.bar { flex: 1 1 0; max-width: 70px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; text-decoration: none; color: var(--text2); }
.bar i { width: 100%; max-width: 34px; border-radius: 4px 4px 0 0; background: var(--accent); }
.bar i.low { background: var(--warn); }
.bar:hover i { filter: brightness(1.2); }
.bar .v { font-size: 12px; color: var(--text); } .bar .l { font-size: 11px; }

/* ---------------------------------------------------------------- pieces (console.css) */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--line2); background: var(--panel2); color: var(--text); cursor: pointer; font-weight: 600; font-size: 13px; text-decoration: none; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--hover); border-color: var(--accent); } .btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; } .btn-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.12); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #1a0d0d; } .btn-danger:hover:not(:disabled) { filter: brightness(.92); background: var(--bad); }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.f { margin-bottom: 12px; } .f label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 4px; } .f .req { color: var(--bad); }
.f input, .f select, .f textarea, .modal input, .modal select { width: 100%; padding: 6px 10px; border: 1px solid var(--line2); border-radius: 10px; }
.f textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus, .modal input:focus, .modal select:focus, .md-card input:focus, .md-card select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.f input[readonly] { background: var(--bg); color: var(--text2); } .f .err { color: var(--bad); font-size: 12px; margin-top: 3px; } .f .hint, .hint { color: var(--text2); font-size: 12px; margin-top: 3px; }
input.bad { border-color: var(--bad) !important; }
label.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin: 4px 0; } label.chk input { width: auto; }
.checks { display: flex; flex-wrap: wrap; gap: 2px 14px; }
.chip { display: inline-block; font-size: 11.5px; border: 1px solid var(--line2); border-radius: 999px; padding: 0 8px; color: var(--text2); white-space: nowrap; vertical-align: 1px; }
.dot { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 12.5px; }
.dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text3); }
.dot-green::before { background: var(--ok); } .dot-amber::before { background: var(--warn); } .dot-red::before { background: var(--bad); } .dot-blue::before { background: var(--info); }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 999px; overflow: hidden; padding: 2px; gap: 2px; background: var(--panel); }
.seg button { border: 0; background: none; color: var(--text2); padding: 5px 15px; cursor: pointer; border-radius: 999px; } .seg button:hover:not(.on) { background: var(--hover); }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
.tabrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; } .tabrow .sp { flex: 1; }
.kv { display: grid; grid-template-columns: minmax(90px, max-content) 1fr; gap: 6px 14px; font-size: 13px; } .kv > span:nth-child(odd) { color: var(--text2); }
.kv + .f, .kv + p, .kv + h4 { margin-top: 14px; }
.mini { border: 0; background: none; color: var(--text2); cursor: pointer; padding: 2px 4px; border-radius: 4px; } .mini:hover { background: var(--hover); color: var(--text); }
.warn-box { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-text); border-radius: 10px; padding: 8px 12px; font-size: 13px; margin: 0 0 12px; }
.ok-box { background: rgba(95, 196, 138, .1); border: 1px solid rgba(95, 196, 138, .35); color: #9fe0ba; border-radius: 10px; padding: 6px 12px; font-size: 13px; margin: 0 0 12px; }
.note { background: var(--accent-bg); border: 1px solid rgba(167, 123, 243, .35); color: var(--text2); border-radius: 8px; padding: 10px 14px; font-size: 13px; }
.note.gap { margin-top: 14px; }
.pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.sq { display: inline-flex; gap: 2px; vertical-align: middle; }
.sq i { width: 7px; height: 13px; border-radius: 2px; background: var(--bad); }
.sq i.ok { background: var(--ok); }
.tbl-wrap { overflow-x: auto; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 8px; }
.mini-table th { text-align: left; color: var(--text2); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line2); white-space: nowrap; background: var(--panel2); }
.mini-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.mini-table tr.bad td, .mini-table tr.warn td:first-child { color: var(--warn-text); }
.mini-table input { width: 100%; min-width: 80px; padding: 3px 6px; border: 1px solid var(--line2); border-radius: 6px; font-size: 12.5px; }
.mini-table input[type=checkbox] { width: auto; min-width: 0; }
.pick-list { max-height: 260px; overflow: auto; border: 1px solid var(--line2); border-radius: 10px; padding: 4px 10px; margin-top: 6px; background: var(--bg); }
.pick-list label.chk { margin: 3px 0; }
.pk-q { width: 100%; }
.fail-item { border-left: 3px solid var(--bad); background: var(--bg); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; display: grid; gap: 3px; }
.mdview { font-size: 13px; } .mdview h3 { font-size: 16px; margin: 4px 0 10px; } .mdview h4 { font-size: 14px; color: var(--text); margin: 14px 0 6px; }
.mdview h5, .mdview h6 { font-size: 13px; margin: 12px 0 6px; } .mdview p { margin: 6px 0; } .mdview ul { margin: 6px 0; padding-left: 20px; }
.mdview li.sub { margin-left: 18px; color: var(--text2); font-size: 12px; } .mdview code { background: var(--bg); padding: 0 4px; border-radius: 4px; font-size: 12px; }
.mdview .md-table { width: auto; border-collapse: collapse; margin: 6px 0; } .mdview .md-table th, .mdview .md-table td { border: 1px solid var(--line2); padding: 4px 8px; text-align: left; }

/* ---------------------------------------------------------------- list + detail (md.js; console.css) */
.mdbox { min-height: 380px; }
.md { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; height: 100%; }
.md-bar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.md-sp { flex: 1; } .md-sep { width: 1px; height: 22px; background: var(--line2); margin: 0 6px; }
.md-ic { width: 34px; height: 32px; border: 0; background: none; border-radius: 9px; color: var(--text2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; position: relative; }
.md-ic svg { width: 18px; height: 18px; } .md-ic:hover:not(:disabled) { background: var(--hover); color: var(--text); } .md-ic.on { background: var(--accent-bg); color: var(--link); }
.md-ic:disabled { opacity: .3; cursor: not-allowed; } .md-ic.red { color: var(--bad); }
.md-ic[data-tip]:hover::after { content: attr(data-tip); position: absolute; top: 36px; left: 50%; transform: translateX(-50%); background: var(--tip); color: #fff; font-size: 12px; padding: 3px 9px; border-radius: 8px; white-space: nowrap; z-index: 300; pointer-events: none; }
.md-dirty { display: none; color: var(--warn); font-size: 12px; margin-right: 4px; } .md.dirty .md-dirty { display: inline; }
.md-colwrap { position: relative; display: inline-flex; }
.md-colmenu { position: absolute; top: 36px; left: 0; z-index: 310; background: var(--panel2); border: 1px solid var(--line2); border-radius: 12px; box-shadow: 0 12px 30px -8px rgba(0,0,0,.6); padding: 6px 0; min-width: 180px; }
.md-colmenu .h { font-size: 12px; color: var(--text2); padding: 4px 12px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; } .md-colmenu .h a { cursor: pointer; }
.md-colmenu label { display: flex; align-items: center; gap: 8px; padding: 5px 12px; cursor: pointer; white-space: nowrap; } .md-colmenu label:hover { background: var(--hover); }
.md-body { display: grid; flex: 1; min-height: 0; } .md-body > * { min-height: 0; }
.md-filter { border-right: 1px solid var(--line); padding: 10px; background: var(--bg); overflow: auto; } .md-filter .fb { margin-bottom: 10px; }
.md-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.md-card .t { display: flex; gap: 4px; align-items: center; } .md-card select, .md-card input { width: 100%; height: 28px; padding: 0 6px; border: 1px solid var(--line2); border-radius: 8px; font-size: 13px; }
.md-card .t select { width: auto; flex: 1; min-width: 0; }
.md-add { border: 1.5px dashed var(--line2); border-radius: 12px; text-align: center; padding: 6px; cursor: pointer; color: var(--text2); font-size: 18px; }
.md-list { overflow: auto; display: flex; flex-direction: column; min-width: 0; }
.md-list table { width: 100%; border-collapse: collapse; font-size: 13px; }
.md-list th { position: sticky; top: 0; z-index: 1; background: var(--panel2); text-align: left; font-size: 12px; font-weight: 600; color: var(--text2); padding: 9px 12px; border-bottom: 1px solid var(--line2); white-space: nowrap; cursor: pointer; user-select: none; }
.md-list th .arrow { margin-left: 4px; color: var(--text3); font-size: 10px; } .md-list th.asc .arrow, .md-list th.desc .arrow { color: var(--link); }
.md-list td { padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.md-list tbody tr { cursor: pointer; } .md-list tbody tr:hover td { background: var(--hover); }
.md-list tbody tr.sel td { background: var(--sel); } .md-list tbody tr.sel td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
.md-empty { color: var(--text2); text-align: center; padding: 40px 16px; }
.md-pg { position: sticky; bottom: 0; background: var(--panel); margin-top: auto; display: flex; justify-content: flex-end; align-items: center; gap: 6px; padding: 7px 10px; font-size: 12px; color: var(--text2); border-top: 1px solid var(--line); }
.md-pg select, .md-pg button { border: 1px solid var(--line2); background: var(--panel2); border-radius: 5px; padding: 1px 7px; color: var(--text); }
.md-split { cursor: col-resize; background: var(--line); } .md-split:hover { background: var(--accent); }
.md-detail { overflow: auto; display: flex; flex-direction: column; min-width: 0; border-left: 1px solid var(--line); }
.md-dh, .md-tabs { flex-shrink: 0; }
.md-dh { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.md-dh h4 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.md-back { display: none; }
.md-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 10px; overflow-x: auto; }
.md-tabs button { border: 0; background: none; padding: 9px 12px; color: var(--text2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.md-tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.md-pane { padding: 14px; }

/* ---------------------------------------------------------------- dialogs, toasts */
.modal-bg { position: fixed; inset: 0; z-index: 400; background: rgba(5, 2, 8, .6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; box-shadow: 0 30px 70px -20px rgba(0,0,0,.7); }
.modal.wide { max-width: 900px; } .modal h3 { margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 16px; }
.modal h4 { margin: 14px 0 6px; }
.modal-body { padding: 14px 18px; } .modal-body p { margin: 0 0 10px; } .modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
#toasts { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 500; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--tip); color: #fff; padding: 10px 18px; border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,.4); max-width: 520px; transition: opacity .3s; }
.toast.error { background: #9c3434; } .toast.out { opacity: 0; }

/* ---------------------------------------------------------------- sign-in */
.login { max-width: 400px; margin: 12vh auto; padding: 0 16px; text-align: center; }
.login .box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 30px 26px; }
.login svg.lock { color: var(--link); }
.login h1 { margin: 10px 0 6px; font-size: 20px; }
.login p { color: var(--text2); }
.login .btn { width: 100%; justify-content: center; margin-top: 14px; height: 42px; }
.login .err { color: var(--bad); min-height: 1.5em; margin: 10px 0 0; }
.login .hint { font-size: 12px; color: var(--text3); margin-top: 18px; text-align: left; }
.login code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; }

@media (max-width: 760px) {
    .layout { grid-template-columns: 1fr; }
    .side { display: none; border-right: 0; border-bottom: 1px solid var(--line); }
    .side.open { display: block; }
    .top .menu-btn { display: inline-flex; padding: 0 10px; }
    .top .who { display: none; }
    main { padding: 14px 16px 30px; }
    .md-body { grid-template-columns: 1fr !important; } .md-split { display: none; }
    .md-filter { position: fixed; left: 0; right: 0; bottom: 0; max-height: 70vh; z-index: 210; box-shadow: 0 -6px 20px rgba(0,0,0,.5); border-radius: 18px 18px 0 0; }
    .md-detail { position: fixed; inset: 51px 0 0 0; z-index: 205; background: var(--panel); display: none; border: 0; }
    .md.show-d .md-detail { display: flex; } .md-back { display: inline-flex; }
}
