:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e8;
  --text: #1c2126;
  --text-muted: #5f6b76;
  --accent: #c8102e;          /* vermelho Honda */
  --accent-soft: #fdecef;
  --ok: #14804a;
  --ok-soft: #e6f4ec;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --err: #b4232c;
  --err-soft: #fdeaea;
  --info: #1f6feb;
  --info-soft: #e8f1ff;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1c2024;
    --surface-2: #23282d;
    --border: #333a41;
    --text: #e7ebef;
    --text-muted: #9aa5b1;
    --accent: #ff4d63;
    --accent-soft: #3a1d22;
    --ok: #4ade80;
    --ok-soft: #14301f;
    --warn: #fbbf24;
    --warn-soft: #33280c;
    --err: #f87171;
    --err-soft: #3a1a1a;
    --info: #60a5fa;
    --info-soft: #16263f;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout --- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 56px;
}
.brand {
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 22px; height: 22px;
  background: var(--accent);
  border-radius: 5px;
  display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 800;
}
nav.main { display: flex; gap: 4px; flex: 1; }
nav.main a {
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
}
nav.main a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
nav.main a.active { background: var(--accent-soft); color: var(--accent); }

.user-chip { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); }

main { max-width: 1400px; margin: 0 auto; padding: 24px 20px 64px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-head h1 { margin: 0 0 4px; font-size: 22px; }
.page-head p { margin: 0; color: var(--text-muted); font-size: 14px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Cartões --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* --- Métricas --- */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; line-height: 1.1; }
.stat .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat.danger .value { color: var(--err); }
.stat.warn .value { color: var(--warn); }
.stat.ok .value { color: var(--ok); }

/* --- Tabelas --- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
.empty { padding: 40px 20px; text-align: center; color: var(--text-muted); }

/* --- Etiquetas --- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--surface-2); color: var(--text-muted); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.ok { background: var(--ok); }
.dot.err { background: var(--err); }
.dot.muted { background: var(--text-muted); }
.dot.live { background: var(--info); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* --- Botões --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.danger:hover { background: var(--err-soft); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

/* --- Formulários --- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field .help { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], input[type=search], select, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--info); box-shadow: 0 0 0 3px var(--info-soft);
}
textarea { min-height: 70px; resize: vertical; }
.checkbox { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 14px; }
.checkbox input { margin-top: 3px; width: 15px; height: 15px; flex-shrink: 0; accent-color: var(--accent); }
.checkbox label { font-weight: 500; font-size: 14px; margin: 0; }
.checkbox .help { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
fieldset { border: none; padding: 0; margin: 0 0 26px; }
fieldset > legend {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); padding: 0 0 10px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border); width: 100%;
}
.form-actions {
  display: flex; gap: 10px; align-items: center;
  padding-top: 18px; border-top: 1px solid var(--border);
}

.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  padding: 14px 18px; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.filters .field { margin: 0; min-width: 130px; }
.filters .field.grow { flex: 1; min-width: 200px; }
.filters label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }

/* --- Avisos --- */
.alert {
  padding: 11px 15px; border-radius: 6px; margin-bottom: 14px;
  font-size: 14px; border: 1px solid transparent;
}
.alert.success { background: var(--ok-soft); color: var(--ok); border-color: currentColor; }
.alert.error   { background: var(--err-soft); color: var(--err); border-color: currentColor; }
.alert.warning { background: var(--warn-soft); color: var(--warn); border-color: currentColor; }
.alert.info    { background: var(--info-soft); color: var(--info); border-color: currentColor; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

/* --- Console de log --- */
.console {
  background: #0f1317; color: #d6dde4;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
  padding: 14px 16px; border-radius: var(--radius);
  max-height: 560px; overflow-y: auto;
}
.console .line { display: flex; gap: 10px; padding: 1px 0; white-space: pre-wrap; word-break: break-word; }
.console .ts { color: #6b7784; flex-shrink: 0; }
.console .lvl { flex-shrink: 0; width: 58px; font-weight: 700; }
.console .lvl.DEBUG { color: #7c8894; }
.console .lvl.INFO { color: #58a6ff; }
.console .lvl.WARNING { color: #e3b341; }
.console .lvl.ERROR { color: #ff7b72; }
.console .ph { color: #a371f7; flex-shrink: 0; min-width: 92px; }
.console .msg { flex: 1; }
.console .placeholder { color: #6b7784; font-style: italic; }

.log-row.ERROR td { background: var(--err-soft); }
.log-row.WARNING td { background: var(--warn-soft); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.truncate { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

pre.payload {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 14px; overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px; margin: 0;
}

/* --- Paginação --- */
.pagination {
  display: flex; gap: 8px; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-top: 1px solid var(--border); font-size: 13px;
  color: var(--text-muted); flex-wrap: wrap;
}
.pagination .pages { display: flex; gap: 6px; }

/* --- Login --- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 32px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 4px; font-size: 19px; text-align: center; }
.login-card .sub { text-align: center; color: var(--text-muted); font-size: 13px; margin: 0 0 24px; }

/* --- Definições --- */
dl.defs { margin: 0; display: grid; grid-template-columns: minmax(140px, auto) 1fr; gap: 9px 20px; font-size: 14px; }
dl.defs dt { color: var(--text-muted); font-size: 13px; }
dl.defs dd { margin: 0; word-break: break-word; }

.htmx-request .spinner { display: inline-block; }
.spinner { display: none; font-size: 13px; color: var(--text-muted); }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

progress { width: 100%; height: 6px; border-radius: 3px; }
