:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c1f24;
  --muted: #6b7280;
  --border: #e3e6ea;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --refund: #1f8a4c;
  --refund-bg: #e7f6ed;
  --reject: #c0392b;
  --reject-bg: #fbeaea;
  --review: #b7791f;
  --review-bg: #fdf4e3;
  --info-bg: #eef2f7;
  --auto-row: #fff6e6;
  --disconnect-row: #fdecec;
  --error-row: #fbeef5;
  --system-text: #8a919c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --surface: #1b1e24;
    --text: #e7e9ec;
    --muted: #9aa1ab;
    --border: #2c3038;
    --accent: #6d8ff0;
    --accent-text: #0e1320;
    --refund: #4cc485;
    --refund-bg: #15291e;
    --reject: #f07a6c;
    --reject-bg: #2f1a19;
    --review: #e8b04f;
    --review-bg: #2d2414;
    --info-bg: #222730;
    --auto-row: #2a2416;
    --disconnect-row: #2e1a1a;
    --error-row: #2b1a24;
    --system-text: #737b86;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

h1 { font-size: 18px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 16px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

main { max-width: 1200px; margin: 0 auto; padding: 20px 24px 48px; }

.game-picker { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.game-picker select { font-weight: 600; color: var(--text); }

.search { display: flex; gap: 8px; flex: 1; max-width: 560px; }
.search input { flex: 1; }

input, select, textarea {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
}
textarea { width: 100%; resize: vertical; }

button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-text);
}
button.secondary { background: var(--info-bg); color: var(--text); }
button.refund { background: var(--refund); color: #fff; }
button.reject { background: var(--reject); color: #fff; }
button.courtesy { background: var(--review); color: #fff; }
button:disabled { opacity: .5; cursor: default; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

.grid { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.grid .card { margin-bottom: 0; }
#analysis .grid { margin-bottom: 16px; }

.summary { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.summary div { display: flex; flex-direction: column; }
.summary span:first-child { color: var(--muted); font-size: 12px; }
.summary strong { font-weight: 600; }

.claim { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.claim label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }

.verdict { border-left-width: 6px; }
.verdict.REFUND { border-left-color: var(--refund); background: var(--refund-bg); }
.verdict.REJECT { border-left-color: var(--reject); background: var(--reject-bg); }
.verdict.REVIEW { border-left-color: var(--review); background: var(--review-bg); }
.verdict-title { font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.verdict ul { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.verdict li { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.finding-kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-right: 6px; }
.finding-kind.OUR_FAULT { color: var(--refund); }
.finding-kind.USER_FAULT { color: var(--reject); }
.finding-kind.UNCLEAR { color: var(--review); }
.finding-kind.INFO { color: var(--muted); }
.finding-kind.COURTESY { color: var(--review); }

.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 600; }

.ending { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

.health h2 { display: flex; align-items: center; gap: 8px; }
.health .status { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.health .status.OK { background: var(--refund-bg); color: var(--refund); }
.health .status.PROBLEM { background: var(--reject-bg); color: var(--reject); }
.health .status.NOT_ENOUGH_DATA { background: var(--review-bg); color: var(--review); }
.health-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 12px 0; }
.health-stats div { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.health-stats strong { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.health-stats span { color: var(--muted); font-size: 12px; }
.health ul { margin: 8px 0 0; padding-left: 18px; color: var(--reject); }

.segmented { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.segmented label { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
.segmented label:has(input:checked) { border-color: var(--accent); background: var(--info-bg); font-weight: 600; }
.segmented .suggested::after { content: "sugerida"; font-size: 10px; font-weight: 700; color: var(--accent); margin-left: 4px; }

.badge.REFUND { background: var(--refund-bg); color: var(--refund); }
.badge.COURTESY_REFUND { background: var(--review-bg); color: var(--review); }
.badge.REJECT { background: var(--reject-bg); color: var(--reject); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.filters { display: flex; gap: 16px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
.timeline { width: 100%; border-collapse: collapse; }
.timeline th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.timeline td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.timeline .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline td:first-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline tr.auto { background: var(--auto-row); }
.timeline tr.disconnect { background: var(--disconnect-row); }
.timeline tr.error { background: var(--error-row); }
.timeline tr.system td { color: var(--system-text); }
.timeline tr.claimant td:nth-child(2) { font-weight: 700; }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--info-bg); }
.badge.AUTO { background: var(--review-bg); color: var(--review); }
.badge.MANUAL { background: var(--refund-bg); color: var(--refund); }
.badge.DESCONEXION, .badge.ERROR { background: var(--reject-bg); color: var(--reject); }

.message { padding: 10px 14px; border-radius: 8px; background: var(--review-bg); }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12px; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; }
.list button { padding: 4px 10px; }

@media (max-width: 800px) {
  .topbar, main { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: 1fr; }
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
