/* App Ad Exchange — single stylesheet for marketing + dashboard.
   Ink/chart tokens follow the validated dataviz reference palette. */

:root {
    --accent:        #4f46e5;
    --accent-hover:  #4338ca;
    --accent-soft:   #eef2ff;
    --page:          #f9f9f7;
    --surface:       #fcfcfb;
    --ink:           #0b0b0b;
    --ink-2:         #52514e;
    --muted:         #898781;
    --hairline:      #e1e0d9;
    --border:        rgba(11,11,11,0.10);
    --good:          #006300;
    --bad:           #d03b3b;
    --series-1:      #2a78d6;   /* served */
    --series-2:      #1baf7a;   /* earned */
    --series-3:      #eda100;   /* clicks */
    --radius:        14px;
    --shadow:        0 1px 2px rgba(11,11,11,.05), 0 8px 24px -12px rgba(11,11,11,.12);
}
@media (prefers-color-scheme: dark) {
    :root {
        --accent:       #6366f1;
        --accent-hover: #818cf8;
        --accent-soft:  #1e1b4b;
        --page:         #0d0d0d;
        --surface:      #1a1a19;
        --ink:          #ffffff;
        --ink-2:        #c3c2b7;
        --muted:        #898781;
        --hairline:     #2c2c2a;
        --border:       rgba(255,255,255,0.10);
        --good:         #0ca30c;
        --bad:          #e66767;
        --series-1:     #3987e5;
        --series-2:     #199e70;
        --series-3:     #c98500;
        --shadow:       0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.5);
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px; line-height: 1.55;
    color: var(--ink); background: var(--page);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -0.015em; }
img { max-width: 100%; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 20px 64px; }

/* ---- Header ------------------------------------------------------------ */
.site-header { border-bottom: 1px solid var(--hairline); background: var(--surface); position: sticky; top: 0; z-index: 40; }
.site-header-inner { max-width: 1080px; margin: 0 auto; padding: 0 20px; height: 58px; display: flex; align-items: center; gap: 24px; }
.brand { font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 9px; font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand-mark { background: var(--accent); color: #fff; border-radius: 8px; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; }
.app-nav, .marketing-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.app-nav a, .marketing-nav a { color: var(--ink-2); padding: 7px 12px; border-radius: 8px; font-weight: 500; }
.app-nav a:hover, .marketing-nav a:hover { color: var(--ink); text-decoration: none; background: var(--page); }
.app-nav a.active { color: var(--accent); background: var(--accent-soft); }
/* Buttons inside the navs keep button styling (the nav link rules above are
   more specific than .btn-primary and would otherwise repaint them). */
.marketing-nav a.btn-primary, .app-nav a.btn-primary { color: #fff; background: var(--accent); }
.marketing-nav a.btn-primary:hover, .app-nav a.btn-primary:hover { color: #fff; background: var(--accent-hover); }
.header-right { display: flex; align-items: center; gap: 10px; }
.balance-pill { background: var(--accent-soft); color: var(--accent); font-weight: 700; padding: 5px 12px; border-radius: 999px; font-size: 13px; cursor: default; }

/* ---- Buttons / forms ---------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent;
    border-radius: 10px; padding: 10px 18px; font-weight: 600; font-size: 15px; cursor: pointer; transition: all .12s; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--border); }
.btn-ghost:hover { color: var(--ink); border-color: var(--muted); }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--border); }
.btn-sm { padding: 6px 13px; font-size: 13.5px; border-radius: 8px; }
.btn-lg { padding: 14px 26px; font-size: 17px; border-radius: 12px; }
.btn[disabled] { opacity: .5; cursor: default; }

label { display: block; font-weight: 600; font-size: 13.5px; margin: 14px 0 5px; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=url], textarea, select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--ink); font: inherit; font-size: 15px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

/* ---- Cards / layout ------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card h2 { font-size: 17px; margin-bottom: 14px; }
.grid { display: grid; gap: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.flash { border-radius: 10px; padding: 11px 14px; margin: 0 0 16px; font-weight: 500; font-size: 14px; }
.flash-error { background: rgba(208,59,59,.09); color: var(--bad); }
.flash-ok { background: rgba(12,163,12,.10); color: var(--good); }

.auth-card { max-width: 400px; margin: 48px auto; }
.auth-card h1 { font-size: 24px; }
.auth-card .btn { width: 100%; margin-top: 18px; }
.auth-alt { text-align: center; margin-top: 16px; color: var(--muted); font-size: 14px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; margin: 0; }

/* ---- Stat tiles (dataviz contract) -------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.tile .t-label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.tile .t-value { font-size: 28px; font-weight: 650; margin-top: 2px; }
.tile .t-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tile.t-accent { border-color: var(--accent); }
.tile.t-accent .t-value { color: var(--accent); }

/* ---- Chart --------------------------------------------------------------- */
.chart-card { position: relative; }
.chart-legend { display: flex; gap: 18px; align-items: center; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; flex-wrap: wrap; }
.chart-legend .key { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend .swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow); border-radius: 10px; padding: 8px 11px; font-size: 12.5px; display: none; z-index: 5; min-width: 130px; }
.chart-tip .tip-date { font-weight: 650; margin-bottom: 3px; }
.chart-tip .tip-row { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-2); }
.chart-tip .tip-row b { color: var(--ink); font-variant-numeric: tabular-nums; }
svg .grid-line { stroke: var(--hairline); stroke-width: 1; }
svg .axis-text { fill: var(--muted); font-size: 11px; font-family: system-ui, sans-serif; }

/* ---- Tables --------------------------------------------------------------- */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--hairline); }
table.data td { padding: 10px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.app-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.app-cell img, .app-icon { width: 38px; height: 38px; border-radius: 9px; object-fit: cover; background: var(--page); border: 1px solid var(--border); flex: none; }
.app-cell .nm { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-cell .cat { font-size: 12.5px; color: var(--muted); }

.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; letter-spacing: .02em; }
.badge-on { background: rgba(12,163,12,.12); color: var(--good); }
.badge-off { background: var(--page); color: var(--muted); border: 1px solid var(--border); }
.badge-wait { background: rgba(237,161,0,.14); color: #9a6a00; }
@media (prefers-color-scheme: dark) { .badge-wait { color: #eda100; } }
.tag { display: inline-block; background: var(--page); border: 1px solid var(--border); color: var(--ink-2); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; margin: 0 4px 6px 0; }

/* (?) tooltip — pure CSS, shows on hover/focus */
.help-tip { position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 15px; height: 15px; border-radius: 999px; background: var(--muted); color: var(--surface);
    font-size: 10px; font-weight: 700; cursor: help; margin-left: 3px; vertical-align: 1px; }
.help-tip::after { content: attr(data-tip); position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%);
    background: var(--ink); color: var(--surface); border-radius: 9px; padding: 9px 12px; width: 240px;
    font-size: 12px; font-weight: 400; line-height: 1.45; text-transform: none; letter-spacing: 0;
    white-space: normal; text-align: left; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 30;
    box-shadow: var(--shadow); }
.help-tip:hover::after, .help-tip:focus::after { opacity: 1; }

/* ---- Import picker -------------------------------------------------------- */
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.pick { display: flex; align-items: center; gap: 11px; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: pointer; background: var(--surface); transition: border-color .1s; }
.pick:hover { border-color: var(--muted); }
.pick input { accent-color: var(--accent); width: 17px; height: 17px; flex: none; }
.pick img { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--border); }
.pick .nm { font-weight: 600; font-size: 14px; line-height: 1.25; }
.pick .cat { font-size: 12px; color: var(--muted); }
.dev-row { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.dev-row .icons { display: flex; }
.dev-row .icons img { width: 34px; height: 34px; border-radius: 8px; border: 2px solid var(--surface); margin-left: -8px; }
.dev-row .icons img:first-child { margin-left: 0; }

/* ---- Screenshots / creatives ---------------------------------------------- */
.shots { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.shots img { height: 210px; border-radius: 12px; border: 1px solid var(--border); }
.creative-preview { max-width: 260px; border-radius: 14px; border: 1px solid var(--border); display: block; }

/* ---- Code blocks ----------------------------------------------------------- */
pre.code { background: #16161d; color: #e2e2ef; border-radius: 12px; padding: 16px 18px; overflow-x: auto; line-height: 1.5; position: relative; }
pre.code .cm { color: #7d7d95; }
.copy-btn { position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,.09); color: #cfcfe4; border: 0; border-radius: 7px; padding: 5px 11px; font-size: 12px; cursor: pointer; }
.copy-btn:hover { background: rgba(255,255,255,.18); }
.key-chip { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; }

/* ---- MakeAppAds cross-promo card ------------------------------------------ */
.maa-card { display: flex; gap: 16px; align-items: center; border: 1px dashed var(--accent); background: var(--accent-soft); border-radius: var(--radius); padding: 16px 18px; }
.maa-card .maa-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; flex: none; }
.maa-card h3 { margin: 0 0 3px; font-size: 15px; }
.maa-card p { margin: 0; font-size: 13.5px; color: var(--ink-2); }

/* ---- Marketing landing ------------------------------------------------------ */
.hero { background: linear-gradient(180deg, #101024 0%, #1c1846 60%, #241d63 100%); color: #fff; padding: 88px 20px 96px; text-align: center; }
.hero h1 { font-size: clamp(34px, 6vw, 58px); font-weight: 800; letter-spacing: -0.03em; margin: 0 auto 18px; max-width: 820px; }
.hero h1 .hl { background: linear-gradient(90deg, #a5b4fc, #67e8f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.sub { font-size: clamp(16px, 2.4vw, 20px); color: #c7c9e6; max-width: 640px; margin: 0 auto 30px; }
.hero .cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero .btn-hero { background: #fff; color: #1c1846; font-weight: 700; }
.hero .btn-hero:hover { background: #e8e8ff; }
.hero .btn-hero-ghost { border: 1px solid rgba(255,255,255,.35); color: #fff; }
.hero .hero-note { margin-top: 16px; font-size: 13.5px; color: #9294bf; }
.section { max-width: 1080px; margin: 0 auto; padding: 72px 20px; }
.section h2 { font-size: clamp(26px, 4vw, 36px); text-align: center; margin-bottom: 10px; letter-spacing: -0.02em; }
.section .section-sub { text-align: center; color: var(--muted); max-width: 560px; margin: 0 auto 44px; font-size: 16px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.feature .f-icon { font-size: 26px; margin-bottom: 10px; }
.feature h3 { font-size: 16.5px; margin-bottom: 6px; }
.feature p { margin: 0; color: var(--ink-2); font-size: 14px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; counter-reset: step; }
.step { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 22px 22px; }
.step::before { counter-increment: step; content: counter(step); position: absolute; top: -14px; left: 20px;
    background: var(--accent); color: #fff; width: 28px; height: 28px; border-radius: 999px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.step h3 { font-size: 15.5px; margin: 4px 0 6px; }
.step p { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.ratio-banner { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); text-align: center; padding: 30px 20px; margin: 0 auto; max-width: 760px; }
.ratio-banner .big { font-size: clamp(22px, 4vw, 30px); font-weight: 800; color: var(--accent); letter-spacing: -0.02em; }
.faq { max-width: 720px; margin: 0 auto; }
.faq details { border-bottom: 1px solid var(--hairline); padding: 4px 0; }
.faq summary { font-weight: 600; cursor: pointer; padding: 13px 0; font-size: 15.5px; list-style: none; display: flex; justify-content: space-between; }
.faq summary::after { content: "+"; color: var(--muted); font-weight: 400; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 0 0 16px; color: var(--ink-2); }
.final-cta { text-align: center; padding: 80px 20px 90px; }

/* Phone mockup (pure CSS interstitial preview) */
.phone { width: 270px; border-radius: 38px; background: #000; padding: 10px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.5); margin: 0 auto; }
.phone-screen { border-radius: 30px; overflow: hidden; background: linear-gradient(170deg, #f6f7ff, #e9ecff); color: #14142b; padding: 26px 18px 22px; text-align: center; position: relative; min-height: 430px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.phone-screen .ad-x { position: absolute; top: 12px; right: 14px; background: rgba(20,20,43,.08); color: #6b6b8a; border-radius: 999px; width: 26px; height: 26px; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.phone-screen .ad-icon { width: 74px; height: 74px; border-radius: 18px; background: linear-gradient(135deg, #6366f1, #22d3ee); box-shadow: 0 10px 24px -8px rgba(79,70,229,.5); display: flex; align-items: center; justify-content: center; font-size: 34px; }
.phone-screen .ad-name { font-weight: 800; font-size: 18px; }
.phone-screen .ad-tag { font-size: 13px; color: #5a5a78; max-width: 200px; }
.phone-screen .ad-get { background: #4f46e5; color: #fff; font-weight: 700; padding: 10px 34px; border-radius: 999px; font-size: 14px; margin-top: 6px; }
.phone-screen .ad-note { font-size: 10.5px; color: #9a9ab5; margin-top: 10px; }

/* ---- Footer ------------------------------------------------------------------ */
.site-footer { border-top: 1px solid var(--hairline); background: var(--surface); margin-top: 40px; }
.site-footer-inner { max-width: 1080px; margin: 0 auto; padding: 22px 20px; display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); }
.site-footer a { color: var(--ink-2); margin-left: 14px; }
.site-footer-inner > span a { margin-left: 0; }

@media (max-width: 720px) {
    .site-header-inner { gap: 10px; }
    .app-nav a, .marketing-nav a { padding: 6px 8px; font-size: 13.5px; }
    .balance-pill { display: none; }
    .page-head h1 { font-size: 20px; }
}
