:root {
  color-scheme: dark;
  --background: #0c1118;
  --panel: #151d28;
  --panel-2: #1c2633;
  --border: #334154;
  --text: #f4f7fb;
  --muted: #aeb9c8;
  --accent: #5fb8ff;
  --accent-text: #05111b;
  --danger: #ff7777;
  --success: #88e29d;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 9px;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

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

.secondary-button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.full-width-button {
  width: 100%;
}

.section-button {
  margin-top: 15px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 11px;
  background: #0f1620;
  color: var(--text);
}

textarea {
  resize: vertical;
}

textarea[readonly] {
  color: var(--text);
  background: #0b121b;
}

label {
  display: block;
  margin-top: 12px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.9rem;
}

h1,
h2,
p {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

.screen {
  min-height: 100%;
}

.login-screen {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
}

.login-card > button:first-of-type {
  width: 100%;
  margin-top: 16px;
}

.login-card .secondary-button {
  margin-top: 10px;
}

.status {
  min-height: 1.3em;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 330px 1fr;
  height: 100%;
  min-height: 0;
}

.sidebar {
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.sidebar-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.sidebar-heading h1 {
  margin-bottom: 4px;
  font-size: 1.25rem;
}

.sidebar-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.sidebar-heading button {
  flex: 0 0 auto;
  padding: 8px 10px;
}

.role-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--panel-2);
  font-size: 0.9rem;
}

.sidebar-section {
  margin-top: 19px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-section h2 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.section-help {
  margin: -3px 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

#invite-result {
  margin-top: 12px;
}

.filter-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.85rem;
}

.filter-option input {
  width: auto;
  margin: 0;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title-row span {
  color: var(--muted);
  font-size: 0.85rem;
}

.item-list {
  display: grid;
  gap: 8px;
}

.item-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
}

.item-main {
  min-width: 0;
}

.item-title-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 700;
}

.item-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}

.item-edit-button {
  padding: 7px 9px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.8rem;
}

.sidebar-help {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.map-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  background: #07101a;
}

.map-loading {
  position: absolute;
  z-index: 1000;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel);
  color: var(--text);
}

.popup-title {
  margin: 0 0 4px;
  font-weight: 800;
}

.popup-category {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.8rem;
}

.popup-notes {
  margin: 0;
  white-space: pre-wrap;
}

@media (max-width: 800px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(480px, 1fr);
    height: auto;
    min-height: 100%;
  }

  .sidebar {
    max-height: none;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .map-panel {
    min-height: 70vh;
  }
}
