:root {
  color-scheme: dark;
  --bg: #050911;
  --panel: #08131d;
  --panel-strong: #0b1f2f;
  --panel-critical: #1b0b0d;
  --line: #0b8ee8;
  --line-soft: rgba(11, 142, 232, 0.34);
  --cyan: #08f2c4;
  --blue: #0da2ff;
  --red: #ff4038;
  --amber: #f7a733;
  --green: #39d98a;
  --text: #f4f8fc;
  --muted: #93a7b8;
  --muted-strong: #bfd2e0;
  --shadow: rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(90deg, rgba(13, 162, 255, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(13, 162, 255, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 18% 20%, rgba(8, 242, 196, 0.1), transparent 24%),
    radial-gradient(circle at 78% 0%, rgba(255, 64, 56, 0.08), transparent 24%),
    var(--bg);
  background-size: 72px 72px, 72px 72px, auto, auto, auto;
  color: var(--text);
}

body[data-state="critico"] {
  --line-soft: rgba(255, 64, 56, 0.36);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  min-height: 44px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
  color: var(--text);
  background: rgba(13, 162, 255, 0.14);
  font: inherit;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: var(--cyan);
  outline: none;
}

button.danger {
  border-color: rgba(255, 64, 56, 0.62);
  background: rgba(255, 64, 56, 0.16);
}

button.secondary {
  background: rgba(255, 255, 255, 0.045);
}

.shell {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar,
.panel-heading,
.system-status,
.driver-meta,
.item-row,
.event-row,
.critical-banner,
.main-nav,
.identity-meter {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.45rem, 4.5vw, 4.8rem);
  line-height: 0.95;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--blue);
  text-shadow: 0 0 28px rgba(13, 162, 255, 0.24);
}

h2 {
  font-size: 1.12rem;
  letter-spacing: 0;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.system-status {
  width: min(330px, 100%);
  justify-content: flex-start;
  gap: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(8, 19, 29, 0.82);
  box-shadow: 0 0 34px rgba(13, 162, 255, 0.1);
}

.auth-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 230px;
  justify-content: flex-end;
}

.auth-status strong,
.auth-status small {
  display: block;
  text-align: right;
}

.auth-status small {
  color: var(--muted);
}

.auth-status button {
  min-height: 38px;
  padding: 0.5rem 0.7rem;
}

.system-status small {
  display: block;
  color: var(--muted);
}

.pulse {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 20px var(--cyan);
}

body[data-state="alerta"] .pulse {
  background: var(--amber);
  box-shadow: 0 0 20px var(--amber);
}

body[data-state="critico"] .pulse {
  background: var(--red);
  box-shadow: 0 0 24px var(--red);
}

.main-nav {
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.main-nav a {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 0.62rem 0.82rem;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.035);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 700;
}

.main-nav a.active,
.main-nav a:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(8, 242, 196, 0.08);
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(1040px, 100%);
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 28px;
  align-items: center;
  min-height: 620px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 36px;
  background:
    linear-gradient(120deg, rgba(5, 9, 17, 0.42), rgba(5, 9, 17, 0.9)),
    linear-gradient(180deg, rgba(11, 31, 47, 0.9), rgba(6, 14, 23, 0.96));
  box-shadow: 0 22px 64px var(--shadow);
}

.login-panel h1 {
  max-width: 720px;
  font-size: 2.1rem;
  line-height: 1.04;
  white-space: nowrap;
}

.login-panel .eyebrow {
  font-size: 0.78rem;
  white-space: nowrap;
}

.login-form {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 22px;
  background: rgba(5, 9, 17, 0.78);
}

.login-form p {
  color: var(--muted-strong);
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.login-form input {
  min-height: 46px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 0 0.85rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  font: inherit;
}

.login-form input:focus {
  border-color: var(--cyan);
  outline: none;
}

.form-error {
  border: 1px solid rgba(255, 64, 56, 0.58);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(255, 64, 56, 0.12);
}

.form-error[hidden] {
  display: none;
}

.kpis,
.operations-grid,
.detail-grid {
  display: grid;
  gap: 14px;
}

.kpis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 14px;
}

.kpis article,
.panel {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(11, 31, 47, 0.88), rgba(6, 14, 23, 0.95));
  box-shadow: 0 18px 52px var(--shadow);
}

.kpis article {
  min-height: 92px;
  padding: 15px;
}

.kpis span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.kpis strong {
  display: block;
  margin-top: 7px;
  color: var(--cyan);
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.1;
}

.kpis article:last-child strong {
  font-size: 1rem;
}

.critical-banner {
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 64, 56, 0.68);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text);
  background: linear-gradient(90deg, rgba(255, 64, 56, 0.24), rgba(27, 11, 13, 0.92));
  box-shadow: 0 0 34px rgba(255, 64, 56, 0.18);
}

.critical-banner[hidden] {
  display: none;
}

.critical-banner strong {
  color: var(--red);
  text-transform: uppercase;
}

.critical-banner small {
  color: var(--muted-strong);
}

.operations-grid {
  grid-template-columns: minmax(0, 1.42fr) minmax(390px, 0.58fr);
  margin-bottom: 14px;
}

.hero-grid {
  align-items: stretch;
}

.bottom-grid,
.checkpoint-grid,
.demo-grid {
  grid-template-columns: minmax(360px, 0.42fr) minmax(0, 0.58fr);
}

.detail-grid {
  grid-template-columns: 370px minmax(0, 1fr);
  margin-bottom: 14px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.badge,
.severity-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--cyan);
  background: rgba(8, 242, 196, 0.08);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.badge.critical {
  color: var(--red);
  border-color: rgba(255, 64, 56, 0.58);
  background: rgba(255, 64, 56, 0.12);
}

.map {
  position: relative;
  min-height: 545px;
  overflow: hidden;
  border: 1px solid rgba(13, 162, 255, 0.3);
  border-radius: 8px;
  background: #07131f;
}

.real-map-frame,
.map-tactical-layer {
  position: absolute;
  inset: 0;
}

.real-map-frame {
  width: 100%;
  height: 100%;
  border: 0;
  filter: saturate(0.78) contrast(1.12) brightness(0.62);
}

.map-tactical-layer {
  pointer-events: none;
  background:
    linear-gradient(rgba(5, 9, 17, 0.18), rgba(5, 9, 17, 0.28)),
    linear-gradient(90deg, rgba(13, 162, 255, 0.1) 1px, transparent 1px),
    linear-gradient(rgba(13, 162, 255, 0.08) 1px, transparent 1px);
  background-size: auto, 42px 42px, 42px 42px;
  mix-blend-mode: screen;
  opacity: 0.72;
}

.map-compact {
  min-height: 340px;
}

.full-map-panel .map {
  min-height: 680px;
}

.map-point {
  position: absolute;
  z-index: 3;
  width: 164px;
  min-height: 58px;
  background: rgba(5, 9, 17, 0.86);
  text-align: left;
}

.item-markers {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.identity-map-marker {
  position: absolute;
  z-index: 4;
  left: 48%;
  top: 54%;
  display: grid;
  grid-template-columns: 36px minmax(0, auto);
  column-gap: 9px;
  min-width: 152px;
  border: 1px solid rgba(8, 242, 196, 0.52);
  border-radius: 8px;
  padding: 9px 11px;
  background: rgba(5, 9, 17, 0.88);
  box-shadow: 0 0 30px rgba(8, 242, 196, 0.26);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.identity-map-marker::after {
  content: "";
  position: absolute;
  left: 24px;
  bottom: -10px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  background: rgba(5, 9, 17, 0.96);
  box-shadow: 0 0 20px rgba(8, 242, 196, 0.65);
}

.identity-map-marker span {
  display: grid;
  grid-row: 1 / span 2;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 4px;
  color: #061019;
  background: var(--cyan);
  font-weight: 900;
}

.identity-map-marker strong {
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.1;
}

.identity-map-marker small {
  color: var(--muted-strong);
  font-size: 0.72rem;
  white-space: nowrap;
}

.identity-map-marker.away {
  border-color: rgba(255, 64, 56, 0.64);
  box-shadow: 0 0 34px rgba(255, 64, 56, 0.34);
}

.identity-map-marker.away span {
  color: var(--text);
  background: var(--red);
}

.identity-map-marker.away::after {
  border-color: var(--red);
  box-shadow: 0 0 22px rgba(255, 64, 56, 0.75);
}

.item-marker {
  position: absolute;
  display: grid;
  grid-template-columns: 30px minmax(0, auto);
  column-gap: 8px;
  min-width: 132px;
  border: 1px solid rgba(8, 242, 196, 0.36);
  border-radius: 8px;
  padding: 7px 9px;
  background: rgba(5, 9, 17, 0.82);
  box-shadow: 0 0 24px rgba(8, 242, 196, 0.18);
  backdrop-filter: blur(6px);
}

.item-marker::after {
  content: "";
  position: absolute;
  left: 18px;
  bottom: -9px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  background: rgba(5, 9, 17, 0.92);
  box-shadow: 0 0 18px rgba(8, 242, 196, 0.55);
}

.item-marker span {
  display: grid;
  grid-row: 1 / span 2;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 4px;
  color: #061019;
  background: var(--cyan);
  font-size: 0.66rem;
  font-weight: 900;
}

.item-marker strong {
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.1;
}

.item-marker small {
  color: var(--muted-strong);
  font-size: 0.68rem;
  white-space: nowrap;
}

.item-marker.away {
  border-color: rgba(255, 64, 56, 0.62);
  box-shadow: 0 0 28px rgba(255, 64, 56, 0.36);
}

.item-marker.away span {
  color: var(--text);
  background: var(--red);
}

.item-marker.away::after {
  border-color: var(--red);
  box-shadow: 0 0 20px rgba(255, 64, 56, 0.72);
}

.item-marker-capacete {
  left: 35%;
  top: 48%;
}

.item-marker-uniforme {
  left: 45%;
  top: 39%;
}

.item-marker-bag {
  left: 52%;
  top: 50%;
}

.item-marker-smartphone {
  left: 42%;
  top: 58%;
}

.item-marker-moto {
  left: 57%;
  top: 59%;
}

.map-point span {
  display: block;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 900;
}

.map-point.active,
.map-point.critical {
  color: var(--text);
}

.map-point.active {
  border-color: var(--cyan);
  box-shadow: 0 0 28px rgba(8, 242, 196, 0.36);
}

.map-point.critical {
  border-color: var(--red);
  box-shadow: 0 0 34px rgba(255, 64, 56, 0.5);
}

.map-point.critical span {
  color: var(--red);
}

.point-anchieta {
  right: 12%;
  top: 31%;
}

.point-centro {
  left: 42%;
  top: 45%;
}

.point-norte {
  left: 17%;
  top: 23%;
}

.point-rodoviaria {
  right: 22%;
  bottom: 15%;
}

.map-overlay {
  position: absolute;
  z-index: 3;
  border: 1px solid rgba(8, 242, 196, 0.3);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(5, 9, 17, 0.76);
  backdrop-filter: blur(6px);
}

.map-overlay strong,
.map-overlay span {
  display: block;
}

.map-overlay strong {
  color: var(--cyan);
  text-transform: uppercase;
}

.map-overlay span {
  color: var(--muted-strong);
  font-size: 0.82rem;
}

.top-left {
  left: 14px;
  top: 14px;
}

.bottom-right {
  right: 14px;
  bottom: 14px;
}

.incident-panel {
  display: flex;
  flex-direction: column;
}

.incident-panel.is-critical {
  border-color: rgba(255, 64, 56, 0.6);
  background: linear-gradient(180deg, rgba(71, 18, 23, 0.84), rgba(9, 13, 19, 0.94));
}

.driver-meta {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

.identity-meter {
  justify-content: space-between;
  gap: 12px;
  min-height: 76px;
  margin-bottom: 12px;
  border: 1px solid rgba(8, 242, 196, 0.2);
  border-radius: 8px;
  padding: 12px;
  background: rgba(8, 242, 196, 0.06);
}

.identity-meter strong {
  color: var(--cyan);
  font-size: 2.3rem;
  line-height: 1;
}

.identity-meter span {
  color: var(--muted-strong);
  font-weight: 800;
  text-transform: uppercase;
}

.items,
.events,
.actions,
.checkpoint-actions {
  display: grid;
  gap: 10px;
}

.item-row,
.event-row {
  gap: 12px;
  min-height: 64px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.035);
}

.item-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(104px, 0.34fr);
  align-items: center;
}

.event-row {
  display: flex;
  justify-content: space-between;
}

.item-alert {
  border-color: rgba(255, 64, 56, 0.42);
  background: rgba(255, 64, 56, 0.08);
}

.items-table .item-row {
  grid-template-columns: 42px minmax(0, 1.1fr) 190px 230px;
  align-items: center;
}

.item-layer {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(8, 242, 196, 0.42);
  border-radius: 4px;
  color: var(--cyan);
  background: rgba(8, 242, 196, 0.08);
  font-size: 0.78rem;
  font-weight: 900;
}

.item-status,
.item-detail {
  justify-self: end;
  text-align: right;
}

.item-row strong,
.event-row strong {
  display: block;
}

.item-row small,
.event-row small {
  color: var(--muted);
}

.item-extra {
  display: block;
  margin-top: 2px;
}

.state-online,
.severity-INFO {
  color: var(--cyan);
}

.state-away,
.severity-CRITICA,
.severity-ALTA {
  color: var(--red);
}

.severity-MEDIA {
  color: var(--amber);
}

.actions button,
.checkpoint-actions button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 50px;
  text-align: left;
}

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

.actions span {
  display: inline-grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  border-radius: 4px;
  color: #061019;
  background: var(--cyan);
  font-weight: 900;
}

.checkpoint-actions span {
  display: inline-flex;
  width: 72px;
  min-width: 72px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: #061019;
  background: var(--cyan);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

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

.profile-panel {
  display: grid;
  align-content: start;
  gap: 18px;
}

.profile-avatar {
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  border: 1px solid var(--cyan);
  border-radius: 50%;
  color: var(--cyan);
  background: rgba(8, 242, 196, 0.08);
  font-size: 1.8rem;
  font-weight: 900;
}

.definition-grid {
  display: grid;
  gap: 12px;
  margin: 0;
}

.definition-grid div {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}

.definition-grid dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.definition-grid dd {
  margin: 4px 0 0;
  color: var(--text);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 850px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--cyan);
  font-size: 0.75rem;
  text-transform: uppercase;
}

td {
  color: var(--muted-strong);
}

.table-action {
  min-height: 36px;
  padding: 0.4rem 0.65rem;
}

.empty-state {
  color: var(--muted);
}

.error-panel {
  border-color: rgba(255, 64, 56, 0.56);
}

@media (max-width: 1180px) {
  .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .operations-grid,
  .bottom-grid,
  .checkpoint-grid,
  .demo-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .login-panel {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 16px;
  }

  .topbar {
    display: grid;
  }

  .auth-status {
    justify-content: space-between;
    min-width: 0;
  }

  .auth-status strong,
  .auth-status small {
    text-align: left;
  }

  .kpis,
  .actions-expanded,
  .checkpoint-actions {
    grid-template-columns: 1fr;
  }

  .map,
  .full-map-panel .map {
    min-height: 430px;
  }

  .map-point {
    width: 136px;
    font-size: 0.78rem;
  }

  .identity-map-marker {
    min-width: 118px;
    grid-template-columns: 28px minmax(0, auto);
    left: 43%;
    top: 56%;
  }

  .identity-map-marker span {
    width: 28px;
    height: 28px;
    font-size: 0.72rem;
  }

  .item-marker {
    min-width: 98px;
    grid-template-columns: 24px minmax(0, auto);
    padding: 6px 7px;
  }

  .item-marker span {
    width: 24px;
    height: 24px;
    font-size: 0.58rem;
  }

  .item-marker strong {
    font-size: 0.68rem;
  }

  .item-marker small {
    display: none;
  }

  .items-table .item-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .items-table .item-status,
  .items-table .item-detail {
    grid-column: 2;
    justify-self: start;
    text-align: left;
  }

  .critical-banner {
    display: grid;
  }

  .login-body {
    padding: 16px;
  }

  .login-panel {
    padding: 20px;
  }

  .login-panel h1 {
    font-size: 1.35rem;
  }

  .login-panel .eyebrow {
    font-size: 0.68rem;
  }

  .login-form {
    padding: 18px;
  }
}
