:root {
  --bg-0: #0f1419;
  --bg-1: #172029;
  --bg-2: #24303b;
  --panel: rgba(19, 25, 31, 0.88);
  --line: rgba(255, 255, 255, 0.14);
  --text-main: #f2f6fa;
  --text-soft: #b6c2cf;
  --accent: #ff7a1a;
  --accent-2: #ffb14a;
  --ok: #38c172;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Rajdhani", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(1200px 500px at 20% -10%, rgba(255, 122, 26, 0.35), transparent 60%),
    radial-gradient(900px 400px at 85% -20%, rgba(255, 177, 74, 0.2), transparent 60%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 40%, var(--bg-2));
}

.bg-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(transparent 95%, rgba(255, 255, 255, 0.03) 96%),
    linear-gradient(90deg, transparent 95%, rgba(255, 255, 255, 0.03) 96%);
  background-size: 28px 28px;
  opacity: 0.25;
}

.page {
  position: relative;
  z-index: 1;
  width: min(1200px, 96%);
  margin: 20px auto 32px;
  display: flex;
  flex-direction: column;
}

.hero {
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  background: linear-gradient(130deg, rgba(255, 122, 26, 0.14), rgba(10, 15, 20, 0.8) 35%);
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.hero h1 {
  margin: 0;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 1.1px;
  font-size: clamp(2.2rem, 4.6vw, 3.2rem);
}

.hero p {
  margin: 0;
  color: var(--text-soft);
  font-size: 1rem;
}

.hero-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
}

.dashboard {
  padding: 14px 16px 18px;
  margin-bottom: 12px;
  order: 2;
}

.dashboard h2 {
  margin: 0 0 10px;
  font-size: 1.2rem;
  color: var(--accent-2);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.dash-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(12, 17, 22, 0.8);
  padding: 10px;
}

.dash-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.dash-stat {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
  color: var(--text-soft);
}

.dash-stat strong {
  color: var(--text-main);
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  padding: 12px;
  margin-bottom: 12px;
  order: 3;
}

.control-group label {
  display: block;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.view-tabs {
  display: flex;
  gap: 8px;
}

.view-tab {
  border: 1px solid #3b4d61;
  background: #263240;
  color: var(--text-main);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 700;
}

.view-tab.active {
  border-color: transparent;
  color: #111;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

select,
input[type="text"],
input[type="password"] {
  width: 100%;
  background: #111820;
  color: var(--text-main);
  border: 1px solid #2a3947;
  border-radius: 8px;
  padding: 10px 11px;
  font-size: 1rem;
}

.table-panel {
  padding: 0;
  overflow: hidden;
  order: 4;
}

.map-panel {
  margin-top: 12px;
  padding: 12px;
  order: 5;
}

.map-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background-color: #0f161e;
  background-image: url("https://cpt-hedge.com/images/maps/season-2-dark.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

#mapSvg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}

.map-point {
  cursor: pointer;
  stroke: rgba(0, 0, 0, 0.55);
  stroke-width: 1.25;
}

.map-point.checked {
  opacity: 0.45;
}

.map-point.selected {
  stroke: #fff;
  stroke-width: 2.5;
}

.map-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.level-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.legend-chip {
  font-size: 0.86rem;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.legend-chip.l1 { background: rgba(255, 0, 0, 0.35); }
.legend-chip.l2 { background: rgba(0, 255, 0, 0.35); }
.legend-chip.l3 { background: rgba(0, 100, 255, 0.35); }
.legend-chip.l4 { background: rgba(255, 255, 0, 0.35); }
.legend-chip.l5 { background: rgba(255, 0, 255, 0.35); }
.legend-chip.l6 { background: rgba(0, 255, 255, 0.35); }
.legend-chip.l7 { background: rgba(255, 165, 0, 0.35); }

.map-detail {
  flex: 1;
  min-width: 250px;
  text-align: right;
  color: var(--text-soft);
}

.coord-cell {
  cursor: copy;
}

.map-detail button {
  margin-left: 8px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 280px);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 10px;
  background: #16212b;
  border-bottom: 1px solid var(--line);
  color: var(--accent-2);
  font-size: 1rem;
}

.sort-btn {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  font-weight: 700;
}

.sort-icon {
  color: #8ea5bc;
  font-size: 0.9rem;
}

.sort-icon.active {
  color: var(--accent-2);
}

tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

tbody tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.03);
}

.check-cell {
  width: 90px;
}

.check-toggle {
  cursor: pointer;
  font-size: 1.05rem;
  user-select: none;
}

.check-toggle.locked {
  opacity: 0.8;
}

.check-toggle.checked {
  color: var(--ok);
}

.note-input {
  width: 100%;
  min-width: 180px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
}

.btn-accent {
  color: #111;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.btn-muted {
  color: var(--text-main);
  background: #263240;
  border-color: #3b4d61;
}

.save-status {
  min-width: 110px;
  text-align: right;
  color: var(--text-soft);
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.65);
  padding: 16px;
}

.modal-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  background: #141d26;
  border-radius: 12px;
  padding: 16px;
}

.modal-card h3 {
  margin: 0 0 6px;
  color: var(--accent-2);
}

.modal-card p {
  margin: 0 0 10px;
  color: var(--text-soft);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.code-error {
  margin-top: 8px;
  color: #ff6b6b;
  font-weight: 600;
}

@media (max-width: 700px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .save-status {
    text-align: left;
  }

  .dashboard {
    order: 10;
    margin-top: 12px;
    margin-bottom: 0;
  }
}
