:root {
  --yellow: #b8e0c8;
  --yellow-deep: #8fca9f;
  --ink: #17171a;
  --muted: #83838b;
  --soft: #aaa69d;
  --surface: #fffdf8;
  --background: #f4f1ea;
  --field: #f0ece4;
  --line: #e3ded3;
  --green: #12a150;
  --orange: #d9960a;
  --blue: #2f6bff;
  --red: #e5484d;
  --sidebar: #1a1a1c;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Roboto", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------- login ---------- */
.login-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 32px;
  background:
    radial-gradient(700px 500px at 80% 0%, rgba(184, 224, 200, 0.22), transparent 65%),
    linear-gradient(140deg, #17171a, #29292d);
  color: #fff;
}
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-mark {
  width: 56px; height: 56px; border-radius: 17px;
  background: var(--yellow); color: var(--ink);
  display: grid; place-items: center;
  font-size: 30px; font-weight: 900;
}
.login-wordmark { font-size: 24px; font-weight: 900; letter-spacing: 4px; }
.login-sub { margin-top: 3px; color: #a6a6ad; font-size: 12px; letter-spacing: 2px; }
.login-card {
  width: min(390px, 100%);
  background: var(--surface);
  color: var(--ink);
  border-radius: 26px;
  padding: 26px;
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
}
.login-card h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -.7px; }
.login-card p { margin: 0 0 22px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.login-card label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--muted); }
.login-card input {
  width: 100%; margin-top: 8px; padding: 14px;
  border: 1px solid var(--line); border-radius: 14px;
  outline: none; background: #fff; font-size: 15px;
}
.login-card input:focus { border-color: var(--yellow-deep); }
.primary {
  width: 100%; min-height: 52px;
  margin-top: 14px;
  border: 0; border-radius: 15px;
  background: var(--yellow); color: var(--ink);
  font-weight: 800; font-size: 15px;
}
.primary:disabled { background: #e7e1d4; color: #aaa59b; }
.login-error { margin-top: 10px; color: var(--red); font-size: 13px; }
.login-foot { color: #818189; font-size: 12px; }
.login-foot span { color: var(--yellow); }
.login-back { display: inline-block; margin-top: 18px; color: #818189; font-size: 12px; text-decoration: none; }
.login-back:hover { color: #fff; }

/* ---------- panel ---------- */
.panel { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 68px; flex: 0 0 68px;
  background: #17171a;
  color: #fff;
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--yellow); color: var(--ink);
  display: grid; place-items: center;
  font-size: 21px; font-weight: 900;
}
.brand-name { font-size: 18px; font-weight: 900; letter-spacing: 2px; }
.brand-divider { width: 1px; height: 24px; background: #36363b; margin: 0 4px; }
.brand-page { color: #a8a8b0; font-size: 13px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.connection { font-size: 12px; color: #a8a8b0; display: flex; align-items: center; gap: 7px; }
.connection i { width: 8px; height: 8px; border-radius: 50%; background: #3ac47d; box-shadow: 0 0 0 3px rgba(58,196,125,.14); }
.connection.offline i { background: var(--red); box-shadow: 0 0 0 3px rgba(229,72,77,.14); }
.top-count { font-size: 12px; color: #cfcfd5; background: #2a2a2f; padding: 7px 12px; border-radius: 999px; }
.top-count b { color: var(--yellow); }
.ghost-btn {
  border: 1px solid #3b3b42; background: transparent; color: #d6d6dc;
  border-radius: 10px; padding: 8px 12px; font-size: 12px;
}
.ghost-btn:hover { border-color: #686871; }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(410px, 1fr);
}
.map-panel { position: relative; min-height: 0; background: #e6e2d8; }
#map { position: absolute; inset: 0; }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-bottom.leaflet-right { right: auto; left: 12px; }
.map-badge {
  position: absolute; z-index: 400;
  top: 16px; left: 16px;
  background: rgba(23,23,26,.9); color: #fff;
  padding: 9px 13px; border-radius: 10px;
  font-size: 12px;
}
.map-btn {
  position: absolute; z-index: 400;
  top: 16px; right: 16px;
  background: #fff; color: var(--ink);
  border-radius: 10px; padding: 9px 13px;
  font-size: 12px; font-weight: 600;
  box-shadow: 0 5px 16px rgba(0,0,0,.15);
}
.map-legend {
  position: absolute; z-index: 400;
  bottom: 16px; left: 16px;
  display: flex; gap: 14px;
  background: rgba(255,255,255,.96);
  padding: 10px 13px; border-radius: 11px;
  font-size: 11px; color: #56565e;
  box-shadow: 0 5px 18px rgba(0,0,0,.13);
}
.map-legend span { display: flex; align-items: center; gap: 6px; }
.map-route {
  position: absolute; z-index: 400; left: 16px; right: 16px; top: 68px;
  display: flex; align-items: center; gap: 12px;
  background: #17171a; color: #fff; border-radius: 14px;
  padding: 12px 14px; box-shadow: 0 12px 30px rgba(0,0,0,.22);
}
.map-route > div { flex: 1; min-width: 0; }
.map-route b { display: block; font-size: 12px; }
.map-route span { display: block; color: #b7b7bd; font-size: 11px; margin-top: 3px; }
.map-route button {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  background: rgba(255,255,255,.12); color: #fff; font-size: 20px; line-height: 1;
}
.map-route.hidden { display: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.free { background: var(--green); }
.dot.break { background: var(--orange); }
.dot.busy { background: var(--blue); }

/* driver map markers */
.driver-pin {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--yellow);
  border: 3px solid var(--ink);
  color: var(--ink);
  display: grid; place-items: center;
  font-size: 14px; font-weight: 900;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.driver-pin.break { background: #ffd980; }
.driver-pin.busy { background: #9bbcff; border-color: #1746b3; }
.driver-pin-wrap { background: transparent; border: 0; }
.driver-pin-wrap.selected .driver-pin { box-shadow: 0 0 0 5px rgba(184,224,200,.45), 0 4px 14px rgba(0,0,0,.25); }
.driver-popup b { display: block; font-size: 13px; }
.driver-popup span { display: block; color: #77777f; font-size: 11px; margin-top: 2px; }

/* ---------- drivers panel ---------- */
.drivers-panel {
  background: var(--surface);
  border-left: 1px solid var(--line);
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.panel-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 20px 20px 14px;
}
.eyebrow { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 1.5px; }
.panel-head h1 { margin: 3px 0 0; font-size: 28px; letter-spacing: -1px; }
.panel-count {
  min-width: 34px; height: 34px; padding: 0 10px;
  border-radius: 999px; background: var(--yellow);
  display: grid; place-items: center;
  font-size: 14px; font-weight: 800;
}
.table-head, .driver-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1.15fr) 92px minmax(0, 1.2fr) 116px;
  gap: 10px;
  align-items: center;
}
.table-head {
  padding: 9px 20px;
  background: #faf7f0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.1px;
  text-transform: uppercase;
}
.drivers-list { overflow-y: auto; flex: 1; min-height: 0; }
.driver-row {
  padding: 13px 20px;
  border-bottom: 1px solid #f0ece4;
  transition: background .12s ease;
}
.driver-row:hover { background: #fdfaf3; }
.driver-row.selected { background: #fff7d1; }
.driver-number {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--yellow);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 900;
}
.driver-main { min-width: 0; }
.driver-main b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.driver-main span { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-pill {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; padding: 5px 8px;
  font-size: 10px; font-weight: 700; white-space: nowrap;
}
.status-pill.free { background: #e7f8ee; color: #187a40; }
.status-pill.break { background: #fff4d2; color: #8a6511; }
.status-pill.busy { background: #e9f0ff; color: #2456b8; }
.order-cell { min-width: 0; }
.order-cell b { display: block; font-size: 10px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-cell span { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-cell.empty { color: #bbb6ac; font-size: 10px; }
.assign-btn {
  border: 0; border-radius: 9px;
  background: var(--yellow);
  padding: 9px 8px;
  font-size: 11px; font-weight: 800;
  white-space: nowrap;
}
.assign-btn:disabled {
  background: #f0ece4; color: #a9a49b;
  cursor: not-allowed;
}
.empty-state {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 30px; text-align: center;
}
.empty-icon { font-size: 44px; margin-bottom: 12px; filter: grayscale(.2); color: var(--muted); }
.empty-icon svg { width: 34px; height: 34px; }
.empty-state b { font-size: 17px; }
.empty-state p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; max-width: 270px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(18,18,22,.6); backdrop-filter: blur(2px); }
.modal-card {
  position: relative;
  width: min(430px, 100%);
  max-height: 86dvh; overflow-y: auto;
  background: var(--surface);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,.3);
  animation: modalIn .16s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(7px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-card h2 { margin: 0; font-size: 25px; letter-spacing: -.7px; }
.modal-card .driver-target {
  display: flex; align-items: center; gap: 10px;
  background: var(--field); border-radius: 13px; padding: 10px;
  margin: 14px 0 18px;
}
.modal-card .driver-target .driver-number { flex: 0 0 30px; }
.modal-card .driver-target b { display: block; font-size: 13px; }
.modal-card .driver-target span { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.field-label { display: block; margin-top: 12px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.input {
  width: 100%; margin-top: 7px; padding: 13px;
  border: 1px solid var(--line); border-radius: 13px;
  background: #fff; outline: none; font-size: 14px;
}
.input:focus { border-color: var(--yellow-deep); }
.address-field { position: relative; }
.address-suggestions {
  position: relative; z-index: 20; left: auto; right: auto; top: auto;
  margin-top: 4px;
  max-height: 220px; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0,0,0,.16);
}
.address-suggestion {
  display: block; width: 100%; text-align: left;
  padding: 10px 12px; border-bottom: 1px solid #f1ece3;
}
.address-suggestion:last-child { border-bottom: 0; }
.address-suggestion:hover { background: #fffaf0; }
.address-suggestion b { display: block; font-size: 12px; }
.address-suggestion small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; line-height: 1.3; }
.address-empty { padding: 10px 12px; color: var(--muted); font-size: 11px; }
.modal-note { color: var(--muted); font-size: 11px; line-height: 1.4; margin-top: 10px; }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; }
.modal-actions button { flex: 1; min-height: 46px; border-radius: 12px; font-weight: 700; font-size: 13px; }
.modal-actions .cancel { border: 1px solid var(--line); background: #fff; color: var(--muted); }
.modal-actions .confirm { border: 0; background: var(--yellow); color: var(--ink); }
.modal-actions .confirm:disabled { background: #e7e1d4; color: #aaa59b; }
.modal-error { color: var(--red); font-size: 12px; margin-top: 10px; }
.toast {
  position: fixed; z-index: 1200;
  left: 50%; bottom: 22px; transform: translateX(-50%);
  background: rgba(23,23,26,.94); color: #fff;
  border-radius: 999px; padding: 10px 16px;
  font-size: 12px; max-width: 88vw; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 44dvh 1fr; }
  .drivers-panel { border-left: 0; border-top: 1px solid var(--line); }
  .table-head, .driver-row { grid-template-columns: 30px minmax(0,1.2fr) 80px 96px; }
  .table-head span:nth-child(4), .order-cell { display: none; }
  .brand-divider, .brand-page, .connection, .top-count { display: none; }
  .topbar { padding: 0 14px; height: 58px; flex-basis: 58px; }
  .layout { height: calc(100dvh - 58px); }
}
@media (max-width: 600px) {
  .table-head, .driver-row { grid-template-columns: 28px minmax(0,1fr) 78px 96px; }
  .panel-head { padding: 15px 14px 10px; }
  .driver-row, .table-head { padding-left: 14px; padding-right: 14px; }
  .drivers-panel { overflow: hidden; }
  .map-legend { display: none; }
}


/* passenger tab and history */
.panel-tabs { display: flex; gap: 6px; padding: 0 20px 12px; }
.panel-tab { flex: 1; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.panel-tab.active { background: var(--yellow); border-color: var(--yellow); color: #102018; }
.history-btn { border: 0; border-radius: 9px; background: var(--yellow); color: #102018; padding: 9px 8px; font: inherit; font-size: 11px; font-weight: 700; cursor: pointer; }
.history-btn:hover { filter: brightness(.96); }
.history-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow: auto; margin: 12px 0; }
.history-card { background: var(--field); border-radius: 14px; padding: 12px; }
.history-card summary { list-style: none; cursor: pointer; }
.history-card summary::-webkit-details-marker { display: none; }
.history-main { display: flex; flex-direction: column; gap: 3px; padding-right: 10px; }
.history-main b { font-size: 13px; }
.history-main span { font-size: 12px; color: var(--ink); }
.history-main small { font-size: 10px; color: var(--muted); }
.history-card summary { display: flex; justify-content: space-between; gap: 10px; }
.history-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: 13px; font-weight: 700; flex: 0 0 auto; }
.history-chat { width: 30px; height: 30px; border: 0; border-radius: 50%; background: #000; color: #fff; display: grid; place-items: center; cursor: pointer; }
.history-details { border-top: 1px solid var(--line); margin-top: 9px; padding-top: 8px; display: flex; flex-direction: column; gap: 7px; }
.history-review { font-size: 12px; }
.history-review b { margin-right: 6px; }
.history-review span { color: #d2a53a; letter-spacing: 1px; }
.history-review p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.history-muted { color: var(--muted); font-size: 12px; }
.chat-list.readonly { max-height: 55vh; overflow: auto; display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.chat-message { background: var(--field); border-radius: 12px; padding: 8px 10px; font-size: 13px; line-height: 1.35; }
.chat-message.driver { border-left: 3px solid var(--yellow); }
.chat-message.passenger { border-left: 3px solid #2f6bff; }
.chat-message small { display: block; color: var(--muted); font-size: 10px; margin-bottom: 2px; }

.history-chat img { width: 18px; height: 14px; display: block; }

.driver-main .driver-rating { color: var(--muted); font-size: 11px; }

.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0; }
.modal-x { width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--field); color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer; }


.reports-list { overflow-y: auto; flex: 1; min-height: 0; padding: 0 20px 16px; }
.report-card { background: var(--field); border-radius: 16px; padding: 13px 14px; margin-bottom: 8px; cursor: pointer; border: 1px solid transparent; }
.report-card:hover { border-color: var(--yellow-deep); }
.report-card.selected { border-color: var(--yellow-deep); background: #fff7d1; }
.report-head { display: flex; justify-content: space-between; gap: 10px; }
.report-head b { font-size: 14px; }
.report-head span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.report-route { margin-top: 5px; font-size: 13px; line-height: 1.35; }
.report-route span { color: var(--muted); }
.report-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; color: var(--muted); font-size: 11px; }
.report-meta b { color: var(--ink); font-size: 13px; }

.report-details { border-top: 1px solid var(--line); margin-top: 9px; padding-top: 8px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.report-details .history-review { font-size: 12px; }
.report-details .history-review p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.report-chat { position: absolute; right: 0; top: 7px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: #000; color: #fff; display: grid; place-items: center; cursor: pointer; }
.report-chat img { width: 18px; height: 14px; }

.report-details .history-review b { margin-right: 6px; }

.report-info { margin-top: 6px; color: var(--muted); font-size: 11px; font-weight: 600; }

.report-time { margin-top: 4px; color: var(--muted); font-size: 11px; }


.report-group { margin-bottom: 8px; }
.report-group > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; list-style: none; cursor: pointer; padding: 11px 14px; border-radius: 13px; background: var(--field); font-size: 14px; font-weight: 700; }
.report-group > summary::-webkit-details-marker { display: none; }
.report-group > summary::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 18px; transform: rotate(0deg); transition: transform .15s ease; }
.report-group[open] > summary::after { transform: rotate(90deg); }
.report-group-count { color: var(--muted); font-size: 12px; font-weight: 600; }
.report-group-list { padding-top: 7px; }
