:root {
  --bg: #f5f7fc;
  --text: #18233f;
  --muted: #566176;
  --line: #cdd6ea;
  --panel: #ffffff;
  --primary: #253b93;
  --primary-dark: #1d2e73;
  --danger: #b42318;
  --warn: #f4c542;
  --late: #e5484d;
  --done: #dff5e8;
  --info: #e8f1fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
}

a {
  color: var(--primary);
}

.page {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 64px;
}

.page.wide {
  width: min(1440px, calc(100% - 20px));
}

.topbar,
.driver-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  padding: 10px 0;
}

.brand-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.driver-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.top-actions .small-btn {
  width: auto;
}

.language-switch {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.language-switch .small-btn {
  width: auto;
  min-height: 36px;
  padding: 7px 10px;
}

.language-switch .active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.language-switch.compact {
  justify-content: flex-end;
}

.brand-logo {
  width: min(260px, 42vw);
  max-height: 76px;
  object-fit: contain;
  background: white;
  border-radius: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 32px;
  margin-bottom: 4px;
}

h2 {
  font-size: 22px;
}

.panel,
.driver-card,
.next-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
}

.flat {
  background: transparent;
  border: 0;
  padding: 0;
}

.narrow {
  max-width: 420px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.grid,
.upload-grid,
.review-grid,
.manual-grid,
.config-grid {
  display: grid;
  gap: 12px;
}

.upload-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.review-grid {
  grid-template-columns: 1fr 1fr;
}

.manual-grid {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  margin-top: 8px;
}

.config-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.stats {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 16px;
}

.stats div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.stats strong {
  display: block;
  font-size: 24px;
}

.stats span,
.muted,
.topbar p,
.driver-header p {
  color: var(--muted);
}

input,
select,
textarea,
button,
.link-btn,
.small-btn {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
}

button,
.link-btn,
.small-btn {
  background: var(--pale);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.primary:hover {
  background: var(--primary-dark);
}

.danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.warning-btn {
  background: var(--warn);
  color: #17211b;
  border-color: #d6a90e;
  font-weight: 700;
}

.version-message {
  margin-top: 12px;
  line-height: 1.35;
}

.inline-download {
  width: auto;
  min-height: 38px;
  margin-top: 8px;
}

.download-panel {
  max-width: 640px;
  margin: 32px auto;
  text-align: center;
}

.download-main {
  min-height: 58px;
  font-size: 20px;
  margin: 14px auto 0;
}

.download-help {
  margin-top: 18px;
  color: var(--muted);
  line-height: 1.4;
}

.big {
  font-size: 20px;
  min-height: 56px;
}

.huge {
  font-size: 22px;
  min-height: 66px;
  margin-top: 12px;
}

.small-btn,
.link-btn {
  width: auto;
  min-width: 120px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.route-list {
  display: grid;
  gap: 10px;
}

.route-item {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfb;
}

.route-item p {
  margin: 4px 0 0;
  color: var(--muted);
}

.notice {
  background: #eaf7ef;
  border: 1px solid #b8e2c7;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.notice.warn {
  background: #fff8dc;
  border-color: #f0d675;
}

.notice.error {
  background: #ffe8e6;
  border-color: #efb4ae;
  color: #6f120b;
}

.android-announcement {
  white-space: pre-wrap;
  line-height: 1.45;
}

.copy-link-field {
  font-weight: 700;
  color: var(--primary-dark);
  background: #fbfdfb;
}

.soft-separator {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

.sql-ok {
  display: inline-flex;
  align-items: center;
  width: auto;
  min-height: 34px;
  border-radius: 999px;
  padding: 6px 12px;
  background: #e7f7ed;
  color: var(--primary-dark);
  font-weight: 700;
}

.archive-list {
  display: grid;
  gap: 8px;
}

.nav-routes {
  display: grid;
  grid-template-columns: 140px 1fr 140px;
  align-items: center;
  text-align: center;
}

.disabled-link {
  opacity: 0.45;
  pointer-events: none;
}

.log-box {
  background: #101815;
  color: #eaf7ef;
  border-radius: 8px;
  padding: 14px;
  overflow: auto;
  min-height: 360px;
  max-height: 70vh;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.45;
}

.table-wrap {
  overflow-x: auto;
}

.route-depot-group + .route-depot-group {
  margin-top: 22px;
}

.route-depot-group h3 {
  margin: 12px 0 6px;
  padding: 8px 10px;
  border-left: 4px solid var(--primary);
  background: #f4f7fa;
  font-size: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 700;
}

.review-head,
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.badges,
.summary-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.choice-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.choice-line input[type="checkbox"] {
  width: auto;
  min-height: auto;
  margin-top: 3px;
}

.choice-line .muted {
  display: block;
  margin-top: 4px;
}

.choice-block {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.review-head.compact {
  align-items: center;
  gap: 12px;
}

.combine-list {
  display: grid;
  gap: 8px;
}

.combine-row {
  display: grid;
  grid-template-columns: 28px minmax(180px, 1fr) 120px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.combine-row input[type="checkbox"] {
  width: auto;
  min-height: auto;
}

.combine-main {
  font-weight: 700;
}

.combine-group-input {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.combine-group-input input {
  min-height: 34px;
  width: 64px;
  padding: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eef3ef;
  font-size: 14px;
}

.badge.gasit {
  background: var(--done);
}

.badge.incert {
  background: #fff5cc;
}

.badge.negasit {
  background: #ffe8e6;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: rgba(245, 247, 245, 0.95);
  padding: 12px 0;
}

.driver-page {
  width: min(760px, calc(100% - 16px));
  margin: 0 auto;
  padding: 12px 0 48px;
}

.map-page {
  width: min(1200px, calc(100% - 16px));
  margin: 0 auto;
  padding: 12px 0;
}

.map-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.route-map {
  width: 100%;
  height: calc(100vh - 110px);
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #eef3ef;
}

.driver-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 10px 0;
}

.status-pill {
  width: auto;
  min-height: 34px;
  border-radius: 999px;
  padding: 8px 12px;
  background: #e7f7ed;
  white-space: nowrap;
}

.status-pill.offline {
  background: #fff1c2;
}

.progress-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.next-card {
  border-color: #b7d8c5;
  box-shadow: 0 6px 24px rgba(18, 106, 67, 0.08);
}

.client-title {
  font-size: 26px;
  line-height: 1.18;
  margin-bottom: 8px;
}

.stop-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.stop-meta span {
  background: #f1f4f2;
  border-radius: 8px;
  padding: 8px;
}

.nav-grid,
.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.option-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stop-list {
  display: grid;
  gap: 8px;
}

.row-actions {
  display: grid;
  gap: 8px;
  min-width: 150px;
}

.agent-dialog {
  width: min(520px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.agent-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.agent-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.agent-row strong {
  min-width: 0;
  font-size: clamp(14px, 3.6vw, 17px);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.agent-row .link-btn {
  min-width: 110px;
}

.stop-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.stop-row.livrat {
  background: var(--done);
}

.stop-row.sarit {
  background: var(--info);
}

.stop-row.geocodat_gresit {
  background: #fff2df;
  border-color: #f0b15f;
}

.stop-row.geocodat_gresit .order-pill {
  background: #f59e0b;
  color: white;
}

.stop-row.client_inchis,
.stop-row.refuzat {
  background: #ffe8e6;
  border-color: #efb4ae;
}

.stop-row.client_inchis .order-pill,
.stop-row.refuzat .order-pill {
  background: var(--danger);
  color: white;
}

.order-pill {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: #eef3ef;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.details {
  display: grid;
  gap: 8px;
}

.details div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.details dt {
  color: var(--muted);
}

.details dd {
  margin: 0;
  text-align: right;
  font-weight: 700;
}

@media (max-width: 760px) {
  h1 {
    font-size: 26px;
  }

  .upload-grid,
  .review-grid,
  .manual-grid,
  .config-grid,
  .stop-meta,
  .nav-grid,
  .option-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .map-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .route-map {
    height: calc(100vh - 150px);
  }

  .stop-row {
    grid-template-columns: 42px 1fr;
  }

  .stop-row .small-btn,
  .row-actions {
    grid-column: 1 / -1;
    width: 100%;
  }
}
.test-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 8px 16px;
  background: #8a2f17;
  color: #fff;
  text-align: center;
  font-weight: 800;
}

.borg-entry {
  margin-bottom: 18px;
}

.borg-toolbar .inline-form {
  align-items: end;
}

.borg-email-rule {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 4px solid #147a49;
  background: #edf8f2;
  color: #174f36;
}

.borg-driver-block {
  padding: 16px 0;
  border-top: 1px solid #d9e1dc;
}

.borg-driver-block:first-of-type {
  border-top: 0;
}

.borg-driver-block h3 {
  margin: 0 0 4px;
}

.borg-group-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.borg-group-total {
  display: grid;
  gap: 2px;
  padding: 7px 9px;
  border: 1px solid #c7d4cc;
  border-radius: 6px;
  background: #f5f8f6;
  font-size: 12px;
  line-height: 1.25;
  min-width: 130px;
}

.borg-group-total strong {
  color: #174f36;
}

.borg-unit-value {
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.borg-client-table th:last-child,
.borg-client-table td:last-child {
  width: 170px;
}

.borg-client-table select {
  min-width: 150px;
}

.borg-client-table tr.client-unmapped td {
    background: #fff1ef;
}

.loading-editor {
  margin-top: 10px;
}

.loading-editor > summary {
  cursor: pointer;
  width: fit-content;
  list-style: none;
}

.loading-editor > summary::-webkit-details-marker {
  display: none;
}

.loading-editor[open] > summary {
  margin-bottom: 10px;
  background: #126a43;
  border-color: #126a43;
  color: white;
}

.stop-row.client-unmapped {
  border-left: 6px solid #b42318;
  background: #fff1ef;
}

button.success-action {
  border-color: #147a49;
  background: #147a49;
  color: #fff;
}

.weekday-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.weekday-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.schedule-time-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

@media (max-width: 600px) {
  .schedule-time-grid {
    grid-template-columns: 1fr;
  }
}

.borg-actions,
.borg-generate-form {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 900px) {
  .borg-group-totals {
    justify-content: flex-start;
  }
}
.compact-settings {
  max-width: 720px;
}

.input-suffix {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-suffix input,
.minutes-input {
  max-width: 110px;
}

.tabs-inline,
.client-time-search {
  display: flex;
  gap: 8px;
}

.client-time-search {
  margin: 14px 0;
}

/* Geraico mobile: explicit location proposal before administrator approval. */
.geocode-dialog { width: min(680px, calc(100vw - 24px)); max-height: 95dvh; padding: 20px; }
.geocode-picker-map { height: min(48dvh, 380px); min-height: 230px; border-radius: 14px; border: 1px solid #d9d6e8; }
.geocode-dialog .dialog-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.geocode-picker-pin span { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 3px solid white; border-radius: 50%; background: #6750a4; color: white; font: 700 26px system-ui; box-shadow: 0 2px 10px #0006; }

/* GO identity shared with the Geraico Android application. Status colors retain meaning. */
:root { --pale: #ebeffb; }
h1,h2,h3 { letter-spacing: -.025em; }
h1 { font-size: clamp(24px, 3.2vw, 32px); }
body { line-height: 1.45; }
.panel,.driver-card,.next-card,.stats div,.progress-line { border-radius: 18px; box-shadow: 0 3px 14px #18233f05; }
.panel,.driver-card,.next-card { padding: 22px; }
input,select,textarea,button,.link-btn,.small-btn { border-radius: 12px; min-height: 46px; }
.primary,button.primary,a.primary,.language-switch .active,.loading-editor[open]>summary { background: var(--primary); border-color: var(--primary); color: white; }
input:focus-visible,select:focus-visible,textarea:focus-visible,button:focus-visible,a:focus-visible { outline: 3px solid #253b9366; outline-offset: 3px; }
.topbar,.driver-header,.map-header { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.brand-logo { width: 94px; max-height: 76px; border: 0; padding: 0; border-radius: 10px; }
.brand-mark { width: 68px; height: 56px; object-fit: contain; background: white; flex: 0 0 auto; border-radius: 10px; }
.route-identity { display: flex; align-items: center; gap: 14px; min-width: 0; }
.route-identity>div { min-width: 0; }
.route-identity h1,.route-identity p { overflow-wrap: anywhere; }
.driver-header { top: 8px; flex-wrap: wrap; }
.driver-actions { flex: 1 1 auto; justify-content: flex-end; }
.next-card { border-color: #cdd6ea; box-shadow: 0 8px 28px #253b930d; }
.stop-meta span,.loading-editor>summary { background: var(--pale); }
.nav-grid button,.nav-grid a { min-height: 50px; }
.dialog-actions { flex-wrap: wrap; }
dialog { border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 20px 70px #18233f38; }
dialog::backdrop { background: #18233f66; }
@media(max-width:600px) {
  .page,.page.wide,.driver-page { width: calc(100% - 20px); padding-top: 10px; }
  .topbar,.driver-header,.map-header { position: static; padding: 12px; gap: 12px; }
  .brand-head { gap: 10px; }
  .brand-logo { width: 72px; max-height: 56px; }
  .brand-mark { width: 54px; height: 46px; }
  .route-identity { gap: 10px; width: 100%; }
  .top-actions,.driver-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .top-actions form { flex: 0 0 auto; }
  .panel,.driver-card,.next-card { padding: 16px; }
  .client-title { font-size: 24px; overflow-wrap: anywhere; }
  .progress-line { padding: 14px; }
  .nav-grid,.option-grid { gap: 8px; }
  .nav-grid button,.nav-grid a,.option-grid button { padding: 10px 8px; font-size: 15px; }
  .geocode-dialog { padding: 16px; max-width: calc(100vw - 20px); }
  .geocode-dialog .dialog-actions button { width: 100%; }
}

/* Mobile route controls stay in two predictable rows, including old WebViews. */
@media(max-width:600px) {
  .driver-header .driver-actions { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; min-width: 0; }
  .driver-header .driver-actions .language-switch { grid-column: 1 / -1; display: flex; flex-wrap: nowrap; justify-content: flex-end; gap: 6px; }
  .driver-header .language-switch .small-btn { width: 44px; min-width: 44px; min-height: 44px; padding: 8px 6px; }
  .driver-header .driver-actions > .small-btn { width: auto; min-width: 0; min-height: 44px; padding: 8px 10px; font-size: 14px; white-space: nowrap; }
  .driver-header .driver-actions > .status-pill { min-width: 0; max-width: 94px; padding: 8px 10px; font-size: 12px; text-align: center; }
  .driver-header .status-pill.offline { white-space: normal; overflow-wrap: anywhere; }
}
