/* ── Geographic Rules viewer ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f5f5;
  color: #222;
  font-size: 13px;
}

#toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 16px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 20;
}
.back-btn {
  text-decoration: none;
  color: #666;
  font-size: 17px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 5px;
}
.back-btn:hover { background: #f0f0f0; }
.app-title { font-weight: 700; font-size: 14px; }
.tabs { display: flex; gap: 4px; }
.tab {
  border: 1px solid transparent;
  background: none;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  color: #666;
  font-family: inherit;
}
.tab:hover { background: #f2f2f2; }
.tab.active { background: #eef3fb; border-color: #cfe0f5; color: #1b4d8f; font-weight: 600; }
.summary { margin-left: auto; color: #999; font-size: 11.5px; }

#main { padding: 0; }
.pane { display: none; }
.pane.active { display: block; }

/* ── Trace ──────────────────────────────────────────────────────── */
#pane-trace.active { display: grid; grid-template-columns: 300px 1fr; min-height: calc(100vh - 42px); }
.sidebar { border-right: 1px solid #e0e0e0; background: #fafafa; padding: 12px; overflow-y: auto; max-height: calc(100vh - 42px); }
.side-head {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: #999; margin: 4px 0 8px;
}
.side-head:not(:first-child) { margin-top: 18px; }
.ex {
  display: block; width: 100%; text-align: left; background: #fff;
  border: 1px solid #e3e3e3; border-radius: 6px; padding: 8px 9px;
  margin-bottom: 6px; cursor: pointer; font-family: inherit; font-size: 12px;
}
.ex:hover { border-color: #b9cfe8; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.ex.active { border-color: #6b9fd6; background: #f4f9ff; }
.ex .ex-raw { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: #1b4d8f; word-break: break-word; }
.ex .ex-year { color: #999; font-size: 10.5px; }
.ex .ex-why { color: #777; font-size: 11px; margin-top: 3px; line-height: 1.35; }

.picker input {
  width: 100%; padding: 6px 8px; border: 1px solid #d5d5d5; border-radius: 5px;
  font-family: inherit; font-size: 12px; margin-bottom: 6px;
}
.picker-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.picker-row button {
  padding: 6px 12px; border: 1px solid #cfe0f5; background: #eef3fb; color: #1b4d8f;
  border-radius: 5px; cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 600;
}
#raw-hits { margin-top: 8px; font-size: 11px; color: #888; }

.trace-area { padding: 18px 22px; overflow-y: auto; max-height: calc(100vh - 42px); }
.empty { color: #aaa; padding: 40px; text-align: center; }

.tr-head { margin-bottom: 14px; }
.tr-head .tr-raw {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px; font-weight: 600;
}
.tr-head .tr-meta { color: #888; font-size: 11.5px; margin-top: 3px; }

.stage {
  background: #fff; border: 1px solid #e3e3e3; border-radius: 8px;
  padding: 11px 13px; margin-bottom: 10px;
}
.stage h4 {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em;
  color: #999; margin-bottom: 8px; font-weight: 700;
}
.stage .note { color: #777; font-size: 11.5px; }

.tok { display: flex; align-items: baseline; gap: 9px; padding: 5px 0; border-top: 1px dashed #eee; }
.tok:first-of-type { border-top: none; }
.tok .t-text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; min-width: 210px; }
.badge {
  font-size: 10px; padding: 1px 6px; border-radius: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.badge.token   { background: #e8f1fc; color: #1b4d8f; }
.badge.alias   { background: #eef7ee; color: #2c6b34; }
.badge.ignored { background: #f2f2f2; color: #999; }
.badge.UNRESOLVED { background: #fdecea; color: #b3261e; }
.badge.alias-multi { background: #eef7ee; color: #2c6b34; }
.tok .t-detail { color: #777; font-size: 11.5px; }
.tok .t-units { margin-left: auto; font-family: ui-monospace, monospace; font-size: 11px; color: #555; }

.chip {
  display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 11.5px;
  background: #eef3fb; color: #1b4d8f; border: 1px solid #d7e5f6; margin: 2px 3px 2px 0;
}
.chip.agg { background: #fff4e5; color: #8a5a12; border-color: #f2ddbc; }
.chip.hist { background: #f3ecfa; color: #5b3d8a; border-color: #e0d2f0; }

.result {
  background: #f4f9ff; border: 1px solid #cfe0f5; border-radius: 8px;
  padding: 12px 14px; margin-top: 4px;
}
.result h4 { color: #1b4d8f; }
.result .countries {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; line-height: 1.6; margin-top: 6px;
}
.result .caption { color: #6a86a8; font-size: 11px; margin-top: 7px; }

svg.dag { display: block; margin: 4px 0; }
svg.dag text { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 11px; }
svg.dag .node-box { fill: #fff; stroke: #cfd8e3; }
svg.dag .node-box.parent { fill: #fff4e5; stroke: #e6c48d; }
svg.dag .node-box.dropped { fill: #fafafa; stroke: #e5e5e5; stroke-dasharray: 3 2; }
svg.dag .edge { stroke: #c4cfdb; fill: none; }
svg.dag .edge.dropped { stroke: #e5e5e5; stroke-dasharray: 3 2; }
svg.dag .lbl { fill: #333; }
svg.dag .lbl.dim { fill: #bbb; }
svg.dag .uid { fill: #9aa7b4; font-size: 9.5px; }

/* ── Tables / rules ─────────────────────────────────────────────── */
.filterbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; background: #fff; border-bottom: 1px solid #eee;
}
.filterbar input {
  padding: 6px 9px; border: 1px solid #d5d5d5; border-radius: 5px;
  font-family: inherit; font-size: 12px; width: 260px;
}
.hint { color: #999; font-size: 11.5px; }

.rules-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 16px 18px; }
.rules-cols h3 { font-size: 12.5px; margin-bottom: 8px; }
.rules-cols h3 small { color: #aaa; font-weight: 400; margin-left: 6px; }

table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e5e5e5; border-radius: 6px; }
th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: #999; padding: 7px 9px; border-bottom: 1px solid #eee; font-weight: 700;
}
td { padding: 6px 9px; border-top: 1px solid #f2f2f2; vertical-align: top; font-size: 12px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f7fbff; }
td.num { text-align: right; color: #666; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }
.cond { color: #8a5a12; font-size: 11px; }

/* ── Timelines ──────────────────────────────────────────────────── */
#timelines { padding: 16px 18px; }
.tl-row { display: grid; grid-template-columns: 190px 1fr; gap: 12px; align-items: center; margin-bottom: 7px; }
.tl-name { font-size: 12px; text-align: right; color: #444; }
.tl-name .uid { color: #aaa; font-family: ui-monospace, monospace; font-size: 10.5px; margin-left: 5px; }
.tl-bar { position: relative; height: 26px; background: #fff; border: 1px solid #e8e8e8; border-radius: 5px; }
.tl-seg {
  position: absolute; top: 0; bottom: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; color: #1b4d8f; background: #eef3fb; border-right: 1px solid #fff;
  overflow: hidden; white-space: nowrap; padding: 0 5px;
}
.tl-seg:nth-child(even) { background: #e3edf9; }
.tl-axis { display: grid; grid-template-columns: 190px 1fr; gap: 12px; margin-bottom: 6px; }
.tl-ticks { position: relative; height: 14px; }
.tl-tick { position: absolute; font-size: 10px; color: #bbb; transform: translateX(-50%); }

/* ── Impact ─────────────────────────────────────────────────────── */
#impact-list { padding: 14px 18px; }
.imp {
  background: #fff; border: 1px solid #e5e5e5; border-radius: 7px;
  padding: 10px 12px; margin-bottom: 7px; cursor: pointer;
}
.imp:hover { border-color: #c3d6ec; }
.imp .imp-raw { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.imp .imp-n { color: #888; font-size: 11px; margin-left: 8px; }
.imp .add { color: #2c6b34; font-size: 11.5px; margin-top: 4px; }
.imp .rem { color: #b3261e; font-size: 11.5px; margin-top: 2px; }
