/* Delivery pricing simulator — loaded after legal.css, which supplies the base tokens,
   the header/footer chrome and the document typography. */

:root {
  --ok: var(--green);
  --warn: var(--amber);
  --surface-2: var(--surface-sunken);
  --shadow: var(--shadow-card);
  --radius: var(--radius-md);
  --maxw: 1180px;
}

.wrap { max-width: var(--maxw); }
.doc-head .lede { max-width: 62ch; }
.hint { font-size: 0.8rem; color: var(--muted); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tag {
  font-size: 0.75rem; font-weight: 500; color: var(--ink-muted); background: var(--surface-raised);
  border: 1px solid var(--line); padding: 3px 9px; border-radius: var(--radius-sm); display: inline-block;
}

/* opened straight from disk: modules and fetch are both blocked, so say so */
#fileWarn { display: none; }
html[data-file="1"] #fileWarn { display: block; }
html[data-file="1"] #simApp { display: none; }

/* ---------- buttons (same shapes as the landing page) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 20px; border-radius: 12px; cursor: pointer; border: 1px solid transparent;
  font: 600 0.95rem/1.2 var(--font-text); white-space: nowrap;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: var(--ink-inverse); }
.btn-primary:hover { background: var(--blue-hover); }
.btn-ghost { background: transparent; color: var(--blue); border-color: var(--blue); }
.btn-ghost:hover { background: var(--blue-soft); }
.btn-wa { background: #25D366; color: #06371c; }
.btn-sm { padding: 8px 13px; font-size: 0.83rem; border-radius: 10px; }

/* ---------- tabs ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 26px 0 22px; }
.tab {
  padding: 9px 17px; border-radius: 100px; cursor: pointer; font: 600 0.88rem/1.3 var(--font-text);
  color: var(--text-2); background: var(--surface); border: 1px solid var(--line);
}
.tab:hover { border-color: var(--blue); color: var(--blue); }
.tab[aria-selected="true"] { background: var(--blue); border-color: var(--blue); color: var(--ink-inverse); }
.tabs.pick { margin: 12px 0 0; }
.tabs.pick .tab { padding: 7px 14px; font-size: 0.82rem; }

/* ---------- layout ---------- */
.sim-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 20px; align-items: start; }
.stack { display: grid; gap: 18px; }

/* ---------- map + zone chips ---------- */
.cov { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; }
.cov-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 2px 4px 12px; }
.cov-head h2 { font-size: 1rem; font-weight: 700; }
.cov-map { height: 330px; border-radius: var(--radius-md); overflow: hidden; background: var(--surface-sunken); direction: ltr; position: relative; z-index: 0; border: 1px solid var(--line); }
.cov-map .leaflet-container { background: var(--surface-sunken); font-family: var(--font-sans); }
.cov-map .leaflet-tile-pane { filter: saturate(0.6) brightness(1.02); }
html[data-theme="dark"] .cov-map .leaflet-tile-pane { filter: invert(1) hue-rotate(186deg) brightness(0.78) contrast(0.95) saturate(0.4); }
.cov-map .leaflet-control-attribution { background: rgba(255, 255, 255, 0.75); color: var(--ink-muted); font-size: 10px; }
html[data-theme="dark"] .cov-map .leaflet-control-attribution { background: rgba(11, 13, 31, 0.75); }
.cov-map .leaflet-control-attribution a { color: var(--ink-muted); }
.cov-map .zone-tip {
  background: var(--navy-deep); color: #fff; border: 0; border-radius: var(--radius-md);
  padding: 6px 10px; font: 600 0.8rem/1.3 var(--font-sans); box-shadow: 0 12px 26px -14px rgba(15, 19, 48, .7); white-space: nowrap;
}
html[data-theme="dark"] .cov-map .zone-tip { background: var(--navy); color: var(--ink-inverse); }
.cov-map .zone-tip::before { border-top-color: var(--navy-deep); }
html[data-theme="dark"] .cov-map .zone-tip::before { border-top-color: var(--navy); }
.zone-label small { display: block; font-weight: 500; opacity: 0.8; font-size: 0.72rem; margin-top: 2px; }
.mk-pick { width: 18px; height: 18px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px rgba(4, 11, 247, .25); display: grid; place-items: center; }
html[data-theme="dark"] .mk-pick { box-shadow: 0 0 0 4px rgba(123, 132, 255, .3); }
.mk-pick::after { content: ""; width: 6px; height: 6px; border-radius: 2px; background: #fff; }
.gov-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.gov {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: var(--radius-pill); cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line-strong); color: var(--ink);
  font: 600 0.86rem/1.2 var(--font-sans);
}
.gov:hover { border-color: var(--blue); }
.gov .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; opacity: .85; flex: none; }
.gov[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.cov-foot { display: flex; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; padding: 12px 4px 0; font-size: 0.78rem; color: var(--muted); }

/* ---------- forms ---------- */
.form-card { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; }
.form-card h2 { font-size: 1.05rem; font-weight: 700; }
.form-card > p { font-size: 0.86rem; color: var(--muted); margin-top: 6px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 0.78rem; font-weight: 600; color: var(--text-2); }
.field input, .field select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-md); background: var(--surface);
  border: 1.5px solid var(--line-strong); color: var(--ink); font: 400 0.92rem/1.5 var(--font-sans);
}
.field input[type="number"] { font-variant-numeric: tabular-nums; }
.field input:focus-visible, .field select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.field input:focus, .field select:focus { border-color: var(--blue); }

/* per-zone batch rows */
.zone-rows { margin-top: 16px; display: grid; gap: 8px; }
.zone-rows .zr-head, .zone-row { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 8px; align-items: center; }
.zone-rows .zr-head span { font-size: 0.72rem; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
html[lang="ar"] .zone-rows .zr-head span { text-transform: none; font-size: 0.8rem; }
.zone-rows .zr-head span:not(:first-child), .zone-row input { text-align: end; }
.zone-row .zname { font-size: 0.86rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.zone-row input { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface); border: 1.5px solid var(--line-strong); color: var(--ink); font: 400 0.88rem/1.4 var(--font-sans); font-variant-numeric: tabular-nums; width: 100%; }

/* ---------- results ---------- */
.verdict[hidden] { display: none; }   /* [hidden] loses to display:grid without this */
.verdict { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; background: var(--surface-raised); display: grid; gap: 4px; }
.verdict .vtitle { font-weight: 700; font-size: 1rem; display: flex; align-items: center; gap: 9px; }
.verdict .vbody { font-size: 0.88rem; color: var(--text-2); }
.verdict .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.verdict.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); }
.verdict.ok .dot, .verdict.ok .vtitle { color: var(--ok); }
.verdict.ok .dot { background: var(--ok); }
.verdict.breach { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); }
.verdict.breach .dot, .verdict.breach .vtitle { color: var(--warn); }
.verdict.breach .dot { background: var(--warn); }

.details { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px 24px; }
.details h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.dgroup { margin-top: 14px; }
.dgroup > .gtitle { font-size: 0.72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
html[lang="ar"] .dgroup > .gtitle { text-transform: none; font-size: 0.82rem; }
.drow { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.drow:last-child { border-bottom: 0; }
.drow .k { color: var(--muted); }
.drow .v { font-weight: 600; text-align: end; overflow-wrap: anywhere; }
.drow.is-total { border-top: 1px solid var(--line); border-bottom: 0; margin-top: 2px; }
.drow.is-total .k, .drow.is-total .v { color: var(--text); font-weight: 700; }
.drow.is-cap .v { color: var(--blue); }

.bill-wrap { overflow-x: auto; margin-top: 12px; }
.bill { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 460px; }
.bill th, .bill td { text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.bill th { font-size: 0.72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
html[lang="ar"] .bill th { text-transform: none; font-size: 0.8rem; }
.bill td.num, .bill th.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bill tfoot td { font-weight: 700; border-bottom: 0; border-top: 1px solid var(--line); }

.res-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.res-actions .btn { flex: 1 1 auto; min-width: 0; white-space: normal; }

/* ---------- rate card + JSON panels ---------- */
details.panel { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 22px; margin-top: 18px; }
details.panel > summary { cursor: pointer; font-weight: 700; font-size: 0.98rem; display: flex; align-items: center; gap: 10px; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "+"; margin-inline-start: auto; color: var(--muted); font-weight: 600; }
details.panel[open] > summary::after { content: "–"; }
details.panel > summary + p { font-size: 0.84rem; color: var(--muted); margin-top: 8px; }
.rate-group { margin-top: 16px; }
.rate-group h3 { font-size: 0.8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
html[lang="ar"] .rate-group h3 { text-transform: none; font-size: 0.88rem; }
.rate-group .fields { grid-template-columns: repeat(3, 1fr); margin-top: 0; }
.json-io { display: grid; gap: 14px; margin-top: 16px; }
.json-io textarea {
  width: 100%; min-height: 150px; resize: vertical; padding: 12px; border-radius: 12px;
  background: var(--surface-raised); border: 1px solid var(--line); color: var(--ink);
  font: 400 0.8rem/1.6 var(--font-mono);
  direction: ltr; unicode-bidi: isolate;
}
.json-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.callout { background: var(--surface-raised); border: 1px solid var(--line); border-inline-start: 6px solid var(--blue); border-radius: var(--radius-md); padding: 14px 18px; margin-top: 18px; }
.callout p { font-size: 0.9rem; color: var(--ink-muted); }
.callout.warn { border-inline-start-color: var(--warn); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .sim-grid { grid-template-columns: 1fr; }
  .rate-group .fields { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  .fields, .rate-group .fields { grid-template-columns: 1fr; }
  .cov-map { height: 280px; }
  .cov, .form-card, .details, details.panel { padding: 16px; }
  .zone-rows .zr-head, .zone-row { grid-template-columns: 1fr repeat(3, 60px); gap: 6px; }
  .zone-row .zname { font-size: 0.8rem; }
  .res-actions .btn { min-width: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
