:root {
  --bg: #0b1017;
  --panel: #111823;
  --panel2: #161f2c;
  --line: #222d3c;
  --text: #e6edf6;
  --muted: #8a97a8;
  --accent: #4f8cff;
  --green: #3ccf7a;
  --red: #ff5d5d;
  --yellow: #f5c451;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.brand { color: var(--text); font-weight: 700; font-size: 18px; }
.host { color: var(--muted); font-family: var(--mono); font-size: 13px; }
#logout { margin-left: auto; }
main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
h1 { font-size: 26px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 8px 14px; border-radius: 10px; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #33435a; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--red); border-color: #5a2a2a; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #2b4f8f; border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }

.login { max-width: 360px; margin: 80px auto; }
.error { color: var(--red); min-height: 20px; font-size: 14px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.st-running { color: var(--green); } .st-running .dot { background: var(--green); }
.st-restarting, .st-created { color: var(--yellow); } .st-restarting .dot, .st-created .dot { background: var(--yellow); }
.st-exited, .st-dead { color: var(--red); } .st-exited .dot, .st-dead .dot { background: var(--red); }
.st-not_created { color: var(--muted); }

.bots { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 20px; }
.bot-card { display: block; color: var(--text); }
.bot-card:hover { border-color: #33435a; }
.bot-card .name { font-size: 18px; font-weight: 700; }
.stats { display: flex; gap: 16px; margin-top: 12px; color: var(--muted); font-size: 14px; font-family: var(--mono); flex-wrap: wrap; }
.stats b { color: var(--text); font-weight: 600; }

.head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.head .actions { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0; overflow-x: auto; }
.tabs a { color: var(--muted); padding: 10px 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--accent); }

.console { background: #070b10; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.console-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 13px; }
.console-bar .tools { margin-left: auto; display: flex; gap: 6px; }
.log { height: 60vh; overflow: auto; padding: 10px 16px; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.log .ln { display: flex; gap: 12px; }
.log .ts { color: #4b5768; flex: none; user-select: none; }
.log .cmd { color: var(--accent); }
.log .sys { color: var(--yellow); }
.log.no-ts .ts { display: none; }
.console-input { display: flex; border-top: 1px solid var(--line); }
.console-input span { padding: 10px 0 10px 16px; color: var(--accent); font-family: var(--mono); }
.console-input input { border: 0; border-radius: 0; background: transparent; font-family: var(--mono); font-size: 13px; }
.console-input input:focus { outline: none; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td.size, th.size { text-align: right; width: 110px; }
td.mod { color: var(--muted); width: 170px; }
td.ops { width: 1%; white-space: nowrap; text-align: right; }
tr.file:hover td { background: var(--panel2); }
.fname { cursor: pointer; color: var(--text); }
.crumbs { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-family: var(--mono); }
.crumbs a { cursor: pointer; }
.drop { border: 2px dashed transparent; border-radius: 16px; }
.drop.over { border-color: var(--accent); }
textarea.editor { font-family: var(--mono); font-size: 13px; min-height: 60vh; resize: vertical; tab-size: 4; white-space: pre; }

.env-row { display: grid; grid-template-columns: minmax(140px, 1fr) 2fr auto auto; gap: 10px; margin-bottom: 10px; }
.env-row input { font-family: var(--mono); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.danger-zone { border-color: #5a2a2a; margin-top: 20px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
pre.out { background: #070b10; border: 1px solid var(--line); border-radius: 10px; padding: 10px; max-height: 300px; overflow: auto; font-size: 12px; white-space: pre-wrap; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal { width: 100%; max-width: 460px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 12px; z-index: 20; max-width: 90vw; }
.toast.err { border-color: var(--red); color: var(--red); }

@media (max-width: 640px) {
  main { padding: 16px; }
  .env-row { grid-template-columns: 1fr auto auto; }
  .env-row input:first-child { grid-column: 1 / -1; }
  td.mod, th.mod { display: none; }
  .log { height: 55vh; font-size: 12px; }
}
