:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f9fbff;
  --text: #172032;
  --muted: #6a778b;
  --accent: #3b82f6;
  --accent-soft: #e8f1ff;
  --border: #dfe5ee;
  --danger: #991b1b;
  --danger-bg: #fee2e2;
  --shadow: 0 10px 30px rgba(18, 32, 56, 0.08);
}
body.dark {
  --bg: #0f1724;
  --panel: #162132;
  --panel-soft: #1b2a40;
  --text: #edf3ff;
  --muted: #9eb0c7;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.15);
  --border: #2a3850;
  --danger: #fecaca;
  --danger-bg: rgba(153, 27, 27, 0.28);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; }
code { background: var(--panel-soft); padding: 2px 6px; border-radius: 6px; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 270px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow);
  z-index: 10;
}
.brand-block { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
}
.brand-title { font-size: 20px; font-weight: 700; }
.brand-subtitle { color: var(--muted); font-size: 13px; }
.nav-links { display: flex; flex-direction: column; gap: 10px; }
.nav-links a, .theme-toggle, .logout-link {
  text-decoration: none;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: 14px;
  cursor: pointer;
  transition: 0.2s ease;
}
.nav-links a:hover, .theme-toggle:hover, .logout-link:hover, .nav-links a.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.sidebar-spacer { flex: 1; }
.sidebar-user { padding: 14px; border: 1px solid var(--border); border-radius: 16px; background: var(--panel-soft); }
.sidebar-user-name { font-weight: 700; }
.sidebar-user-email { color: var(--muted); font-size: 13px; margin-top: 4px; word-break: break-word; }
.sidebar-actions { display: grid; gap: 10px; }
.app-main { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px 0 24px;
}
.topbar-title { font-size: 24px; font-weight: 700; }
.topbar-subtitle { color: var(--muted); font-size: 14px; margin-top: 4px; }
.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
}
.content-area { padding: 24px; }
.page-header { margin-bottom: 20px; }
.page-header h1 { margin: 0 0 8px 0; font-size: 30px; }
.page-header p { margin: 0; color: var(--muted); }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stats-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card, .card, .form-card, .login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-label { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.stat-value { font-size: 34px; font-weight: 700; }
.stat-value.small { font-size: 22px; }
.card-grid { display: grid; gap: 18px; }
.card-grid.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-grid.live-layout { grid-template-columns: 1.35fr 0.95fr; align-items: start; }
.card-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { margin: 0; font-size: 20px; }
.card-subtitle { margin: 6px 0 0 0; color: var(--muted); font-size: 14px; }
.button-stack { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 16px;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-secondary { background: var(--panel-soft); color: var(--text); }
.btn-block { width: 100%; text-align: center; }
.stack-form label { display: block; margin-top: 14px; margin-bottom: 6px; }
input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
}
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.data-table th, .data-table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { font-size: 13px; color: var(--muted); font-weight: 700; }
.table-link { color: var(--accent); text-decoration: none; }
.mono { font-family: Consolas, monospace; font-size: 12px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.status-pill.active { background: rgba(34, 197, 94, 0.12); color: #15803d; border-color: rgba(34, 197, 94, 0.35); }
.status-pill.completed { background: rgba(59, 130, 246, 0.12); color: #1d4ed8; border-color: rgba(59, 130, 246, 0.35); }
.status-pill.cancelled { background: rgba(239, 68, 68, 0.12); color: #b91c1c; border-color: rgba(239, 68, 68, 0.35); }
.empty-state {
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 18px;
}
.empty-state.compact { padding: 14px; }
.detail-list { display: grid; gap: 12px; }
#map, #detailMap {
  width: 100%;
  height: 560px;
  border-radius: 16px;
  background: var(--panel-soft);
}
.card-map { overflow: hidden; }
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at top left, rgba(59,130,246,0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(139,92,246,0.20), transparent 28%),
    var(--bg);
}
.login-shell { width: 100%; max-width: 460px; padding: 24px; }
.login-card { padding: 28px; }
.login-brand { color: var(--accent); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; }
.login-card h1 { margin: 8px 0 10px 0; }
.login-card p { margin: 0 0 18px 0; color: var(--muted); }
.error-box { background: var(--danger-bg); color: var(--danger); padding: 12px; border-radius: 12px; margin-bottom: 12px; }
.filters-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; }
.filter-actions { display: flex; gap: 10px; }
@media (max-width: 1100px) {
  .stats-grid, .stats-grid.compact, .card-grid.two-up, .card-grid.live-layout, .filters-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 0;
    left: -290px;
    height: 100vh;
    transition: left 0.2s ease;
  }
  .sidebar.open { left: 0; }
  .content-area { padding: 18px; }
  .topbar { padding: 16px 18px 0 18px; }
}
