:root {
  --bg: #edf8fc;
  --surface: #ffffff;
  --surface-soft: #eaf5f5;
  --line: #b8d4db;
  --text: #123d3a;
  --muted: #587875;
  --primary: #176b52;
  --leaf: #69b77d;
  --sky: #78c6dc;
  --route: #4aabc5;
  --success: #2f8a5b;
  --warning: #d89b34;
  --danger: #c74848;
  --accent: var(--primary);
  --accent-soft: var(--leaf);
  --radius-lg: 16px;
  --radius-sm: 10px;
  --shadow: 0 14px 30px rgba(18, 38, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg) 0%, var(--surface-soft) 100%);
  min-height: 100vh;
}

.app-mode-user .manager-only {
  display: none !important;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.1rem;
  display: grid;
  gap: 1rem;
}

.hero {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 1.7rem 1.1rem;
}

.hero__content {
  max-width: 1080px;
  margin: 0 auto;
}

.hero__brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.app-logo {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  box-shadow: 0 6px 18px rgba(20, 55, 38, 0.16);
}

.app-logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

.app-logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 14px;
}

.eyebrow {
  margin: 0 0 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-size: 0.72rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.65rem, 2.5vw, 2.2rem);
  line-height: 1.05;
}

.hero-subtitle {
  margin: 0.28rem 0 0;
  color: var(--muted);
}

.hero p {
  color: var(--muted);
}

.status-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin: 0.9rem 0 0;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.36rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
}

.status::before {
  content: "●";
  color: var(--accent);
}

.status.offline::before {
  color: var(--danger);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.8rem;
}

.stats h2 {
  margin: 0;
  font-size: 0.98rem;
}

.stats p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.toolbar {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 1.6fr 1fr 1fr auto;
  align-items: end;
}

.toolbar__field {
  display: grid;
  gap: 0.35rem;
}

.toolbar__field label,
.detail-card h2,
.trail .meta,
h2 {
  color: var(--text);
}

input,
select,
button {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  padding: 0.62rem 0.72rem;
  font: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 125, 93, 0.12);
}

.toolbar button,
button {
  cursor: pointer;
}

.outline {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.outline:hover {
  background: rgba(46, 125, 93, 0.06);
}

.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}

.primary:hover {
  background: #24664b;
}

.layout {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 1rem;
}

.detail-grid {
  display: grid;
  gap: 0.45rem;
}

.detail-grid .muted,
.detail-meta,
.muted {
  color: var(--muted);
}

.detail-grid .meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.mini-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.82rem;
  background: #fafcfb;
}

.route-map-shell {
  position: relative;
}

#route-map {
  width: 100%;
  height: 320px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  overflow: hidden;
}

#route-map-fallback {
  width: 100%;
  height: 320px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.04) 75%, rgba(255, 255, 255, 0.04)),
    linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.04) 75%, rgba(255, 255, 255, 0.04)),
    #edf2ee;
  background-position: 0 0, 6px 6px;
  background-size: 12px 12px;
}

.route-nav-marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #0b2c4a;
  background: #24d1ff;
  box-shadow: 0 0 0 3px rgba(36, 209, 255, 0.24);
}

.map-controls {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 0.5rem;
  margin: 0.6rem 0 0.2rem;
  align-items: end;
}

#map-download-note {
  margin: 0.55rem 0 0;
}

.position-state {
  margin-top: 0.5rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.58rem;
  background: var(--surface-soft);
}

#position-events {
  margin: 0.6rem 0 0;
  max-height: 130px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem;
}

#position-events p {
  margin: 0 0 0.4rem;
}

.bookings-list {
  list-style: none;
  margin: 0.45rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.bookings-list li {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem;
  background: var(--surface-soft);
}

.bookings-list .danger {
  border-color: #f0c1c1;
  color: #ad4343;
}

.booking-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

.trail-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.trail {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem;
  background: var(--surface-soft);
}

.trail:hover {
  border-color: var(--accent-soft);
}

.trail h3 {
  margin: 0;
}

.trail .meta {
  margin: 0.4rem 0 0.8rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 0.24rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
}

.btn-small {
  font-size: 0.85rem;
  padding: 0.45rem 0.6rem;
}

#detail-content h3 {
  margin: 0 0 0.4rem;
}

.quick-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  background: var(--surface-soft);
  cursor: pointer;
  font-size: 0.88rem;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.planner-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.8rem;
}

.check-item {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.58rem;
  background: var(--surface-soft);
}

.hidden {
  display: none;
}

footer {
  text-align: center;
  color: var(--muted);
  padding: 1.4rem 1rem 2rem;
}

@media (max-width: 860px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .map-controls,
  .mini-grid,
  .room-row {
    grid-template-columns: 1fr;
  }

  .layout {
    grid-template-columns: 1fr;
  }
}
