:root {
  --bg: #0b0d12;
  --card: #141822;
  --card-elev: #171c28;
  --border: #2a3142;
  --border-soft: #232a3a;
  --text: #eef1f6;
  --muted: #9aa3b5;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: #3b82f622;
  --ok: #22c55e;
  --ok-soft: #22c55e18;
  --amber: #f59e0b;
  --amber-soft: #f59e0b18;
  --err: #ef4444;
  --err-soft: #ef444418;
  --gray: #6b7280;
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", Menlo, monospace;
  --shadow: 0 8px 28px #00000040;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(900px 420px at 12% -8%, #1a2744 0%, transparent 55%),
    radial-gradient(700px 360px at 100% 0%, #132018 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

#app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 16px 56px;
}

/* Brand */
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}
.brand.compact {
  margin-bottom: 0;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(145deg, #60a5fa, #1d4ed8);
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px #93c5fd33 inset, 0 6px 16px #1d4ed844;
}
.eyebrow {
  margin: 0 0 2px;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.72rem;
}
h1 {
  font-size: 1.2rem;
  margin: 0 0 2px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0;
  font-weight: 700;
}
h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 650;
}
.muted {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}
.small {
  font-size: 0.8rem;
}
.center {
  text-align: center;
}
.opt {
  font-weight: 400;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

/* Login */
.login-wrap {
  min-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 400px;
}

/* Cards */
.card {
  background: linear-gradient(180deg, var(--card-elev) 0%, var(--card) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.history-head {
  align-items: center;
}
.hist-hint {
  margin-top: 2px;
}

/* Top bar */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 0 -4px 14px;
  padding: 10px 4px 12px;
  flex-wrap: wrap;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  backdrop-filter: blur(8px);
}
.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.header-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
}

/* Live pulse */
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  background: var(--gray);
  box-shadow: 0 0 0 0 transparent;
}
.live-dot.on {
  background: var(--ok);
  box-shadow: 0 0 0 0 #22c55e66;
  animation: pulse 2s ease-out infinite;
}
.live-dot.off {
  background: var(--gray);
}
.live-dot.paused {
  background: var(--amber);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 #22c55e55;
  }
  70% {
    box-shadow: 0 0 0 8px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot.on {
    animation: none;
  }
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}
@media (max-width: 720px) {
  .stats {
    grid-template-columns: repeat(3, 1fr);
  }
  .stats .stat:first-child {
    grid-column: span 3;
  }
}
@media (max-width: 420px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats .stat:first-child {
    grid-column: span 2;
  }
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.stat.hot {
  border-color: #22c55e55;
  background: var(--ok-soft);
}
.stat-n {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-l {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.stat.ok .stat-n {
  color: var(--ok);
}
.stat.amber .stat-n {
  color: var(--amber);
}
.stat.err .stat-n {
  color: var(--err);
}
.stat.muted-stat .stat-n {
  color: var(--gray);
}

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0 0 16px;
  font-size: 0.78rem;
  color: var(--muted);
}
.leg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot.green {
  background: var(--ok);
}
.dot.amber {
  background: var(--amber);
}
.dot.gray {
  background: var(--gray);
}
.muted-inline {
  opacity: 0.85;
}

/* Grid: esquerda = veículos+histórico, direita = config (sem vazio) */
.grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  align-items: start;
}
.col-main {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}
.col-side {
  min-width: 0;
}
.config-card {
  position: sticky;
  top: 72px;
}
@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .config-card {
    position: static;
  }
  /* No mobile: veículos, depois config, depois histórico */
  .col-main {
    display: contents;
  }
  .col-side {
    display: contents;
  }
  .vehicles-card {
    order: 1;
  }
  .config-card {
    order: 2;
  }
  .history-card {
    order: 3;
  }
  .grid {
    display: flex;
    flex-direction: column;
  }
}

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  margin-bottom: 10px;
  color: var(--muted);
}
.field span {
  font-weight: 500;
}
input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 11px;
  font: inherit;
  width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input::placeholder {
  color: #6b7280aa;
}
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.9rem;
  user-select: none;
}
.check input {
  accent-color: var(--primary);
  width: auto;
}
.cfg-block {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.cfg-block:last-of-type {
  border-bottom: none;
  margin-bottom: 8px;
}

.cfg-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pill {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--bg);
}
.pill.on {
  border-color: #22c55e55;
  color: #86efac;
  background: var(--ok-soft);
}
.pill.off {
  opacity: 0.7;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.row input {
  flex: 1;
  min-width: 160px;
}
.row.actions {
  margin-top: 4px;
}
.add-row {
  align-items: stretch;
}

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-weight: 650;
  font: inherit;
  cursor: pointer;
  background: #374151;
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: filter 0.12s, background 0.12s, border-color 0.12s;
}
.btn:hover {
  filter: brightness(1.08);
}
.btn:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}
.btn.primary {
  background: var(--primary);
}
.btn.primary:hover {
  background: var(--primary-hover);
  filter: none;
}
.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn.small {
  padding: 5px 9px;
  font-size: 0.78rem;
}
.btn.danger {
  background: transparent;
  border: 1px solid #7f1d1d88;
  color: #fca5a5;
}
.btn.danger:hover {
  background: var(--err-soft);
  filter: none;
}
.btn.block {
  width: 100%;
  margin-top: 4px;
}

/* Messages */
.msg {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 4px 0 8px;
}
.msg.ok {
  color: var(--ok);
}
.msg.err {
  color: #fca5a5;
}

.empty-state {
  text-align: center;
  padding: 28px 12px 18px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #0d1017aa;
}
.empty-state.compact {
  padding: 20px 12px;
}
.empty-title {
  margin: 0 0 4px;
  font-weight: 650;
  font-size: 0.95rem;
}
.empty-state.hidden {
  display: none !important;
}

/* Items */
.items,
.logs {
  list-style: none;
  padding: 0;
  margin: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.items {
  max-height: 360px;
  overflow-y: auto;
}
.logs {
  max-height: 520px;
  overflow-y: auto;
}
.items li {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px 11px 14px;
  margin-bottom: 8px;
  background: var(--bg);
  border-left: 3px solid var(--gray);
  transition: border-color 0.15s, background 0.15s;
}
.items li.status-online_reservable {
  border-left-color: var(--ok);
  background: linear-gradient(90deg, var(--ok-soft), var(--bg) 40%);
}
.items li.status-cta_only {
  border-left-color: var(--amber);
  background: linear-gradient(90deg, var(--amber-soft), var(--bg) 40%);
}
.items li.status-error {
  border-left-color: var(--err);
  background: linear-gradient(90deg, var(--err-soft), var(--bg) 40%);
}
.items li.status-no_cta,
.items li.status-unknown {
  border-left-color: var(--gray);
}
.item-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 6px;
}
.item-name {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}
.item-id {
  color: var(--muted);
  font-size: 0.75rem;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 2px;
}
.item-reason {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}
.item-links {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  align-items: center;
}
.item-links a {
  color: #93c5fd;
  font-size: 0.8rem;
  text-decoration: none;
  font-weight: 500;
}
.item-links a:hover {
  text-decoration: underline;
  color: #bfdbfe;
}
.item-time {
  color: var(--muted);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  line-height: 1.25;
  max-width: 100%;
}
.badge.no_cta {
  background: #4b5563;
  color: #f3f4f6;
}
.badge.cta_only {
  background: var(--amber);
  color: #1c1403;
}
.badge.online_reservable {
  background: var(--ok);
  color: #052e16;
}
.badge.error {
  background: var(--err);
  color: #fff;
}
.badge.unknown {
  background: #374151;
  color: #d1d5db;
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.chip:hover {
  border-color: #4b5563;
  color: var(--text);
}
.chip.active {
  background: var(--primary-soft);
  border-color: #3b82f688;
  color: #93c5fd;
}
.chip:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

/* Logs — linha com data completa: 25/07/26 02:25 · nome · OK · status */
.logs li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: var(--bg);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
.logs li.fail {
  border-color: #7f1d1d55;
  background: var(--err-soft);
}
.logs li.notified {
  border-color: #3b82f644;
}
.logs li .log-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.4;
}
.logs li .log-bell {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1.2;
}
.logs li.not-notified .log-bell {
  opacity: 0.45;
  filter: grayscale(0.4);
}
.logs li.notified .log-bell {
  opacity: 1;
}

.foot {
  text-align: center;
  margin-top: 4px;
  opacity: 0.85;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: #1e293b;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 12px 32px #00000066;
  font-size: 0.88rem;
  max-width: min(420px, calc(100vw - 32px));
  text-align: center;
  animation: toast-in 0.2s ease-out;
}
.toast.ok {
  border-color: #22c55e55;
}
.toast.err {
  border-color: #ef444466;
  color: #fecaca;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }
}
