:root {
  --bg: #0f1419; --panel: #1a2129; --panel2: #232c36; --line: #2d3947;
  --txt: #e6edf3; --muted: #8b98a5; --green: #3fb950; --red: #f85149;
  --yellow: #d29922; --blue: #58a6ff;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--txt); font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: normal; }
.error { color: var(--red); min-height: 18px; margin-top: 8px; font-size: 13px; }

/* Login */
.login { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card {
  background: var(--panel); padding: 32px; border-radius: 12px; width: 320px;
  border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px;
}
.login-card h1 { margin: 0; font-size: 20px; }
input, button, select { font: inherit; }
input, select {
  background: var(--panel2); border: 1px solid var(--line); color: var(--txt);
  padding: 9px 11px; border-radius: 7px; width: 100%;
}
button {
  background: var(--panel2); border: 1px solid var(--line); color: var(--txt);
  padding: 9px 14px; border-radius: 7px; cursor: pointer;
}
button:hover { border-color: var(--blue); }
button.ok { background: #1f6f33; border-color: #2a8f43; }
button.warn { background: #7a5a12; border-color: #a07818; }
button.danger { background: #7d2620; border-color: #a8352c; }
button.ghost { background: transparent; }

/* Layout */
header {
  display: flex; align-items: center; gap: 18px; padding: 12px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 16px; }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tabs button { background: transparent; border: none; padding: 8px 12px; border-radius: 7px; }
.tabs button.active { background: var(--panel2); color: var(--blue); }
main { padding: 20px; max-width: 1000px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }

/* Dashboard */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; display: flex; flex-direction: column; gap: 6px;
}
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.card .big { font-size: 22px; font-weight: 700; }
.actions { display: flex; gap: 10px; margin: 20px 0; }
#players-online { margin-top: 10px; }

/* Console */
.logbox {
  background: #0a0e12; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; height: 58vh; overflow-y: auto; white-space: pre-wrap;
  word-break: break-word; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px;
  line-height: 1.5; margin: 0;
}
.cmd-row { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.cmd-row .prompt { color: var(--green); font-family: monospace; font-size: 18px; }
.cmd-row input { flex: 1; font-family: ui-monospace, monospace; }

/* Properties */
.toolbar { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.props-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.prop {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.prop label { font-size: 13px; font-weight: 600; }
.prop .desc { font-size: 12px; color: var(--muted); line-height: 1.4; }
.prop .key { font-size: 11px; color: #5a6673; font-family: monospace; }
#props-filter, #gr-filter { max-width: 280px; }

/* Gamerules : en-tête (libellé + interrupteur) */
.gr-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gr-head label { font-size: 13px; font-weight: 600; }
.gr-num { width: 90px; flex: none; }

/* Interrupteur (toggle switch) */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0; background: #3a4654;
  border-radius: 24px; transition: .2s;
}
.slider::before {
  content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #e6edf3; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* Players + backups */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.panel h3 { margin: 0 0 12px; }
.add-row { display: flex; gap: 8px; margin-bottom: 12px; }
.add-row input { flex: 1; }
.plist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.plist li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 9px 12px;
}
.plist li .meta { color: var(--muted); font-size: 12px; }
.plist li button { padding: 4px 9px; font-size: 12px; }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--line); padding: 12px 18px;
  border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.4); z-index: 100; max-width: 80%;
}
.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--red); }

@media (max-width: 760px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .props-grid, .cols { grid-template-columns: 1fr; }
}
