/* Monetizd UI design system — DESIGN.md §13.
   Dark, modern, dense-but-breathing. No CDN, no external fonts. */

:root {
  --bg: #0b0f1a;
  --surface: #121826;
  --surface-2: #1a2234;
  --border: rgba(148, 163, 184, .14);
  --text: #e6ecf7;
  --muted: #8b96ab;
  --accent: #6366f1;
  --accent-2: #22d3ee;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sidebar-width: 232px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

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

h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 600; }

/* -------------------------------------------------------------------- */
/* Portal shell: sidebar + topbar                                        */
/* -------------------------------------------------------------------- */

.portal-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 20px 20px;
  font-weight: 700;
  font-size: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.brand-mark { color: var(--text); }

.portal-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}

.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 500;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  background: var(--surface-2);
  color: var(--text);
}

.portal-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left { font-weight: 600; font-size: 16px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.balance-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 600;
  color: var(--green);
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, .18);
  display: inline-block;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-menu-name { color: var(--muted); }

.portal-content {
  padding: 24px;
  flex: 1;
}

.inline-form { display: inline; margin: 0; }

/* -------------------------------------------------------------------- */
/* KPI cards                                                             */
/* -------------------------------------------------------------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
}

.kpi-sublabel {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.kpi-trend-up { color: var(--green); }
.kpi-trend-down { color: var(--red); }

/* -------------------------------------------------------------------- */
/* Tables                                                                */
/* -------------------------------------------------------------------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

/* -------------------------------------------------------------------- */
/* Status badges                                                        */
/* -------------------------------------------------------------------- */

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.status-active, .status-valid, .status-paid, .status-completed {
  color: var(--green);
  border-color: rgba(52, 211, 153, .3);
}

.status-pending, .status-pending_review, .status-requested {
  color: var(--amber);
  border-color: rgba(251, 191, 36, .3);
}

.status-suspended, .status-rejected, .status-paused,
.status-rejected_expired, .status-rejected_reused, .status-rejected_rate,
.status-rejected_bot, .status-rejected_budget, .status-rejected_dup {
  color: var(--red);
  border-color: rgba(248, 113, 113, .3);
}

.status-draft { color: var(--muted); }

/* -------------------------------------------------------------------- */
/* Forms                                                                 */
/* -------------------------------------------------------------------- */

.form-group { margin-bottom: 16px; }

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--muted);
  font-size: 13px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="url"],
select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.field-error {
  color: var(--red);
  font-size: 12px;
  margin-top: 4px;
}

/* Group R (5 Jul 2026): a rejected creative's reason, previously a
   barely-visible muted caption -- given the same red-tinted treatment as
   a validation error so it reads as what it is, not incidental metadata. */
.rejection-reason-note {
  color: var(--red);
  background: rgba(248, 113, 113, .08);
  border: 1px solid rgba(248, 113, 113, .25);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
  margin-top: 4px;
  display: inline-block;
}

.form-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

/* -------------------------------------------------------------------- */
/* Buttons                                                               */
/* -------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #5457d8; text-decoration: none; }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); text-decoration: none; }

.btn-danger { background: transparent; border-color: rgba(248, 113, 113, .4); color: var(--red); }
.btn-danger:hover { background: rgba(248, 113, 113, .1); text-decoration: none; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* -------------------------------------------------------------------- */
/* Tabs                                                                  */
/* -------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 16px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  font-weight: 500;
  cursor: pointer;
}

.bulk-actions-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab.active, .tab:hover {
  color: var(--text);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

/* -------------------------------------------------------------------- */
/* Flash toasts                                                         */
/* -------------------------------------------------------------------- */

.flash-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.flash {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}

.flash-success { border-left-color: var(--green); }
.flash-error { border-left-color: var(--red); }
.flash-warning { border-left-color: var(--amber); }

.flash-text { flex: 1; font-size: 13px; }

.flash-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

/* -------------------------------------------------------------------- */
/* Modals (plain <dialog>)                                              */
/* -------------------------------------------------------------------- */

dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  width: 90vw;
}

dialog::backdrop {
  background: rgba(11, 15, 26, .7);
}

/* -------------------------------------------------------------------- */
/* Empty states                                                          */
/* -------------------------------------------------------------------- */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state-title {
  color: var(--text);
  font-weight: 600;
  margin-bottom: 8px;
}

/* -------------------------------------------------------------------- */
/* Pagination                                                            */
/* -------------------------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
  padding: 16px 0;
}

.page-link {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}

.page-link.disabled {
  color: var(--muted);
  pointer-events: none;
  opacity: .5;
}

.page-status { color: var(--muted); font-size: 13px; }

/* -------------------------------------------------------------------- */
/* Public landing + demo blog: lighter hero styles, same CSS vars        */
/* -------------------------------------------------------------------- */

.hero {
  padding: 80px 24px;
  text-align: center;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-size: 42px;
  margin-bottom: 16px;
}

.hero p {
  color: var(--muted);
  font-size: 18px;
  max-width: 640px;
  margin: 0 auto 24px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.site-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  padding: 40px 0;
}

.value-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.counter-strip {
  display: flex;
  justify-content: center;
  gap: 48px;
  padding: 24px;
  flex-wrap: wrap;
}

.counter-item { text-align: center; }

.counter-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-2);
}

.counter-label {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

/* -------------------------------------------------------------------- */
/* Admin panel — live ops dashboard, approval queues, ledger, etc.       */
/* (Task 6 additions, built on the existing components above)           */
/* -------------------------------------------------------------------- */

.admin-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  .admin-grid { grid-template-columns: 1fr; }
}

.admin-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}

.admin-panel-wide { min-width: 0; }

.admin-panel h2 {
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.queue-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mz-runbook-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.mz-runbook-toc a {
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  border-bottom: 1px dashed var(--border);
}

.mz-runbook-toc a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.queue-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}

.queue-link:hover { border-color: var(--accent); text-decoration: none; }

.queue-link-label { font-weight: 500; }

.queue-link-count {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-weight: 700;
  color: var(--muted);
  min-width: 24px;
  text-align: center;
}

.queue-link-count-pending {
  color: var(--amber);
  border-color: rgba(251, 191, 36, .35);
}

.live-feed {
  max-height: 560px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.live-feed-row {
  display: grid;
  grid-template-columns: 170px 100px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.live-feed-row:last-child { border-bottom: none; }

.live-feed-time { color: var(--muted); font-variant-numeric: tabular-nums; }

.live-feed-data {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Filter bars on list pages (users/campaigns/sites/fraud/ledger/audit). */

.filter-bar {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-field { margin-bottom: 0; min-width: 160px; }

.filter-submit { min-width: 0; }

/* Key/value profile table (user detail page). */

.kv-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.kv-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 14px 8px 0;
  vertical-align: top;
  width: 160px;
}
.kv-table td { padding: 8px 0; }

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--muted);
}

.truncate-cell {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.amount-positive { color: var(--green); font-variant-numeric: tabular-nums; }
.amount-negative { color: var(--red); font-variant-numeric: tabular-nums; }

.muted-text { color: var(--muted); }

.approval-reject-form {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-left: 6px;
}

.reject-reason-input {
  width: 160px;
  padding: 5px 8px;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.url-reputation-warning {
  margin-top: 4px;
}
.warning-line {
  font-size: 11.5px;
  color: var(--amber);
  white-space: normal;
}
.landing-screenshot-thumb {
  width: 120px;
  height: 75px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
}

.form-actions { margin-top: 16px; }

/* Ledger integrity PASS/FAIL badge. */

.ledger-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.integrity-card.integrity-pass { border-color: rgba(52, 211, 153, .35); }
.integrity-card.integrity-fail { border-color: rgba(248, 113, 113, .45); }

.integrity-badge-pass, .integrity-badge-fail {
  font-size: 16px;
  padding: 4px 16px;
}

/* Monospace code/token block -- embed snippets (publisher/embed.html) and
   domain-verification instructions (publisher/site_detail.html). */

.mz-embed-code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}
