/* ============ Placematic Delivery Cost Calculator ============ */

:root {
  --accent: #3DD6B5;
  --accent-strong: #2bbf9f;
  --accent-ink: #06251f;
  --navy: #0d1b3e;

  /* light theme (default) */
  --page-bg: #EBEEF2;
  --widget-bg: #FFFFFF;
  --form-bg: #FFFFFF;
  --text: #0A1628;
  --muted: #6B7480;
  --faint: #9AA3AE;
  --border: #E4E8EC;
  --border-strong: #D2D8DE;
  --input-bg: #F7F8FA;
  --chip-bg: #F1F3F6;
  --shadow: 0 24px 60px -20px rgba(10, 22, 40, 0.28), 0 8px 24px -12px rgba(10, 22, 40, 0.12);

  /* output panel (dark in both themes, but values swap) */
  --panel-bg: #0A1628;
  --panel-surface: #142436;
  --panel-line: rgba(255,255,255,0.08);
  --panel-text: #FFFFFF;
  --panel-muted: #8C99AB;
  --panel-faint: #5E6C80;

  /* HERE suite + data-viz */
  --here: #2B6FDB;
  --mm-grid: #DCE3EA;
  --mm-water: #9FC3E8;
  --dc0: #EEF2F5; --dc1: #BFE9DC; --dc2: #6FD8BE; --dc3: #2BBF9F;
}

html[data-theme="dark"] {
  --page-bg: #050B14;
  --widget-bg: #0C1827;
  --form-bg: #0C1827;
  --text: #EAF0F5;
  --muted: #8A97A8;
  --faint: #5E6C80;
  --border: #1C2E44;
  --border-strong: #25394f;
  --input-bg: #0F1E30;
  --chip-bg: #122134;
  --shadow: 0 30px 70px -24px rgba(0,0,0,0.7);

  --panel-bg: #07111E;
  --panel-surface: #102134;
  --panel-line: rgba(255,255,255,0.07);

  --here: #4D8DF5;
  --mm-grid: #1C2E44;
  --mm-water: #244A6E;
  --dc0: #122134; --dc1: #14463A; --dc2: #1E7A63; --dc3: #2BBF9F;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: transparent;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease;
}

.stage {
  background: transparent;
  transition: background 0.4s ease;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 24px;
}

html.pm-embedded .stage {
  min-height: 0;
  padding: 20px 24px 56px;
}

.mono { font-family: "DM Mono", ui-monospace, monospace; }

/* ---------- widget shell ---------- */
.widget {
  width: 940px;
  max-width: 100%;
  background: var(--widget-bg);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: background 0.4s ease, border-color 0.4s ease;
}

/* ---------- header ---------- */
.header {
  background: var(--navy);
  background-image: radial-gradient(120% 140% at 100% 0%, rgba(61,214,181,0.16) 0%, rgba(61,214,181,0) 45%);
  padding: 18px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: #6b8afd;
  svg {
    fill: #6b8afd;
  }
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand-sub { 
      font-size: 11px;
    margin-top: 2px;
  font-weight: 500; letter-spacing: 0.02em; }

.header-right { display: flex; align-items: center; gap: 14px; }
.pill-tag {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  color: #cdd6e2; background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 5px 10px; border-radius: 999px; text-transform: uppercase;
}

/* theme toggle */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 0;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px; padding: 3px; cursor: pointer;
}
.theme-toggle button {
  border: 0; background: transparent; cursor: pointer;
  width: 30px; height: 26px; border-radius: 999px;
  display: grid; place-items: center; color: #9fb0c2;
  transition: all 0.2s ease;
}
.theme-toggle button.on { background: var(--accent); color: var(--accent-ink); }

/* ---------- body grid ---------- */
.body {
  display: grid;
  grid-template-columns: 1fr 372px;
}
.form {
  padding: 28px 30px 32px;
  background: var(--form-bg);
  transition: background 0.4s ease;
  overflow-y: auto !important;
    max-height: 930px;  
}
.form::-webkit-scrollbar {
    width: 10px;
}
.form::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 8px;
    border: 3px solid white;
}

/* ---------- sections ---------- */
.section + .section { margin-top: 26px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.section-num {
  width: 22px; height: 22px; border-radius: 7px;
  background: var(--chip-bg); color: var(--muted);
  font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
.section-title { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }

/* ---------- fields ---------- */
.field { margin-bottom: 16px; position: relative; }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-icon { position: absolute; left: 13px; color: var(--faint); display: grid; place-items: center; pointer-events: none; }

.input, .select-btn {
  width: 100%;
  height: 46px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  padding: 0 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.4s ease;
  outline: none;
}
.input.has-icon { padding-left: 40px; }
.input.is-loading { border-color: rgba(61,214,181,0.55); }
.input::placeholder { color: var(--faint); }
.input:focus, .select-btn:focus, .select-btn.open {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(61,214,181,0.15);
}

.dollar-prefix {
  position: absolute; left: 14px; font-weight: 600; color: var(--muted); font-size: 15px;
}
.input.has-dollar { padding-left: 28px; font-family: "DM Mono", monospace; font-weight: 500; }

/* ---------- autocomplete ---------- */
.ac-list {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--widget-bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 18px 40px -16px rgba(10,22,40,0.35);
  z-index: 30; overflow: hidden; padding: 5px;
}
.ac-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  font-size: 13.5px; color: var(--text);
}
.ac-item:hover, .ac-item.active { background: var(--chip-bg); }
.ac-item svg { color: var(--accent-strong); flex: none; }
.ac-item .ac-sub { color: var(--faint); font-size: 12px; }
.ac-item.ac-status {
  cursor: default;
  color: var(--faint);
}
.ac-item.ac-status:hover { background: transparent; }
.ac-item.ac-status svg { color: var(--faint); }
.ac-main { display: flex; flex-direction: column; line-height: 1.25; }

/* ---------- custom select / dropdown ---------- */
.select-btn { display: flex; align-items: center; justify-content: space-between; cursor: pointer; text-align: left; }
.select-btn .chev { color: var(--faint); transition: transform 0.2s ease; }
.select-btn.open .chev { transform: rotate(180deg); }
.menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--widget-bg); border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: 0 18px 40px -16px rgba(10,22,40,0.35);
  z-index: 30; padding: 5px;
}
.menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 11px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.menu-item:hover { background: var(--chip-bg); }
.menu-item.sel { color: var(--accent-strong); font-weight: 600; }
.menu-item .tick { color: var(--accent-strong); }

/* ---------- segmented toggle ---------- */
.segment {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--chip-bg); border-radius: 11px; padding: 4px; gap: 4px;
}
.seg-btn {
  border: 0; background: transparent; cursor: pointer;
  height: 38px; border-radius: 8px; font-family: inherit;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.18s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.on {
  background: var(--widget-bg); color: var(--text);
  box-shadow: 0 2px 6px -2px rgba(10,22,40,0.18);
}
[data-theme="dark"] .seg-btn.on { background: #1d3047; color: #fff; }
.seg-btn .seg-sub { font-size: 11px; font-weight: 500; color: var(--faint); }

/* ---------- vehicle selector ---------- */
.vehicles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.veh {
  border: 1.5px solid var(--border); background: var(--input-bg);
  border-radius: 12px; padding: 14px 8px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--muted); transition: all 0.18s ease;
}
.veh:hover { border-color: var(--border-strong); color: var(--text); }
.veh.on {
  border-color: var(--accent); color: var(--text);
  background: color-mix(in srgb, var(--accent) 10%, var(--input-bg));
  box-shadow: 0 0 0 3px rgba(61,214,181,0.12);
}
.veh-label { font-size: 12px; font-weight: 600; }.veh-fee { font-size: 10.5px; font-weight: 500; color: var(--faint); font-family: "DM Mono", monospace; }
.veh.on .veh-fee { color: var(--accent-strong); }

/* in-form free delivery bar */
.form-freeship { margin-top: 11px; }
.form-freeship-bar {
  height: 7px; border-radius: 999px; overflow: hidden;
  background: var(--chip-bg); border: 1px solid var(--border);
}
.form-freeship-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  transition: width 0.45s cubic-bezier(.4,0,.2,1);
}
.form-freeship-cap { margin-top: 7px; font-size: 11.5px; color: var(--muted); }
.form-freeship-cap b { color: var(--accent-strong); font-family: "DM Mono", monospace; font-weight: 600; }
.form-freeship-cap .ff-muted { color: var(--faint); }
.form-freeship-cap .ff-unlocked { color: var(--accent-strong); font-weight: 600; }
.form-warning {
  margin-top: 9px;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid color-mix(in srgb, #d94848 34%, var(--border));
  background: color-mix(in srgb, #d94848 9%, var(--input-bg));
  color: #d94848;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
}

/* disabled vehicle red badge */
.veh-badge {
  margin-top: 4px; font-size: 9.5px; font-weight: 700; letter-spacing: 0.01em;
  color: #e5484d; background: color-mix(in srgb, #e5484d 13%, transparent);
  border: 1px solid color-mix(in srgb, #e5484d 30%, transparent);
  padding: 2px 6px; border-radius: 6px; line-height: 1.25; text-align: center;
  white-space: nowrap;
}
.veh.disabled { filter: none; }
.veh.disabled .veh-label, .veh.disabled svg, .veh.disabled .veh-fee { opacity: 0.5; filter: grayscale(1); }

/* disabled vehicle + tooltip */
.veh { position: relative; }
.veh.disabled {
  cursor: not-allowed; opacity: 0.4;
  border-color: var(--border); background: var(--input-bg);
  filter: grayscale(1);
}
.veh.disabled:hover { border-color: var(--border); color: var(--muted); }
.veh-tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 150px; white-space: normal;
  background: var(--navy); color: #fff;
  font-size: 11px; font-weight: 500; line-height: 1.3; letter-spacing: 0;
  padding: 7px 9px; border-radius: 8px; text-align: center;
  box-shadow: 0 10px 24px -8px rgba(10,22,40,0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.15s ease, transform 0.15s ease;
  transform: translateX(-50%) translateY(4px); z-index: 40; filter: none;
}
.veh-tip::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--navy);
}
.veh.disabled:hover .veh-tip { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-theme="dark"] .veh-tip { background: #1d3047; }
[data-theme="dark"] .veh-tip::after { border-top-color: #1d3047; }

/* ---------- slider ---------- */
.slider-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 9px; }
.slider-row .now { color: var(--accent-strong); font-weight: 700; }
.slider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 8px;
  border-radius: 999px; outline: none; cursor: pointer;
  background: var(--chip-bg);
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 4px solid var(--accent);
  box-shadow: 0 3px 8px -2px rgba(10,22,40,0.35); cursor: grab;
}
.slider::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 4px solid var(--accent);
  box-shadow: 0 3px 8px -2px rgba(10,22,40,0.35); cursor: grab; border-radius:50%;
}
.slider-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--faint); margin-top: 7px; }

/* extras collapsible */
.extras-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font-family: inherit; padding: 0; margin-bottom: 0;
}
.extras-head .extras-chev { margin-left: auto; color: var(--faint); transition: transform 0.22s ease; }
.extras-head.open .extras-chev { transform: rotate(180deg); }
.extras-body { margin-top: 16px; }
.promo-row { display: flex; gap: 8px; }
.promo-row .input { flex: 1; }
.promo-apply {
  appearance: none; border: 0; cursor: pointer; flex: none;
  height: 46px; padding: 0 18px; border-radius: 11px;
  background: var(--navy); color: #fff; font-family: inherit; font-size: 13.5px; font-weight: 600;
  transition: background 0.16s ease;
}
[data-theme="dark"] .promo-apply { background: var(--accent); color: var(--accent-ink); }
.promo-apply:hover { background: #16263d; }
[data-theme="dark"] .promo-apply:hover { background: var(--accent-strong); }
.promo-ok { display: block; margin-top: 8px; font-size: 11.5px; color: var(--accent-strong); font-weight: 500; }
.promo-ok.promo-bad { color: #d94848; }

/* ============ OUTPUT PANEL ============ */
.panel {
  background: var(--panel-bg);
  background-image: radial-gradient(120% 80% at 100% 0%, rgba(61,214,181,0.12) 0%, rgba(61,214,181,0) 50%);
  color: var(--panel-text);
  padding: 26px 24px 22px;
  display: flex; flex-direction: column;
  position: relative;
}
.panel-topbar { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.panel-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--panel-muted); white-space: nowrap; }

.cost {
  display: flex; align-items: flex-start; gap: 2px;
  margin-top: 8px; margin-bottom: 2px;
  font-family: "DM Mono", monospace;
}
.cost .cur { font-size: 26px; font-weight: 500; color: var(--accent); margin-top: 7px; }
.cost .amt { font-size: 56px; font-weight: 500; line-height: 1; letter-spacing: -0.02em; color: #fff; font-variant-numeric: tabular-nums; }
.cost .amt.blocked { font-family: "DM Sans", sans-serif; font-size: 38px; font-weight: 700; letter-spacing: 0; color: #fff; }
.cost-flash { animation: flash 0.5s ease; }
@keyframes flash { 0% { color: var(--accent); } 100% { color: #fff; } }

.eta {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 4px; color: var(--panel-text);
  background: var(--panel-surface);
  border: 1px solid var(--panel-line);
  padding: 7px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; align-self: flex-start; white-space: nowrap;
}
.eta svg { color: var(--accent); }
.eta .eta-num { font-family: "DM Mono", monospace; }

.route {
  margin-top: 18px; padding: 14px;
  background: var(--panel-surface); border: 1px solid var(--panel-line);
  border-radius: 12px;
}
.route-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.route-row + .route-row { margin-top: 4px; }
.route-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.route-dot.from { background: var(--panel-faint); }
.route-dot.to { background: var(--accent); }
.route-line { width: 9px; display: flex; justify-content: center; }
.route-line span { width: 2px; height: 12px; background: var(--panel-line); border-radius: 2px; }
.route-addr { color: var(--panel-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route-meta { margin-left: auto; color: var(--panel-muted); font-family: "DM Mono", monospace; font-size: 11.5px; flex: none; }

/* receipt */
.receipt { margin-top: 18px; border-top: 1px dashed var(--panel-line); padding-top: 14px; }
.receipt-title { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--panel-muted); margin-bottom: 10px; white-space: nowrap; }
.line { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; padding: 4px 0; min-height: 22px; }
.line .lbl { color: var(--panel-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line .val { font-family: "DM Mono", monospace; color: var(--panel-text); font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; }
.line .val.neg { color: var(--accent); }
.line.total {
  margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--panel-line);
  font-size: 15px;
}
.line.total .lbl { color: #fff; font-weight: 700; }
.line.total .val { color: #fff; font-weight: 700; font-size: 17px; }

.service-alert {
  margin-top: 18px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, #d94848 42%, var(--panel-line));
  background: color-mix(in srgb, #d94848 12%, var(--panel-surface));
  color: var(--panel-text);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.service-alert b { color: #fff; font-size: 13px; }
.service-alert span { color: var(--panel-muted); font-size: 12px; line-height: 1.45; }

/* free-delivery threshold */
.freeship { margin-top: 14px; }
.freeship-top { font-size: 11.5px; color: var(--panel-muted); margin-bottom: 8px; }
.freeship-bar {
  height: 7px; border-radius: 999px; overflow: hidden;
  background: var(--panel-surface); border: 1px solid var(--panel-line);
}
.freeship-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  transition: width 0.45s cubic-bezier(.4,0,.2,1);
}
.freeship-cap { margin-top: 8px; font-size: 11.5px; color: var(--panel-muted); }
.freeship-amt { color: var(--accent); font-weight: 700; font-family: "DM Mono", monospace; }
.freeship-unlocked { color: var(--accent); font-weight: 600; }

.cta {
  margin-top: 18px; width: 100%; height: 48px;
  border: 0; border-radius: 12px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  font-family: inherit; font-size: 14.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 10px 24px -10px rgba(61,214,181,0.6);
}
.cta:hover { background: var(--accent-strong); transform: translateY(-1px); box-shadow: 0 14px 28px -10px rgba(61,214,181,0.7); }
.cta:active { transform: translateY(0); }
.cta.disabled,
.cta:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}
.cta.disabled:hover,
.cta:disabled:hover {
  background: var(--accent);
  transform: none;
  box-shadow: none;
}

.here-caption {
  margin-top: 16px; display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 10.5px; color: var(--panel-faint); letter-spacing: 0.02em;
}
.here {
  width: 100%;
}
.here b { color: var(--panel-muted); font-weight: 600; }
.here-logo {
    display: none;
  /* display: inline-grid;  */
  place-items: center;
  background: #48DAD0; color: #00263A; font-weight: 800;
  font-size: 9px; letter-spacing: 0.03em;
  padding: 2px 5px; border-radius: 3px;
}

.placematic-logo, .placematic-logo a {
  /* display: none; */
  display: inline-grid; 
  place-items: center;
  color: #fff; font-weight: 800;
  font-size: 14px;
  line-height: 18px;  
  letter-spacing: 0.03em;
  background: linear-gradient(90deg, rgb(184, 156, 236), rgb(127, 168, 255)) text;
  -webkit-text-fill-color: transparent;
  cursor: pointer;
  text-decoration: none;
}
.placematic-logo a:hover {
  transition: 0.2s;
  transform: translateY(-2px);
  text-decoration: none;
}

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .stage { padding: 0; }
  .widget { border-radius: 0; min-height: 100vh; border: 0; }
  .body { grid-template-columns: 1fr; }
  .vehicles { grid-template-columns: repeat(3, 1fr); }
  .panel { border-top: 1px solid var(--panel-line); }
  .uwidget, .form {
    max-height: unset;
  }
  .acc-body {
    max-width: 94vw !important;
  }
  .cfg-scroll {
    max-height: unset !important;
    max-width: 100vw !important;
    padding: 12px !important;
  }
  .cfg-foot {
    flex-direction: column;
  }
  .pill-tag {
    display: none;
  }
  .utab-body {
        height: unset !important;
  }
  .route-addr, .veh-badge {
    white-space: normal;
  }
  .live-config-badge, .foot-spacer {
    display: none !important;
  }
  .opt-cards.three {
    grid-template-columns: 1fr !important;
  }
  .api-page {
        padding: 12px !important;
  }
  .api-section {
    max-width: calc(100vw - 48px) !important;
  }
}
