:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --ok: #2f855a;
  --ok-bg: #e8f5ee;
  --attention: #9a6700;
  --attention-bg: #fff4d6;
  --alert: #b54708;
  --alert-bg: #ffe8d6;
  --lost: #b42318;
  --lost-bg: #ffe4e1;
  --focus: #1d64d8;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.wide-shell {
  width: min(1180px, calc(100% - 32px));
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.1;
}

h2 {
  font-size: 26px;
  line-height: 1.15;
}

.cycle {
  min-width: 230px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: right;
}

.cycle strong,
.cycle span {
  display: block;
}

.cycle span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.access-panel,
.driver-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.access-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 28px;
  align-items: center;
  padding: 28px;
}

.access-copy p,
.driver-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.id-form label {
  display: block;
  margin-bottom: 8px;
  color: #344054;
  font-size: 14px;
  font-weight: 800;
}

.id-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.id-row input {
  width: 100%;
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.tool-field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.tool-field input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(29, 100, 216, 0.14);
}

.tool-field span {
  display: block;
  margin-bottom: 6px;
  color: #344054;
  font-size: 14px;
  font-weight: 800;
}

.id-row input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(29, 100, 216, 0.14);
}

.id-row button {
  min-width: 104px;
  height: 48px;
  border: 0;
  border-radius: 6px;
  background: var(--focus);
  color: #ffffff;
  font-weight: 800;
}

.form-message {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--lost);
  font-weight: 700;
}

.driver-detail {
  padding: 20px;
  overflow: hidden;
}

.driver-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.risk {
  min-width: 180px;
  text-align: right;
}

.risk strong {
  display: block;
  font-size: 46px;
  line-height: 0.95;
}

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

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 0;
}

.badge {
  display: inline-flex;
  min-width: 108px;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.badge.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge.atencao {
  background: var(--attention-bg);
  color: var(--attention);
}

.badge.alerta {
  background: var(--alert-bg);
  color: var(--alert);
}

.badge.perdida {
  background: var(--lost-bg);
  color: var(--lost);
}

.link-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: #344054;
  min-height: 36px;
  padding: 0 12px;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.segmented button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: #344054;
  font-weight: 700;
}

.segmented button.active {
  border-color: var(--focus);
  background: #eaf1ff;
  color: #143d85;
}

.whatsapp-tools,
.whatsapp-summary,
.message-card,
.manager-summary,
.manager-tools,
.manager-list,
.manager-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.whatsapp-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
  align-items: end;
  padding: 16px;
  margin-bottom: 14px;
}

.whatsapp-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 14px;
  overflow: hidden;
}

.whatsapp-summary article {
  min-height: 88px;
  padding: 14px;
  border-right: 1px solid var(--line);
}

.whatsapp-summary article:last-child {
  border-right: 0;
}

.whatsapp-summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.whatsapp-summary strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 1;
}

.message-list {
  display: grid;
  gap: 12px;
}

.message-card {
  padding: 16px;
}

.message-card.missing-phone {
  border-color: #ffd7ad;
  background: #fffaf2;
}

.message-card header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.message-card header span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.message-card textarea {
  width: 100%;
  min-height: 152px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: #344054;
  line-height: 1.45;
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.message-actions button,
.message-actions a {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 6px;
  font-weight: 800;
  text-decoration: none;
}

.message-actions button {
  border: 0;
  background: var(--focus);
  color: #ffffff;
}

.message-actions a {
  border: 1px solid #a7e4c1;
  background: #e8f5ee;
  color: #166534;
}

.manager-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 14px;
  overflow: hidden;
}

.manager-summary article {
  min-height: 92px;
  padding: 14px;
  border-right: 1px solid var(--line);
}

.manager-summary article:last-child {
  border-right: 0;
}

.manager-summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.manager-summary strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 1;
}

.metric-warning {
  background: #fff8ee;
}

.metric-danger {
  background: #fff2f0;
}

.manager-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
  align-items: end;
  padding: 16px;
  margin-bottom: 14px;
}

.manager-grid {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.manager-list {
  max-height: 690px;
  overflow: auto;
}

.manager-driver {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 13px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
}

.manager-driver:hover,
.manager-driver.active {
  background: #f4f8ff;
}

.manager-driver strong,
.manager-driver small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manager-driver small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.driver-count {
  color: #344054;
  font-weight: 900;
}

.manager-detail {
  min-height: 690px;
  padding: 18px;
  overflow: hidden;
}

.manager-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.manager-detail-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.manager-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.manager-actions a {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: #344054;
  font-weight: 800;
  text-decoration: none;
}

.manager-actions a:last-child {
  border-color: #a7e4c1;
  background: #e8f5ee;
  color: #166534;
}

.empty-panel {
  display: grid;
  min-height: 220px;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.progress {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 18px 0 16px;
}

.progress div {
  height: 12px;
  border-radius: 999px;
  background: #e7edf5;
}

.progress[data-level="1"] div:nth-child(1),
.progress[data-level="2"] div:nth-child(-n + 2),
.progress[data-level="3"] div {
  background: var(--ok);
}

.progress[data-status="atencao"] div:nth-child(1) {
  background: var(--attention);
}

.progress[data-status="alerta"] div:nth-child(-n + 2) {
  background: var(--alert);
}

.progress[data-status="perdida"] div {
  background: var(--lost);
}

.notice {
  margin: 0 0 16px;
  padding: 14px;
  border-radius: 8px;
  background: #f8fafc;
  color: #344054;
  font-weight: 800;
}

.notice.atencao {
  background: var(--attention-bg);
  color: var(--attention);
}

.notice.alerta {
  background: var(--alert-bg);
  color: var(--alert);
}

.notice.perdida {
  background: var(--lost-bg);
  color: var(--lost);
}

.share-box {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.share-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.share-box code {
  overflow-wrap: anywhere;
  color: #344054;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 13px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.occurrence-table {
  width: 100%;
  border-collapse: collapse;
}

.occurrence-table th,
.occurrence-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.occurrence-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.occurrence-table td {
  font-size: 14px;
}

.occurrence-table .type {
  font-weight: 800;
}

[hidden] {
  display: none !important;
}

.driver-hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 920px);
    padding: 18px 0;
  }

  .wide-shell {
    width: min(100% - 20px, 1180px);
  }

  .topbar,
  .driver-head,
  .manager-detail-head {
    align-items: stretch;
    flex-direction: column;
  }

  .cycle,
  .risk {
    text-align: left;
  }

  .access-panel {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .whatsapp-tools,
  .whatsapp-summary,
  .manager-tools,
  .manager-summary,
  .manager-grid {
    grid-template-columns: 1fr;
  }

  .whatsapp-summary article,
  .manager-summary article {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .whatsapp-summary article:last-child,
  .manager-summary article:last-child {
    border-bottom: 0;
  }

  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .id-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 26px;
  }

  h2 {
    font-size: 23px;
  }

  .driver-detail {
    padding: 14px;
  }

  .status-row {
    align-items: stretch;
    flex-direction: column;
  }

  .message-card header,
  .message-actions,
  .manager-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .manager-list {
    max-height: 440px;
  }

  .manager-detail {
    min-height: 0;
    padding: 14px;
  }

  .link-button {
    width: 100%;
  }

  .occurrence-table {
    min-width: 720px;
    white-space: nowrap;
  }
}
