:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d7e0e8;
  --header: #17212b;
  --primary: #ef3b6d;
  --primary-dark: #bd2852;
  --secondary: #1677c8;
  --green: #127c56;
  --amber: #9a5b00;
  --red: #b42318;
  --shadow: 0 10px 28px rgba(17, 34, 51, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

button,
input,
select,
textarea,
a {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #82c5ff;
  outline-offset: 2px;
}

h1,
h2,
p {
  margin: 0;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 22px;
  background: #eaf0f5;
}

.login-card {
  width: min(100%, 420px);
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid #c8d4df;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card img {
  width: 160px;
  height: 72px;
  object-fit: contain;
  justify-self: center;
}

.login-card h1,
.login-card p {
  text-align: center;
}

.login-card h1 {
  font-size: 26px;
}

.login-card p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px;
  border: 1px solid #becbd6;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-size: 16px;
}

textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.45;
}

.form-error {
  min-height: 21px;
  color: var(--red);
  font-weight: 800;
}

.btn,
.icon-text-btn,
.close-btn,
.action-tab {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
}

.btn.primary {
  background: var(--primary);
  color: #ffffff;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  background: var(--secondary);
  color: #ffffff;
}

.btn.full {
  width: 100%;
}

.btn[aria-disabled="true"] {
  opacity: 0.48;
  pointer-events: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--header);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.header-brand,
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-brand img {
  width: 42px;
  height: 42px;
}

.header-brand strong,
.header-brand span {
  display: block;
}

.header-brand strong {
  font-size: 16px;
}

.header-brand span {
  margin-top: 2px;
  color: #cbd5df;
  font-size: 12px;
}

.network-badge {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  background: #fff1c2;
  color: #684000;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.network-badge.online {
  background: #d8f8e8;
  color: #075f3f;
}

.network-badge.offline {
  background: #fee4e2;
  color: #8f1c13;
}

.icon-text-btn,
.close-btn {
  padding: 9px 12px;
  background: #2d3d4d;
  color: #ffffff;
}

.icon-text-btn.danger {
  background: #8f1c13;
}

main {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 18px 18px 42px;
}

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

.summary-grid article {
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-grid span,
.summary-grid strong {
  display: block;
}

.summary-grid span {
  color: var(--muted);
  font-size: 13px;
}

.summary-grid strong {
  margin-top: 6px;
  font-size: 26px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(160px, 220px) auto auto;
  gap: 10px;
  margin-top: 16px;
}

.notice {
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid #b9d9f5;
  border-radius: 8px;
  background: #edf7ff;
  color: #174f7c;
  line-height: 1.4;
}

.notice.error {
  border-color: #f1b8b4;
  background: #fff1f0;
  color: #8f1c13;
}

.route-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.route-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--secondary);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.route-card.visited {
  border-left-color: var(--green);
}

.route-card.unsuccessful {
  border-left-color: var(--amber);
}

.route-card.paid {
  border-left-color: var(--green);
  background: #f5fcf8;
}

.route-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.route-card h2 {
  font-size: 18px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.route-card .cpf {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  height: fit-content;
  padding: 5px 8px;
  border-radius: 999px;
  background: #e9f2fb;
  color: #175b91;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.route-card address {
  min-height: 44px;
  color: #344054;
  font-style: normal;
  line-height: 1.4;
}

.route-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.route-meta div {
  padding: 9px;
  border-radius: 6px;
  background: #f4f7fa;
}

.route-meta span,
.route-meta strong {
  display: block;
}

.route-meta span {
  color: var(--muted);
  font-size: 11px;
}

.route-meta strong {
  margin-top: 3px;
  font-size: 14px;
}

.route-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.route-actions .btn {
  flex: 1 1 120px;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 34px 18px;
  border: 1px dashed #b7c5d1;
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  text-align: center;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(14, 24, 34, 0.66);
}

.sheet {
  width: min(100%, 680px);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 20px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.small-sheet {
  width: min(100%, 430px);
  display: grid;
  gap: 14px;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.sheet-header h2 {
  margin-top: 3px;
  font-size: 23px;
  overflow-wrap: anywhere;
}

.sheet-header p {
  margin-top: 5px;
  color: var(--muted);
}

.eyebrow {
  color: var(--secondary);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.client-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.client-facts div {
  padding: 12px;
  border-radius: 6px;
  background: #f3f6f9;
}

.client-facts .wide {
  grid-column: 1 / -1;
}

.client-facts span,
.client-facts strong {
  display: block;
}

.client-facts span {
  color: var(--muted);
  font-size: 12px;
}

.client-facts strong {
  margin-top: 4px;
  line-height: 1.35;
}

.message-field {
  margin-top: 16px;
}

.message-field textarea {
  background: #f9fbfc;
}

.contact-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.action-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 20px 0 14px;
  padding: 5px;
  border-radius: 8px;
  background: #e9eef3;
}

.action-tab {
  padding: 9px 8px;
  background: transparent;
  color: #475467;
}

.action-tab.active {
  background: #ffffff;
  color: #17212b;
  box-shadow: 0 2px 8px rgba(16, 32, 48, 0.12);
}

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

.form-grid label:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.location-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin-top: 14px;
  font-size: 14px;
}

.location-option input {
  width: 22px;
  height: 22px;
  min-height: 0;
}

.muted-text {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 300;
  max-width: min(440px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 8px;
  background: #17212b;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--red);
}

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
  }

  .header-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .network-badge {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  main {
    padding: 14px 12px 34px;
  }

  .toolbar,
  .route-list {
    grid-template-columns: 1fr;
  }

  .toolbar .btn {
    width: 100%;
  }

  .sheet-backdrop {
    align-items: end;
    padding: 0;
  }

  .sheet {
    width: 100%;
    max-height: calc(100vh - max(14px, env(safe-area-inset-top)));
    padding: 18px 16px max(22px, env(safe-area-inset-bottom));
    border-radius: 8px 8px 0 0;
  }
}

@media (max-width: 470px) {
  .header-brand img {
    width: 36px;
    height: 36px;
  }

  .header-brand strong {
    font-size: 14px;
  }

  .icon-text-btn {
    min-height: 42px;
    padding: 8px 10px;
  }

  .summary-grid article {
    min-height: 78px;
    padding: 11px;
  }

  .summary-grid strong {
    font-size: 22px;
  }

  .route-meta,
  .client-facts,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .client-facts .wide,
  .form-grid label:last-child:nth-child(odd) {
    grid-column: auto;
  }

  .contact-actions,
  .action-tabs {
    grid-template-columns: 1fr;
  }

  .action-tab {
    min-height: 44px;
  }
}
