:root {
  --navy: #0f2a4a;
  --navy-2: #1e40af;
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --bg: #eef2f8;
  --panel: #f6f8fc;
  --card: #ffffff;
  --border: #e3e9f2;
  --text: #0f172a;
  --muted: #64748b;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --shadow: 0 1px 2px rgba(15, 42, 74, .04), 0 4px 16px rgba(15, 42, 74, .06);
  --nav-h: 60px;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, 'Inter', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============ TOP NAV (dispecer) ============ */
.topnav {
  height: var(--nav-h);
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 500;
}
.topnav .brand { font-weight: 800; font-size: 18px; letter-spacing: .3px; margin-right: 8px; white-space: nowrap; }
.topnav .brand span { color: #7dd3fc; }
.topnav .spacer { flex: 1; }
.topnav .tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.topnav .tabs::-webkit-scrollbar { display: none; }
.topnav .tabs button {
  background: none; border: none; color: #b6c6dd; cursor: pointer;
  font-size: 14.5px; font-weight: 600; padding: 9px 14px; border-radius: 9px;
  white-space: nowrap; transition: background .15s, color .15s;
}
.topnav .tabs button:hover { color: #fff; background: rgba(255,255,255,.08); }
.topnav .tabs button.active { color: #fff; background: rgba(56,189,248,.18); box-shadow: inset 0 -2px 0 #38bdf8; }
.nav-ext { color: #b6c6dd; text-decoration: none; font-size: 13.5px; white-space: nowrap; }
.nav-ext:hover { color: #fff; }

/* ============ WORKSPACE ============ */
#workspace { display: flex; height: calc(100vh - var(--nav-h)); }
#map { flex: 1.5; min-width: 0; height: 100%; background: #e5edf5; }
#content { flex: 1; min-width: 0; overflow-y: auto; padding: 22px; }

/* map mode → content devine panou lateral */
body.with-map #content {
  flex: 0 0 540px; max-width: 540px;
  background: var(--panel); border-left: 1px solid var(--border);
}
/* content mode → harta ascunsă, pagini pe lat, centrate */
body:not(.with-map) #map { display: none; }
body:not(.with-map) #content { padding: 28px; }
body:not(.with-map) .page { max-width: 900px; margin: 0 auto; }
body:not(.with-map) .page-grid { max-width: 1200px; }

.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 18px; align-items: start; }
.page-grid-full { grid-column: 1 / -1; }

/* ============ CARDURI & TIPOGRAFIE ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.page-grid .card { margin-bottom: 0; }
.card.accent { border-left: 4px solid var(--blue); }
h2 { font-size: 18px; margin: 0 0 12px; color: var(--navy); font-weight: 700; }
h3 { font-size: 13px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 700; }
.muted { font-size: 13px; color: var(--muted); }
.warn { font-size: 13px; color: var(--amber); margin-top: 8px; }

label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 15px; font-family: inherit; background: #fff; color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }
input[type=color] { padding: 4px; height: 42px; }
input[type=checkbox] { width: auto; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 7px; font-size: 14px; color: var(--text); font-weight: 500; margin: 0; }
.check input { width: auto; }
.scrollbox { max-height: 200px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 8px; }

/* ============ BUTOANE ============ */
button {
  cursor: pointer; border: none; border-radius: 10px; padding: 11px 18px;
  font-size: 15px; font-weight: 600; font-family: inherit;
  background: var(--blue); color: #fff; transition: background .15s, transform .05s;
}
button:hover { background: var(--navy-2); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.big { padding: 13px 22px; font-size: 16px; }
button.secondary { background: #fff; color: var(--navy-2); border: 1px solid var(--border); }
button.secondary:hover { background: var(--bg); }
button.danger { background: #fff; color: var(--red); border: 1px solid #fecaca; }
button.danger:hover { background: #fef2f2; }
button.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }

details.card > summary { cursor: pointer; font-weight: 700; color: var(--navy); list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: '▸ '; color: var(--blue); }
details.card[open] > summary::before { content: '▾ '; }

/* ============ LISTE / RÂNDURI ============ */
.list-item { border: 1px solid var(--border); border-radius: 12px; padding: 13px; margin-bottom: 10px; background: #fff; }
.list-item .title { font-weight: 700; font-size: 15px; }
.list-item .meta { color: var(--muted); font-size: 13px; margin-top: 3px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.badge.programat { background: #e2e8f0; color: #475569; }
.badge.pe_drum, .badge.in_curs { background: #fef3c7; color: var(--amber); }
.badge.sosit { background: var(--blue-light); color: var(--navy-2); }
.badge.finalizat { background: #dcfce7; color: var(--green); }
.badge.anulat { background: #fee2e2; color: var(--red); }

.stop-row { display: flex; align-items: center; gap: 11px; border: 1px solid var(--border); border-radius: 12px; padding: 11px; margin-bottom: 8px; background: #fff; }
.stop-row .seq { width: 30px; height: 30px; border-radius: 50%; background: var(--navy-2); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.stop-row .info { flex: 1; min-width: 0; }
.stop-row .info .name { font-weight: 600; }
.stop-row .info .sub { font-size: 13px; color: var(--muted); }
.eta-chip { font-size: 13px; font-weight: 700; color: var(--navy-2); background: var(--blue-light); padding: 3px 9px; border-radius: 7px; white-space: nowrap; }

.waze-btn, .maps-btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 11px; border-radius: 8px; font-weight: 700; font-size: 12.5px; text-decoration: none; }
.waze-btn { background: #33ccff; color: #06283d; }
.maps-btn { background: #34a853; color: #fff; }
.waze-btn:hover, .maps-btn:hover { filter: brightness(.95); }

.empty { color: var(--muted); text-align: center; padding: 26px 8px; font-size: 14px; }
.gdpr-note { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; font-size: 13px; padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; line-height: 1.55; }
.client-pick { display: flex; align-items: center; gap: 9px; padding: 7px; border-radius: 8px; font-weight: 500; cursor: pointer; }
.client-pick:hover { background: var(--bg); }
.client-pick input { width: auto; }

/* ============ TOPBAR (tehnician/live) ============ */
.topbar { background: var(--navy); color: #fff; padding: 12px 18px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow); }
.topbar .brand { font-weight: 700; font-size: 17px; }
.topbar .brand span { color: #7dd3fc; }
.topbar .spacer { flex: 1; }
.topbar a { color: #cbd5e1; text-decoration: none; font-size: 14px; }
.topbar a:hover { color: #fff; }

/* ============ TOAST / MODAL ============ */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 13px 20px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 9999; font-size: 15px; opacity: 0; transition: opacity .2s; max-width: 90vw; }
.toast.show { opacity: 1; }
.toast.error { background: var(--red); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,42,74,.45); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal-backdrop.show { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 22px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal h2 { margin-top: 0; }

/* ============ MARKERE HARTĂ ============ */
.num-marker { background: var(--navy-2); color: #fff; border: 2px solid #fff; border-radius: 50%; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.base-marker { background: var(--green); }
.car-marker { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; box-shadow: 0 1px 5px rgba(0,0,0,.35); }

/* ============ RESPONSIVE (telefon) ============ */
@media (max-width: 900px) {
  .topnav { gap: 4px; padding: 0 10px; }
  .topnav .brand { font-size: 16px; }
  .nav-ext { display: none; }
  body.with-map #workspace { flex-direction: column; height: calc(100vh - var(--nav-h)); }
  body.with-map #map { flex: none; height: 42vh; }
  body.with-map #content { flex: 1; max-width: none; border-left: none; border-top: 1px solid var(--border); }
  body:not(.with-map) #content { padding: 16px; }
  .row { flex-wrap: wrap; }
}
