:root {
  --iron: #14140f;
  --hall: #1d1c17;
  --hall-2: #262420;
  --fjord: #3c5a63;
  --ember: #8a3324;
  --gold: #c9a15a;
  --gold-dim: #7f6a41;
  --bone: #ded2b8;
  --mist: #8b8878;
  --good: #4a8c5f;
  --warn: #c98a3a;
  --danger: #a5372a;
  --radius: 10px;
}

@media (prefers-color-scheme: light) {
  :root {
    --iron: #f4efe4;
    --hall: #ffffff;
    --hall-2: #efe8d8;
    --bone: #2a2620;
    --mist: #5c5748;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--iron);
  color: var(--bone);
  min-height: 100vh;
}

.hidden { display: none !important; }

.screen { min-height: 100vh; }

/* ---- Login ---- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--hall);
  border: 1px solid var(--hall-2);
  border-radius: var(--radius);
  padding: 28px 24px;
}

.brand { text-align: center; margin-bottom: 20px; }
.rune { color: var(--gold); font-size: 1.6rem; margin-right: 6px; }
.brand h1 { font-size: 1.4rem; margin: 6px 0 2px; color: var(--bone); }
.brand .sub { color: var(--mist); font-size: 0.85rem; margin: 0; }
.brand-logo { max-width: 200px; width: 70%; height: auto; margin: 0 auto 8px; display: block; filter: drop-shadow(0 4px 16px rgba(0,0,0,0.5)); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--mist);
  margin: 14px 0 6px;
}

input[type="text"], input[type="password"], input[type="number"], textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--hall-2);
  background: var(--hall-2);
  color: var(--bone);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

input:focus { outline: 2px solid var(--gold-dim); }

button { font-family: inherit; cursor: pointer; }

.btn {
  padding: 12px 16px;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--hall-2);
  color: var(--bone);
}

.btn.full { width: 100%; margin-top: 18px; }
.btn-primary { background: var(--gold); color: #1a1508; }
.btn-good { background: var(--good); color: #fff; }
.btn-warn { background: var(--warn); color: #1a1508; }
.btn-danger { background: var(--danger); color: #fff; }

.error {
  color: #e07860;
  font-size: 0.85rem;
  margin-top: 10px;
  text-align: center;
}

/* ---- Panel ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--hall);
  border-bottom: 1px solid var(--hall-2);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand-small { font-weight: 700; color: var(--bone); font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.topbar-logo { height: 22px; width: auto; display: block; }
.ghost-btn {
  background: transparent;
  border: 1px solid var(--hall-2);
  color: var(--mist);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
}

main { max-width: 480px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--hall);
  border: 1px solid var(--hall-2);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.status-card .status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--mist);
  margin-right: 8px;
}
.status-dot.online { background: var(--good); }
.status-dot.offline { background: var(--danger); }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--mist);
  font-size: 1.2rem;
}

.server-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
.server-actions .btn { padding: 10px 6px; font-size: 0.85rem; }

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.tab-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--hall-2);
  background: var(--hall);
  color: var(--mist);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}
.tab-btn.active { background: var(--gold); color: #1a1508; border-color: var(--gold); }

h2 { font-size: 1rem; margin: 0 0 4px; color: var(--bone); }

.row { display: flex; gap: 12px; }
.row .col { flex: 1; }

.autocomplete {
  margin-top: 4px;
  border: 1px solid var(--hall-2);
  border-radius: 8px;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}
.autocomplete-item {
  padding: 10px 12px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--hall-2);
  background: var(--hall-2);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item span { color: var(--mist); font-size: 0.78rem; margin-left: 6px; }

.selected-chip {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--hall-2);
  border-radius: 8px;
  font-size: 0.9rem;
  border: 1px solid var(--gold-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.clear-btn {
  background: transparent;
  border: 1px solid var(--danger);
  color: #e58a7a;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.78rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.feedback {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  scroll-margin-top: 70px;
}
.feedback.ok { background: rgba(74,140,95,0.18); color: #7ecb92; }
.feedback.err { background: rgba(165,55,42,0.18); color: #e58a7a; }

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.action-btn { padding: 12px 8px; font-size: 0.85rem; }
.warn-btn { background: var(--warn); color: #1a1508; }
.danger-btn { background: var(--danger); color: #fff; }
.good-btn { background: var(--good); color: #fff; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}
.confirm-box {
  background: var(--hall);
  border: 1px solid var(--hall-2);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 320px;
  width: 100%;
}
.confirm-box p { color: var(--bone); margin: 0 0 16px; font-size: 0.95rem; }
.confirm-buttons { display: flex; gap: 10px; }
.confirm-buttons .btn { flex: 1; }

.hint { color: var(--mist); font-size: 0.85rem; margin: -6px 0 18px; }

.event-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 4px; border-bottom: 1px solid var(--hall-2);
  gap: 10px; flex-wrap: wrap;
}
.event-row:last-of-type { border-bottom: none; }
.event-name { color: var(--bone); font-size: 1rem; font-weight: 600; }

.event-controls { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.start-now-btn {
  background: var(--ember); color: #fff; border: none;
  padding: 8px 12px; border-radius: 8px; font-size: 0.8rem; font-weight: 700;
  white-space: nowrap;
}
.start-now-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--hall-2); border: 1px solid var(--gold-dim);
  border-radius: 28px; transition: background 0.2s ease;
}
.switch .slider::before {
  content: ""; position: absolute; height: 20px; width: 20px;
  left: 3px; top: 3px; background: var(--mist);
  border-radius: 50%; transition: transform 0.2s ease, background 0.2s ease;
}
.switch input:checked + .slider { background: var(--good); border-color: var(--good); }
.switch input:checked + .slider::before { transform: translateX(22px); background: #fff; }
.switch input:disabled + .slider { opacity: 0.5; cursor: not-allowed; }
