/* =========================================================
   Planificator curse TRMT — stiluri
   Paletă: asfalt, hârtie de diagramă tahograf, albastru conducere,
   chihlimbar pauză, verde repaus.
   ========================================================= */

:root {
  --asphalt: #1b2430;
  --asphalt-2: #263241;
  --paper: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #f8f9f7;
  --ink: #17202b;
  --ink-2: #3a4553;
  --muted: #5d6877;
  --line: #d8dcdf;
  --line-soft: #e7eae9;

  --drive: #1f4e9e;
  --drive-soft: #dfe7f5;
  --work: #5e6b7c;
  --avail: #a7b2bf;
  --break: #c98a12;
  --break-soft: #f8ecd2;
  --rest: #2f7656;
  --rest-soft: #dcede4;
  --danger: #b3261e;
  --danger-soft: #f9e2e0;

  --on-dark: #eef0ee;
  --on-dark-muted: #a6b0bc;

  --font: "Barlow", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-cond: "Barlow Semi Condensed", "Barlow", "Arial Narrow", system-ui, sans-serif;

  --r-sm: 6px;
  --r-md: 10px;
  --shadow: 0 1px 0 rgba(23, 32, 43, 0.04), 0 8px 24px -16px rgba(23, 32, 43, 0.35);

  --gap: clamp(16px, 2.2vw, 28px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12171e;
    --surface: #19202a;
    --surface-2: #1e2631;
    --ink: #e9ece9;
    --ink-2: #c4cad1;
    --muted: #8f9aa7;
    --line: #2e3845;
    --line-soft: #252e3a;
    --drive: #6f9be6;
    --drive-soft: #1d2b44;
    --work: #8f9cad;
    --avail: #566373;
    --break: #e2a23b;
    --break-soft: #3a2e17;
    --rest: #4fae83;
    --rest-soft: #173126;
    --danger: #f08a82;
    --danger-soft: #3b1d1b;
    --asphalt: #0d1117;
    --asphalt-2: #18202a;
    --shadow: 0 8px 24px -18px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #12171e; --surface: #19202a; --surface-2: #1e2631; --ink: #e9ece9; --ink-2: #c4cad1;
  --muted: #8f9aa7; --line: #2e3845; --line-soft: #252e3a; --drive: #6f9be6; --drive-soft: #1d2b44;
  --work: #8f9cad; --avail: #566373; --break: #e2a23b; --break-soft: #3a2e17; --rest: #4fae83;
  --rest-soft: #173126; --danger: #f08a82; --danger-soft: #3b1d1b; --asphalt: #0d1117; --asphalt-2: #18202a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

:root {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
html { scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 80px); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, svg { max-width: 100%; }
a { color: var(--drive); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--break); outline-offset: 2px; border-radius: 3px; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--surface); color: var(--ink); padding: 10px 14px; border-radius: var(--r-sm);
}
.skip-link:focus { top: 12px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- header ---------- */

.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  background: var(--asphalt);
  color: var(--on-dark);
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  background: var(--asphalt); z-index: 60;
}
.site-header__inner {
  max-width: 1440px; margin: 0 auto;
  padding: 0 var(--gap);
  height: 64px;
  display: flex; align-items: center; gap: 24px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  color: inherit; text-decoration: none;
}
.brand svg { width: 34px; height: 34px; flex: none; }
.brand__name {
  font-family: var(--font-cond); font-weight: 600; font-size: 1.15rem; letter-spacing: 0.01em;
  line-height: 1.1;
}
.brand__sub { display: block; font-family: var(--font); font-weight: 400; font-size: 0.8rem; color: var(--on-dark-muted); letter-spacing: 0; }

.site-nav { margin-left: auto; display: flex; gap: 4px; }
.site-nav a {
  color: var(--on-dark-muted); text-decoration: none; white-space: nowrap;
  font-weight: 500; font-size: 0.95rem;
  padding: 8px 14px; border-radius: var(--r-sm);
}
.site-nav a:hover { color: var(--on-dark); background: var(--asphalt-2); }
.site-nav a[aria-current="page"] { color: var(--on-dark); background: var(--asphalt-2); box-shadow: inset 0 -2px 0 var(--break); }

/* Bara de drum sub header: marcaj rutier discret, singurul ornament */
.road-mark {
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--break) 0 24px, transparent 24px 52px) var(--asphalt-2);
}

main { flex: 1; width: 100%; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer__inner {
  max-width: 1440px; margin: 0 auto; padding: 22px var(--gap);
  display: flex; flex-wrap: wrap; gap: 8px 32px; align-items: center; justify-content: space-between;
}
.site-footer strong { color: var(--ink); font-weight: 600; }
.site-footer nav { display: flex; gap: 20px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--ink); }

/* ---------- page intro ---------- */

.intro {
  max-width: 1440px; margin: 0 auto;
  padding: clamp(28px, 4vw, 48px) var(--gap) clamp(20px, 3vw, 32px);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 40px; align-items: end;
}
.intro h1 {
  font-family: var(--font-cond); font-weight: 600;
  font-size: clamp(2rem, 1.3rem + 2.6vw, 3.25rem);
  line-height: 1.02; letter-spacing: -0.01em; margin: 0;
  max-width: 18ch;
}
.intro p { margin: 12px 0 0; color: var(--ink-2); font-size: 1.08rem; max-width: 62ch; }
.intro__rules {
  display: flex; gap: 0; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); overflow: hidden;
}
.intro__rules div { padding: 10px 18px; border-left: 1px solid var(--line-soft); }
.intro__rules div:first-child { border-left: 0; }
.intro__rules b { display: block; font-family: var(--font-cond); font-weight: 600; font-size: 1.35rem; line-height: 1.1; }
.intro__rules span { font-size: 0.82rem; color: var(--muted); }

/* ---------- app layout ---------- */

.app {
  max-width: 1440px; margin: 0 auto; padding: 0 var(--gap) 56px;
  display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: var(--gap); align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
}

/* formular */
.planner { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 84px); max-height: calc(100vh - 100px); overflow: auto; }
.planner form { padding: 6px 0 0; }

.fieldset { border: 0; margin: 0; padding: 18px 22px; border-top: 1px solid var(--line-soft); }
.fieldset:first-of-type { border-top: 0; }
.fieldset > legend, .fieldset__title {
  float: left; width: 100%; padding: 0; margin: 0 0 14px;
  font-family: var(--font-cond); font-weight: 600; font-size: 1.05rem; color: var(--ink);
}
.fieldset > legend + * { clear: both; }

.mode {
  display: grid; grid-template-columns: 1fr 1fr; padding: 4px; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.mode input { position: absolute; opacity: 0; pointer-events: none; }
.mode label {
  text-align: center; padding: 8px 6px; border-radius: 4px; cursor: pointer;
  font-weight: 500; font-size: 0.92rem; color: var(--muted);
}
.mode input:checked + label { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12), inset 0 0 0 1px var(--line); }
.mode input:focus-visible + label { outline: 3px solid var(--break); outline-offset: 1px; }
.mode-note { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); }
.mode-note[data-tone="warn"] { color: var(--break); }

/* itinerariu: inputuri legate printr-o linie de traseu */
.itinerary { position: relative; display: grid; gap: 12px; }
.itinerary::before {
  content: ""; position: absolute; left: 13px; top: 40px; bottom: 40px; width: 2px;
  background: repeating-linear-gradient(180deg, var(--line) 0 6px, transparent 6px 11px);
}
.stop-row { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: start; }
.stop-pin {
  position: relative; z-index: 1;
  width: 28px; height: 28px; margin-top: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-cond); font-weight: 700; font-size: 0.85rem;
  background: var(--surface); color: var(--ink); border: 2px solid var(--ink);
}
.stop-pin--origin { background: var(--ink); color: var(--surface); }
.stop-fields { display: grid; grid-template-columns: minmax(0, 1fr) 92px; gap: 8px; }
.stop-fields .field--wide { grid-column: 1 / -1; }
.stop-row--origin .stop-fields { grid-template-columns: 1fr; }

.field { display: grid; gap: 5px; min-width: 0; }
.field label, .field .label { font-size: 0.85rem; color: var(--ink-2); font-weight: 500; }
.field input, .field select {
  width: 100%; min-width: 0;
  font: inherit; font-size: 0.98rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 11px; height: 42px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:hover { border-color: var(--muted); }
.field input:focus { outline: none; border-color: var(--drive); box-shadow: 0 0 0 3px var(--drive-soft); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field .unit { position: relative; }
.field .unit input { padding-right: 40px; }
.field .unit span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-size: 0.85rem; color: var(--muted); pointer-events: none; }
.field small { font-size: 0.8rem; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

.manual-only { display: none; }
[data-mode="manual"] .manual-only { display: grid; }
[data-mode="manual"] .ors-only { display: none; }

details.more { margin-top: 14px; }
details.more summary {
  cursor: pointer; font-size: 0.9rem; font-weight: 500; color: var(--drive);
  list-style: none; display: inline-flex; align-items: center; gap: 6px;
}
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+"; font-weight: 700; width: 12px; }
details.more[open] summary::before { content: "−"; }
details.more > div { margin-top: 12px; }

.actions {
  position: sticky; bottom: 0; padding: 16px 22px 20px;
  background: linear-gradient(to bottom, transparent, var(--surface) 24%);
  border-top: 1px solid var(--line-soft);
}
.btn {
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 1rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 0 18px; height: 46px; border-radius: var(--r-sm);
  text-decoration: none;
}
.btn--primary { width: 100%; background: var(--ink); color: var(--surface); }
.btn--primary:hover { background: var(--drive); }
.btn--primary[disabled] { opacity: .7; cursor: progress; }
.btn--ghost { height: 36px; padding: 0 12px; font-size: 0.9rem; font-weight: 500; background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.btn--ghost:hover { border-color: var(--ink-2); color: var(--ink); }
.btn svg { width: 18px; height: 18px; flex: none; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; display: none; }
.is-loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.form-error {
  margin: 12px 0 0; padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--danger-soft); color: var(--danger); font-size: 0.9rem;
}
.form-error[hidden] { display: none; }
.form-error button { all: unset; cursor: pointer; text-decoration: underline; font-weight: 600; }

/* ---------- rezultate ---------- */

.results { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); min-width: 0; }
.results > * { min-width: 0; }

.result-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px;
}
.result-head h2 {
  margin: 0; font-family: var(--font-cond); font-weight: 600; font-size: clamp(1.4rem, 1rem + 1.2vw, 1.9rem); line-height: 1.15;
}
.result-head p { margin: 4px 0 0; color: var(--muted); font-size: 0.95rem; }
.result-tools { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-block; vertical-align: middle; margin-left: 8px;
  font-family: var(--font); font-size: 0.78rem; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.badge--live { background: var(--rest-soft); color: var(--rest); border-color: transparent; }

/* rezumat: o bandă continuă, nu carduri separate */
.summary {
  display: grid; grid-template-columns: 1.3fr repeat(4, minmax(0, 1fr));
}
.summary > div { padding: 18px 20px; border-left: 1px solid var(--line-soft); min-width: 0; }
.summary > div:first-child { border-left: 0; }
.summary dt { font-size: 0.84rem; color: var(--muted); }
.summary dd { margin: 4px 0 0; font-family: var(--font-cond); font-weight: 600; font-size: clamp(1.25rem, 0.9rem + 0.8vw, 1.55rem); line-height: 1.1; white-space: nowrap; }
.summary dd small { white-space: normal; }
.summary dd small { display: block; font-family: var(--font); font-weight: 400; font-size: 0.84rem; color: var(--muted); margin-top: 3px; }
.summary .summary__arrival dd { font-size: 1.9rem; }

/* hartă + segmente */
.route-block { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); }
.map {
  min-height: 340px; height: 100%;
  border-radius: var(--r-md) 0 0 var(--r-md);
  background: var(--surface-2);
  position: relative; overflow: hidden; z-index: 0;
}
.map-empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px;
  color: var(--muted); font-size: 0.95rem;
  background:
    linear-gradient(var(--line-soft) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px) 0 0 / 32px 32px;
}
.map-empty p { max-width: 34ch; margin: 0; background: var(--surface); padding: 12px 16px; border-radius: var(--r-sm); border: 1px solid var(--line); }

.legs { padding: 20px 22px; border-left: 1px solid var(--line-soft); }
.legs h3, .block-title {
  margin: 0 0 14px; font-family: var(--font-cond); font-weight: 600; font-size: 1.15rem;
}
.leg-list { list-style: none; margin: 0; padding: 0; }
.leg-list li { position: relative; padding: 0 0 18px 26px; }
.leg-list li::before {
  content: ""; position: absolute; left: 6px; top: 8px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--ink);
}
.leg-list li::after { content: ""; position: absolute; left: 10px; top: 22px; bottom: 2px; width: 2px; background: var(--line); }
.leg-list li:last-child { padding-bottom: 0; }
.leg-list li:last-child::after { display: none; }
.leg-list li.is-origin::before { background: var(--ink); }
.leg-list .place { font-weight: 600; }
.leg-list .meta { font-size: 0.88rem; color: var(--muted); }
.leg-list .meta b { color: var(--ink-2); font-weight: 600; }

/* ---------- tahograf (elementul principal) ---------- */

.tacho { padding: 22px 22px 18px; }
.tacho__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 24px; margin-bottom: 6px; }
.tacho__head p { margin: 0; color: var(--muted); font-size: 0.9rem; max-width: 60ch; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 16px; padding: 0; list-style: none; font-size: 0.88rem; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend svg { width: 18px; height: 18px; }
.legend i { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }

.tacho__scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px 4px; }
.tacho svg.chart { display: block; width: 100%; min-width: 720px; height: auto; font-family: var(--font); }
.chart .axis text { font-size: 11px; fill: var(--muted); }
.chart .axis line { stroke: var(--line-soft); }
.chart .axis .day line { stroke: var(--line); }
.chart .axis .day text { font-size: 11.5px; fill: var(--ink-2); font-weight: 600; }
.chart .lane-label { font-family: var(--font-cond); font-size: 14px; font-weight: 600; fill: var(--ink); }
.chart .level-label { font-size: 10px; fill: var(--muted); }
.chart .baseline { stroke: var(--line); }
.chart .trace { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; }
.chart .marker line { stroke: var(--ink-2); stroke-dasharray: 3 3; }
.chart .marker text { font-size: 11px; fill: var(--ink-2); font-weight: 600; }
.chart .seg { cursor: crosshair; }
.chart .seg:hover { filter: brightness(1.12); }
.chart .act-drive { fill: var(--drive); }
.chart .act-work { fill: var(--work); }
.chart .act-avail { fill: var(--avail); }
.chart .act-break { fill: var(--break); }
.chart .act-rest { fill: var(--rest); }

.tooltip {
  position: fixed; z-index: 80; pointer-events: none;
  background: var(--asphalt); color: var(--on-dark);
  padding: 8px 11px; border-radius: var(--r-sm); font-size: 0.85rem; line-height: 1.35;
  max-width: 280px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.tooltip b { display: block; font-weight: 600; }
.tooltip[hidden] { display: none; }

/* contoare șoferi */
.drivers { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line-soft); }
.driver { padding: 18px 22px; }
.driver + .driver { border-left: 1px solid var(--line-soft); }
.driver h4 { margin: 0 0 12px; font-family: var(--font-cond); font-weight: 600; font-size: 1.05rem; }
.meter { display: grid; grid-template-columns: 116px minmax(0, 1fr) 140px; align-items: center; gap: 10px; font-size: 0.86rem; margin-top: 8px; }
.meter span:first-child { color: var(--muted); white-space: nowrap; }
.meter .bar { height: 8px; background: var(--line-soft); border-radius: 4px; overflow: hidden; }
.meter .bar i { display: block; height: 100%; background: var(--drive); border-radius: 4px; }
.meter .bar i.is-full { background: var(--break); }
.meter b { font-weight: 600; min-width: 92px; text-align: right; }

/* ---------- jurnal ---------- */

.log { padding: 22px; }
.log__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.log__head h3 { margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button {
  font: inherit; font-size: 0.86rem; cursor: pointer;
  padding: 5px 12px; border-radius: 999px;
  background: transparent; color: var(--ink-2); border: 1px solid var(--line);
}
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.log-day { margin: 0; }
.log-day + .log-day { margin-top: 18px; }
.log-day h4 {
  margin: 0 0 6px; padding: 6px 0; font-size: 0.9rem; font-weight: 600; color: var(--ink-2);
  border-bottom: 1px solid var(--line); text-transform: none;
}
.log-list { list-style: none; margin: 0; padding: 0; }
.log-list li {
  display: grid; grid-template-columns: 52px 22px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 0.93rem;
}
.log-list li:last-child { border-bottom: 0; }
.log-list time { color: var(--muted); font-weight: 500; padding-top: 1px; }
.log-list .ico { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 4px; }
.log-list .ico svg { width: 14px; height: 14px; }
.ico--drive { background: var(--drive-soft); color: var(--drive); }
.ico--break, .ico--alert, .ico--wait { background: var(--break-soft); color: var(--break); }
.ico--rest { background: var(--rest-soft); color: var(--rest); }
.ico--service, .ico--info, .ico--route, .ico--shift, .ico--swap, .ico--arrive { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.log-list li[data-type="alert"] .msg { color: var(--break); font-weight: 500; }
.log-list li[data-type="arrive"] .msg { font-weight: 600; }
.log-empty { color: var(--muted); font-size: 0.92rem; padding: 12px 0; }

.disclaimer { font-size: 0.86rem; color: var(--muted); margin: 0; padding: 0 2px; max-width: 90ch; }

/* stare inițială rezultate */
.results[aria-busy="true"] { opacity: .55; transition: opacity .2s; }
.reveal { animation: reveal .45s ease-out both; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Leaflet ---------- */

.leaflet-container { font-family: var(--font); background: var(--surface-2); }
.pin {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-cond); font-weight: 700; font-size: 13px;
  background: #fff; color: #17202b; border: 2px solid #17202b;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.pin--origin { background: #17202b; color: #fff; }

/* =========================================================
   Pagina Ghid
   ========================================================= */

.guide {
  max-width: 1200px; margin: 0 auto; padding: 0 var(--gap) 72px;
  display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: clamp(24px, 5vw, 72px); align-items: start;
}
.toc { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 92px); font-size: 0.93rem; }
.toc p { margin: 0 0 10px; font-weight: 600; color: var(--ink); }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.toc li a {
  display: block; white-space: nowrap; padding: 6px 0 6px 14px; margin-left: -2px; border-left: 2px solid transparent;
  color: var(--muted); text-decoration: none;
}
.toc li a:hover { color: var(--ink); }
.toc li a.is-active { color: var(--ink); border-left-color: var(--break); font-weight: 500; }

.prose { max-width: 72ch; }
.prose section { padding-top: 8px; }
.prose section + section { margin-top: 56px; padding-top: 40px; border-top: 1px solid var(--line); }
.prose h2 {
  font-family: var(--font-cond); font-weight: 600; font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.15rem);
  line-height: 1.1; margin: 0 0 16px;
}
.prose h3 { font-family: var(--font-cond); font-weight: 600; font-size: 1.25rem; margin: 32px 0 10px; }
.prose p, .prose li { font-size: 1.04rem; line-height: 1.65; color: var(--ink-2); }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 16px; }
.prose li + li { margin-top: 6px; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose .lead { font-size: 1.18rem; color: var(--ink); line-height: 1.55; }
.prose code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.88em;
  background: var(--surface); border: 1px solid var(--line); padding: 1px 6px; border-radius: 4px;
}
.prose pre {
  background: var(--asphalt); color: var(--on-dark); padding: 14px 16px; border-radius: var(--r-sm);
  overflow-x: auto; font-size: 0.9rem; line-height: 1.55;
}
.prose pre code { background: none; border: 0; padding: 0; color: inherit; }

/* pași: chiar sunt o secvență */
.steps { list-style: none; padding: 0 !important; counter-reset: step; margin: 20px 0 0 !important; }
.steps > li { counter-increment: step; position: relative; padding: 0 0 22px 52px; margin: 0 !important; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-cond); font-weight: 700; font-size: 1rem;
  background: var(--ink); color: var(--surface);
}
.steps > li::after { content: ""; position: absolute; left: 16px; top: 40px; bottom: 6px; width: 2px; background: var(--line); }
.steps > li:last-child::after { display: none; }
.steps h3 { margin: 4px 0 6px; font-size: 1.12rem; }
.steps p { margin: 0; }

/* tabel limite */
.table-wrap { overflow-x: auto; margin: 20px 0 8px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.96rem; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
thead th { font-weight: 600; color: var(--ink); background: var(--surface-2); border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
td.val { font-family: var(--font-cond); font-weight: 600; font-size: 1.12rem; color: var(--ink); white-space: nowrap; }
td small { display: block; color: var(--muted); font-size: 0.86rem; margin-top: 2px; }
.tag { display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.tag--yes { background: var(--rest-soft); color: var(--rest); }
.tag--part { background: var(--break-soft); color: var(--break); }
.tag--no { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.callout {
  margin: 22px 0; padding: 16px 18px 16px 20px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--break);
}
.callout p:last-child { margin-bottom: 0; }
.callout--rest { border-left-color: var(--rest); }

.symbols { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0; margin: 18px 0; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.symbols div { padding: 14px 16px; border-left: 1px solid var(--line-soft); }
.symbols div:first-child { border-left: 0; }
.symbols svg { width: 26px; height: 26px; display: block; margin-bottom: 8px; }
.symbols b { display: block; color: var(--ink); }
.symbols span { font-size: 0.9rem; color: var(--muted); }

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .summary > div:nth-child(4) { border-left: 0; }
  .summary > div:nth-child(n + 4) { border-top: 1px solid var(--line-soft); }
  .route-block { grid-template-columns: 1fr; }
  .map { border-radius: var(--r-md) var(--r-md) 0 0; min-height: 300px; }
  .legs { border-left: 0; border-top: 1px solid var(--line-soft); }
}

@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .planner { position: static; max-height: none; }
  .intro { grid-template-columns: 1fr; }
  .guide { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; }
  .toc ol { display: flex; flex-wrap: wrap; border-left: 0; gap: 6px; }
  .toc li a { border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; margin: 0; }
  .toc li a.is-active { border-color: var(--ink); }
}

@media (max-width: 640px) {
  .site-header__inner { height: 58px; gap: 12px; }
  .brand__sub { display: none; }
  .nav-long { display: none; }
  .brand__name { white-space: nowrap; }
  .site-nav a { padding: 7px 10px; font-size: 0.9rem; }
  .intro__rules { flex-wrap: wrap; }
  .intro__rules div { flex: 1 1 40%; }
  .intro__rules div:nth-child(3) { border-left: 0; }
  .intro__rules div:nth-child(n + 3) { border-top: 1px solid var(--line-soft); }
  .summary { grid-template-columns: 1fr 1fr; }
  .summary > div { border-left: 0 !important; border-top: 1px solid var(--line-soft); }
  .summary > div:nth-child(2n) { border-left: 1px solid var(--line-soft) !important; }
  .summary > div:first-child { grid-column: 1 / -1; border-top: 0; }
  .summary > div:nth-child(2) { border-left: 0 !important; }
  .summary > div:nth-child(2n + 1):not(:first-child) { border-left: 1px solid var(--line-soft) !important; }
  .drivers { grid-template-columns: 1fr; }
  .driver + .driver { border-left: 0; border-top: 1px solid var(--line-soft); }
  .log-list li { grid-template-columns: 46px 20px minmax(0, 1fr); gap: 8px; }
  .meter { grid-template-columns: 108px minmax(0, 1fr) auto; }
  .meter b { min-width: 0; }
  .site-footer__inner { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .road-mark, .planner, .result-tools, .filters, .site-footer nav, .map { display: none !important; }
  .app { grid-template-columns: minmax(0, 1fr); }
  body { background: #fff; }
  .panel { box-shadow: none; }
}

.intro--guide { max-width: 1200px; grid-template-columns: minmax(0, 1fr); }


/* =========================================================
   Tema TRMT — slate / blue, cu contrast și straturi vizuale
   ========================================================= */
:root[data-theme="light"] {
  --asphalt: #202c3c;
  --asphalt-2: #2a394d;
  --paper: #e7ebf1;
  --surface: #f5f7fa;
  --surface-2: #ebf0f6;
  --ink: #19273a;
  --ink-2: #40516a;
  --muted: #687991;
  --line: #cbd5e2;
  --line-soft: #dfe6ef;
  --drive: #315fd6;
  --drive-soft: #dce6ff;
  --work: #62748a;
  --avail: #a8b7c9;
  --break: #b87913;
  --break-soft: #fff0cf;
  --rest: #187654;
  --rest-soft: #d9f0e5;
  --danger: #b62d37;
  --danger-soft: #fbe1e3;
  --on-dark: #f4f7fb;
  --on-dark-muted: #bdc8d7;
  --shadow: 0 5px 18px rgba(28, 43, 64, .08);
  --r-sm: 8px;
  --r-md: 13px;
  color-scheme: light;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-size: 15.5px;
}
.site-header {
  position: sticky;
  background: var(--asphalt);
  color: var(--on-dark);
  border-bottom: 1px solid #172231;
  box-shadow: 0 3px 12px rgba(21, 32, 48, .14);
}
body::before { background: var(--asphalt); }
.site-header__inner { max-width: 1480px; height: 68px; }
.brand { color: var(--on-dark); }
.brand__name { font-size: 1.12rem; font-weight: 700; }
.brand__sub { color: var(--on-dark-muted); }
.site-nav a { color: #bdc8d7; border-radius: 8px; }
.site-nav a:hover { color: #fff; background: var(--asphalt-2); }
.site-nav a[aria-current="page"] {
  color: #fff;
  background: #34465f;
  box-shadow: inset 0 -2px 0 #efb545;
}
.road-mark {
  height: 3px;
  opacity: .95;
  background: repeating-linear-gradient(90deg, #efb545 0 30px, transparent 30px 54px) var(--asphalt-2);
}

.intro {
  max-width: 1480px;
  padding: clamp(28px, 3.5vw, 44px) var(--gap) 25px;
  grid-template-columns: minmax(0, 1fr) minmax(350px, 430px);
  gap: 28px;
  align-items: center;
}
.intro h1 {
  max-width: 18ch;
  color: #192a41;
  font-size: clamp(2rem, 1.45rem + 2.1vw, 2.9rem);
  line-height: 1.07;
  letter-spacing: -.035em;
}
.intro p {
  max-width: 65ch;
  margin-top: 13px;
  color: #455771;
  font-size: 1rem;
  line-height: 1.62;
}
.intro__rules {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  border: 0;
  background: transparent;
  overflow: visible;
}
.intro__rules div,
.intro__rules div:first-child {
  min-width: 0;
  padding: 12px 15px;
  border: 1px solid #ccd6e4;
  border-radius: 11px;
  background: #dce3ec;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65);
}
.intro__rules b { color: #284fb6; font-size: 1.32rem; }
.intro__rules span { color: #5e7088; font-size: .81rem; }

.app {
  max-width: 1480px;
  grid-template-columns: minmax(315px, 360px) minmax(0, 1fr);
  gap: 20px;
  padding-bottom: 52px;
}
.panel {
  border: 1px solid #cbd5e2;
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.planner {
  position: static;
  max-height: none;
  overflow: hidden;
}
.planner form { padding-top: 0; }
.fieldset {
  padding: 18px 20px;
  border-top-color: #dbe3ed;
}
.fieldset:nth-of-type(even) { background: #f0f3f8; }
.fieldset > legend, .fieldset__title {
  margin-bottom: 13px;
  color: #263a55;
  font-family: var(--font);
  font-size: .98rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
label { color: #40516a; font-size: .9rem; font-weight: 600; }
input, select, textarea {
  border-color: #c7d2e0;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: none;
}
input:hover, select:hover, textarea:hover { border-color: #91a4be; }
input:focus, select:focus, textarea:focus {
  border-color: #7191ef;
  box-shadow: 0 0 0 3px rgba(49,95,214,.13);
}
.mode {
  padding: 4px;
  gap: 4px;
  border-color: #ccd6e4;
  border-radius: 9px;
  background: #e5eaf2;
}
.mode label { padding: 9px 7px; border-radius: 7px; color: #5b6b81; }
.mode input:checked + label {
  color: #244dbf;
  background: #f9fbfe;
  box-shadow: 0 1px 4px rgba(27,44,77,.13);
}
.mode-note { font-size: .84rem; line-height: 1.55; }
.stop-pin {
  border-color: #bcc9d9;
  background: #e3eaf3;
  color: #354a65;
}
.stop-pin--origin { background: #dce6ff; color: #254ebf; border-color: #b9caff; }
.fieldset .more > summary { color: #2e56c2; font-weight: 650; }
.actions { padding: 0 20px 20px; background: #f0f3f8; }
.btn {
  border-radius: 9px;
  font-weight: 650;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: #315fd6;
  box-shadow: 0 4px 10px rgba(49,95,214,.2);
}
.btn--primary:hover { background: #264fc0; }
.btn--ghost { background: #e8edf4; color: #344860; border-color: #cbd5e2; }
.btn--ghost:hover { background: #dfe6f0; border-color: #b9c7d8; }

.results { gap: 15px; }
.result-head { align-items: center; gap: 12px 20px; padding: 2px 1px 0; }
.result-head h2 {
  color: #1b2b42;
  font-size: clamp(1.35rem, 1rem + .9vw, 1.8rem);
  letter-spacing: -.025em;
}
.result-head p { color: #63748c; line-height: 1.55; }
.result-tools { gap: 8px; }
.badge { margin-left: 4px; font-size: .74rem; }

.summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.summary > div {
  min-width: 0;
  padding: 15px 14px;
  border: 1px solid #cbd5e2;
  border-radius: 11px;
  background: #f0f3f8;
  box-shadow: 0 3px 10px rgba(28, 43, 64, .045);
}
.summary > div:nth-child(2) { background: #e4eaf2; }
.summary > div:nth-child(3) { background: #e1eafa; }
.summary > div:nth-child(4) { background: #f8edda; }
.summary > div:nth-child(5) { background: #e0eee7; }
.summary dt {
  color: #5c6e85;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.summary dd {
  margin-top: 8px;
  color: #1c2d45;
  font-size: clamp(1.08rem, .93rem + .42vw, 1.38rem);
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
}
.summary dd small {
  margin-top: 6px;
  color: #63748b;
  font-size: .77rem;
  line-height: 1.4;
  font-weight: 400;
}
.summary .summary__arrival {
  background: #dce6ff;
  border-color: #bacaff;
}
.summary .summary__arrival dd { color: #254dbd; font-size: clamp(1.2rem, 1rem + .6vw, 1.53rem); }

.route-block {
  grid-template-columns: minmax(0, 1.55fr) minmax(265px, 1fr);
  overflow: hidden;
  border-radius: 13px;
  background: #f3f6fa;
}
.map {
  min-height: 405px;
  border-radius: 12px 0 0 12px;
  background: #d9e1eb;
}
.map .leaflet-control-attribution {
  background: rgba(234,239,246,.94);
  color: #3c4e66;
  font-size: 10px;
}
.map .leaflet-control-attribution a { color: #244dbf; }
.map .leaflet-control-layers {
  border: 1px solid #b9c6d7;
  border-radius: 9px;
  background: rgba(242,246,251,.96);
  color: #22344c;
  box-shadow: 0 2px 10px rgba(20,34,52,.18);
}
.map .leaflet-control-layers-expanded { padding: 9px 12px; }
.map .leaflet-control-layers label { color: #23354e; font-size: 12px; font-weight: 600; }
.map .leaflet-control-layers-separator { border-top-color: #cbd5e2; }
.legs { padding: 22px 22px 18px; border-left-color: #dce3ec; background: #f5f7fa; }
.legs h3, .block-title { color: #243750; font-family: var(--font); font-weight: 700; }
.leg-list li { padding-bottom: 20px; }
.leg-list li::before { border-color: #8ca2bd; background: #f4f7fb; }
.leg-list li.is-origin::before { background: #315fd6; border-color: #315fd6; }
.leg-list li .place { color: #20334d; font-weight: 700; }
.leg-list li .meta { color: #61738b; font-size: .87rem; line-height: 1.5; }
.leg-list li .meta b { color: #304660; }

.results-details { padding: 0; overflow: hidden; box-shadow: var(--shadow); }
.results-details > summary { list-style: none; cursor: pointer; }
.results-details > summary::-webkit-details-marker { display: none; }
.results-details__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 21px;
  background: #e8edf4;
  transition: background .15s ease;
}
.results-details__summary:hover { background: #e0e7f0; }
.results-details[open] > .results-details__summary { background: #dde5f0; }
.results-details__summary > span:first-child { display: grid; gap: 4px; }
.results-details__summary strong { color: #263a55; font-size: .98rem; font-weight: 700; }
.results-details__summary small { color: #61728a; font-size: .84rem; line-height: 1.45; }
.details-toggle {
  display: inline-flex;
  align-items: center;
  color: #2c55c5;
  font-size: .82rem;
  font-weight: 700;
  white-space: nowrap;
}
.details-toggle::after { content: "＋"; margin-left: 8px; font-size: 1rem; }
.results-details[open] .details-toggle::after { content: "−"; }
.results-details__content {
  padding: 20px 22px;
  border-top: 1px solid #d3dce8;
  background: #f5f7fa;
}
.results-details__content .tacho { padding: 0; }
.results-details__content .drivers { margin-top: 22px; }
.tacho__head p { color: #63748b; }
.legend { color: #40516a; }
.log__head { align-items: flex-start; }
.filters button {
  padding: 6px 11px;
  border-radius: 999px;
  border-color: #cbd5e2;
  background: #e9eef5;
  color: #42546d;
}
.filters button:hover { background: #dfe6f0; }
.filters button[aria-pressed="true"] {
  background: #dce6ff;
  border-color: #b7c8ff;
  color: #234dbf;
}
.log-list li { border-bottom-color: #dfe6ef; }
.log-list time { color: #718198; }

.form-error { margin-top: 10px; color: var(--danger); line-height: 1.5; }
.form-error button { margin-left: 4px; }
.disclaimer { margin: 0; padding: 2px 2px 0; color: #61738b; font-size: .84rem; line-height: 1.55; }
.site-footer { background: #dce2eb; border-top: 1px solid #c4cfde; color: #53657d; }
.site-footer strong { color: #273c57; }
.site-footer a { color: #4d6079; }
.site-footer a:hover { color: #234dbf; }

@media (max-width: 1250px) {
  .intro { grid-template-columns: minmax(0, 1fr) 350px; }
  .app { grid-template-columns: minmax(290px, 330px) minmax(0, 1fr); }
  .summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .summary > div { border: 1px solid #cbd5e2 !important; }
  .route-block { grid-template-columns: minmax(0, 1.25fr) minmax(240px, 1fr); }
  .map { min-height: 370px; }
}
@media (max-width: 1050px) {
  .intro { grid-template-columns: minmax(0, 1fr); }
  .intro__rules { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 760px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .planner { position: static; }
  .route-block { grid-template-columns: minmax(0, 1.4fr) minmax(250px, 1fr); }
}
@media (max-width: 800px) {
  .intro { padding-top: 28px; padding-bottom: 22px; }
  .intro h1 { max-width: 22ch; font-size: clamp(1.9rem, 6vw, 2.55rem); }
  .intro__rules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app { padding-left: 16px; padding-right: 16px; gap: 18px; }
  .result-head { align-items: flex-start; flex-direction: column; }
  .result-tools { width: 100%; }
  .route-block { grid-template-columns: minmax(0, 1fr); }
  .map { min-height: 330px; height: 340px; border-radius: 12px 12px 0 0; }
  .legs { border-left: 0; border-top: 1px solid #dce3ec; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary .summary__arrival { grid-column: 1 / -1; }
  .summary > div { padding: 14px; }
  .results-details__summary { padding: 17px; }
  .results-details__content { padding: 17px; }
  .drivers { grid-template-columns: minmax(0, 1fr); }
  .driver + .driver { border-left: 0; border-top: 1px solid #d5dfeb; }
}
@media (max-width: 520px) {
  .site-header__inner { height: 60px; padding-left: 16px; padding-right: 16px; }
  .brand { gap: 8px; }
  .brand svg { width: 30px; height: 30px; }
  .brand__name { font-size: 1rem; }
  .brand__sub { display: none; }
  .site-nav { gap: 0; }
  .site-nav a { padding: 7px 9px; font-size: .84rem; }
  .nav-long { display: none; }
  .intro { padding-left: 16px; padding-right: 16px; }
  .intro p { font-size: .95rem; }
  .intro__rules div { padding: 11px 12px; }
  .result-tools .btn { flex: 1 1 auto; justify-content: center; }
  .summary { gap: 7px; }
  .summary > div { padding: 12px; }
  .summary dd { font-size: 1.1rem; }
  .summary dd small { font-size: .75rem; }
  .map { height: 300px; min-height: 300px; }
  .results-details__summary { align-items: flex-start; }
  .details-toggle { font-size: .76rem; }
  .details-toggle::after { margin-left: 4px; }
  .log-list li { grid-template-columns: 46px 20px minmax(0, 1fr); gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .results-details__summary { transition: none; }
}


/* Clear, stacked action for sending the just-calculated route to the live replay. */
.live-sim-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: .8rem;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid #cbd8e8;
  border-radius: 13px;
  background: linear-gradient(145deg, #f1f6ff, #fff9ef);
}
.live-sim-action[hidden] { display: none !important; }
.live-sim-action__copy {
  order: 0;
  display: grid;
  gap: .3rem;
  min-width: 0;
  text-align: left;
}
.live-sim-action__copy strong { color: #243a58; font-size: .96rem; }
.live-sim-action__copy span { color: #61738b; font-size: .84rem; line-height: 1.45; }
#open-live-simulation {
  order: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  width: 100%;
  min-height: 46px;
  white-space: nowrap;
}
#open-live-simulation span + span { font-size: 1.05rem; }
@media (max-width: 520px) {
  .live-sim-action { align-items: stretch; padding: .85rem; }
  #open-live-simulation { justify-content: center; width: 100%; }
}
