:root {
    --ink: #111827;
    --navy: #0d1b2f;
    --blue: #132b4f;
    --gold: #c7953b;
    --gold-light: #f4e4c6;
    --white: #ffffff;
    --mist: #f4f6f8;
    --line: #d9dde3;
    --muted: #647084;
    --danger: #b42318;
    --success: #0f6f67;
}

* { box-sizing: border-box; }
html { font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); }
body { margin: 0; background: var(--mist); }
a { color: inherit; }
input, textarea, select, button { font: inherit; }

.hidden { display: none !important; }
.brand, .brand-row { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark, .brand span {
    display: inline-flex; width: 42px; height: 42px; align-items: center; justify-content: center;
    border-radius: 8px; background: var(--ink); color: var(--white); font-weight: 900;
}
.brand-row small { display: block; color: rgba(255,255,255,.64); margin-top: 2px; }

.btn {
    display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; background: var(--white);
    color: var(--ink); text-decoration: none; font-weight: 800; cursor: pointer;
}
.btn.primary { background: var(--gold); border-color: var(--gold); color: #111418; }
.btn.support { background: var(--success); border-color: var(--success); color: var(--white); }
.btn.ghost { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.20); color: var(--white); }
.btn.install { background: var(--white); color: var(--ink); }
.btn.danger { color: var(--danger); border-color: #f3bbb5; }
.btn.small { min-height: 34px; padding: 7px 10px; font-size: 13px; }
.btn.wide { width: 100%; }

.admin-body { min-height: 100vh; }
.admin-topbar {
    position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 14px clamp(16px, 4vw, 40px); border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
}
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.admin-nav a { padding: 8px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 700; }
.admin-nav a:hover { background: var(--mist); color: var(--ink); }
.admin-shell { width: min(1180px, calc(100% - 32px)); margin: 26px auto 56px; }

.login-panel { min-height: calc(100vh - 90px); display: grid; place-items: center; }
.login-card { width: min(420px, 100%); padding: 28px; background: var(--white); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 24px 70px -34px rgba(17,24,39,.55); }
.login-card h1, .page-title h1 { margin: 10px 0 6px; font-size: clamp(28px, 5vw, 42px); line-height: 1.08; }
.login-card p, .page-title p { margin: 0; color: var(--muted); }

.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card, .panel {
    background: var(--white); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 45px -28px rgba(17,24,39,.36);
}
.metric-card { padding: 18px; }
.metric-card span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-card strong { display: block; margin-top: 10px; font-size: 28px; }
.panel { padding: 18px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head.split { margin-top: 20px; }
.panel h2 { margin: 0; font-size: 18px; }
.grid-2 { display: grid; grid-template-columns: 1.35fr .85fr; gap: 18px; }
.report-stack { display: grid; gap: 18px; }
.report-panel { width: 100%; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
td small { color: var(--muted); overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.status.active { background: #e4f3f0; color: var(--success); }
.status.inactive { background: #f2f4f7; color: var(--muted); }

.form-stack, .form-grid { display: grid; gap: 14px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 800; }
input, textarea, select {
    width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--white);
    padding: 11px 12px; color: var(--ink); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(199,149,59,.18); }
.full { grid-column: 1 / -1; }
.check-row { display: flex; gap: 18px; flex-wrap: wrap; }
.check-row label, .check-inline { display: flex; align-items: center; gap: 8px; }
.check-row input, .check-inline input { width: auto; }
.form-actions { display: flex; justify-content: flex-end; }
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 700; }
.alert.error { color: var(--danger); background: #fff1f0; border: 1px solid #f3bbb5; }

.chart-bars { display: flex; align-items: end; gap: 8px; min-height: 180px; overflow-x: auto; padding-top: 12px; }
.bar-wrap { min-width: 34px; display: grid; justify-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.bar { width: 18px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, var(--gold), var(--blue)); }

.funnel-body {
    min-height: 100vh; color: var(--white);
    background: linear-gradient(145deg, #08111f, #132b4f 62%, #0d1b2f);
}
.redirect-screen { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.redirect-card { width: min(430px, 100%); display: grid; justify-items: center; gap: 18px; text-align: center; }
.redirect-card .brand-row { justify-self: center; }
.redirect-card .brand-row small { color: rgba(255,255,255,.64); }
.redirect-card h1 { margin: 0; font-size: clamp(30px, 8vw, 48px); line-height: 1.06; letter-spacing: 0; }
.loader-ring {
    width: 62px; height: 62px; border-radius: 50%; border: 4px solid rgba(255,255,255,.16);
    border-top-color: var(--gold); animation: spin 900ms linear infinite;
}
.cta-stack { display: grid; gap: 10px; margin: 8px 0 0; width: 100%; }
.cta-stack.compact { max-width: 340px; }
.redirect-note { margin: 0; color: rgba(255,255,255,.76); font-weight: 800; text-align: center; }
.broker-frame-screen { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; background: #08111f; }
.broker-frame-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px clamp(12px, 3vw, 24px);
    border-bottom: 1px solid rgba(255,255,255,.12); background: rgba(8,17,31,.94); backdrop-filter: blur(10px);
}
.support-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.support-actions .btn { min-height: 38px; padding: 8px 12px; font-size: 13px; }
.broker-frame { min-height: 0; background: var(--white); }
.broker-frame iframe { width: 100%; height: 100%; min-height: calc(100vh - 63px); border: 0; display: block; background: var(--white); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
    .admin-topbar, .page-title { align-items: flex-start; flex-direction: column; }
    .admin-shell { width: min(100% - 24px, 1180px); margin-top: 18px; }
    .grid-2, .form-grid { grid-template-columns: 1fr; }
    .panel, .login-card { padding: 16px; }
    .broker-frame-bar { align-items: flex-start; flex-direction: column; }
    .support-actions { width: 100%; justify-content: stretch; }
    .support-actions .btn { flex: 1; }
    table { min-width: 620px; }
}
