/* Kadana Rute */
:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --surface: #ffffff;
  --ink: #18282b;
  --muted: #637275;
  --line: #e5dfd3;
  --brand: #0f4f4b;
  --brand-2: #14706a;
  --brand-soft: #e3efec;
  --accent: #e08a2e;
  --start: #1d7f55;
  --end: #c0442c;
  --stop: #0f4f4b;
  --route: #14706a;
  --warn-bg: #fff4e2;
  --warn-ink: #8a5310;
  --ok-bg: #e6f4ec;
  --ok-ink: #17623f;
  --err: #b3321f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(24, 40, 43, .06), 0 8px 24px rgba(24, 40, 43, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101718;
    --panel: #151e20;
    --surface: #1b2729;
    --ink: #e8eeec;
    --muted: #93a3a2;
    --line: #2a3a3c;
    --brand: #5cc2b6;
    --brand-2: #4fb3a7;
    --brand-soft: #1d3634;
    --stop: #2a8f86;
    --route: #3fb2a5;
    --warn-bg: #3a2c14;
    --warn-ink: #f3c27a;
    --ok-bg: #173226;
    --ok-ink: #8fd9b0;
    --err: #ff8a75;
    --shadow: 0 8px 28px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14.5px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
b { font-weight: 650; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 430px 1fr; height: 100dvh; }
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); z-index: 2; }
.panel-body { flex: 1; overflow-y: auto; padding: 4px 18px 28px; }
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #dfe6e3; }

@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 42dvh 1fr; }
  .map-wrap { grid-row: 1; }
  .panel { grid-row: 2; border-right: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; margin-top: -14px; box-shadow: 0 -6px 20px rgba(0,0,0,.08); }
  .panel-body { padding: 4px 16px 32px; }
}

/* ---------- header & tabs ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--brand); color: #fff; }
.brand-mark svg { width: 20px; height: 20px; }
.brand-lg { justify-content: center; font-size: 20px; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.tabs { display: flex; gap: 4px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 10px 12px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- blocks ---------- */
.name-input { width: 100%; margin-top: 14px; border: 0; border-bottom: 1.5px dashed var(--line); background: transparent; padding: 6px 0; font-size: 17px; font-weight: 700; outline: none; }
.name-input:focus { border-bottom-color: var(--brand); }
.status-line { margin: 4px 0 0; font-size: 12px; color: var(--muted); min-height: 16px; }
.status-line.is-dirty { color: var(--accent); }
.block { margin-top: 18px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.block-head h3 { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.empty { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.hint { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: var(--brand-soft); font-size: 13.5px; }

/* ---------- inputs & search ---------- */
.search { position: relative; flex: 1; }
.search input, .stack input, .pin-input {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); outline: none; transition: border-color .15s;
}
.search input:focus, .stack input:focus, .pin-input:focus { border-color: var(--brand-2); }
.search input:disabled { opacity: .6; }
.slot-row { display: flex; gap: 8px; }
.dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 1000; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; padding: 4px;
}
.dd-item { display: flex; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 9px; cursor: pointer; align-items: flex-start; }
.dd-item.active, .dd-item:hover { background: var(--brand-soft); }
.dd-ic { color: var(--muted); padding-top: 1px; }
.dd-ic.is-fav { color: var(--accent); }
.dd-ic.is-fav svg { fill: currentColor; }
.dd-txt { display: flex; flex-direction: column; min-width: 0; }
.dd-txt small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-note { padding: 9px 10px; color: var(--muted); font-size: 13px; }

/* ---------- point cards & stops ---------- */
.pcard, .stop, .saved-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px;
}
.pinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pinfo b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinfo small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stops { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.stop { padding-left: 4px; }
.stop-ghost { opacity: .4; }
.drag { cursor: grab; color: var(--muted); padding: 4px 0 4px 4px; touch-action: none; display: flex; }
.drag svg { width: 16px; height: 16px; }
.stop-actions { display: flex; gap: 0; }
.stop-actions .icon-btn { width: 30px; height: 30px; }

.badge {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  font-size: 12px; font-weight: 800; color: #fff; background: var(--stop);
}
.badge-sm { width: 22px; height: 22px; font-size: 11px; }
.b-start { background: var(--start); }
.b-end { background: var(--end); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1.5px solid transparent;
  padding: 11px 16px; border-radius: 12px; font-weight: 700; cursor: pointer; text-decoration: none; transition: filter .15s, background .15s;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-dark { background: var(--ink); color: var(--panel); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: var(--brand-soft); }
.btn-sm { padding: 7px 11px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn.is-busy { position: relative; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: transparent; color: var(--muted); cursor: pointer; flex: none;
}
.icon-btn:hover:not(:disabled) { background: var(--brand-soft); color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.fav svg { fill: none; }
.icon-btn.fav.on { color: var(--accent); }
.icon-btn.fav.on svg { fill: currentColor; }
.btn-locate { width: 44px; height: 44px; border: 1.5px solid var(--line); background: var(--surface); color: var(--brand); }

.seg { display: flex; gap: 4px; padding: 4px; background: var(--brand-soft); border-radius: 12px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 6px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
#endSlot { margin-top: 8px; }

.actions { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; margin-top: 20px; }
.actions-save { grid-template-columns: 1fr; margin-top: 14px; }

/* ---------- result ---------- */
.result-card { margin-top: 16px; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { display: flex; flex-direction: column; padding: 10px; border-radius: 10px; background: var(--brand-soft); }
.stat b { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.stat span { font-size: 11.5px; color: var(--muted); }
.savings { margin-top: 10px; padding: 9px 12px; border-radius: 10px; background: var(--ok-bg); color: var(--ok-ink); font-size: 13px; }
.warn-note { margin-top: 10px; padding: 9px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; }
.legs { list-style: none; margin: 12px 0 0; padding: 0; }
.legs li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px dashed var(--line); }
.leg-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.leg-info b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leg-info small { color: var(--muted); }
.btn-nav { padding: 6px 10px; font-size: 12.5px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); }
.btn-nav svg { width: 14px; height: 14px; }
.gmaps { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.gmaps p { margin: 4px 0 0; }

/* ---------- saved ---------- */
.saved-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.saved-item.current { border-color: var(--brand-2); }
.saved-main { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 0; cursor: pointer; display: flex; flex-direction: column; }
.saved-main small { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin-top: 2px; }
.saved-actions { display: flex; align-items: center; gap: 2px; }

/* ---------- map ---------- */
.pin-wrap { background: none; border: 0; }
.pin {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  font: 800 12.5px 'Plus Jakarta Sans', system-ui, sans-serif; border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35);
  background: var(--stop);
}
.pin-start { background: var(--start); }
.pin-end { background: var(--end); }
.map-fit {
  position: absolute; z-index: 500; top: 14px; right: 14px; border: 0; padding: 8px 12px; border-radius: 10px;
  background: var(--surface); color: var(--ink); font-weight: 700; font-size: 13px; box-shadow: var(--shadow); cursor: pointer;
}
.map-pop { display: flex; flex-direction: column; gap: 6px; min-width: 190px; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; }
.map-pop p { margin: 0 0 2px; }
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-popup-content-wrapper { border-radius: 12px; }
.map-pop .btn-ghost { color: #18282b; border-color: #e5dfd3; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 16px; background: rgba(12, 22, 24, .55); backdrop-filter: blur(4px); }
.card { width: 100%; max-width: 380px; background: var(--panel); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h3 { margin: 0; }
.card hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.login-card { text-align: center; }
.pin-input { text-align: center; font-size: 26px; letter-spacing: .5em; margin: 6px 0 4px; padding-left: calc(13px + .5em); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form-error { color: var(--err); font-size: 13px; min-height: 18px; margin: 4px 0; }

/* ---------- kendaraan ---------- */
.seg-vehicle button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 6px; font-size: 14px; }
.seg-vehicle svg { width: 22px; height: 22px; }
.route-note { margin: 10px 0 0; }

/* ---------- tab lokasi ---------- */
.tab-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 2px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); font-size: 11px; line-height: 18px; text-align: center; }
.tab-count:empty { display: none; }
.dd-head { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.search-filter { margin-bottom: 8px; }
#view-places .small { margin: 6px 0 0; }

.place-item { position: relative; flex-wrap: wrap; padding-left: 8px; }
.place-item.is-selected { border-color: var(--brand-2); background: var(--brand-soft); }
.place-item .saved-main small.note { color: var(--accent); }
.check { display: flex; align-items: center; cursor: pointer; padding: 4px; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check span { width: 20px; height: 20px; border-radius: 6px; border: 1.8px solid var(--line); background: var(--surface); display: grid; place-items: center; transition: background .15s, border-color .15s; }
.check input:checked + span { background: var(--brand); border-color: var(--brand); }
.check input:checked + span::after { content: ''; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check input:focus-visible + span { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.tag { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 6px; background: var(--ok-bg); color: var(--ok-ink); font-size: 10.5px; font-weight: 700; vertical-align: 2px; }
.btn-add { gap: 3px; padding: 6px 9px; }
.btn-add svg { width: 14px; height: 14px; }
.more-menu { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 2px 34px; }
.more-menu button, .more-menu a {
  border: 1px solid var(--line); background: var(--surface); padding: 6px 10px; border-radius: 9px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--ink); text-decoration: none;
}
.more-menu button:hover, .more-menu a:hover { background: var(--brand-soft); }
.more-menu .danger { color: var(--err); }
.bulk-bar {
  position: sticky; bottom: 0; margin: 16px -4px 0; display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-radius: 14px; background: var(--ink); color: var(--panel); box-shadow: var(--shadow);
}
.bulk-bar span { flex: 1; font-weight: 600; font-size: 13.5px; }
.bulk-bar .btn-ghost { color: var(--panel); border-color: rgba(255,255,255,.3); }
.bulk-bar .btn-ghost:hover { background: rgba(255,255,255,.1); }
.pin-saved { width: 26px; height: 26px; background: var(--accent); border-width: 2px; }
.pin-saved svg { width: 14px; height: 14px; fill: #fff; stroke: #fff; }
.row-btns { display: flex; gap: 8px; justify-content: flex-end; }
.row-btns .btn-primary { flex: 1; }

.toast {
  position: fixed; z-index: 4000; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 11px 16px; border-radius: 12px; background: var(--ink); color: var(--panel); font-weight: 600; font-size: 13.5px; box-shadow: var(--shadow);
}
.toast-ok { background: var(--ok-ink); color: #fff; }
.toast-warn { background: var(--warn-ink); color: #fff; }
.toast-err { background: var(--err); color: #fff; }
