:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #f59e0b;
}
* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background: #f1f5f9;
  color: var(--ink);
}
.topbar {
  background: linear-gradient(90deg, #0b1220 0%, #131c31 100%);
  color: #fff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 56px;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(255,255,255,.06);
  box-shadow: 0 1px 3px rgba(2,6,23,.4);
}
.topbar .brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 15px; color: #fff; text-decoration: none; white-space: nowrap;
}
.topbar .brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 24px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #60a5fa);
  font-size: 11px; font-weight: 800; letter-spacing: .5px; color: #fff;
}
.mainnav { display: flex; align-items: center; gap: 2px; flex: 1; flex-wrap: wrap; }
.mainnav a {
  color: #cbd5e1; text-decoration: none; font-size: 13px; font-weight: 500;
  padding: 7px 12px; border-radius: 8px; white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.mainnav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.mainnav a.active { background: rgba(96,165,250,.18); color: #fff; box-shadow: inset 0 -2px 0 var(--accent); }
.topbar .ctx { display: inline-flex; align-items: center; gap: 10px; font-size: 12px; color: #94a3b8; white-space: nowrap; }
.topbar code { background: rgba(255,255,255,.1); padding: 1px 6px; border-radius: 4px; color: #e2e8f0; }
.badge { padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .3px; }
.badge-dry { background: var(--warn); color: #1e293b; }
.badge-live { background: var(--ok); }
/* All pages use one full-width layout. */
main { max-width: none; width: 100%; margin: 24px 0 0; padding: 0 24px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 24px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
h2 { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tpl-list { list-style: none; padding: 0; }
.tpl-list li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.tpl-list li:last-child { border-bottom: none; }
.dl {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.dl:hover { text-decoration: underline; }
form label { display: block; margin: 12px 0; font-size: 13px; color: var(--muted); }
form select, form input[type=file] {
  display: block; margin-top: 6px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px; width: 100%; max-width: 460px;
  background: #fff; color: var(--ink);
}
form button {
  margin-top: 16px;
  background: var(--accent); color: #fff; border: 0;
  padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}
form button:hover { filter: brightness(1.08); }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; margin-right: 6px; }
.pill.ok { background: var(--ok); }
.pill.bad { background: var(--bad); }
.pill.warn { background: var(--warn); color: #1e293b; }
.alert { background: #fffbeb; border: 1px solid var(--warn); border-left-width: 5px; border-radius: 8px; padding: 12px 16px; margin: 12px 0; font-size: 13px; color: #92400e; }
.alert code { background: rgba(146,64,14,.1); padding: 1px 5px; border-radius: 4px; }
table.grid { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
table.grid th, table.grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { background: #f8fafc; color: var(--muted); font-weight: 600; }
pre { background: #0f172a; color: #e2e8f0; padding: 10px; border-radius: 6px; overflow: auto; margin: 0; font-size: 12px; }

/* Inline filter form (audiences page) */
form.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
form.inline label { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
form.inline input[type=text] { padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px; min-width: 260px; }

/* Full-width layout for data-table pages (uploads / audiences).
   Use explicit longhands + !important so any browser that injects a default
   content max-width (e.g. Opera Air's reading layout) is overridden. */
main.wide {
  max-width: 100% !important;
  width: 100% !important;
  margin-top: 24px !important;
  margin-bottom: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 24px !important;
  padding-right: 24px !important;
}
main.wide .card { width: auto; margin-left: 0; margin-right: 0; }
table.grid { table-layout: auto; }
table.grid tbody tr:nth-child(even) { background: #fafbfc; }
table.grid tbody tr:hover { background: #f1f5f9; }
table.grid td code { white-space: nowrap; font-size: 12px; }
table.grid .nowrap { white-space: nowrap; }
table.grid .col-name { min-width: 280px; }

/* Failure-reason "?" with an instant, sticky hover tooltip on Failed audiences */
.qmark {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-left: 6px;
  border-radius: 999px; background: var(--bad); color: #fff;
  font-size: 11px; font-weight: 700; cursor: help; vertical-align: middle;
}
.qmark .qmark-tip {
  display: none;
  position: absolute; left: 22px; top: 50%; transform: translateY(-50%);
  z-index: 100; width: 320px;
  background: #1e293b; color: #fff;
  padding: 8px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 400; line-height: 1.45;
  white-space: normal; text-align: left;
  box-shadow: 0 4px 12px rgba(15,23,42,.3);
}
/* show instantly on hover and stay until the pointer leaves */
.qmark:hover .qmark-tip { display: block; }

/* Job progress state pills */
.pill.queued { background: #94a3b8; }
.pill.info { background: #0ea5e9; }
