:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --bg: #070f24;
  --panel: rgba(31, 41, 55, 0.82);
  --panel-border: #334155;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #3b82f6;
  --primary-strong: #2563eb;
  --online: #22c55e;
  --stopped: #f59e0b;
  --crashed: #ef4444;
  --unknown: #64748b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(900px circle at -10% -10%, #1e3a8a 0%, transparent 45%),
    radial-gradient(900px circle at 110% 120%, #0f766e 0%, transparent 45%),
    var(--bg);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.75rem, 2vw + 1rem, 2.5rem);
}

.hero p {
  color: var(--muted);
  margin: 0.5rem 0 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 1rem;
  backdrop-filter: blur(6px);
}

.hidden {
  display: none !important;
}

.grid-form {
  display: grid;
  gap: 0.6rem;
}

input,
button {
  border-radius: 10px;
  border: 1px solid #42506a;
  background: #0b1733;
  color: #f8fafc;
  padding: 0.7rem 0.8rem;
  font: inherit;
}

input:focus,
button:focus {
  outline: 2px solid #60a5fa;
  outline-offset: 1px;
}

button {
  cursor: pointer;
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  border-color: #1d4ed8;
  font-weight: 600;
}

button.secondary {
  background: rgba(15, 23, 42, 0.6);
  border-color: #4b5563;
}

button.small {
  padding: 0.4rem 0.65rem;
  font-size: 0.86rem;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.actions-row,
.topbar-actions,
.command-row,
.quick-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.command-row {
  width: 100%;
}

.command-row input {
  flex: 1;
}

.command-row-multi {
  flex-wrap: wrap;
}

.command-row-multi input {
  min-width: 200px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar-title {
  margin: 0;
}

.page-nav {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.nav-tab {
  padding: 0.4rem 0.8rem;
  font-size: 0.86rem;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid #4b5563;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-tab.active {
  background: var(--primary);
  border-color: #1d4ed8;
  color: #fff;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.panel-header h2 {
  margin: 0;
}

select {
  border-radius: 10px;
  border: 1px solid #42506a;
  background: #0b1733;
  color: #f8fafc;
  padding: 0.7rem 0.8rem;
  font: inherit;
  width: 100%;
}

select:focus {
  outline: 2px solid #60a5fa;
  outline-offset: 1px;
}

.subtle,
.hint,
#status {
  color: var(--muted);
  margin: 0.5rem 0 0;
}

.cert-prompt {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 0.9rem;
  line-height: 1.5;
}
.cert-prompt a {
  color: var(--primary);
  text-decoration: underline;
  font-weight: 600;
}
.cert-prompt a:hover { color: #93c5fd; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.7rem;
}

.stat-card {
  background: rgba(11, 23, 51, 0.7);
  border: 1px solid #31405e;
  border-radius: 12px;
  padding: 0.8rem;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.inline-form {
  margin-top: 0.6rem;
}

.server-grid {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.8rem;
}

.server-card {
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 0.8rem;
  background: rgba(11, 23, 51, 0.75);
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.server-card:hover {
  transform: translateY(-1px);
  border-color: #60a5fa;
}

.server-card.selected {
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35);
}

.server-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.server-title-row h3 {
  margin: 0;
  font-size: 1rem;
}

.badge {
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge.online {
  background: rgba(34, 197, 94, 0.17);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.badge.stopped {
  background: rgba(245, 158, 11, 0.17);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge.crashed {
  background: rgba(239, 68, 68, 0.17);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge.unknown {
  background: rgba(100, 116, 139, 0.2);
  color: #cbd5e1;
  border: 1px solid rgba(100, 116, 139, 0.35);
}

.server-meta {
  margin-top: 0.5rem;
  color: #cbd5e1;
  font-size: 0.9rem;
}

.rcon-output {
  margin: 0.8rem 0 0;
  padding: 0.8rem;
  border-radius: 12px;
  border: 1px solid #334155;
  background: #07112b;
  color: #a5f3fc;
  min-height: 180px;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
}

/* ── Server Settings page ── */

.server-control-actions {
  display: flex;
  gap: 0.5rem;
  margin: 0.8rem 0;
}

.section-heading {
  margin: 1.2rem 0 0.4rem;
  font-size: 1rem;
  color: var(--muted);
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.35rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.detail-item {
  display: flex;
  flex-direction: column;
  background: rgba(11, 23, 51, 0.5);
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}

.detail-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-value {
  margin-top: 0.15rem;
  font-size: 0.95rem;
  word-break: break-all;
}

.settings-form {
  display: grid;
  gap: 0.5rem;
}

.field-row,
.toggle-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0.5rem;
  align-items: center;
}

.field-row label,
.toggle-row label {
  font-size: 0.9rem;
  color: var(--muted);
}

.toggle-row select {
  width: auto;
}

.mods-list {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.mod-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(11, 23, 51, 0.5);
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
}

.mod-info {
  display: flex;
  flex-direction: column;
}

.mod-name {
  font-size: 0.92rem;
}

.mod-id {
  font-size: 0.78rem;
}

@media (max-width: 980px) {
  .topbar-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 0.75rem;
  }

  .panel {
    padding: 0.8rem;
  }

  .topbar,
  .topbar-actions,
  .actions-row,
  .command-row {
    flex-direction: column;
    align-items: stretch;
  }

  .command-row-multi input {
    min-width: auto;
  }

  .field-row,
  .toggle-row {
    grid-template-columns: 1fr;
  }

  .data-table {
    font-size: 0.8rem;
  }
}

/* ── Data tables (Players, etc.) ── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  padding: 0.45rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid #1e293b;
}

.data-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

.data-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.08);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

/* ── Session / task / backup items ── */

.session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #1e293b;
  gap: 0.5rem;
}

.task-item {
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.4rem;
  cursor: pointer;
  transition: border-color 0.14s ease;
}

.task-item:hover {
  border-color: #60a5fa;
}

.task-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.backup-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(11, 23, 51, 0.5);
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  margin-bottom: 0.35rem;
}

/* ── Debug console log levels ── */

.log-line {
  padding: 0.1rem 0;
}

.log-error {
  color: #fca5a5;
}

.log-warn {
  color: #fcd34d;
}

.log-debug {
  color: #64748b;
}

/* ── Task monitor (bell icon + dropdown) ── */

.task-bell-area {
  display: flex;
  align-items: center;
}

.task-bell-wrapper {
  position: relative;
}

.task-bell {
  position: relative;
  font-size: 1rem;
  padding: 0.35rem 0.6rem;
  line-height: 1;
}

.task-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--crashed);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  pointer-events: none;
}

.task-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 340px;
  max-height: 400px;
  background: #111827;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 999;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.task-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid #1e293b;
}

.task-dropdown-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.task-dropdown-list {
  overflow-y: auto;
  flex: 1;
  max-height: 340px;
}

.task-dropdown-section {
  padding: 0.4rem 0.8rem 0.2rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-top: 1px solid #1e293b;
}

.task-dropdown-section:first-child {
  border-top: none;
}

.task-dropdown-item {
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  transition: background 0.12s ease;
  border-bottom: 1px solid rgba(30, 41, 59, 0.5);
}

.task-dropdown-item:last-child {
  border-bottom: none;
}

.task-dropdown-item:hover {
  background: rgba(59, 130, 246, 0.1);
}

.task-dropdown-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.task-dropdown-item-type {
  font-size: 0.88rem;
  font-weight: 500;
}

.task-dropdown-item-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

@media (max-width: 640px) {
  .task-dropdown {
    width: 280px;
    right: -40px;
  }
}
