:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --muted: #8b93a5;
  --accent: #4ade80;
  --accent-dark: #16a34a;
  --warn: #facc15;
  --danger: #f87171;
  --info: #60a5fa;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 28px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.error { color: var(--danger); margin: 0; }
.right { text-align: right; }
.spacer { flex: 1; }

/* Buttons and inputs */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: #3b4252; background: #252a35; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn.primary:hover { background: #15803d; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }

input:not([type=checkbox]), textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent-dark); }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.login-icon { width: 64px; height: 64px; margin: 0 auto 4px; image-rendering: pixelated; border-radius: 10px; }
.login-card p { margin: 0 0 8px; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 24px;
  background: rgba(15, 17, 21, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand img { width: 28px; height: 28px; image-rendering: pixelated; border-radius: 6px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }

.page { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* Cards */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 26px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-value .unit { font-size: 15px; color: var(--muted); font-weight: 400; }
.bar { height: 6px; background: var(--panel-2); border-radius: 3px; margin-top: 12px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .4s; }
.bar > div.warn { background: var(--warn); }
.bar > div.danger { background: var(--danger); }

.player-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.player { display: flex; align-items: center; gap: 6px; background: var(--panel-2); border-radius: 6px; padding: 3px 8px 3px 3px; font-size: 13px; }
.player img { width: 20px; height: 20px; border-radius: 3px; image-rendering: pixelated; }

.tps-good { color: var(--accent); }
.tps-ok { color: var(--warn); }
.tps-bad { color: var(--danger); }

.container-card { display: flex; flex-direction: column; gap: 12px; }
.container-title { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.running { background: var(--accent); box-shadow: 0 0 8px rgba(74, 222, 128, .6); }
.dot.restarting { background: var(--warn); }
.dot.exited, .dot.dead, .dot.missing { background: var(--danger); }
.container-meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13px; }
.container-meta dt { color: var(--muted); }
.container-meta dd { margin: 0; font-variant-numeric: tabular-nums; }
.container-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }

/* Console */
.console-head, .files-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.segmented { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button { background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.segmented button.active { background: var(--panel-2); color: var(--text); }
.check { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; }

.console {
  margin: 0;
  height: calc(100vh - 250px);
  min-height: 300px;
  overflow: auto;
  background: #0a0c0f;
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 12px 14px;
  font: 13px/1.5 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
}
.console .warn { color: var(--warn); }
.console .err { color: var(--danger); }
.console .cmd { color: var(--info); }
.console .reply { color: #c4b5fd; }
.console .time { color: #5b6476; }
.console-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 8px;
}
.console-input .prompt { font-family: var(--mono); color: var(--accent); padding-left: 6px; }
.console-input input { flex: 1; font-family: var(--mono); font-size: 14px; border: 0; background: transparent; }
.console-input.disabled { opacity: .5; }

/* Files */
.files-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 12px; font-family: var(--mono); font-size: 14px; }
.breadcrumb button { background: none; border: 0; color: var(--info); font: inherit; cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.breadcrumb button:hover { background: var(--panel-2); }
.breadcrumb span { color: var(--muted); }

.files-card { padding: 0; overflow: hidden; position: relative; }
.files { width: 100%; border-collapse: collapse; font-size: 14px; }
.files th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.files td { padding: 7px 14px; border-bottom: 1px solid #20242d; }
.files tr:last-child td { border-bottom: 0; }
.files tbody tr:hover { background: var(--panel-2); }
.files .name { display: flex; align-items: center; gap: 10px; cursor: pointer; word-break: break-all; }
.files .name:hover { color: var(--accent); }
.files .icon { width: 18px; text-align: center; flex: none; }
.files td.size, .files td.date { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.files td.actions { text-align: right; white-space: nowrap; }
.files td.actions .btn { margin-left: 4px; }
.files .empty { text-align: center; color: var(--muted); padding: 30px; }
.drop-hint { display: none; position: absolute; inset: 0; background: rgba(22, 163, 74, .15); border: 2px dashed var(--accent); border-radius: var(--radius); place-items: center; font-weight: 600; }
.files-card.dragging .drop-hint { display: grid; }
.upload-progress { margin-top: 12px; font-size: 13px; color: var(--muted); }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .6); display: grid; place-items: center; padding: 16px; }
.modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; width: 100%; }
.editor-box { max-width: 1100px; height: min(90vh, 900px); display: flex; flex-direction: column; padding: 14px; gap: 10px; }
.editor-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#editor-text { flex: 1; resize: none; font: 13px/1.5 var(--mono); tab-size: 2; white-space: pre; background: #0a0c0f; }
.editor-foot { margin: 0; }
.dialog-box { max-width: 420px; padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.dialog-box p { margin: 0; color: var(--muted); }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  max-width: min(420px, calc(100vw - 40px));
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.toast.error { border-left-color: var(--danger); }

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .tabs { order: 3; width: 100%; }
  .brand { flex: 1; }
  .page { padding: 16px; }
  .hide-mobile { display: none; }
  .files td { padding: 7px 10px; }
  .console { height: calc(100vh - 290px); }
}
