:root,
html[data-mode="dark"] {
  --bg: #0c0d0b;
  --bg-2: #131411;
  --surface: #191b16;
  --surface-2: #22251e;
  --line: #31342b;
  --text: #efece1;
  --muted: #9a978a;
  --accent: #d6a31a;
  --accent-2: #f0c45a;
  --ok: #8fbf4a;
  --warn: #d89a3a;
  --bad: #d46555;
  --info: #6aa8b8;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
  --radius: 12px;
  --glow: 214, 163, 26;
}

html[data-mode="light"] {
  --bg: #f4f1ea;
  --bg-2: #ece7dc;
  --surface: #fffdf8;
  --surface-2: #f7f1e4;
  --line: #d9d0be;
  --text: #1d1b16;
  --muted: #6f6a5e;
  --ok: #4d7a22;
  --shadow: 0 12px 30px rgba(40, 32, 12, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(var(--glow), 0.1), transparent 50%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 42%);
  color: var(--text);
  font-family: Sora, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  background: #2a2c24;
  padding: 0.1em 0.4em;
  border-radius: 6px;
}

.is-hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}

.login-brand {
  padding: 72px 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-card {
  margin: auto 56px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 36px;
  box-shadow: var(--shadow);
  max-width: 460px;
  width: calc(100% - 48px);
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
  color: #1a1506;
  font-weight: 700;
  font-size: 1.4rem;
  margin-bottom: 28px;
}

.brand-mark.sm {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 1.05rem;
  margin: 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--accent);
  margin: 0 0 10px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(2.1rem, 4vw, 3.4rem);
  line-height: 1.15;
}

h2 {
  font-size: 1.7rem;
}

h3 {
  font-size: 1.05rem;
}

.lead {
  color: var(--muted);
  max-width: 38ch;
  line-height: 1.6;
}

.status-list {
  list-style: none;
  padding: 0;
  margin: 32px 0 0;
  color: var(--muted);
}

.status-list li {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.live {
  background: var(--ok);
  box-shadow: 0 0 0 5px rgba(143, 191, 74, 0.15);
}

.clock {
  margin-top: 48px;
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-2);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 24px;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 10px;
}

.tab.is-active {
  background: var(--surface-2);
  color: var(--text);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label,
.auth-form label input,
.auth-form label select,
.auth-form label textarea {
  display: block;
  width: 100%;
}

.rule-set {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px 16px;
  display: grid;
  gap: 8px;
}

.rule-set legend {
  padding: 0 6px;
  color: var(--accent);
  font-size: 0.86rem;
}

.rule-set .check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.rule-set .check input {
  width: auto;
  margin: 0;
}

.auth-form label {
  color: var(--muted);
  font-size: 0.86rem;
}

input,
select {
  margin-top: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.2;
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #14110a;
  font-weight: 600;
}

html[data-mode="light"] .btn.primary {
  color: #14110a;
}

.btn.ghost {
  background: transparent;
  width: auto;
}

.btn.tiny {
  padding: 6px 10px;
  font-size: 0.78rem;
}

.hint {
  color: var(--muted);
  margin-top: 0;
}

.code-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.code-box {
  text-align: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.3rem;
  padding: 12px 0;
}

.form-error {
  color: #ffb2a8;
  background: rgba(212, 101, 85, 0.12);
  border: 1px solid rgba(212, 101, 85, 0.3);
  padding: 10px 12px;
  border-radius: 10px;
  margin: 16px 0 0;
}

.demo-box {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

.demo-box p {
  margin: 6px 0 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.sidebar-brand span,
.muted {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-btn {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.88rem;
}

.nav-btn.is-active,
.nav-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.sidebar-user {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.sidebar-user p,
#logout-btn {
  white-space: nowrap;
}

.sidebar-user p {
  margin: 0 0 4px;
}

.workspace {
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 28px 36px 8px;
}

.topbar-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  font-family: Sora, sans-serif;
}

main {
  padding: 20px 36px 48px;
}

.intro {
  color: var(--muted);
  margin-top: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}

.stat span {
  color: var(--muted);
  font-size: 0.8rem;
}

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: 1.8rem;
}

.split {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
}

.panel header {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  text-align: center;
}

.link {
  border: 0;
  background: none;
  color: var(--accent-2);
  padding: 0;
}

.log-list,
.func-mini {
  display: grid;
  gap: 10px;
}

.log-item,
.func-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.log-item:last-child,
.func-row:last-child {
  border-bottom: 0;
}

.log-item small,
.func-row small {
  color: var(--muted);
  line-height: 1.4;
  max-width: 36ch;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.68rem;
  border-radius: 999px;
  padding: 2px 8px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge.login,
.badge.player_join,
.badge.info { background: rgba(106, 168, 184, 0.16); color: #9fd4e0; }
.badge.funcao,
.badge.command,
.badge.fivem { background: rgba(214, 163, 26, 0.16); color: #f0c45a; }
.badge.utilizador,
.badge.chat,
.badge.on { background: rgba(143, 191, 74, 0.16); color: #c5e08d; }
.badge.sistema,
.badge.resource,
.badge.painel { background: rgba(154, 151, 138, 0.16); color: #d2cfc2; }
.badge.player_leave,
.badge.death,
.badge.em_analise { background: rgba(216, 154, 58, 0.16); color: #f0c49a; }
.badge.novo { background: rgba(214, 163, 26, 0.16); color: #f0c45a; }
.badge.confirmado { background: rgba(143, 191, 74, 0.16); color: #c5e08d; }
.badge.falso_positivo { background: rgba(154, 151, 138, 0.16); color: #d2cfc2; }
.click-row { cursor: pointer; }
.click-row:hover { background: rgba(214, 163, 26, 0.05); }
.click-row.is-active { background: rgba(214, 163, 26, 0.1); }
.click-row small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 4px;
}

.player-detail .subhead {
  margin-top: 16px;
  margin-bottom: 8px;
}

.player-detail .subhead h3 {
  font-size: 0.95rem;
  margin: 0;
}

.timeline-list {
  max-height: 320px;
  overflow: auto;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.timeline-row {
  display: grid;
  grid-template-columns: 5.6rem 5.4rem minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid #2a2c25;
  font-size: 0.8rem;
}

.timeline-row:last-child {
  border-bottom: 0;
}

.timeline-row time {
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  white-space: nowrap;
}

.timeline-row .badge {
  padding: 2px 8px;
  font-size: 0.68rem;
  justify-self: start;
}

.timeline-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.badge.money { background: rgba(143, 191, 74, 0.16); color: #c5e08d; }
.badge.item { background: rgba(106, 168, 184, 0.16); color: #9fd4e0; }

.player-card {
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}

.player-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.player-field {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 8px 14px;
  align-items: start;
}

.player-field dt {
  color: var(--muted);
  font-size: 0.78rem;
  padding-top: 2px;
}

.player-field dd {
  margin: 0;
  word-break: break-all;
  line-height: 1.4;
}

.copy-id {
  margin-left: 8px;
  border: 0;
  background: transparent;
  color: var(--accent-2);
  font-size: 0.72rem;
  padding: 0;
}
.badge.explosion,
.badge.error,
.badge.critical,
.badge.off,
.badge.warn { background: rgba(212, 101, 85, 0.16); color: #ffb2a8; }

.func-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.func-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

.func-card p {
  color: var(--muted);
  margin: 8px 0 0;
  line-height: 1.5;
}

.toggle {
  width: 48px;
  height: 28px;
  border-radius: 999px;
  border: 0;
  background: #3a3d34;
  position: relative;
}

.toggle::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #d8d5c8;
  top: 3px;
  left: 3px;
  transition: transform 0.18s ease;
}

.toggle.is-on {
  background: #8a6a12;
}

.toggle.is-on::after {
  transform: translateX(20px);
  background: var(--accent-2);
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar.wrap {
  flex-wrap: wrap;
}

.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.inline input {
  margin: 0;
}

.log-meta {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0 0 12px;
}

.toolbar input,
.toolbar select {
  margin: 0;
}

.toolbar input {
  flex: 1;
}

#page-utilizadores {
  display: grid;
  gap: 14px;
}

#page-utilizadores.is-hidden {
  display: none !important;
}

.user-form {
  display: grid;
  grid-template-columns: 1fr 1fr 180px auto;
  gap: 12px;
  align-items: end;
}

.user-form label {
  color: var(--muted);
  font-size: 0.86rem;
}

.user-form input,
.user-form select {
  width: 100%;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  overflow-wrap: normal;
  word-break: keep-all;
  white-space: nowrap;
}

#log-table td:nth-child(6),
#log-table td:nth-child(8),
#log-table th:nth-child(6),
#log-table th:nth-child(8) {
  white-space: normal;
  word-break: break-all;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-weight: 500;
  background: var(--surface-2);
}

tr:last-child td {
  border-bottom: 0;
}

.mono {
  font-family: "IBM Plex Mono", monospace;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #2a2412;
  border: 1px solid #6d5616;
  color: #f6e4a8;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 20;
}

@media (max-width: 980px) {
  .login-shell,
  .app-shell,
  .split,
  .stat-grid,
  .func-grid,
  .user-form {
    grid-template-columns: 1fr;
  }

  .player-field {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .login-brand,
  .login-card,
  main,
  .topbar {
    padding-left: 20px;
    padding-right: 20px;
  }

  .login-card {
    margin: 0 auto 36px;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .split.three,
  .search-layout {
    grid-template-columns: 1fr;
  }
}

textarea {
  margin-top: 6px;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  resize: vertical;
}

.split.three {
  grid-template-columns: 1fr 1fr 1fr;
}

.search-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.search-main {
  min-width: 0;
}

.ai-panel {
  max-width: 760px;
}

.ai-chat {
  min-height: 280px;
  max-height: 420px;
  overflow: auto;
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.ai-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ai-form input {
  flex: 1;
  margin: 0;
}

.appearance-panel {
  max-width: 480px;
}

.appear-grid {
  display: grid;
  gap: 14px;
}

.appear-grid label {
  color: var(--muted);
  font-size: 0.86rem;
}

.appear-grid input[type="color"] {
  display: block;
  width: 64px;
  height: 36px;
  padding: 2px;
  margin-top: 6px;
  background: transparent;
  border-radius: 8px;
}

.font-slider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.font-slider input {
  flex: 1;
  margin: 0;
}

#font-size-val {
  min-width: 2.2ch;
  color: var(--text);
}

.ai-bubble {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
  text-align: left;
  font-size: 0.9rem;
  line-height: 1.45;
}

.ai-bubble.me {
  background: #2a2412;
}

.ai-form,
.case-detail {
  display: grid;
  gap: 10px;
}
