:root {
  --bg-base: #070b14;
  --bg-panel: #0d1424;
  --bg-panel-raised: #0f1729;
  --border: #1c2740;
  --border-bright: #2a3a5c;
  --text-primary: #eef2fb;
  --text-dim: #93a0bd;
  --text-dimmer: #5c6889;

  --amber: #2f6bff;
  --amber-dim: #1c4fd6;
  --cyan: #3fd0ff;
  --green: #33e07a;
  --red: #ff5c72;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  height: 100%;
}

::selection { background: var(--amber); color: #100b00; }

/* subtle CRT scanline texture over everything */
.scanlines {
  display: none;
}

/* ---------- LEDs (signature element) ---------- */
.led {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3a3f47;
  box-shadow: inset 0 0 2px rgba(0,0,0,0.6);
  position: relative;
  flex-shrink: 0;
}
.led-green {
  background: var(--green);
  box-shadow: 0 0 6px 2px rgba(53, 208, 127, 0.55), inset 0 0 2px rgba(0,0,0,0.3);
}
.led-red {
  background: var(--red);
  box-shadow: 0 0 6px 2px rgba(255, 76, 76, 0.5), inset 0 0 2px rgba(0,0,0,0.3);
}
.led-amber {
  background: var(--amber);
  box-shadow: 0 0 6px 2px rgba(47, 107, 255, 0.5), inset 0 0 2px rgba(0,0,0,0.3);
}
.led-off { background: #3a3f47; box-shadow: none; }
.led.pulsing { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------- Layout ---------- */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.5px;
}
.accent-amber { color: var(--amber); }
.accent-cyan { color: var(--cyan); }

.brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--text-dim);
  margin-top: 2px;
  margin-bottom: 28px;
}

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.nav-item.active {
  background: var(--bg-panel-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-bright);
}
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.fleet-summary { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); display: flex; flex-direction: column; gap: 6px; }
.fs-row { display: flex; align-items: center; gap: 8px; }

.main { display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; padding: 32px 40px; max-width: 100%; }

.topbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 28px; }
.page-title { font-family: var(--font-display); font-size: 32px; font-weight: 600; margin: 0; letter-spacing: 0.3px; }
.page-sub { color: var(--text-dim); margin: 4px 0 0; font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  border-radius: 6px;
  padding: 10px 16px;
  border: 1px solid var(--border-bright);
  background: var(--bg-panel-raised);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { border-color: var(--amber); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn-primary { background: linear-gradient(135deg, var(--amber), var(--amber-dim)); color: #fff; border-color: transparent; box-shadow: 0 8px 24px -8px rgba(47,107,255,.6); }
.btn-primary:hover { box-shadow: 0 10px 28px -6px rgba(47,107,255,.75); }
.btn-ghost { background: transparent; }
.btn-go { border-color: var(--green); color: var(--green); }
.btn-go:hover { background: rgba(53,208,127,0.1); }
.btn-stop { border-color: var(--red); color: var(--red); }
.btn-stop:hover { background: rgba(255,76,76,0.1); }
.btn-danger { border-color: var(--red); color: var(--red); margin-left: auto; }
.btn-block { width: 100%; }

/* ---------- Server grid ---------- */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.server-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
  position: relative;
}
.server-card:hover { border-color: var(--border-bright); transform: translateY(-2px); }
.server-card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.server-card-icon {
  width: 30px; height: 30px; border-radius: 7px; flex-shrink: 0;
  object-fit: cover; background: var(--bg-panel-raised); border: 1px solid var(--border);
}
.server-card-icon-fallback {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 11px; color: var(--text-dim);
}
.server-card-name { font-family: var(--font-display); font-size: 20px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.server-card-game {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-dim);
  text-transform: uppercase;
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: auto;
  flex-shrink: 0;
}
.server-card-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  gap: 16px;
  margin-top: 12px;
}
.server-card-meta b { color: var(--text-primary); font-weight: 500; }

.empty-state { text-align: center; padding: 80px 20px; color: var(--text-dim); }
.empty-title { font-family: var(--font-display); font-size: 22px; color: var(--text-primary); margin-bottom: 6px; }
.empty-sub { font-size: 13px; }

/* ---------- Detail view ---------- */
.detail-header { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.detail-title-row { display: flex; align-items: center; gap: 12px; }
.detail-title-row h2 { font-family: var(--font-display); font-weight: 600; font-size: 26px; margin: 0; }
.tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cyan);
  border: 1px solid var(--cyan);
  border-radius: 4px;
  padding: 2px 8px;
}
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.stat-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 1px; color: var(--text-dim); text-transform: uppercase; }
.stat-value { font-family: var(--font-mono); font-size: 26px; margin-top: 6px; color: var(--amber); }
.stat-unit { font-size: 14px; color: var(--text-dim); margin-left: 2px; }

.console-panel {
  background: #0a0c0e;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 380px;
}
.console-header {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}
.console-title { font-family: var(--font-mono); font-size: 11px; letter-spacing: 2px; color: var(--amber); }
.console-hint { font-family: var(--font-mono); font-size: 11px; color: var(--text-dimmer); }
.console-output {
  flex: 1;
  padding: 14px 16px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: #c9e8d0;
  white-space: pre-wrap;
  word-break: break-word;
}
.console-line-panel { color: var(--amber); }
.console-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  background: var(--bg-panel);
}
.console-prompt { color: var(--amber); font-family: var(--font-mono); }
.console-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ---------- Forms ---------- */
.field-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 14px 0 6px;
}
.field-input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-bright);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
}
.field-input:focus { outline: none; border-color: var(--amber); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-checkbox { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 13px; color: var(--text-dim); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,6,8,0.75);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  padding: 28px;
  width: 460px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
}
.modal-title { font-family: var(--font-display); font-size: 22px; margin: 0 0 4px; }
.modal-hint { font-size: 12px; color: var(--text-dim); margin-top: 16px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- Login page ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: radial-gradient(circle at 50% 20%, #171b21 0%, var(--bg-base) 65%);
}
.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  padding: 40px;
  width: 380px;
}
.login-led-row { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.login-eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: 2px; color: var(--text-dim); }
.login-title { font-family: var(--font-display); font-size: 38px; margin: 0; font-weight: 700; }
.login-sub { color: var(--text-dim); font-size: 13px; margin: 6px 0 6px; }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ---------- Suspension / billing states ---------- */
.server-card.is-suspended { border-color: rgba(255,76,76,0.4); }
.expiry-warn { color: var(--amber); font-weight: 600; }
.expiry-bad { color: var(--red); font-weight: 600; }

.suspended-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,76,76,0.08);
  border: 1px solid rgba(255,76,76,0.35);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: #ffb3b3;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--border-bright); }

.tag-owner { color: var(--text-dim); border-color: var(--border-bright); }
.tag-admin { color: var(--amber); border-color: var(--amber); }
.tag-staff { color: var(--cyan); border-color: var(--cyan); }

#renewWrap { display: inline-flex; gap: 6px; align-items: center; }
#renewDays { cursor: pointer; padding: 10px 10px; }

.whoami {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dimmer);
  text-transform: lowercase;
}

/* ---------- Users & Billing table ---------- */
.users-toolbar { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.users-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.users-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel-raised);
}
.users-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.users-table tr:last-child td { border-bottom: none; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.text-dim { color: var(--text-dimmer); }

.badge-count {
  background: var(--amber);
  color: #1a1200;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 7px;
  margin-left: auto;
}

.settings-view { display: flex; flex-direction: column; gap: 20px; max-width: 480px; }
.settings-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
}

.modal-wide { width: 640px; }

/* ---------- Support tickets ---------- */
.ticket-list { display: flex; flex-direction: column; gap: 10px; }
.ticket-card {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.ticket-card:hover { border-color: var(--border-bright); background: var(--bg-panel-raised); }
.ticket-card-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-panel-raised); border: 1px solid var(--border-bright);
  font-family: var(--font-display); font-weight: 600; font-size: 14px; color: var(--text-dim);
}
.ticket-card-body { flex: 1; min-width: 0; }
.ticket-card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 3px; }
.ticket-card-subject { font-weight: 600; font-size: 14.5px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-card-from { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }
.ticket-card-preview { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-card-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin-left: auto; padding-left: 12px; }
.ticket-card-time { font-size: 11.5px; color: var(--text-dimmer); font-family: var(--font-mono); white-space: nowrap; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; padding: 3px 9px; border-radius: 20px; }
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.status-pill-open { background: rgba(53, 208, 127, 0.12); color: var(--green); }
.status-pill-open::before { background: var(--green); }
.status-pill-closed { background: rgba(122, 130, 144, 0.15); color: var(--text-dim); }
.status-pill-closed::before { background: var(--text-dimmer); }
.empty-tickets { text-align: center; padding: 40px 20px; color: var(--text-dim); font-size: 14px; }

.ticket-thread-panel {
  background: var(--bg-base); border: 1px solid var(--border); border-radius: 10px;
  display: flex; flex-direction: column; height: 360px; overflow: hidden;
}
.ticket-thread-scroll { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 4px; }
.ticket-msg-row { display: flex; gap: 10px; max-width: 82%; margin-bottom: 12px; }
.ticket-msg-row.from-me { flex-direction: row-reverse; margin-left: auto; }
.ticket-msg-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 11.5px;
}
.ticket-msg-row.role-admin .ticket-msg-avatar { background: rgba(47, 107, 255, 0.15); color: var(--amber); }
.ticket-msg-row.role-customer .ticket-msg-avatar { background: rgba(63, 208, 255, 0.15); color: var(--cyan); }
.ticket-msg-content { min-width: 0; }
.ticket-msg-bubble {
  padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; background: var(--bg-panel-raised); border: 1px solid var(--border);
}
.ticket-msg-row.from-me .ticket-msg-bubble { background: rgba(47, 107, 255, 0.1); border-color: var(--amber-dim); }
.ticket-msg-meta { font-size: 10.5px; color: var(--text-dimmer); margin: 3px 3px 0; font-family: var(--font-mono); }
.ticket-msg-row.from-me .ticket-msg-meta { text-align: right; }

.ticket-compose { display: flex; gap: 10px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--border); background: var(--bg-panel); }
.ticket-compose textarea { flex: 1; margin: 0; resize: none; min-height: 40px; max-height: 120px; }
.ticket-compose .btn { flex-shrink: 0; }

/* ---------- Structured config editor ---------- */
.cfg-field-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 12px 4px; border-bottom: 1px solid var(--border); }
.cfg-field-row:last-child { border-bottom: none; }
.cfg-field-info { flex: 1; min-width: 0; }
.cfg-field-label { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.cfg-field-hint { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.cfg-field-control { flex-shrink: 0; width: 220px; }
.cfg-field-control .field-input { margin: 0; }
.cfg-toggle { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.cfg-toggle input { opacity: 0; width: 0; height: 0; }
.cfg-toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--bg-panel-raised); border: 1px solid var(--border-bright); border-radius: 22px; transition: .15s; }
.cfg-toggle-slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: var(--text-dim); border-radius: 50%; transition: .15s; }
.cfg-toggle input:checked + .cfg-toggle-slider { background: rgba(47,107,255,.18); border-color: var(--amber-dim); }
.cfg-toggle input:checked + .cfg-toggle-slider::before { transform: translateX(18px); background: var(--amber); }
.cfg-field-unset { font-size: 10.5px; color: var(--text-dimmer); font-family: var(--font-mono); margin-top: 3px; }

.file-toolbar { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
.file-path { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); flex: 1; overflow-x: auto; white-space: nowrap; }
.file-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.file-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; cursor: pointer;
}
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--bg-panel-raised); }
.file-row .file-name { flex: 1; }
.file-row .file-size { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.file-row .file-actions { display: flex; gap: 6px; }
.file-editor {
  width: 100%; min-height: 260px; background: #0a0c0e; border: 1px solid var(--border-bright);
  border-radius: 6px; color: var(--text-primary); font-family: var(--font-mono); font-size: 13px;
  padding: 12px; margin-top: 10px; resize: vertical;
}
.mod-card {
  border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px;
  margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 14px;
}
.mod-card-name { font-family: var(--font-display); font-size: 17px; }
.mod-card-desc { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    display: flex;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 250px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 210;
    box-shadow: 4px 0 28px rgba(0,0,0,.5);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .mobile-nav-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(4,5,8,.6);
    z-index: 200;
  }
  .mobile-nav-backdrop.open { display: block; }
  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: 6px;
    border: 1px solid var(--border-bright);
    background: var(--bg-panel-raised);
    color: var(--text-primary);
    margin-right: 12px;
    flex-shrink: 0;
    cursor: pointer;
  }
  .topbar { align-items: center; flex-wrap: wrap; gap: 12px; }
  .topbar-title-row { display: flex; align-items: center; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 20px 16px; }
  .detail-actions .btn { padding: 8px 12px; font-size: 13px; }
  .detail-actions select.btn { padding: 8px 10px; }
}
@media (max-width: 420px) {
  .detail-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 21px; }
}
@media (min-width: 801px) {
  .mobile-nav-toggle, .mobile-nav-backdrop { display: none; }
}
