:root {
  --bg: #0b0f14;
  --bg-soft: #111820;
  --panel: #131c26;
  --panel-2: #18232f;
  --border: #24323f;
  --border-soft: #1b2733;
  --text: #dbe6f0;
  --text-dim: #8ba0b4;
  --text-faint: #5f7284;
  --accent: #35d399;
  --accent-dim: #1f8f68;
  --blue: #4aa8ff;
  --amber: #f2b544;
  --red: #f2585b;
  --violet: #a980ff;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ------------------------------------------------------------------ layout */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  height: 54px;
  background: linear-gradient(180deg, #121a23, #0d141b);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(53, 211, 153, 0.7);
}

.brand small {
  color: var(--text-faint);
  font-weight: 500;
  font-size: 11.5px;
  margin-left: 2px;
}

.topbar .spacer { flex: 1; }

.topbar .meta {
  display: flex;
  gap: 16px;
  color: var(--text-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

nav.tabs {
  display: flex;
  gap: 2px;
  padding: 0 10px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  position: sticky;
  top: 54px;
  z-index: 39;
}

nav.tabs button {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

nav.tabs button:hover { color: var(--text); }
nav.tabs button[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

main { padding: 18px; max-width: 1500px; margin: 0 auto; }

section.tab { display: none; }
section.tab.active { display: block; }

/* ------------------------------------------------------------------ pieces */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.card h3 {
  margin: 0 0 12px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  font-weight: 650;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.big {
  font-size: 30px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.big .unit { font-size: 15px; color: var(--text-faint); font-weight: 500; margin-left: 3px; }

.sub { color: var(--text-dim); font-size: 12px; margin-top: 3px; }

.bar {
  height: 6px;
  border-radius: 99px;
  background: #1d2a37;
  overflow: hidden;
  margin-top: 11px;
}

.bar > i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.4s ease;
}

.bar.warn > i { background: var(--amber); }
.bar.crit > i { background: var(--red); }

.row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border-soft); }
.row:last-child { border-bottom: none; }
.row .k { color: var(--text-dim); }
.row .v { font-variant-numeric: tabular-nums; text-align: right; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge.running, .badge.up { color: var(--accent); background: rgba(53, 211, 153, 0.1); border-color: rgba(53, 211, 153, 0.28); }
.badge.exited, .badge.down { color: var(--red); background: rgba(242, 88, 91, 0.1); border-color: rgba(242, 88, 91, 0.28); }
.badge.paused, .badge.warn { color: var(--amber); background: rgba(242, 181, 68, 0.1); border-color: rgba(242, 181, 68, 0.28); }
.badge.created, .badge.unknown { color: var(--text-dim); background: rgba(139, 160, 180, 0.09); border-color: rgba(139, 160, 180, 0.22); }
.badge.restarting { color: var(--violet); background: rgba(169, 128, 255, 0.1); border-color: rgba(169, 128, 255, 0.28); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  font-weight: 650;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

tbody tr:hover { background: rgba(255, 255, 255, 0.018); }
td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }

button.btn, a.btn {
  appearance: none;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 550;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

button.btn:hover, a.btn:hover { border-color: #33465a; background: #1c2937; text-decoration: none; }
button.btn:disabled { opacity: 0.45; cursor: not-allowed; }
button.btn.primary { background: var(--accent-dim); border-color: var(--accent-dim); color: #04120c; }
button.btn.primary:hover { background: var(--accent); }
button.btn.danger { color: var(--red); border-color: rgba(242, 88, 91, 0.35); }
button.btn.danger:hover { background: rgba(242, 88, 91, 0.12); }
button.btn.ghost { background: transparent; }
button.btn.sm { padding: 3px 8px; font-size: 11.5px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar h2 { margin: 0; font-size: 15px; font-weight: 600; }
.toolbar .spacer { flex: 1; }

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.err { color: var(--red); }
.ok { color: var(--accent); }

input[type="text"], input[type="password"], input[type="search"], select {
  font-family: inherit;
  font-size: 13px;
  background: #0d151d;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 7px 10px;
  outline: none;
  min-width: 0;
}

input:focus, select:focus { border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgba(53, 211, 153, 0.1); }

.spark { display: block; }

.empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

.notice {
  border: 1px solid rgba(242, 181, 68, 0.3);
  background: rgba(242, 181, 68, 0.07);
  color: #f0c675;
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

.notice.bad { border-color: rgba(242, 88, 91, 0.35); background: rgba(242, 88, 91, 0.07); color: #ff9b9d; }

/* ------------------------------------------------------------------ modal */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 12, 0.72);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.overlay.open { display: flex; }

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(1000px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.modal header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.modal header h3 { margin: 0; font-size: 14px; font-weight: 600; }
.modal header .spacer { flex: 1; }

.modal .body {
  padding: 0;
  overflow: auto;
  flex: 1;
}

.logs {
  margin: 0;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c3d2e0;
  background: #0a1118;
  min-height: 300px;
}

.preview {
  margin: 0;
  padding: 14px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c3d2e0;
  background: #0a1118;
}

/* ------------------------------------------------------------------ files */

.crumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 12.5px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  color: var(--text-dim);
}

.crumbs a { color: var(--text-dim); }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { color: var(--text-faint); }

tr.dir td:first-child a { color: var(--blue); }
tr.file td:first-child { color: var(--text); }

/* ------------------------------------------------------------------ terminal */

#term-wrap {
  background: #05090d;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  height: calc(100vh - 210px);
  min-height: 340px;
}

#term { width: 100%; height: 100%; }

/* ------------------------------------------------------------------ login */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1000px 600px at 50% -10%, #16302a 0%, #0b0f14 55%);
}

.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.login-card h1 {
  font-size: 17px;
  margin: 0 0 4px;
  font-weight: 650;
}

.login-card p.sub { margin: 0 0 20px; }

.field { margin-bottom: 13px; }
.field label {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 5px;
  font-weight: 600;
}

.field input { width: 100%; }

.login-card button { width: 100%; justify-content: center; padding: 9px; margin-top: 6px; }

.login-error {
  color: var(--red);
  font-size: 12.5px;
  min-height: 18px;
  margin-top: 10px;
}

.hidden { display: none !important; }
