:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1b2430;
  --muted: #687385;
  --border: #dde2e8;
  --accent: #f5a623;
  --accent-text: #1b2430;
  --primary: #1f6feb;
  --danger: #d93025;
  --hover: #eef2f6;
  --sidebar: 380px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151c;
    --panel: #16202c;
    --text: #e6edf3;
    --muted: #8b98a8;
    --border: #2a3644;
    --primary: #4c8dff;
    --danger: #ff6b5e;
    --hover: #1e2a38;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
[hidden] { display: none !important; }

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { display: flex; align-items: center; gap: .5rem; font-size: 1.6rem; }
h2 { font-size: 1.15rem; }

input, select, textarea, button, .button {
  font: inherit;
  color: inherit;
  border-radius: 8px;
}
input, select, textarea {
  width: 100%;
  padding: .5rem .6rem;
  border: 1px solid var(--border);
  background: var(--panel);
}
label { display: block; margin-bottom: .6rem; font-size: .9rem; color: var(--muted); }
label > input, label > textarea, label > select { margin-top: .2rem; color: var(--text); }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  padding: .45rem .8rem;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .button:hover { background: var(--hover); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { filter: brightness(1.1); }
button.danger { color: var(--danger); }
button.ghost { background: transparent; }
button.link { border: 0; background: none; padding: 0; color: var(--primary); }
button.small { padding: .35rem .6rem; font-size: .85rem; }
button.wide { width: 100%; margin-bottom: .75rem; }

.muted { color: var(--muted); }
.small-text { font-size: .82rem; }
.error { color: var(--danger); margin: .3rem 0; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: .8rem; }
.row > select { flex: 1; min-width: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}

/* Belépés */
.auth { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .primary { width: 100%; margin: .4rem 0 .8rem; padding: .6rem; }

/* Elrendezés */
.layout { display: grid; grid-template-columns: var(--sidebar) 1fr; height: 100%; }
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.bar {
  display: flex; align-items: center; gap: .6rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .4rem; }
.me { margin-left: auto; color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; }
.block { padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.block p { margin: .5rem 0 0; }
.empty { color: var(--muted); }
code { background: var(--hover); padding: .1rem .35rem; border-radius: 4px; letter-spacing: .08em; }

.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tabs button {
  flex: 1; border: 0; border-radius: 0;
  border-bottom: 2px solid transparent;
  background: none; padding: .7rem;
}
.tabs button.active { border-bottom-color: var(--accent); font-weight: 600; }
.badge { background: #2ea043; color: #fff; border-radius: 10px; padding: 0 .45rem; font-size: .75rem; }
.badge:empty { display: none; }
.tab { padding: 1rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .5rem;
  border-radius: 8px;
  cursor: pointer;
}
.list li:hover { background: var(--hover); }
.list .title { font-weight: 600; }
.list .sub { color: var(--muted); font-size: .82rem; }
.list .grow { flex: 1; min-width: 0; }
.list .empty-item { cursor: default; color: var(--muted); }
.list .empty-item:hover { background: none; }

.dot {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: .85rem;
  flex: none;
}
.dot.offline { opacity: .35; }
.dot.has-avatar, .rider-icon.has-avatar { background-size: cover; background-position: center; }
.dot.small { width: 22px; height: 22px; font-size: .65rem; }
.dot.large { width: 56px; height: 56px; font-size: 1.2rem; }
.profile { display: flex; gap: .75rem; align-items: center; padding-bottom: .9rem; margin-bottom: .9rem; border-bottom: 1px solid var(--border); }
.profile .row { margin-top: .4rem; }
button.me { display: flex; align-items: center; gap: .4rem; border: 0; padding: .25rem .4rem; }
.messages li { display: flex; gap: .5rem; align-items: flex-start; }

.waypoints { padding-left: 1.4rem; margin: .4rem 0; }
.waypoints li { margin: .25rem 0; }
.waypoints .wp { display: flex; gap: .3rem; align-items: center; }
.waypoints .wp input { padding: .3rem .45rem; font-size: .88rem; }
.waypoints .wp button { padding: .2rem .5rem; }
.summary { font-weight: 600; }
.desc { white-space: pre-wrap; }

.switch { display: flex; align-items: center; gap: .6rem; color: var(--text); font-size: 1rem; cursor: pointer; }
.switch input { width: 1.2rem; height: 1.2rem; }

/* Térkép */
.map-wrap { position: relative; }
#map { position: absolute; inset: 0; }
.map-btn {
  position: absolute; right: 12px; bottom: 28px; z-index: 500;
  width: 44px; height: 44px; border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  font-size: 1.2rem;
}
.rider-icon {
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,.45);
  color: #fff; font-weight: 700;
  display: grid; place-items: center;
}
.wp-icon {
  background: var(--accent); color: var(--accent-text);
  border: 2px solid #fff; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}

dialog { border: 0; padding: 0; background: transparent; color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .card { min-width: 300px; }

/* Mobil / keskeny képernyő: térkép felül, panel alul */
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 45vh 1fr; }
  .map-wrap { grid-row: 1; }
  .sidebar { grid-row: 2; border-right: 0; border-top: 1px solid var(--border); }
}

/* POI-k */
.poi-icon {
  background: #7b3fe4; color: #fff;
  border: 2px solid #fff; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.poi-icon span { display: grid; place-items: center; width: 100%; height: 100%; transform: rotate(45deg); font-size: 13px; }
.list .actions { display: flex; gap: .25rem; }
.list .actions button { padding: .2rem .45rem; font-size: .85rem; }

/* Üzenetek */
.badge.unread { background: var(--danger); margin-left: .25rem; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 1.2rem 0 .4rem; font-size: 1rem; }
.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.messages li { background: var(--hover); border-radius: 10px; padding: .45rem .65rem; }
.messages li.mine { background: transparent; border: 1px solid var(--border); }
.messages .meta { font-size: .75rem; color: var(--muted); }
.messages .empty-item { background: none; color: var(--muted); padding: 0; }
.toasts {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: .5rem;
  width: min(420px, calc(100% - 32px));
}
.toast {
  background: var(--panel); color: var(--text);
  border-left: 5px solid var(--accent);
  border-radius: 10px; padding: .7rem .9rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  cursor: pointer;
}
.toast strong { display: block; margin-bottom: .15rem; }
