:root {
  --bg-dark: #0d0f14;
  --bg-panel: #161920;
  --bg-card: #1e2230;
  --bg-hover: #252a3a;
  --accent: #e8420a;
  --accent-dim: #b33208;
  --accent-glow: rgba(232,66,10,0.15);
  --green: #2ecc71;
  --yellow: #f1c40f;
  --red: #e74c3c;
  --blue: #3498db;
  --text: #e2e8f0;
  --text-dim: #8892a4;
  --border: #2a2f3e;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

/* LOGIN */
#login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #1a1f2e 0%, #0d0f14 100%);
  z-index: 1000;
}
.login-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo img { height: 60px; margin-bottom: 12px; }
.login-logo h1 { font-size: 1.6rem; color: var(--accent); }
.login-box input {
  width: 100%; padding: 12px 16px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 0.95rem;
  margin-bottom: 12px; transition: border-color 0.2s;
}
.login-box input:focus { outline: none; border-color: var(--accent); }
.login-box button {
  width: 100%; padding: 12px;
  background: var(--accent); border: none; border-radius: 8px;
  color: white; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: background 0.2s;
}
.login-box button:hover { background: var(--accent-dim); }
.login-box button:disabled { opacity: 0.7; cursor: not-allowed; }
#login-error { color: var(--red); text-align: center; margin-top: 12px; font-size: 0.9rem; }

/* LAYOUT */
#main-panel { display: flex; height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
.sidebar-logo {
  padding: 20px 24px;
  font-size: 1.4rem; font-weight: 800;
  border-bottom: 1px solid var(--border);
}
.logo-fox { color: var(--accent); }
.logo-rust { color: var(--text); }

nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; color: var(--text-dim);
  cursor: pointer; transition: all 0.2s;
  font-size: 0.9rem; user-select: none;
  position: relative; text-decoration: none;
}
.nav-item svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); border-right: 3px solid var(--accent); }
.badge {
  position: absolute; right: 14px;
  background: var(--red); color: white;
  font-size: 0.7rem; font-weight: 700;
  padding: 2px 6px; border-radius: 10px;
}

.sidebar-footer {
  padding: 16px; border-top: 1px solid var(--border);
}
.server-status { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 0.85rem; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); flex-shrink: 0;
  box-shadow: 0 0 6px var(--red);
  transition: background 0.3s, box-shadow 0.3s;
}
.status-dot.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }
.logout-btn {
  width: 100%; padding: 8px;
  background: transparent; border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-dim);
  cursor: pointer; font-size: 0.85rem; transition: all 0.2s;
}
.logout-btn:hover { border-color: var(--red); color: var(--red); }

/* CONTENT */
.content {
  flex: 1; overflow-y: auto;
  background: var(--bg-dark); padding: 0;
}
.tab-content { display: none; padding: 28px; animation: fadeIn 0.2s; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 1.4rem; font-weight: 700; }
.header-actions { display: flex; gap: 12px; align-items: center; }
.server-time { color: var(--text-dim); font-size: 0.9rem; }

/* BUTTONS */
.btn-primary { background: var(--blue); border: none; border-radius: 6px; color: white; padding: 8px 16px; cursor: pointer; font-size: 0.85rem; transition: opacity 0.2s; }
.btn-success { background: var(--green); border: none; border-radius: 6px; color: #111; padding: 8px 16px; cursor: pointer; font-size: 0.85rem; font-weight: 600; transition: opacity 0.2s; }
.btn-danger { background: var(--red); border: none; border-radius: 6px; color: white; padding: 8px 16px; cursor: pointer; font-size: 0.85rem; transition: opacity 0.2s; }
.btn-warn { background: var(--yellow); border: none; border-radius: 6px; color: #111; padding: 6px 12px; cursor: pointer; font-size: 0.8rem; font-weight: 600; }
button:hover { opacity: 0.85; }

/* STATS CARDS */
.stats-cards {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--accent); }
.stat-icon { font-size: 2rem; }
.stat-value { font-size: 1.6rem; font-weight: 800; display: block; }
.stat-label { font-size: 0.8rem; color: var(--text-dim); }

/* DASH GRID */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px;
}
.dash-panel h3 { font-size: 0.95rem; color: var(--text-dim); margin-bottom: 14px; text-transform: uppercase; letter-spacing: 0.05em; }
.mini-log { height: 200px; overflow-y: auto; font-size: 0.82rem; }
.quick-cmds { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-cmds button {
  background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: 10px;
  cursor: pointer; font-size: 0.85rem; transition: all 0.2s;
}
.quick-cmds button:hover { border-color: var(--accent); color: var(--accent); }

/* TABLE */
.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th {
  background: var(--bg-card); color: var(--text-dim);
  padding: 12px 16px; text-align: left;
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.player-name { font-weight: 600; }
.player-actions { display: flex; gap: 6px; }
.ping-good { color: var(--green); }
.ping-ok { color: var(--yellow); }
.ping-bad { color: var(--red); }

/* SEARCH */
#player-search {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: 8px 14px;
  font-size: 0.88rem; width: 220px;
}
#player-search:focus { outline: none; border-color: var(--accent); }

/* CHAT */
.chat-log {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
  height: calc(100vh - 240px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.chat-msg { padding: 6px 10px; border-radius: 6px; font-size: 0.88rem; }
.chat-msg:hover { background: var(--bg-hover); }
.chat-name { color: var(--accent); font-weight: 600; margin-right: 8px; }
.chat-server { color: var(--yellow); font-weight: 600; margin-right: 8px; }
.chat-time { color: var(--text-dim); font-size: 0.75rem; margin-right: 8px; }
.chat-input-bar {
  display: flex; gap: 10px; margin-top: 14px;
}
.chat-input-bar input {
  flex: 1; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 12px 16px; font-size: 0.9rem;
}
.chat-input-bar input:focus { outline: none; border-color: var(--accent); }
.chat-input-bar button { background: var(--accent); border: none; border-radius: 8px; color: white; padding: 12px 24px; cursor: pointer; font-weight: 600; }

/* CONSOLE */
.console-log {
  background: #0a0c10; border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
  height: calc(100vh - 240px); overflow-y: auto;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.82rem; line-height: 1.6;
}
.console-line { color: #a0aab4; padding: 1px 0; }
.console-line.error { color: var(--red); }
.console-line.warn { color: var(--yellow); }
.console-line.info { color: var(--green); }
.console-line.cmd { color: var(--accent); }
.console-input-bar {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px 16px;
}
.console-prompt { color: var(--accent); font-family: monospace; font-size: 1.1rem; }
.console-input-bar input {
  flex: 1; background: transparent; border: none;
  color: var(--text); font-family: monospace; font-size: 0.9rem; padding: 8px 0;
}
.console-input-bar input:focus { outline: none; }
.console-input-bar button { background: var(--accent); border: none; border-radius: 6px; color: white; padding: 8px 16px; cursor: pointer; }

/* CHARTS */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px;
}
.chart-card h3 { font-size: 0.9rem; color: var(--text-dim); margin-bottom: 16px; text-transform: uppercase; letter-spacing: 0.05em; }

/* MAP */
.map-container {
  position: relative;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  min-height: 500px;
}
#map-canvas {
  display: block;
  width: min(100%, 1200px);
  margin: 0 auto;
  max-height: none;
  border-radius: 10px;
}
#map-legend {
  position: static;
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.8rem;
}

/* PLUGINS */
.plugins-list { display: flex; flex-direction: column; gap: 8px; }
.plugin-row {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  transition: border-color 0.2s;
}
.plugin-row:hover { border-color: var(--border); }
.plugin-name { font-weight: 600; font-size: 0.92rem; }
.plugin-meta { font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }
.plugin-actions { display: flex; gap: 8px; }
.plugin-status { padding: 3px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.plugin-status.ok { background: rgba(46,204,113,0.15); color: var(--green); }
.plugin-status.error { background: rgba(231,76,60,0.15); color: var(--red); }

/* SCHEDULED */
.scheduled-list { display: flex; flex-direction: column; gap: 10px; }
.scheduled-row {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.sched-info { flex: 1; }
.sched-name { font-weight: 600; margin-bottom: 4px; }
.sched-details { font-size: 0.8rem; color: var(--text-dim); }
.sched-actions { display: flex; gap: 8px; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 5000;
}
.modal {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 12px; width: 420px; max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  overflow: visible;
}
.modal-body select { position: relative; z-index: 5001; }
.modal-header {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1rem; }
.modal-close { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 1.2rem; }
.modal-body { padding: 20px 24px; }
.modal-body input, .modal-body select, .modal-body textarea {
  width: 100%; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: 10px 14px; font-size: 0.9rem;
  margin-bottom: 12px;
}
.modal-body label { font-size: 0.82rem; color: var(--text-dim); display: block; margin-bottom: 4px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* SPINNER */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.panel-loading {
  position: fixed;
  inset: 0;
  background: rgba(13,15,20,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}
.panel-loading-inner {
  min-width: 260px;
  text-align: center;
  padding: 22px 18px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.panel-loading .spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 12px;
  border: 3px solid #333;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
#panel-loading-text {
  font-size: 0.9rem;
  color: var(--text);
}

/* MAP */
#map-canvas { min-height: 500px; }
#map-legend .map-player-chip {
  display: flex; align-items: center; gap: 6px;
  background: rgba(30, 34, 48, 0.95); border-radius: 20px;
  padding: 4px 10px; font-size: 0.78rem; color: var(--text-main);
  border: 1px solid var(--border);
}
#map-legend .map-player-chip .dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
}

/* RESPONSIVE */
@media (max-width: 1200px) {
  .stats-cards { grid-template-columns: 1fr 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  #main-panel { flex-direction: column; height: auto; min-height: 100vh; }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-logo { padding: 14px 16px; }
  .sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
  }
  .server-status { margin-bottom: 0; }
  .logout-btn { width: auto; min-width: 92px; }

  nav {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }
  nav::-webkit-scrollbar { height: 4px; }
  .nav-item {
    display: inline-flex;
    white-space: nowrap;
    padding: 10px 14px;
  }
  .nav-item.active {
    border-right: none;
    border-bottom: 2px solid var(--accent);
  }

  .content {
    overflow: visible;
    min-height: 0;
  }
  .tab-content { padding: 18px 14px; }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  #player-search { width: 100%; }

  .chat-log,
  .console-log {
    height: 48vh;
    min-height: 280px;
  }
  .chat-input-bar,
  .console-input-bar {
    flex-wrap: wrap;
  }
  .chat-input-bar button,
  .console-input-bar button {
    width: 100%;
  }

  .plugin-row,
  .scheduled-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

@media (max-width: 640px) {
  .login-box {
    width: calc(100vw - 24px);
    max-width: 360px;
    padding: 24px 16px;
  }
  .stats-cards { grid-template-columns: 1fr; }
  .quick-cmds { grid-template-columns: 1fr; }
  .player-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .modal {
    width: calc(100vw - 20px);
    max-width: 420px;
  }
  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 14px;
    padding-right: 14px;
  }
}
