/* ══════════════════════════════════════════════════════════
   Affiliate cabinet (nd-aff-*)
   Shared by every /affiliate/* page and the admin affiliate
   table. Built on the workspace teal/orange tokens; chart
   series keep their own hues because they must stay
   distinguishable from each other.
   ══════════════════════════════════════════════════════════ */

.nd-aff-root{
    padding: 24px;
    min-height: 100vh;
    background:
        radial-gradient(1100px 420px at 105% -10%, rgba(20,184,166,.10), transparent 60%),
        radial-gradient(900px 340px at -10% 0%, rgba(249,115,22,.08), transparent 56%),
        rgba(247,248,252,.92);
}

/* ── Hero ── */
.nd-aff-hero{
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 18px;
}
.nd-aff-kicker{
    font-size: 0.6875rem;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(20,184,166,.9);
}
.nd-aff-title{
    margin: 4px 0 0;
    font-size: 1.5rem;
    font-weight: 900;
    color: #111214;
}
.nd-aff-sub{
    margin: 4px 0 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(17,18,20,.55);
}
.nd-aff-code{
    display: inline-block;
    padding: 2px 10px;
    border-radius: 8px;
    background: rgba(20,184,166,.12);
    color: #0f766e;
    font-weight: 900;
    letter-spacing: .04em;
}

/* ── Period / mode controls ── */
.nd-aff-controls{
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}
.nd-aff-periods,
.nd-aff-daterange,
.nd-aff-mode{
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.nd-aff-period,
.nd-aff-mode-btn{
    border: 1px solid rgba(17,18,20,.10);
    background: rgba(255,255,255,.9);
    color: rgba(17,18,20,.7);
    font-weight: 800;
    font-size: 0.75rem;
    padding: 7px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: all .15s ease;
}
.nd-aff-period:hover,
.nd-aff-mode-btn:hover{
    border-color: rgba(20,184,166,.3);
    background: rgba(20,184,166,.05);
}
.nd-aff-period.is-active,
.nd-aff-mode-btn.is-active{
    border-color: rgba(20,184,166,.45);
    background: rgba(20,184,166,.10);
    color: #0f766e;
}
.nd-aff-mode-label{
    font-size: 0.75rem;
    font-weight: 800;
    color: rgba(17,18,20,.45);
}
.nd-aff-date{
    width: auto;
    min-width: 150px;
    height: 38px;
    padding: 0 10px;
}
.nd-aff-dash{
    color: rgba(17,18,20,.35);
    font-weight: 800;
}

/* ── Info note ── */
.nd-aff-note{
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border-radius: 12px;
    border: 1px solid rgba(20,184,166,.20);
    background: rgba(20,184,166,.06);
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgba(17,18,20,.7);
}
.nd-aff-note i{ color: #14b8a6; margin-top: 2px; }

/* ── KPI strip ── */
.nd-aff-kpis{
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}
.nd-aff-kpi{
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,.6);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.04);
    transition: transform .15s, box-shadow .15s;
}
.nd-aff-kpi:hover{
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,.08), 0 12px 32px rgba(0,0,0,.06);
}
.nd-aff-kpi-ic{
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
}
.nd-aff-kpi-body{ flex: 1; min-width: 0; }
.nd-aff-kpi-value{
    font-size: 1.375rem;
    font-weight: 900;
    line-height: 1.1;
    color: #111214;
}
.nd-aff-kpi-label{
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(17,18,20,.55);
    margin-top: 2px;
}
.nd-aff-kpi-badge{
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 0.625rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 99px;
    background: rgba(17,18,20,.06);
    color: rgba(17,18,20,.6);
}

.nd-aff-kpi-blue{ background: linear-gradient(135deg, #eff6ff, #dbeafe); }
.nd-aff-kpi-blue .nd-aff-kpi-ic{ background: rgba(59,130,246,.14); color: #3b82f6; }
.nd-aff-kpi-indigo{ background: linear-gradient(135deg, #eef2ff, #e0e7ff); }
.nd-aff-kpi-indigo .nd-aff-kpi-ic{ background: rgba(99,102,241,.14); color: #6366f1; }
.nd-aff-kpi-green{ background: linear-gradient(135deg, #ecfdf5, #d1fae5); }
.nd-aff-kpi-green .nd-aff-kpi-ic{ background: rgba(16,185,129,.14); color: #10b981; }
.nd-aff-kpi-amber{ background: linear-gradient(135deg, #fffbeb, #fef3c7); }
.nd-aff-kpi-amber .nd-aff-kpi-ic{ background: rgba(245,158,11,.14); color: #f59e0b; }
.nd-aff-kpi-violet{ background: linear-gradient(135deg, #f5f3ff, #ede9fe); }
.nd-aff-kpi-violet .nd-aff-kpi-ic{ background: rgba(139,92,246,.14); color: #8b5cf6; }

/* ── Secondary metrics ── */
.nd-aff-metrics{
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.nd-aff-metric{
    background: #fff;
    border: 1px solid rgba(17,18,20,.07);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.nd-aff-metric-ic{ font-size: 1rem; opacity: .85; }
.nd-aff-metric-value{
    font-size: 1.25rem;
    font-weight: 900;
    color: #111214;
}
.nd-aff-metric-label{
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(17,18,20,.5);
}

/* ── Panels ── */
.nd-aff-grid{
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}
.nd-aff-panel{
    background: #fff;
    border: 1px solid rgba(17,18,20,.07);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.nd-aff-panel-wide{ margin-bottom: 16px; }
.nd-aff-panel-head{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.nd-aff-panel-head h3{
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 900;
    color: #111214;
    display: flex;
    align-items: center;
    gap: 8px;
}
.nd-aff-panel-head h3 i{
    font-size: 0.875rem;
    color: rgba(17,18,20,.35);
}
.nd-aff-panel-note{
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(17,18,20,.42);
}
.nd-aff-empty{
    padding: 28px 12px;
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 700;
    color: rgba(17,18,20,.4);
}

/* ── Charts ── */
.nd-aff-chart-wrap{
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(248,250,252,1), rgba(241,245,249,.6));
    padding: 10px 8px 4px;
}
.nd-aff-chart{
    width: 100%;
    height: 180px;
    display: block;
}
.nd-aff-chart-bars{ height: 150px; }
.nd-aff-line{
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.nd-aff-line-clicks{ stroke: #3b82f6; }
.nd-aff-line-regs{ stroke: #10b981; }
.nd-aff-bar{ fill: #14b8a6; opacity: .85; }
.nd-aff-legend{
    margin-top: 10px;
    display: flex;
    gap: 14px;
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(17,18,20,.5);
}
.nd-aff-legend span{ display: inline-flex; align-items: center; gap: 6px; }
.nd-aff-legend-right{ margin-left: auto; }
.nd-aff-dot{
    width: 8px;
    height: 8px;
    border-radius: 99px;
    flex-shrink: 0;
}

/* ── Funnel ── */
.nd-aff-funnel{
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.nd-aff-funnel-step{
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.nd-aff-funnel-info{
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.nd-aff-funnel-val{
    font-size: 0.9375rem;
    font-weight: 900;
    color: #111214;
}
.nd-aff-funnel-lbl{
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(17,18,20,.5);
}
.nd-aff-funnel-pct{
    margin-left: auto;
    font-size: 0.6875rem;
    font-weight: 900;
    color: rgba(20,184,166,.9);
    background: rgba(20,184,166,.1);
    padding: 2px 8px;
    border-radius: 99px;
}
.nd-aff-funnel-bar{
    height: 20px;
    border-radius: 8px;
    background: rgba(17,18,20,.04);
    overflow: hidden;
}
.nd-aff-funnel-fill{
    height: 100%;
    border-radius: 8px;
    transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* ── Link builder ── */
.nd-aff-builder{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}
.nd-aff-field{ display: grid; gap: 6px; }
.nd-aff-hint{
    font-weight: 700;
    font-size: 0.6875rem;
    color: rgba(17,18,20,.4);
    margin-left: 6px;
}
.nd-aff-landing-desc{
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: rgba(17,18,20,.6);
}
.nd-aff-linkbox{
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px dashed rgba(20,184,166,.35);
    background: rgba(20,184,166,.05);
}
.nd-aff-link{
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #0f766e;
    word-break: break-all;
}
.nd-aff-link-sm{
    font-size: 0.75rem;
    color: rgba(17,18,20,.62);
}
.nd-aff-inline-code{
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    background: rgba(17,18,20,.05);
    color: rgba(17,18,20,.75);
}
.nd-aff-presets{
    margin-top: 16px;
    display: grid;
    gap: 8px;
}
.nd-aff-presets-title{
    font-size: 0.6875rem;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(17,18,20,.42);
}
.nd-aff-preset{
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(248,250,252,.9);
    border: 1px solid rgba(17,18,20,.05);
}
.nd-aff-preset-name{
    min-width: 78px;
    font-size: 0.75rem;
    font-weight: 900;
    color: rgba(17,18,20,.6);
}

/* ── Postback editor ── */
.nd-aff-postback-row{
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.nd-aff-url-input{
    flex: 1;
    min-width: 280px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8125rem;
}
.nd-aff-status-input{
    width: 140px;
    flex-shrink: 0;
}
.nd-aff-method{
    width: 96px;
    flex-shrink: 0;
}
.nd-aff-inline-error{ margin-top: 10px; }
.nd-aff-ok{
    margin-top: 10px;
    font-size: 0.8125rem;
    font-weight: 700;
    color: rgba(20,184,166,.95);
}
.nd-aff-preview{
    margin-top: 12px;
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}
.nd-aff-preview-label{
    font-size: 0.6875rem;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(17,18,20,.4);
}

.nd-aff-events{
    display: grid;
    gap: 10px;
}
.nd-aff-event{
    border: 1px solid rgba(17,18,20,.08);
    border-radius: 14px;
    padding: 14px;
    background: rgba(252,253,255,.9);
    transition: border-color .15s, opacity .15s;
}
.nd-aff-event:hover{ border-color: rgba(20,184,166,.25); }
.nd-aff-event.is-off{ opacity: .55; }
.nd-aff-event-head{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.nd-aff-event-title{
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 900;
    color: #111214;
}
.nd-aff-event-title i{ color: rgba(20,184,166,.9); }
.nd-aff-event-body{
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.nd-aff-switch{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 800;
    color: rgba(17,18,20,.55);
    cursor: pointer;
    user-select: none;
}
.nd-aff-switch input{
    width: 16px;
    height: 16px;
    accent-color: #14b8a6;
    cursor: pointer;
}

.nd-aff-event-pill{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 800;
    color: rgba(17,18,20,.7);
    white-space: nowrap;
}
.nd-aff-event-pill i{ color: rgba(20,184,166,.85); }

/* ── Test result ── */
.nd-aff-test{
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.8125rem;
    display: grid;
    gap: 6px;
}
.nd-aff-test.is-ok{
    background: rgba(16,185,129,.08);
    border: 1px solid rgba(16,185,129,.22);
}
.nd-aff-test.is-fail{
    background: rgba(239,68,68,.06);
    border: 1px solid rgba(239,68,68,.22);
}
.nd-aff-test-head{
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    color: rgba(17,18,20,.78);
}
.nd-aff-test.is-ok .nd-aff-test-head i{ color: #059669; }
.nd-aff-test.is-fail .nd-aff-test-head i{ color: #dc2626; }
.nd-aff-test-detail{
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(17,18,20,.6);
    word-break: break-word;
}

/* ── Macros ── */
.nd-aff-macros{
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 8px;
}
.nd-aff-macro{
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: left;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(17,18,20,.07);
    background: rgba(248,250,252,.9);
    cursor: pointer;
    transition: all .15s ease;
}
.nd-aff-macro:hover{
    border-color: rgba(20,184,166,.35);
    background: rgba(20,184,166,.05);
}
.nd-aff-macro code{
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8125rem;
    font-weight: 800;
    color: #0f766e;
}
.nd-aff-macro span{
    font-size: 0.6875rem;
    font-weight: 600;
    color: rgba(17,18,20,.5);
}

/* ── Filters + tables ── */
.nd-aff-filters{
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}
.nd-aff-url-cell{
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
    color: rgba(17,18,20,.55);
}
.nd-aff-error-text{
    color: #dc2626;
    font-weight: 700;
    font-size: 0.75rem;
}
.nd-aff-tablefoot{
    margin-top: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(17,18,20,.4);
}

/* ── Responsive ── */
@media (max-width: 1360px){
    .nd-aff-kpis{ grid-template-columns: repeat(3, 1fr); }
    .nd-aff-metrics{ grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1100px){
    .nd-aff-grid{ grid-template-columns: 1fr; }
    .nd-aff-filters{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px){
    .nd-aff-root{ padding: 16px; }
    .nd-aff-kpis{ grid-template-columns: repeat(2, 1fr); }
    .nd-aff-metrics{ grid-template-columns: repeat(2, 1fr); }
    .nd-aff-controls{ align-items: flex-start; width: 100%; }
    .nd-aff-builder{ grid-template-columns: 1fr; }
}
@media (max-width: 720px){
    .nd-aff-chart{ height: 140px; }
    .nd-aff-chart-bars{ height: 120px; }
    .nd-aff-event-body{ flex-direction: column; align-items: stretch; }
    .nd-aff-status-input,
    .nd-aff-method,
    .nd-aff-url-input{ width: 100%; min-width: 0; }
    .nd-aff-preset{ flex-wrap: wrap; }
}
@media (max-width: 520px){
    .nd-aff-root{ padding: 12px; }
    .nd-aff-kpis{ grid-template-columns: 1fr; }
    .nd-aff-filters{ grid-template-columns: 1fr; }
    .nd-aff-title{ font-size: 1.25rem; }
    .nd-aff-date{ min-width: 130px; }
}
