/* ── Reset & base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #080b14;
  --bg2:       #0d1120;
  --bg3:       #131826;
  --border:    #1a2038;
  --border2:   #243060;
  --accent:    #3d85c8;
  --accent2:   #5ba0e0;
  --green:     #27c77a;
  --red:       #e03c3c;
  --orange:    #e07c3c;
  --yellow:    #d4a017;
  --sand:      #c8b88a;
  --text:      #cdd4e8;
  --text-dim:  #6b7699;
  --text-mute: #2e3660;
  --font:      'Segoe UI', system-ui, sans-serif;
  --mono:      'Cascadia Code', 'Consolas', monospace;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* navbar removed */

/* ── Container ────────────────────────────────────── */
.container {
  max-width: 1340px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ── Alerts ───────────────────────────────────────── */
.alert {
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  border-left: 3px solid;
}
.alert-success { background: #081f14; border-color: var(--green); color: var(--green); }
.alert-warning { background: #1f1008; border-color: var(--orange); color: var(--orange); }

/* ── Dashboard header ─────────────────────────────── */
.dash-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
  padding: 18px 24px;
  background: linear-gradient(135deg, #0d1220 0%, #111828 50%, #0d1220 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
}

.dash-header::before {
  content: '';
  position: absolute;
  right: -40px;
  top: 50%;
  transform: translateY(-50%);
  width: 200px;
  height: 200px;
  background: url('/static/logo.png') center/contain no-repeat;
  opacity: 0.06;
  pointer-events: none;
}

.dash-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 0 12px rgba(61,133,200,0.3));
}

.dash-logo,
.dash-header-text,
.dash-header-nav {
  position: relative;
  z-index: 1;
}

.dash-header-text {
  flex: 1 1 260px;
  min-width: 0;
}

.dash-header-text h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sand);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.dash-header-text p {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 4px;
}

.dash-header-nav {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

@media (max-width: 720px) {
  .container {
    padding: 14px 10px;
  }

  .dash-header {
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border-radius: 12px;
  }

  .dash-header::before {
    right: -62px;
    width: 170px;
    height: 170px;
    opacity: 0.045;
  }

  .dash-logo {
    width: 48px;
    height: 48px;
  }

  .dash-header-text {
    flex: 1 1 calc(100% - 62px);
    padding-top: 3px;
  }

  .dash-header-text h1 {
    font-size: 16px;
    line-height: 1.18;
  }

  .dash-header-text p {
    font-size: 10px;
    line-height: 1.35;
  }

  .dash-header-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    width: 100%;
    gap: 8px;
  }

  .dash-header-nav .btn {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    padding: 8px 8px;
    white-space: normal;
    text-align: center;
  }
}

@media (max-width: 380px) {
  .dash-header-nav {
    grid-template-columns: 1fr;
  }
}

/* btn-help and btn-blockade defined in unified button system below */

/* ── Stats bar ────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 110px;
  gap: 3px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent2);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Grid ─────────────────────────────────────────── */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

@media (max-width: 900px) {
  .grid-2col { grid-template-columns: 1fr; }
}

/* ── Panel ────────────────────────────────────────── */
.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.panel-wide { margin-bottom: 14px; }

.panel-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  display: flex;
  align-items: center;
  gap: 7px;
}

.panel-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}

.empty-state {
  color: var(--text-mute);
  text-align: center;
  padding: 30px 16px;
  font-size: 13px;
  line-height: 1.9;
}

/* btn-sync inherits from .btn.btn-ghost below */

/* ── Rank divider / section header ────────────────── */
.rank-divider {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 16px 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sand);
  background: linear-gradient(90deg, rgba(200,184,138,0.07) 0%, transparent 70%);
  border-bottom: 1px solid rgba(200,184,138,0.10);
  border-top: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}

.rank-divider:hover { background: linear-gradient(90deg, rgba(200,184,138,0.13) 0%, transparent 70%); }

.rank-divider--has-online {
  color: var(--green);
  background: linear-gradient(90deg, rgba(39,199,122,0.08) 0%, transparent 70%);
  border-bottom-color: rgba(39,199,122,0.12);
}

.rank-divider--has-online:hover { background: linear-gradient(90deg, rgba(39,199,122,0.14) 0%, transparent 70%); }

.rank-label { flex: 1; }

.rank-count {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-mute);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  letter-spacing: 0.04em;
}

.rank-count--online { color: var(--green); border-color: rgba(39,199,122,0.3); }

.rank-chevron {
  font-size: 8px;
  color: var(--text-mute);
  transition: transform 0.15s;
  width: 10px;
  text-align: center;
}

/* ── Scrollable panel bodies ──────────────────────── */
#members-list,
#alerts-list {
  max-height: 300px;
  overflow-y: auto;
}

/* ── Member cards ─────────────────────────────────── */
.member-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.member-card:last-child { border-bottom: none; }
.member-card:hover { background: var(--bg3); }

.member-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.member-online .member-status-dot {
  background: var(--green);
  box-shadow: 0 0 7px var(--green);
}

.member-offline .member-status-dot {
  background: var(--text-mute);
}

.member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border2);
}

.member-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
}

.member-info { flex: 1; min-width: 0; }

.member-name-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.member-name {
  font-weight: 600;
  font-size: 14px;
  color: #e0e6f4;
  letter-spacing: 0.02em;
}

.member-rank {
  font-size: 10px;
  color: var(--sand);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.75;
}

.member-offline .member-name { color: var(--text-dim); }
.member-offline .member-rank { opacity: 0.4; }

.member-details {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}

.member-offline-label {
  font-size: 11px;
  color: var(--text-mute);
}

/* ── Badges ───────────────────────────────────────── */
.badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--mono);
}

.badge-ship {
  background: #0a1e3a;
  color: #5ba0e0;
  border: 1px solid #152e58;
}

.badge-zone {
  background: #0a1e20;
  color: #3abba0;
  border: 1px solid #153028;
}

.badge-menu {
  background: #1a1a2e;
  color: #7070aa;
  border: 1px solid #2a2a50;
}

/* ── Alert cards (blockades + help) ──────────────── */
.alert-card {
  padding: 10px 14px 10px 16px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  transition: background 0.1s;
}
.alert-card:last-child { border-bottom: none; }
.alert-card:hover { background: var(--bg3); }

.alert-card--blockade { border-left-color: var(--red); }
.alert-card--help     { border-left-color: var(--orange); }

.alert-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.alert-type-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
}
.alert-type-badge--blockade { background: rgba(224,60,60,.15); color: #ff8080; }
.alert-type-badge--help     { background: rgba(224,124,60,.15); color: #ffb070; }

.alert-player {
  font-size: 13px;
  font-weight: 600;
  color: #d0d8f0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alert-time {
  font-size: 11px;
  color: var(--text-mute);
  flex-shrink: 0;
}

.alert-route {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
  font-size: 12px;
  font-family: var(--mono);
}
.alert-route .route-from,
.alert-route .route-to {
  background: rgba(224,60,60,.1);
  color: #ee9090;
  padding: 2px 7px;
  border-radius: 4px;
}
.alert-route .route-arrow { color: var(--red); }

.alert-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 5px;
}

.alert-message {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  line-height: 1.5;
}

.alert-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

/* ── Blockade cards ───────────────────────────────── */
.blockade-card {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.blockade-card:last-child { border-bottom: none; }

.blockade-route {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 5px;
}

.route-from, .route-to {
  background: #200a0a;
  border: 1px solid #50181818;
  color: #ee8888;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
  border-color: #501818;
}

.route-arrow { color: var(--red); font-size: 16px; }

.blockade-desc {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.blockade-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-mute);
}

.blockade-reporter { color: var(--text-dim); }

/* ── Event feed ───────────────────────────────────── */
.event-feed {
  max-height: 380px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 12px;
}

.event-row {
  display: grid;
  grid-template-columns: 65px 110px 145px 1fr;
  gap: 8px;
  padding: 5px 16px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  transition: background 0.1s;
}

.event-row:hover { background: var(--bg3); }

.event-time   { color: var(--text-mute); }
.event-player { color: #8ab0e0; font-weight: 600; }
.event-type   { font-weight: 600; }
.event-detail { color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.event-ship_entered .event-type   { color: var(--accent2); }
.event-ship_left .event-type      { color: var(--text-dim); }
.event-contract_accepted .event-type { color: var(--green); }
.event-contract_complete .event-type { color: #50e090; }
.event-location_change .event-type  { color: var(--sand); }
.event-station_detected .event-type { color: #b0a070; }
.event-zone_change .event-type     { color: var(--yellow); }
.event-injury .event-type         { color: var(--orange); }
.event-death .event-type          { color: var(--red); }
.event-server_join .event-type    { color: var(--accent); }
.event-game_start .event-type     { color: #aaaaff; }
.event-game_quit .event-type      { color: var(--text-mute); }
.event-med_heal .event-type       { color: var(--green); }

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: filter 0.12s;
  text-decoration: none;
  letter-spacing: 0.03em;
  line-height: 1.4;
  white-space: nowrap;
  user-select: none;
}
.btn:hover                         { text-decoration: none; filter: brightness(1.18); }
.btn:active                        { filter: brightness(0.88); }
.btn:disabled, .btn[disabled]      { opacity: 0.38; cursor: default; pointer-events: none; }

.btn-primary                       { background: #2a5fa8; color: #e8f0ff; }
.btn-danger,  .btn-blockade        { background: #7a1818; color: #ffd0d0; }
.btn-warning, .btn-help            { background: #7a3e10; color: #ffd4a0; }
.btn-success, .btn-resolve         { background: #0f3d22; color: #a0f0c0; }
.btn-ghost,   .btn-secondary,
.btn-sync                          { background: #1a2038; color: #8090b8; }

.btn-sm  { padding: 4px 10px; font-size: 11px; border-radius: 5px; }

/* ── Forms ────────────────────────────────────────── */
.back-link { margin-bottom: 16px; }

.form-page { max-width: 640px; margin: 0 auto; }

.form-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--sand);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.form-subtitle { color: var(--text-dim); margin-bottom: 24px; font-size: 13px; }

.org-form {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; flex: 1; }

.form-row { display: flex; gap: 14px; }

@media (max-width: 600px) { .form-row { flex-direction: column; } }

label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.optional { font-weight: 400; text-transform: none; color: var(--text-mute); }

/* ── Cascade select rows ──────────────────────────── */
.cascade-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 0;
}

.cascade-group { flex: 1; display: flex; flex-direction: column; gap: 6px; }

.cascade-arrow {
  color: var(--text-mute);
  font-size: 18px;
  padding-bottom: 10px;
  flex-shrink: 0;
}

select:disabled { opacity: 0.4; cursor: not-allowed; }

input[type="text"], textarea, select {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 7px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--font);
  transition: border-color 0.15s;
  width: 100%;
}

input:focus, textarea:focus { outline: none; border-color: var(--accent); }

textarea { resize: vertical; min-height: 80px; }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 4px; }

/* ── Help type grid ───────────────────────────────── */
.help-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.help-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 13px 8px;
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}

.help-type-card input[type="radio"] { display: none; }

.help-type-card:hover { border-color: var(--border2); }

.help-type-card:has(input:checked) {
  border-color: var(--accent);
  background: #0a1e38;
}

.help-type-icon { font-size: 22px; }

.help-type-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Modal ────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.modal.open { display: flex; }

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 16px;
  width: min(640px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: modal-in 0.15s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 0;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--sand);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.modal-close:hover { background: var(--bg3); color: var(--text); }

.modal-box .org-form {
  border: none;
  border-radius: 0;
  padding: 16px 24px 24px;
  background: none;
}

/* ── Scrollbar ────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
