@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700;900&family=Rajdhani:wght@400;500;600;700&display=swap');

:root {
  --space-950: #05070d;
  --space-900: #0a0e18;
  --space-800: #121828;
  --space-700: #1b2338;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --cyan: #22d3ee;
  --cyan-dim: rgba(34, 211, 238, 0.35);
  --blue: #3b82f6;
  --amber: #f59e0b;
  --red: #ef4444;
  --green: #22c55e;
  --text: #e5e9f2;
  --text-dim: #8993a8;
  --text-faint: #4b5468;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'Rajdhani', sans-serif;
  background: radial-gradient(ellipse at top, #0d1424 0%, var(--space-950) 60%);
  color: var(--text);
  min-height: 100vh;
}

h1, h2, h3, .brand, .nav-item span, .btn {
  font-family: 'Orbitron', sans-serif;
}

a { color: var(--cyan); }

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

input, select, textarea {
  font-family: 'Rajdhani', sans-serif;
  font-size: 15px;
  background: var(--space-900);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-dim);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--cyan); }
.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  border: none;
  color: #04101c;
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.25);
}
.btn-danger { border-color: rgba(239, 68, 68, 0.5); color: #fca5a5; }
.btn-danger:hover { border-color: var(--red); box-shadow: 0 0 15px rgba(239, 68, 68, 0.25); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: rgba(10, 14, 24, 0.85);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  padding: 18px 0;
}

.brand {
  padding: 0 20px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.12em;
  color: #fff;
}
.brand .frz { color: var(--cyan); text-shadow: 0 0 12px var(--cyan-dim); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.nav-item:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.nav-item.active { color: var(--cyan); border-left-color: var(--cyan); background: rgba(34, 211, 238, 0.06); }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 20px 0;
  border-top: 1px solid var(--border);
}
.sidebar-user { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.sidebar-user b { color: var(--text); }

.main {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
  max-height: 100vh;
}

.panel { display: none; }
.panel.active { display: block; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.panel-header h1 {
  font-size: 20px;
  letter-spacing: 0.06em;
  color: #fff;
  margin: 0;
}
.panel-header h1 .accent { color: var(--cyan); }

/* Card */
.card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

/* Galaxy grid */
.galaxy-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.galaxy-controls label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; margin-right: 4px; }
.galaxy-controls input[type=number] { width: 80px; }

.position-list { display: flex; flex-direction: column; gap: 8px; }
.position-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.015);
}
.position-row.occupied { border-color: rgba(34, 211, 238, 0.25); }
.position-slot {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--space-800);
  font-weight: 700;
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.position-info { flex: 1; min-width: 0; }
.position-info .name { font-weight: 700; color: var(--text); }
.position-info .owner { font-size: 13px; color: var(--text-dim); }
.position-empty { color: var(--text-faint); font-style: italic; }
.position-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Layout with sidebar (galaxy + history) */
.split {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

.history-list { display: flex; flex-direction: column; gap: 10px; max-height: 70vh; overflow-y: auto; }
.history-entry { font-size: 12.5px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.history-entry .meta { color: var(--text-dim); margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; }
.history-entry .diff { color: var(--text); line-height: 1.5; }
.history-entry .diff b { color: var(--cyan); }
.history-action { font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; font-size: 10px; padding: 1px 6px; border-radius: 4px; }
.history-action.create { color: var(--green); background: rgba(34, 197, 94, 0.12); }
.history-action.update { color: var(--amber); background: rgba(245, 158, 11, 0.12); }
.history-action.delete { color: var(--red); background: rgba(239, 68, 68, 0.12); }

/* Search results */
.search-results { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.search-result {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.coords { color: var(--cyan); font-family: 'Orbitron', sans-serif; font-size: 11px; }

/* Tables (stats) */
.stats-section { margin-bottom: 28px; }
.stats-section h2 {
  font-size: 14px;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-dim); font-weight: 700; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.06em; }
.table-scroll { overflow-x: auto; }
.notes-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }

/* Announcements */
.announcement { padding: 16px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; background: rgba(255, 255, 255, 0.015); }
.announcement-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 12px; color: var(--text-dim); }
.announcement-meta b { color: var(--cyan); }
.announcement-content { white-space: pre-wrap; line-height: 1.5; }
.announcement-actions { margin-top: 10px; display: flex; gap: 6px; }

/* Forms */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(2, 4, 10, 0.7);
  display: flex; align-items: center; justify-content: center; z-index: 200;
  backdrop-filter: blur(3px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--space-800);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 24px;
  width: 380px;
  max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.modal h2 { margin: 0 0 16px; font-size: 15px; letter-spacing: 0.06em; }
.modal-error { color: #fca5a5; font-size: 12.5px; margin-top: 8px; min-height: 1em; }

/* Login page */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 380px; max-width: 100%; padding: 32px; }
.login-title { text-align: center; margin-bottom: 6px; font-size: 20px; letter-spacing: 0.1em; color: #fff; }
.login-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.login-hint { font-size: 12px; color: var(--amber); margin-top: -6px; margin-bottom: 14px; min-height: 1em; }

/* Table CRUD (users) */
.users-table td, .users-table th { white-space: normal; }
.badge { font-size: 10px; padding: 2px 8px; border-radius: 20px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.badge-admin { background: rgba(245, 158, 11, 0.15); color: var(--amber); }
.badge-pending { background: rgba(239, 68, 68, 0.12); color: #fca5a5; }
.badge-ok { background: rgba(34, 197, 94, 0.12); color: var(--green); }

/* Toast */
.toast-stack { position: fixed; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 300; }
.toast {
  background: var(--space-800);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--cyan);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toast-in 0.2s ease-out;
}
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.text-dim { color: var(--text-dim); }
.mt-16 { margin-top: 16px; }
.empty-state { color: var(--text-faint); text-align: center; padding: 40px 0; font-style: italic; }
