:root {
  --bg: #f4f0e6;
  --ink: #111111;
  --paper: #ffffff;
  --accent: #e63c2f;
  --accent-2: #1363df;
  --stroke: #111111;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: linear-gradient(165deg, #f4f0e6 0%, #ece7dc 100%);
  color: var(--ink);
  font-family: "Courier New", "IBM Plex Mono", monospace;
}

.traffic-shell {
  width: min(1180px, calc(100vw - 1.8rem));
  margin: 1rem auto;
  border: 4px solid var(--stroke);
  background: var(--paper);
  box-shadow: 12px 12px 0 #111111;
  min-height: calc(100vh - 2rem);
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.traffic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  padding: 1rem;
  border-bottom: 4px solid var(--stroke);
  background: repeating-linear-gradient(
    -45deg,
    #ffffff 0 14px,
    #f6f2eb 14px 28px
  );
}

.traffic-header h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2.8vw, 2.1rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: "Impact", "Arial Black", sans-serif;
}

.traffic-back {
  display: inline-block;
  border: 3px solid var(--stroke);
  background: var(--accent);
  color: #ffffff;
  text-decoration: none;
  padding: 0.55rem 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
}

.traffic-back:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 #111111;
}

.traffic-toolbar {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.85rem 1rem;
  border-bottom: 4px solid var(--stroke);
  background: #efe9de;
}

.traffic-cycle-btn {
  border: 3px solid var(--stroke);
  background: var(--accent-2);
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.5rem 0.7rem;
  min-width: 230px;
}

.traffic-cycle-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 #111111;
}

.traffic-cycle-text {
  white-space: nowrap;
}

.traffic-cycle-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.traffic-state-stripe {
  width: 6px;
  height: 14px;
  border: 2px solid #ffffff;
  background: transparent;
  opacity: 0.5;
}

.traffic-state-stripe.active {
  background: #ffffff;
  opacity: 1;
}

.traffic-refresh-btn {
  margin-left: auto;
  width: 46px;
  height: 46px;
  min-width: 46px;
  border: 3px solid var(--stroke);
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.traffic-refresh-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 #111111;
}

.traffic-refresh-btn.is-refreshing {
  animation: trafficRefreshSpin 380ms linear;
}

@keyframes trafficRefreshSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(180deg);
  }
}

.traffic-feed {
  padding: 1rem;
  overflow: auto;
}

.traffic-empty {
  margin: 0;
  border: 3px solid var(--stroke);
  padding: 0.8rem;
  background: #fff5bd;
  font-weight: 700;
}

.traffic-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.traffic-date-divider {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.25rem;
  margin-bottom: -0.05rem;
}

.traffic-date-line {
  flex: 1;
  min-width: 0;
  height: 0;
  border-top: 3px solid #111111;
}

.traffic-date-label {
  display: inline-block;
  border: 3px solid #111111;
  background: #fff5bd;
  padding: 0.18rem 0.55rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.traffic-row {
  border: 3px solid var(--stroke);
  background: #ffffff;
}

.traffic-row-top {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 0.5rem 0.65rem;
  border-bottom: 3px solid var(--stroke);
  background: #faf7f1;
  font-weight: 700;
}

.traffic-pill {
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--stroke);
  padding: 0.1rem 0.45rem;
  background: #ffffff;
  font-weight: 700;
}

.traffic-pill[data-site="phone"] {
  background: #d6ecff;
}

.traffic-pill[data-site="admin"] {
  background: #ffe6ce;
}

.traffic-pill[data-action="login"] {
  background: #dbf6e1;
}

.traffic-pill[data-action="interaction"] {
  background: #fff5bd;
}

.traffic-pill[data-action="logoff"] {
  background: #ffd8d8;
}

.traffic-row-meta {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0.4rem 0.8rem;
  padding: 0.65rem;
  font-size: 0.9rem;
}

.traffic-row-meta dt {
  margin: 0;
  font-weight: 700;
  text-transform: uppercase;
}

.traffic-row-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.hidden {
  display: none !important;
}

@media (max-width: 720px) {
  .traffic-shell {
    width: calc(100vw - 0.9rem);
    margin: 0.45rem auto;
    min-height: calc(100vh - 0.9rem);
    box-shadow: 6px 6px 0 #111111;
  }

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

  .traffic-refresh-btn {
    margin-left: 0;
  }
}
