:root {
  --bg: #08111a;
  --sidebar: #0b1622;
  --panel: #101b28;
  --panel-2: #132233;
  --line: rgba(148, 163, 184, 0.16);
  --text: #e8eef5;
  --muted: #8ea0b5;
  --accent: #12b8a8;
  --accent-2: #3dd6c6;
  --warn: #f5b942;
  --danger: #ef6b6b;
  --ok: #34d399;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Manrope", sans-serif;
  background: radial-gradient(1200px 500px at 80% -10%, rgba(18, 184, 168, 0.12), transparent 50%),
              var(--bg);
  color: var(--text);
}

a { color: var(--accent-2); text-decoration: none; }
button, input, select { font-family: inherit; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: visible;
  z-index: 20;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--text);
  padding: 6px 8px 18px;
}
.brand strong { display: block; font-size: 16px; }
.brand small { color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  padding: 11px 12px;
  border-radius: 12px;
  font-weight: 600;
}
.nav a:hover, .nav a.is-active {
  background: rgba(18, 184, 168, 0.12);
  color: var(--text);
}
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 14px; position: relative; z-index: 50; }
.who { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.who-meta { flex: 1; min-width: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #134e4a; color: #99f6e4;
  display: grid; place-items: center; font-weight: 800;
}
.who strong, .who small { display: block; }
.who strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--muted); text-transform: capitalize; }
.who-actions { position: relative; flex: 0 0 auto; }
.who-actions > summary {
  list-style: none;
}
.who-actions > summary::-webkit-details-marker,
.who-actions > summary::marker { display: none; content: none; }
.icon-btn {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
}
.icon-btn-settings:hover,
.who-actions[open] .icon-btn-settings {
  color: var(--accent-2);
  background: rgba(18, 184, 168, 0.12);
}
.icon-btn-logout:hover { background: rgba(239, 107, 107, 0.16); color: #fecaca; }
.settings-pop {
  display: none;
  position: fixed;
  left: 16px;
  bottom: 78px;
  width: 240px;
  box-sizing: border-box;
  background: #10202d;
  border: 1px solid rgba(18, 184, 168, 0.28);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  padding: 10px;
  z-index: 9999;
}
.who-actions[open] .settings-pop { display: block; }
.settings-pop::after { display: none; }
.settings-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 10px;
  margin: 0 0 6px;
  border-bottom: 1px solid var(--line);
}
.settings-pop-head span {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}
.settings-pop-head em {
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
  color: #99f6e4;
  background: rgba(18, 184, 168, 0.16);
  border-radius: 999px;
  padding: 3px 8px;
}
.settings-pop a {
  display: flex !important;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 4px;
  color: #e8eef5 !important;
  padding: 10px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
}
.settings-pop a:last-child { margin-bottom: 0; }
.settings-pop a svg { color: var(--accent-2); flex: 0 0 16px; width: 16px; height: 16px; }
.settings-pop a:hover { background: rgba(18, 184, 168, 0.14); color: #e8eef5 !important; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 28px 8px;
}
.topbar h1 { margin: 0; font-size: 26px; letter-spacing: -0.03em; }
.crumb { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.menu-btn {
  display: none;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  width: 40px; height: 40px; border-radius: 10px;
}
.content { padding: 12px 28px 40px; }

.flash {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-weight: 600;
}
.flash-success { background: rgba(52, 211, 153, 0.14); color: #bbf7d0; }
.flash-error { background: rgba(239, 107, 107, 0.16); color: #fecaca; }
.flash-info { background: rgba(18, 184, 168, 0.14); color: #99f6e4; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: linear-gradient(180deg, var(--panel), #0e1a26);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  border-left: 3px solid var(--accent);
}
.stat span { color: var(--muted); font-size: 13px; font-weight: 700; }
.stat strong { display: block; margin-top: 6px; font-size: 28px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; font-size: 16px; }
.card-body { padding: 16px 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #042f2e;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}
.btn:hover { background: var(--accent-2); color: #042f2e; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-sm { padding: 7px 10px; font-size: 13px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th, table.data td {
  text-align: left;
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data th { color: var(--muted); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
table.data td.wrap { white-space: normal; }
.mono { font-family: "JetBrains Mono", monospace; font-size: 12px; color: #9fe8df; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}
.badge::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
}
.badge-on { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.badge-off { background: rgba(245, 185, 66, 0.14); color: var(--warn); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; color: var(--muted); font-weight: 700; }
.field input, .field select {
  background: #0b1520;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
}
.help { color: var(--muted); font-size: 12px; margin: 0; }
.empty { color: var(--muted); padding: 28px 8px; text-align: center; }

.map-frame {
  height: 460px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.map-tall { height: 560px; }
.playback-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}
.playback-bar input[type="range"] { flex: 1; min-width: 160px; }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}
.auth-art {
  padding: 48px;
  background:
    radial-gradient(800px 400px at 20% 20%, rgba(18, 184, 168, 0.2), transparent 45%),
    linear-gradient(160deg, #071018, #0e2430);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.auth-art h1 { font-size: 42px; margin: 0 0 8px; letter-spacing: -0.04em; }
.auth-art p { color: var(--muted); max-width: 420px; line-height: 1.6; }
.auth-form {
  display: grid;
  place-items: center;
  padding: 32px;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
}
.auth-card h2 { margin: 0 0 6px; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.stack .btn { width: 100%; padding: 12px; }

.leaflet-container { background: #0b1c27; font-family: inherit; }
.sidebar-backdrop { display: none; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .sidebar.is-open { transform: none; }
  .menu-btn { display: inline-grid; place-items: center; }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 15;
  }
  .sidebar-backdrop.is-on { display: block; }
  .form-grid { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}
