:root {
  --ink: #14231d;
  --muted: #69756f;
  --line: #e2e8e4;
  --surface: #ffffff;
  --soft: #f3f6f4;
  --green: #1f684d;
  --green-strong: #15553d;
  --green-soft: #e8f3ed;
  --lime: #b9d65a;
  --orange: #d78035;
  --red: #d04b43;
  --shadow: 0 18px 45px rgba(21, 46, 36, 0.16);
  font-family: Inter, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--soft);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; background: var(--soft); }
.topbar {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 1000;
}

.brand, .topbar-actions, .sync-state, .account-button, .detail-topline { display: flex; align-items: center; }
.brand { gap: 13px; }
.brand-mark {
  width: 43px; height: 43px; border-radius: 13px; display: grid; place-items: center;
  color: white; background: var(--green); box-shadow: 0 7px 16px rgba(31,104,77,.24);
}
.brand-mark svg { width: 29px; fill: currentColor; }
.brand p { margin: 0 0 2px; font-size: 9px; letter-spacing: .2em; color: var(--green); font-weight: 800; }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: .02em; }

.topbar-actions { gap: 12px; }
.sync-state { gap: 9px; padding-right: 6px; color: var(--muted); }
.sync-state > span:last-child { display: grid; }
.sync-state strong { font-size: 12px; color: var(--green); }
.sync-state small { font-size: 10px; margin-top: 2px; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: #3ea477; box-shadow: 0 0 0 5px rgba(62,164,119,.12); }

.icon-button, .account-button { border: 1px solid var(--line); background: #fff; cursor: pointer; }
.icon-button { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.icon-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button.loading svg { animation: spin .8s linear infinite; }
.account-button { border-radius: 13px; gap: 9px; padding: 6px 10px 6px 7px; text-align: left; }
.account-button > span { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; background: var(--green-soft); color: var(--green); font-weight: 800; }
.account-button div { display: grid; }
.account-button strong { font-size: 11px; }
.account-button small { font-size: 9px; color: var(--muted); margin-top: 2px; }
.account-button svg { width: 12px; fill: none; stroke: currentColor; stroke-width: 1.5; }

.main-layout { height: calc(100vh - 78px); display: grid; grid-template-columns: 370px minmax(0, 1fr); }
.sidebar { background: #fff; border-right: 1px solid var(--line); overflow: auto; z-index: 500; }
.overview { padding: 24px 22px 18px; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.eyebrow { margin: 0 0 3px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.section-heading h2 { margin: 0; font-size: 20px; }
.date-label { color: var(--muted); font-size: 11px; }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric-card { min-height: 82px; padding: 12px; border-radius: 14px; background: var(--soft); position: relative; }
.metric-card.primary { color: white; background: var(--green); }
.metric-card span { display: block; font-size: 10px; opacity: .82; }
.metric-card strong { display: inline-block; margin-top: 8px; font-size: 27px; line-height: 1; }
.metric-card small { font-size: 10px; margin-left: 3px; opacity: .8; }

.driver-section { padding: 17px 14px 24px; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; width: 17px; left: 13px; top: 12px; fill: none; stroke: #7f8984; stroke-width: 1.8; stroke-linecap: round; }
.search-wrap input { width: 100%; height: 41px; border: 1px solid var(--line); background: var(--soft); border-radius: 12px; padding: 0 12px 0 39px; outline: none; color: var(--ink); }
.search-wrap input:focus { border-color: #8ab5a3; box-shadow: 0 0 0 3px rgba(31,104,77,.08); background: #fff; }
.filter-row { display: flex; gap: 6px; padding: 12px 0; }
.filter-button { border: 0; border-radius: 999px; background: transparent; padding: 7px 12px; font-size: 11px; font-weight: 700; color: var(--muted); cursor: pointer; }
.filter-button.active { background: var(--green-soft); color: var(--green); }
.driver-list { display: grid; gap: 7px; }

.driver-card { width: 100%; border: 1px solid transparent; background: #fff; border-radius: 15px; padding: 12px; display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: center; text-align: left; cursor: pointer; transition: .18s ease; }
.driver-card:hover { background: var(--soft); }
.driver-card.selected { border-color: #acd1bf; background: #f0f8f4; box-shadow: inset 3px 0 var(--green); }
.avatar { width: 39px; height: 39px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 800; background: var(--avatar, var(--green)); }
.avatar.large { width: 51px; height: 51px; border-radius: 16px; font-size: 15px; }
.driver-info { min-width: 0; }
.driver-info strong { display: block; font-size: 13px; }
.driver-info p { margin: 4px 0 0; font-size: 10px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.driver-meta { text-align: right; display: grid; justify-items: end; gap: 6px; }
.driver-meta small { font-size: 9px; color: #8b958f; }
.status-badge { display: inline-flex; align-items: center; width: fit-content; border-radius: 999px; padding: 5px 8px; font-size: 9px; line-height: 1; font-weight: 800; color: var(--status-color); background: var(--status-bg); }
.status-badge::before { content: ""; width: 5px; height: 5px; margin-right: 5px; border-radius: 50%; background: currentColor; }
.empty-state { padding: 30px 12px; text-align: center; color: var(--muted); font-size: 12px; }

.map-panel { position: relative; min-width: 0; background: #dfe7e1; }
#map { width: 100%; height: 100%; z-index: 1; }
.leaflet-container { font-family: inherit; background: #dfe7e1; }
.leaflet-control-zoom { border: none !important; box-shadow: 0 8px 25px rgba(20,35,29,.16) !important; }
.leaflet-control-zoom a { color: var(--ink) !important; border: 0 !important; }
.leaflet-control-attribution { font-size: 9px; }

.map-toolbar { position: absolute; z-index: 450; top: 17px; left: 17px; right: 17px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.map-action, .map-legend { pointer-events: auto; background: rgba(255,255,255,.94); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,.8); box-shadow: 0 8px 24px rgba(21,46,36,.13); }
.map-action { height: 39px; border-radius: 12px; padding: 0 13px; display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 11px; font-weight: 750; }
.map-action svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.map-legend { border-radius: 12px; display: flex; gap: 15px; padding: 11px 13px; font-size: 9px; font-weight: 700; color: var(--muted); }
.map-legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.legend-dot.working { background: var(--green); }
.legend-dot.available { background: #58a9cc; }
.legend-dot.attention { background: var(--orange); }

.driver-marker { position: relative; width: 42px; height: 42px; border-radius: 15px 15px 15px 4px; transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 7px 18px rgba(20,35,29,.28); display: grid; place-items: center; background: var(--marker-color); }
.driver-marker span { transform: rotate(45deg); color: white; font-size: 11px; font-weight: 900; }
.driver-marker.selected { box-shadow: 0 0 0 5px rgba(31,104,77,.18), 0 10px 24px rgba(20,35,29,.32); }
.leaflet-div-icon { background: transparent; border: none; }

.driver-detail { position: absolute; z-index: 460; left: 18px; bottom: 19px; width: min(380px, calc(100% - 36px)); border: 1px solid rgba(255,255,255,.9); background: rgba(255,255,255,.97); backdrop-filter: blur(18px); border-radius: 20px; box-shadow: var(--shadow); padding: 18px; }
.detail-close { position: absolute; top: 12px; right: 13px; border: 0; background: var(--soft); border-radius: 9px; width: 29px; height: 29px; cursor: pointer; font-size: 18px; line-height: 1; }
.detail-topline { gap: 12px; }
.detail-topline h2 { margin: 4px 0 2px; font-size: 18px; }
.detail-topline p { margin: 0; color: var(--muted); font-size: 10px; }
.detail-grid { margin: 17px 0 13px; display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.detail-grid div { border-top: 1px solid var(--line); padding-top: 9px; }
.detail-grid .wide { grid-column: 1 / -1; }
.detail-grid dt { font-size: 9px; color: var(--muted); }
.detail-grid dd { margin: 4px 0 0; font-size: 11px; font-weight: 700; }
.route-summary { display: flex; align-items: center; justify-content: space-between; padding: 10px 11px; border-radius: 12px; background: var(--soft); font-size: 10px; color: var(--muted); }
.route-summary strong { color: var(--ink); font-size: 13px; }
.route-line { display: flex; align-items: center; gap: 6px; }
.route-line i { width: 20px; border-top: 3px solid var(--red); border-radius: 3px; }
.demo-notice { position: absolute; z-index: 440; right: 18px; bottom: 19px; display: flex; align-items: center; gap: 8px; color: #55625b; background: rgba(255,255,255,.91); border-radius: 10px; padding: 8px 10px; font-size: 9px; box-shadow: 0 7px 20px rgba(20,35,29,.1); }
.demo-notice span { color: #9b6227; font-weight: 900; letter-spacing: .08em; background: #fff1df; border-radius: 6px; padding: 3px 5px; }

@keyframes spin { to { transform: rotate(360deg); } }
.login-screen { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 25% 20%, #294d3f 0, #14231d 48%, #0c1712 100%); }
.login-screen[hidden] { display: none; }
.login-card { width: min(390px, 100%); padding: 34px; border: 1px solid rgba(255,255,255,.17); border-radius: 24px; background: rgba(255,255,255,.97); box-shadow: 0 28px 80px rgba(0,0,0,.35); }
.login-mark { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 22px; border-radius: 15px; color: #fff; background: var(--green); font-size: 13px; font-weight: 900; }
.login-card h2 { margin: 3px 0 7px; font-size: 25px; }
.login-lead { margin: 0 0 23px; color: var(--muted); font-size: 12px; }
.login-card label { display: grid; gap: 7px; margin-top: 14px; color: var(--muted); font-size: 11px; font-weight: 700; }
.login-card input { height: 45px; border: 1px solid var(--line); border-radius: 11px; padding: 0 13px; color: var(--ink); background: var(--soft); font: inherit; outline: none; }
.login-card input:focus { border-color: #78a993; background: #fff; box-shadow: 0 0 0 3px rgba(31,104,77,.09); }
.login-card button { width: 100%; height: 46px; margin-top: 19px; border: 0; border-radius: 12px; color: #fff; background: var(--green); font-weight: 800; cursor: pointer; }
.login-card button:disabled { opacity: .6; cursor: wait; }
.login-error { min-height: 16px; margin: 10px 0 -6px; color: var(--red); font-size: 11px; }
.connection-error { color: #9d3a31 !important; }
@media (max-width: 860px) {
  body { overflow: auto; }
  .topbar { height: 68px; padding: 0 15px; }
  .sync-state, .account-button div, .account-button svg { display: none; }
  .account-button { padding: 5px; }
  .main-layout { height: auto; min-height: calc(100vh - 68px); grid-template-columns: 1fr; grid-template-rows: auto 65vh; }
  .sidebar { max-height: 44vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .overview { padding: 17px 15px 13px; }
  .driver-section { padding: 13px; }
  .driver-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-legend { display: none; }
}
@media (max-width: 520px) {
  .driver-list { grid-template-columns: 1fr; }
  .metric-card { min-height: 72px; padding: 10px; }
  .metric-card strong { font-size: 23px; }
  .demo-notice { display: none; }
}
