/* Top Z Media affiliate portal — shared theme (light + dark via [data-theme]). */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #0a0a0a;
  --bg-2: #111214;
  --surface: #161718;
  --surface-2: #1e2022;
  --surface-3: #26292c;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f4f6;
  --text-2: #c3c7cd;
  --muted: #8b9199;
  --accent: #00c3ff;
  --accent-2: #7df9ff;
  --accent-ink: #001a24;
  --accent-soft: rgba(0, 195, 255, 0.12);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.14);
  --warn: #f5b041;
  --warn-soft: rgba(245, 176, 65, 0.14);
  --danger: #f05252;
  --danger-soft: rgba(240, 82, 82, 0.14);
  --info-soft: rgba(0, 195, 255, 0.1);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 248px;
  --topbar-h: 60px;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f3f5f8;
  --bg-2: #eaeef3;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --surface-3: #e9edf2;
  --border: #e1e6ec;
  --border-strong: #c9d1db;
  --text: #0f1722;
  --text-2: #2f3a48;
  --muted: #65718a;
  --accent: #0a8fc4;
  --accent-2: #0678a5;
  --accent-ink: #ffffff;
  --accent-soft: rgba(10, 143, 196, 0.1);
  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.1);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.1);
  --danger: #c81e1e;
  --danger-soft: rgba(200, 30, 30, 0.09);
  --info-soft: rgba(10, 143, 196, 0.08);
  --shadow: 0 10px 30px rgba(15, 23, 34, 0.1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; font-weight: 700; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.bold { font-weight: 600; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  padding: 9px 16px; border-radius: 100px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; line-height: 1.2; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--accent); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.btn.success:hover { background: var(--success); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn.xs { padding: 4px 9px; font-size: 11px; }
.btn.block { width: 100%; justify-content: center; }
.btn.icon { padding: 8px; border-radius: 50%; width: 36px; height: 36px; justify-content: center; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* Forms */
label.field { display: block; margin-bottom: 14px; }
label.field > span, .field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; letter-spacing: .2px; }
.input, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input[type="tel"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; background: var(--bg-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 10px 12px; font: inherit; font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
[data-theme="light"] .input, [data-theme="light"] input, [data-theme="light"] select, [data-theme="light"] textarea { background: #fff; }
input:focus, select:focus, textarea:focus, .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 90px; resize: vertical; }
select { cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding: 4px 0; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.checks.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; }
.checks.cols2 .check { padding: 5px 0; }
.help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.error-text { color: var(--danger); font-size: 13px; font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.input-row { display: flex; gap: 8px; }
.input-row > * { min-width: 0; }
.input-row .btn { flex: none; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 800; margin-top: 4px; letter-spacing: -.3px; }
.stat .d { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 100px; font-size: 11px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; background: var(--surface-3); color: var(--text-2); white-space: nowrap; vertical-align: middle; }
.badge.ok, .badge.active, .badge.approved, .badge.paid, .badge.public { background: var(--success-soft); color: var(--success); }
.badge.pending, .badge.open, .badge.apply, .badge.paused { background: var(--warn-soft); color: var(--warn); }
.badge.rejected, .badge.revoked, .badge.ended, .badge.void, .badge.fail, .badge.blocked_geo, .badge.blocked_device, .badge.not_approved, .badge.cap_reached, .badge.offer_paused { background: var(--danger-soft); color: var(--danger); }
.badge.accent, .badge.private, .badge.featured { background: var(--accent-soft); color: var(--accent); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th, table.table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
table.table tr:last-child td { border-bottom: none; }
table.table tbody tr:hover td { background: var(--surface-2); }
table.table td.num, table.table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.table tr.total td { font-weight: 700; background: var(--surface-2); }
table.table tr.clickable { cursor: pointer; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Tabs / pills */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: 10px 14px; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; margin-bottom: -1px; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); border-radius: 100px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.pill.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input, .toolbar select, .toolbar input { width: auto; min-width: 140px; padding: 8px 10px; font-size: 13px; }
.toolbar .search { min-width: 220px; }

/* Alerts */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--info-soft); font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.alert.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.alert.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert.success { background: var(--success-soft); border-color: transparent; color: var(--success); }

/* Copy box */
.copybox { display: flex; gap: 8px; align-items: stretch; }
.copybox input { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.codeblock { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; word-break: break-all; white-space: pre-wrap; }

/* Toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; max-width: min(360px, calc(100vw - 32px)); }
.toast { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; font-weight: 500; animation: toast-in .2s ease; }
.toast.ok { border-color: var(--success); }
.toast.err { border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; z-index: 900; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: var(--shadow); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* Auth pages */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: radial-gradient(1200px 600px at 10% 0%, rgba(0, 195, 255, .18), transparent 60%), linear-gradient(160deg, #0b1725 0%, #0a0a0a 70%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; letter-spacing: .5px; }
.auth-side .brand img { width: 44px; height: 44px; border-radius: 8px; }
.auth-side h1 { font-size: 34px; line-height: 1.15; margin: 0 0 14px; font-weight: 800; }
.auth-side p { color: #c3c7cd; font-size: 15px; max-width: 460px; }
.auth-side ul { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 10px; }
.auth-side li { display: flex; gap: 10px; align-items: center; color: #e5e7eb; font-size: 14px; }
.auth-side li::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.auth-side .foot { color: #8b9199; font-size: 12px; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; position: relative; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card.wide { max-width: 640px; }
.auth-card h2 { font-size: 22px; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); margin-bottom: 22px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 13px; flex-wrap: wrap; }
.theme-fab { position: absolute; top: 16px; right: 16px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 70px; }
.pw-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--accent); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); }
.steps span.on { background: var(--accent); }
@media (max-width: 860px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 20px; min-height: 0; }
  .auth-side h1 { font-size: 24px; }
  .auth-side ul, .auth-side .foot { display: none; }
}

/* App shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 800; font-size: 15px; letter-spacing: .4px; color: var(--text); }
.sidebar .brand img { width: 36px; height: 36px; border-radius: 8px; }
.sidebar .brand small { display: block; font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text-2); font-weight: 600; font-size: 13px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav a .count { margin-left: auto; background: var(--warn-soft); color: var(--warn); font-size: 11px; padding: 1px 7px; border-radius: 100px; }
.nav .sec { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; padding: 14px 10px 6px; }
.sidebar .foot { margin-top: auto; padding: 12px 8px 0; font-size: 11px; color: var(--muted); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 50; }
.topbar .title { font-weight: 700; font-size: 15px; flex: 1; min-width: 0; }
.topbar .user { font-size: 12px; color: var(--muted); text-align: right; line-height: 1.3; }
.topbar .user b { color: var(--text); display: block; font-size: 13px; }
.content { padding: 22px 24px 60px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.menu-btn { display: none; }
.side-back { display: none; }
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); z-index: 200; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .side-back { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 150; }
  .side-back.open { display: block; }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px 16px 60px; }
  .topbar { padding: 0 12px; }
  .topbar .user { display: none; }
}

/* Offer cards */
.offer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.offer-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: border-color .15s, transform .1s; }
.offer-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.offer-card .thumb { width: 100%; height: 120px; border-radius: 8px; background: var(--surface-2) center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--muted); font-weight: 700; font-size: 20px; }
.offer-card .name { font-weight: 700; font-size: 15px; }
.offer-card .payout { font-weight: 800; font-size: 18px; color: var(--accent); }
.offer-card .meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dd { margin-bottom: 8px; } }

/* Chart box */
.chart-box { position: relative; height: 260px; }
@media (max-width: 640px) { .chart-box { height: 200px; } }

/* Theme toggle */
.theme-toggle { display: inline-flex; align-items: center; gap: 6px; }
.theme-toggle .sun, .theme-toggle .moon { width: 16px; height: 16px; }
[data-theme="light"] .theme-toggle .moon { display: none; }
:root:not([data-theme="light"]) .theme-toggle .sun { display: none; }

/* Loading */
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* Pagination */
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 13px; color: var(--muted); }

/* Skip link */
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 6px; z-index: 2000; }
