:root {
  --bg: #0e1014;
  --bg-soft: #15181e;
  --card: #181c23;
  --card-hover: #1d222b;
  --border: #262c36;
  --border-soft: #20252e;
  --text: #e6e9ef;
  --text-dim: #9aa3b2;
  --text-faint: #5f6877;
  --accent: #4ade80;
  --accent-dim: #2faa5e;
  --danger: #f1675c;
  --warn: #f3c969;
  --blue: #6ea8fe;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: radial-gradient(1200px 600px at 80% -10%, #161b24 0%, var(--bg) 55%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--blue); text-decoration: none; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { max-width: 1040px; margin: 0 auto; padding: 28px 20px 80px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 26px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), var(--accent-dim));
  display: grid; place-items: center; color: #0c130d; font-weight: 800; font-size: 18px;
  box-shadow: 0 4px 16px rgba(74,222,128,.25);
}
.brand h1 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.brand .sub { font-size: 12px; color: var(--text-faint); }
.topbar .right { display: flex; align-items: center; gap: 10px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--text); font-weight: 550; font-size: 13.5px;
  transition: .15s; white-space: nowrap;
}
.btn:hover { background: var(--card-hover); border-color: #313845; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #08210f; }
.btn.primary:hover { background: #5dea8d; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: rgba(241,103,92,.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- server cards ---------- */
.servers { display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 22px 24px;
  transition: .15s; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 18px;
}
.card:hover { border-color: var(--border); background: var(--card-hover); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.card-name { min-width: 0; display: flex; align-items: center; gap: 10px; }
.card-name h3 { font-size: 17px; font-weight: 640; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.card .meta { color: var(--text-faint); font-size: 13px; display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.card .meta .msep b { color: var(--text); font-weight: 600; margin-left: 3px; }
.card .actions { display: flex; gap: 8px; align-items: center; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 100px;
  border: 1px solid var(--border); color: var(--text-dim); background: var(--bg-soft);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.badge.online { color: var(--accent); border-color: rgba(74,222,128,.3); background: rgba(74,222,128,.08); }
.badge.online .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.badge.starting { color: var(--warn); border-color: rgba(243,201,105,.3); background: rgba(243,201,105,.07); }
.badge.starting .dot { background: var(--warn); animation: pulse 1.1s infinite; }
.badge.stopped .dot { background: var(--text-faint); }
.badge.crashed, .badge.unhealthy, .badge.error { color: var(--danger); border-color: rgba(241,103,92,.3); background: rgba(241,103,92,.07); }
.badge.crashed .dot, .badge.unhealthy .dot, .badge.error .dot { background: var(--danger); }
.badge.kind { text-transform: capitalize; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-dim); }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 70px 20px; color: var(--text-faint); }
.empty .big { font-size: 40px; margin-bottom: 14px; opacity: .5; }
.empty p { margin-bottom: 18px; }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(6,8,11,.72); backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.modal {
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.modal.wide { max-width: 760px; }
.modal.console-modal { max-width: 1000px; }
.modal h2 { font-size: 17px; font-weight: 640; margin-bottom: 4px; }
.modal .desc { color: var(--text-faint); font-size: 13px; margin-bottom: 18px; }
.modal .close { position: absolute; }

.tabs { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 10px; margin-bottom: 18px; border: 1px solid var(--border-soft); }
.tabs button { flex: 1; padding: 8px; border-radius: 7px; color: var(--text-dim); font-weight: 550; font-size: 13px; transition: .15s; }
.tabs button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.3); }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; font-weight: 550; }
.field .hint { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border); color: var(--text); transition: .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgba(74,222,128,.12); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.filedrop {
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  padding: 26px; text-align: center; color: var(--text-faint); transition: .15s; cursor: pointer;
}
.filedrop:hover, .filedrop.drag { border-color: var(--accent-dim); color: var(--text-dim); background: rgba(74,222,128,.04); }
.filedrop b { color: var(--text); }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- cf search results ---------- */
.cf-results { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; margin-top: 6px; }
.cf-item { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); cursor: pointer; transition: .12s; }
.cf-item:hover { border-color: var(--accent-dim); background: var(--card); }
.cf-item.sel { border-color: var(--accent); background: rgba(74,222,128,.06); }
.cf-item img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--card); flex-shrink: 0; }
.cf-item .info { min-width: 0; }
.cf-item .info h4 { font-size: 14px; font-weight: 600; }
.cf-item .info p { font-size: 12px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- console ---------- */
.console-wrap { display: flex; flex-direction: column; height: 82vh; }
.console-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.console {
  flex: 1; background: #0a0c10; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; overflow-y: auto; font-family: var(--mono); font-size: 12.5px;
  line-height: 1.55; color: #c7cdd6; white-space: pre-wrap; word-break: break-word;
}
.console .warnln { color: var(--warn); }
.console .errln { color: var(--danger); }
.console .infoln { color: #c7cdd6; }
.console .sys { color: var(--accent); }
.cmd-row { display: flex; gap: 10px; margin-top: 12px; }
.cmd-row input { font-family: var(--mono); }

/* ---------- login ---------- */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px 26px; box-shadow: var(--shadow); }
.login-card .brand { justify-content: center; margin-bottom: 22px; flex-direction: column; text-align: center; gap: 10px; }
.login-card .logo { width: 46px; height: 46px; font-size: 24px; }

/* ---------- toast ---------- */
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; max-width: 340px; animation: slidein .2s; }
.toast.err { border-left-color: var(--danger); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

.spinner { width: 15px; height: 15px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 620px) {
  .card .row { flex-wrap: wrap; }
  .card .actions { width: 100%; justify-content: flex-end; }
  .two { grid-template-columns: 1fr; }
}
