:root {
  --bg: #0f1412;
  --panel: #171f1b;
  --panel-2: #1e2823;
  --line: #2b3832;
  --text: #e4ebe6;
  --muted: #8fa198;
  --accent: #5fbf4a;
  --accent-ink: #0d1a09;
  --warn: #e5b94a;
  --danger: #e2574c;
  --info: #5aa9e6;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
a { color: var(--info); }
code, pre { font-family: var(--mono); }
h2, h3 { margin: 0 0 10px; font-weight: 650; }
h2 { font-size: 22px; }
h3 { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.error-text { color: var(--danger); min-height: 1.2em; margin: 4px 0 0; }
.center { text-align: center; margin-top: 10px; }

.block-icon { width: 30px; height: 30px; border-radius: 6px; flex: none; background:
  linear-gradient(#5fbf4a 0 36%, transparent 36%),
  linear-gradient(90deg, transparent 20%, #5fbf4a 20% 32%, transparent 32% 62%, #5fbf4a 62% 74%, transparent 74%) 0 36% / 100% 14% no-repeat,
  #7a5a33; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { display: block; font-size: 16px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; }

.sticky-head { position: sticky; top: 0; z-index: 5; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar .brand { margin-right: auto; }
.tabs { display: flex; gap: 4px; padding: 8px 16px; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--panel); scrollbar-width: thin; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 8px; cursor: pointer; font: inherit; white-space: nowrap; }
.tabs button:hover { color: var(--text); background: var(--panel-2); }
.tabs button.active { color: var(--accent-ink); background: var(--accent); font-weight: 600; }
main { padding: 18px 20px 40px; max-width: 1200px; margin: 0 auto; }

.banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: var(--radius); background: #3a3214; border: 1px solid #6b5a1e; color: #f4dfa0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.error { background: #3a1916; border-color: #7a2c25; color: #f7c4bf; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--panel-2); border: 1px dashed var(--line); margin-bottom: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid > .card { margin-bottom: 0; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 16px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.row-between.wrap { flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; }
.btn:hover:not(:disabled) { border-color: #48594f; background: #24302a; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: #6fd15a; }
.btn.danger { background: transparent; border-color: #7a2c25; color: #f39a92; }
.btn.danger:hover:not(:disabled) { background: #3a1916; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.tiny { padding: 2px 8px; font-size: 12px; border-radius: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions.end { justify-content: flex-end; }

input, select, textarea { font: inherit; color: var(--text); background: #0c110f; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(95,191,74,.45); border-color: var(--accent); }
textarea { font-family: var(--mono); font-size: 13px; resize: vertical; }
label { display: grid; gap: 5px; align-content: start; font-size: 14px; color: var(--muted); }
label small { font-size: 12px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 200px; width: auto; }
.inline-form select { width: auto; flex: 0 0 auto; }

.pill { padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); }
.pill.running { background: rgba(95,191,74,.15); color: #8be07a; border-color: rgba(95,191,74,.4); }
.pill.starting, .pill.stopping { background: rgba(229,185,74,.12); color: var(--warn); border-color: rgba(229,185,74,.4); }
.pill.error { background: rgba(226,87,76,.14); color: #f39a92; border-color: rgba(226,87,76,.4); }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); font-weight: 600; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.tag.warn { color: var(--warn); border-color: rgba(229,185,74,.4); }
.tag.ok { color: #8be07a; border-color: rgba(95,191,74,.4); }

.status-card .status-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.dot { width: 16px; height: 16px; border-radius: 50%; background: #55625b; margin-top: 6px; flex: none; }
.dot.running { background: var(--accent); box-shadow: 0 0 0 5px rgba(95,191,74,.18); }
.dot.starting, .dot.stopping { background: var(--warn); animation: pulse 1.2s infinite; }
.dot.error { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }
.operation { margin: 12px 0 0; color: var(--warn); font-size: 14px; }
.operation::before { content: ""; display: inline-block; width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; margin-right: 8px; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
#status-detail { margin: 2px 0 0; word-break: break-word; }

.address-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.address-row code { font-size: 18px; padding: 8px 12px; background: #0c110f; border: 1px solid var(--line); border-radius: 8px; flex: 1; overflow-x: auto; white-space: nowrap; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0 0; font-size: 14px; }
.facts.wide { grid-template-columns: repeat(4, auto 1fr); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-all; }

.metric { display: grid; gap: 6px; }
.metric strong { font-size: 26px; font-weight: 650; }
.bar { height: 6px; border-radius: 6px; background: var(--panel-2); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.bar span.high { background: var(--warn); }

.console-card { display: grid; gap: 10px; }
.console-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.console-tools input { flex: 1 1 200px; width: auto; }
.log { margin: 0; height: min(62vh, 640px); overflow: auto; background: #070a09; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.log .l-warn { color: var(--warn); }
.log .l-error { color: #ff8a80; }
.log .l-join { color: #8be07a; }
.log .l-leave { color: #9db0a6; }
.log .l-panel { color: var(--info); }
.log .l-cmd { color: #c9a8ff; }
.console-input { display: flex; gap: 8px; align-items: center; }
.console-input .prompt { font-family: var(--mono); color: var(--accent); font-size: 18px; }
.console-input input { font-family: var(--mono); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { font: 12px var(--mono); padding: 4px 9px; border-radius: 6px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); cursor: pointer; }
.quick button:hover { color: var(--text); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.list li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--panel-2); border-radius: 8px; min-width: 0; }
.list li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.list li.empty { background: none; color: var(--muted); padding-left: 0; }
.list li img, .result img { width: 34px; height: 34px; border-radius: 7px; background: #0c110f; flex: none; object-fit: cover; }
.head { width: 22px; height: 22px; border-radius: 4px; image-rendering: pixelated; flex: none; }
.mods li .grow small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin-top: 12px; }
.result { display: flex; gap: 10px; padding: 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; min-width: 0; }
.result .body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.result .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .title a { color: var(--text); text-decoration: none; }
.result .desc { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.result .meta .btn { margin-left: auto; }

.crumbs { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; font-family: var(--mono); font-size: 14px; }
.crumbs button { background: none; border: 0; color: var(--info); cursor: pointer; font: inherit; padding: 2px 4px; border-radius: 4px; }
.crumbs button:hover { background: var(--panel-2); }
table.files { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; table-layout: fixed; }
table.files th { text-align: left; color: var(--muted); font-weight: 500; font-size: 13px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.files td { padding: 7px 8px; border-bottom: 1px solid #1f2a25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.files th:first-child { width: 50%; }
table.files th:last-child { width: 190px; }
table.files tr:hover td { background: #1a231f; }
table.files .num { text-align: right; width: 90px; }
table.files .hide-sm { width: 150px; }
table.files td.ops { text-align: right; }
table.files td.ops .btn { margin-left: 4px; }
.fname { background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; padding: 0; text-align: left; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.fname.dir { color: var(--info); font-weight: 550; }
.fname.dir::before { content: "▸ "; color: var(--muted); }
.progress { height: 6px; background: var(--panel-2); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 100%; width: 0; background: var(--info); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.sticky-actions { position: sticky; bottom: 0; display: flex; gap: 8px; justify-content: flex-end; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 35%); z-index: 3; }
.danger-zone { border-color: #5a2520; }

.editor { width: min(1000px, 96vw); max-width: none; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); }
.editor::backdrop { background: rgba(0,0,0,.6); }
.editor-inner { display: grid; gap: 10px; padding: 14px; }
.editor textarea { height: 65vh; white-space: pre; overflow: auto; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-radius: 9px; background: #22302a; border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0,0,0,.35); font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.toast.error { background: #3a1916; border-color: #7a2c25; }
.toast.ok { border-color: rgba(95,191,74,.5); }

@media (max-width: 860px) {
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .facts.wide { grid-template-columns: auto 1fr; }
}
@media (max-width: 640px) {
  main { padding: 12px 12px 32px; }
  .topbar { padding: 10px 12px; }
  .tabs { padding: 6px 8px; }
  .banner { margin: 10px 12px 0; }
  .hide-sm { display: none; }
  table.files th:last-child { width: 120px; }
  table.files .num { width: 70px; }
  .address-row code { font-size: 15px; }
  .btn { padding: 8px 12px; }
}
