:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e3e5e8;
  --text: #1f2328;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.error { color: var(--danger); min-height: 1em; margin: 6px 0 0; }
h1 { margin: 0 0 4px; font-size: 22px; }
h2 { margin: 0 0 10px; font-size: 16px; }
h3 { margin: 0 0 8px; font-size: 14px; }

input, select, textarea {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; width: 100%;
}
select.small { width: auto; padding: 4px 6px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
label input, label select { margin-top: 3px; color: var(--text); }
label.check { display: flex; align-items: center; gap: 6px; margin: 0; }
label.check input { width: auto; margin: 0; }

.btn {
  font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 6px; padding: 7px 14px;
}
.btn:hover { filter: brightness(0.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 6px 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }

/* login */
.login { display: grid; place-items: center; height: 100%; padding: 16px; }
.login-card { width: 100%; max-width: 340px; }
.login-card .btn { width: 100%; margin-top: 6px; }

/* layout */
.app { display: flex; flex-direction: column; height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 14px; height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.brand { font-weight: 700; white-space: nowrap; }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; }
.tabs button {
  font: inherit; background: none; border: 0; padding: 8px 12px; border-radius: 6px;
  cursor: pointer; color: var(--muted); white-space: nowrap;
}
.tabs button.active { background: #eef2ff; color: var(--primary); font-weight: 600; }
.right { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.conn { color: var(--danger); font-size: 12px; }
.conn.on { color: var(--ok); }
.badge { background: var(--danger); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; margin-left: 3px; }

.main { flex: 1; display: flex; min-height: 0; }
.panel { width: 380px; flex-shrink: 0; overflow-y: auto; padding: 14px; border-right: 1px solid var(--border); background: var(--bg); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }
.map { flex: 1; min-width: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.form-grid label:first-child:nth-last-child(3) { grid-column: 1 / -1; }

.summary { display: flex; gap: 8px; margin: 8px 0 12px; flex-wrap: wrap; }
.pill { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 12px; color: var(--muted); }

.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  cursor: pointer; display: flex; gap: 10px; align-items: flex-start;
}
.item:hover { border-color: #c7cbd1; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.item .sub { font-size: 12px; color: var(--muted); }
.item.unread { border-left: 3px solid var(--danger); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.status { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.status.online { background: #dcfce7; color: #166534; }
.status.offline { background: #f3f4f6; color: #6b7280; }
.status.stale { background: #fef3c7; color: #92400e; }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; color: #fff; }

.player { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 12px; }
.player-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.player input[type=range] { padding: 0; border: 0; }
.hint { font-size: 12px; background: #eff6ff; color: #1e40af; padding: 6px 8px; border-radius: 6px; margin: 0 0 10px; }

/* map labels */
.staff-label { background: rgba(255,255,255,.95); border: 0; box-shadow: var(--shadow); font-weight: 600; padding: 1px 6px; }
.staff-label::before { display: none; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 5000; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.25); max-width: 340px; }
.toast.alert { background: var(--danger); }

@media (max-width: 800px) {
  .main { flex-direction: column-reverse; }
  .panel { width: 100%; height: 45%; border-right: 0; border-top: 1px solid var(--border); }
  .map { min-height: 55%; }
  .brand, #meName { display: none; }
  .topbar { gap: 8px; padding: 0 8px; }
}
.status.lost { background: #fee2e2; color: #991b1b; }
.status.leader { background: #ede9fe; color: #5b21b6; }

.photo-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.photo-strip figure { margin: 0; text-align: center; }
.photo-strip img { object-fit: cover; border-radius: 6px; background: #eee; cursor: zoom-in; display: block; }
.photo-strip figcaption { font-size: 10px; color: var(--muted); margin-top: 2px; }
