/*
 * Affiliate pages. Public landing and dashboard use the UI kit (css/kd-ui.css) plus the aff-* rules below.
 * The first block (affiliate-admin, affiliate-table) and the last block (aff-rates) are for older admin markup.
 */
.affiliate-admin,
.affiliate-table form,
#affiliate-notice form {
    width: auto;
}
.affiliate-admin label {
    display: block;
    margin: 0 0 12px;
}
.affiliate-admin input,
.affiliate-admin select {
    width: 100%;
    max-width: 420px;
}
.affiliate-admin button,
.affiliate-admin .btn,
.affiliate-table button,
.affiliate-table .btn,
#affiliate-notice button,
#affiliate-notice .btn {
    width: auto;
}
.affiliate-table input,
.affiliate-table select {
    width: auto;
    max-width: 100%;
}
.affiliate-admin [hidden] {
    display: none;
}
.affiliate-table {
    width: 100%;
    border-collapse: collapse;
}
.affiliate-table th,
.affiliate-table td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid #ddd;
    vertical-align: top;
}
@media (max-width: 800px) {
    .affiliate-table,
    .affiliate-table tbody,
    .affiliate-table tr,
    .affiliate-table td {
        display: block;
        box-sizing: border-box;
        width: 100%;
    }
    .affiliate-table thead {
        display: none;
    }
}

/* ---------- shared helpers ---------- */
.aff-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.aff-small {
    margin: 10px 0 0;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--text-muted, #5d6b81);
}
.aff-pad-top {
    margin-top: 10px;
}
body.page-affiliate-landing {
    overflow-x: hidden;
}
.aff-app,
.aff-land {
    overflow-wrap: break-word;
}

/* ---------- logged-out landing ---------- */
.aff-land {
    max-width: 960px;
}
.aff-land .kd-card {
    margin-bottom: 0;
}
.aff-hero {
    margin: 8px 0 24px;
    padding: 24px 16px;
    text-align: center;
    background: var(--color-primary-soft, #e8f1ff);
    border: 1px solid var(--border, #d9e2ec);
    border-radius: 14px;
}
.aff-h1 {
    margin: 0 0 12px;
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
}
.aff-h2 {
    margin: 0 0 12px;
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1.25;
}
.aff-hero-lead {
    max-width: 38rem;
    margin: 0 auto 16px;
    font-size: 1.05rem;
    line-height: 1.45;
}
.aff-hero-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 8px;
}
.aff-hero-actions .kd-btn {
    width: 100%;
}
.aff-hero-login {
    margin: 10px 0 0;
}
.aff-section {
    margin: 0 0 28px;
    scroll-margin-top: 80px;
}
.aff-section-sub {
    margin: -6px 0 12px;
    color: var(--text-secondary, #4a5970);
}
.aff-steps,
.aff-week,
.aff-next {
    list-style: none;
    margin: 0;
    padding: 0;
}
.aff-steps {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
}
.aff-step p {
    margin: 4px 0 0;
}
.aff-week {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
}
.aff-day {
    display: grid;
    grid-template-columns: 3rem minmax(0, 1fr);
    gap: 0 10px;
    padding: 10px 12px;
    background: var(--bg-surface, #fff);
    border: 1px solid var(--border, #d9e2ec);
    border-radius: 10px;
}
.aff-day-name {
    grid-row: 1 / span 2;
    align-self: center;
    font-size: 1rem;
}
.aff-day-do {
    font-weight: 700;
}
.aff-day-share {
    color: var(--text-secondary, #4a5970);
    font-size: 0.9rem;
}
.aff-ways {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
}
.aff-way p {
    margin: 6px 0 0;
}
.aff-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
}
.aff-list li {
    padding: 6px 0;
    border-top: 1px solid var(--border-soft, #e4ecf5);
}
.aff-checks {
    list-style: none;
    margin: 0;
    padding: 0;
}
.aff-checks li {
    position: relative;
    margin: 0 0 8px;
    padding-left: 1.7em;
    line-height: 1.45;
}
.aff-checks li::before {
    content: "\2713";
    position: absolute;
    left: 0;
    font-weight: 800;
    color: var(--color-success, #27a268);
}
.aff-join {
    scroll-margin-top: 80px;
    text-align: center;
}
.aff-next {
    max-width: 34rem;
    margin: 0 auto 16px;
    text-align: left;
    counter-reset: aff-next;
}
.aff-next li {
    position: relative;
    margin: 0 0 8px;
    padding-left: 2.1em;
    line-height: 1.45;
    counter-increment: aff-next;
}
.aff-next li::before {
    content: counter(aff-next);
    position: absolute;
    left: 0;
    top: 0.1em;
    width: 1.6em;
    height: 1.6em;
    border-radius: 50%;
    background: var(--color-primary, #007bff);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.6em;
    text-align: center;
}

/* sticky "Join free" bar, phones only */
.aff-sticky {
    display: none;
}
.aff-sticky[hidden] {
    display: none !important;
}
@media (max-width: 639px) {
    .aff-sticky {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 800;
        display: block;
        padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
        background: var(--bg-surface, #fff);
        border-top: 1px solid var(--border, #d9e2ec);
        box-shadow: 0 -6px 20px rgba(16, 32, 58, 0.14);
    }
    body.app-shell .aff-sticky {
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
        padding-bottom: 8px;
    }
    .aff-land {
        padding-bottom: 96px;
    }
}
@media (min-width: 640px) {
    .aff-hero {
        padding: 36px 28px;
    }
    .aff-h1 {
        font-size: 2.1rem;
    }
    .aff-hero-actions {
        flex-direction: row;
        justify-content: center;
    }
    .aff-hero-actions .kd-btn {
        width: auto;
    }
    .aff-steps {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .aff-ways {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (min-width: 900px) {
    .aff-steps {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .aff-week {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }
    .aff-day {
        display: flex;
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }
    .aff-day-name {
        grid-row: auto;
    }
}
body.app-shell .aff-hero {
    padding: 18px 12px;
}
body.app-shell .aff-h1 {
    font-size: 1.4rem;
}
body.app-shell .aff-land,
body.app-shell .aff-app {
    max-width: 100%;
}

/* ---------- signed-in page ---------- */
.aff-form .aff-fieldset,
.aff-app .aff-fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}
.aff-invalid {
    outline: 2px solid var(--color-danger, #d93025);
    outline-offset: 4px;
    border-radius: 8px;
    scroll-margin-top: 88px;
}
#aff-error {
    scroll-margin-top: 88px;
}
.aff-req-note {
    margin-bottom: 12px;
}
.aff-form .kd-h2 {
    display: flex;
    align-items: center;
}
.aff-weekly-call {
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 2px solid #b8860b;
    border-radius: 10px;
    background: #fff6d8;
    color: #3d3200;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.35;
}
.aff-weekly {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 4px;
    border-radius: 12px;
}
.aff-weekly:not(:has(input:checked)) {
    outline: 2px dashed #b8860b;
    outline-offset: 4px;
}
.aff-weekly .kd-choice {
    min-height: 84px;
    border-width: 2px;
}
.aff-num {
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px 6px;
}
.aff-weekly-err {
    margin: 10px 0 0;
}
.aff-num input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}
.aff-num {
    position: relative;
}
.aff-num:has(input:focus-visible) {
    outline: 3px solid var(--color-primary, #007bff);
    outline-offset: 2px;
}
.aff-num b {
    font-size: 1.5rem;
    line-height: 1.1;
}
.aff-plans,
.aff-pay-choices {
    grid-template-columns: minmax(0, 1fr);
}
.aff-copy-status {
    min-height: 1.2em;
    margin: 4px 0 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-success, #27a268);
}
.aff-share-row {
    margin-top: 8px;
}
.aff-dl {
    margin: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px 16px;
}
.aff-dl dt {
    margin-top: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted, #5d6b81);
}
.aff-dl dd {
    margin: 0;
    overflow-wrap: anywhere;
}
.aff-dl dd a {
    margin-right: 10px;
}
@media (min-width: 640px) {
    .aff-dl {
        grid-template-columns: 11rem minmax(0, 1fr);
    }
    .aff-dl dt {
        margin-top: 0;
        padding-top: 4px;
    }
    .aff-dl dd {
        margin-top: 0;
    }
}
.aff-links {
    list-style: none;
    margin: 0;
    padding: 0;
}
.aff-links li + li {
    border-top: 1px solid var(--border-soft, #e4ecf5);
}
.aff-links a {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 44px;
    padding: 10px 2px;
    text-decoration: none;
}
.aff-links b {
    color: var(--text-link, #0056b3);
}
.aff-links span {
    font-size: 0.875rem;
    color: var(--text-muted, #5d6b81);
}
.aff-terms-line {
    margin-top: 8px;
}
.aff-earn-wrap {
    margin-bottom: 16px;
}
@media (max-width: 360px) {
    .aff-weekly {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ---------- older admin rates markup ---------- */
.aff-rates {
    max-width: 52rem;
}
.aff-rates h2 {
    margin: 1.4rem 0 0.4rem;
}
.aff-rates h3 {
    margin: 1.1rem 0 0.35rem;
    font-size: 1.05rem;
}
.aff-card {
    border: 1px solid var(--border, #d5dbe3);
    border-radius: 10px;
    padding: 14px 16px 8px;
    margin: 0 0 16px;
}
.aff-rates .aff-card.affiliate-admin,
.aff-rates .aff-card form,
.aff-rates form.affiliate-admin {
    width: auto;
    max-width: 46rem;
}
.aff-help {
    margin: 4px 0 14px;
    max-width: 46rem;
    color: var(--text-muted, #5d6b81);
    font-size: 0.92rem;
    line-height: 1.45;
}
.aff-rates textarea {
    width: 100%;
    max-width: 420px;
    min-height: 4.5rem;
}
.aff-rates .affiliate-admin button,
.aff-rates .affiliate-table button,
.aff-rates .btn {
    width: auto;
}
.aff-share-text {
    margin: 0.4rem 0 0.8rem;
    font-weight: 700;
    word-break: break-all;
    user-select: all;
}
@media (max-width: 720px) {
    .aff-card {
        padding: 12px;
    }
}

/* ---------- earning showcase (partials/affiliate_showcase.php) ---------- */
.aff-hero-img {
    display: block;
    width: 100%;
    max-width: 720px;
    height: auto;
    aspect-ratio: 1024 / 537;
    object-fit: cover;
    margin: 18px auto 0;
    border: 1px solid var(--border, #d9e2ec);
    border-radius: 12px;
}
.aff-stats {
    margin: 0 0 28px;
}
.aff-stat-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.aff-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 12px;
    text-align: center;
    background: var(--color-primary-soft, #e8f1ff);
    border: 1px solid var(--border, #d9e2ec);
    border-radius: 12px;
}
.aff-stat-num {
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1.15;
    color: var(--text-link, #0056b3);
}
.aff-stat-label {
    font-size: 0.85rem;
    line-height: 1.3;
    color: var(--text-secondary, #4a5970);
}
.aff-pay-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}
.aff-pay-card {
    display: flex;
    flex-direction: column;
}
.aff-pay-card p {
    margin: 6px 0 0;
}
.aff-pay-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.aff-pay-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--color-primary-soft, #e8f1ff);
    color: var(--text-link, #0056b3);
}
.aff-pay-tag {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.3;
    background: var(--color-success-soft, #e3f5ec);
    color: var(--color-success-text, #14633f);
}
.aff-pay-link {
    margin-top: auto !important;
    padding-top: 12px;
}
.aff-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
}
.aff-chart {
    margin: 0;
}
.aff-chart-title {
    display: block;
    margin-bottom: 14px;
    font-size: 1.05rem;
    font-weight: 800;
}
.aff-chart-title span {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted, #5d6b81);
}
.aff-cols {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    height: 230px;
    align-items: end;
}
.aff-col {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    height: 100%;
}
.aff-col-val {
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
}
.aff-col-bar {
    display: block;
    width: 100%;
    max-width: 56px;
    height: calc(var(--h, 10) * 1.55px);
    border-radius: 8px 8px 0 0;
    background: linear-gradient(180deg, #2f9e6e, #1c7d4f);
}
.aff-col-lab {
    padding-top: 4px;
    border-top: 2px solid var(--border, #d9e2ec);
    width: 100%;
    font-size: 0.78rem;
    line-height: 1.2;
    text-align: center;
    color: var(--text-muted, #5d6b81);
}
.aff-chart .aff-cols + .aff-small {
    margin-top: 12px;
}
.aff-stack {
    display: flex;
    height: 34px;
    overflow: hidden;
    border: 1px solid var(--border, #d9e2ec);
    border-radius: 10px;
}
.aff-seg {
    flex: 1 1 0;
    min-width: 6px;
}
.aff-seg-views,
.aff-dot.aff-seg-views {
    background: #2f80ed;
}
.aff-seg-voice,
.aff-dot.aff-seg-voice {
    background: #f2994a;
}
.aff-seg-parts,
.aff-dot.aff-seg-parts {
    background: #27a268;
}
.aff-legend {
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}
.aff-legend li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
}
.aff-dot {
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.aff-legend-name {
    flex: 1 1 auto;
    min-width: 0;
}
.aff-legend-total {
    margin-top: 6px;
    padding-top: 10px !important;
    border-top: 1px solid var(--border, #d9e2ec);
    font-size: 1.05rem;
}
.aff-coach-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
}
.aff-coach-copy p {
    margin: 0 0 12px;
}
.aff-coach-media {
    display: grid;
    gap: 10px;
    align-content: start;
}
.aff-coach-media img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--border, #d9e2ec);
    border-radius: 10px;
}
.aff-coach-media img.aff-coach-shot {
    max-height: 300px;
    object-fit: cover;
    object-position: top left;
}
.aff-showcase-cta {
    text-align: center;
}
.aff-fine {
    max-width: 46rem;
    margin-left: auto;
    margin-right: auto;
}
@media (max-width: 639px) {
    .aff-stat:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
}
@media (min-width: 800px) {
    .aff-coach-card {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: center;
    }
}
.aff-pillars img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
}
.aff-pay-img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 0 12px;
    border-radius: 10px;
}

/* ---------- vertical showcase (affiliate_tour.php) ---------- */
body.page-affiliate-landing .aff-tour {
    max-width: 960px;
}
.tour-slide {
    margin: 0 0 18px;
    overflow: hidden;
    border-radius: 16px;
    background: #0b0f17;
    color: #fff;
}
.tour-slide img {
    display: block;
    width: 100%;
    height: auto;
}
.tour-body {
    padding: 18px 18px 22px;
}
.tour-body p {
    margin: 8px 0 0;
    color: #dfe6f2;
    line-height: 1.45;
}
.tour-slide h1,
.tour-slide h2 {
    margin: 0;
    color: #fff;
    font-weight: 800;
    line-height: 1.15;
}
.tour-h1 {
    font-size: 2rem;
}
.tour-slide h2 {
    font-size: 1.5rem;
}
.tour-center {
    text-align: center;
}
.tour-lead {
    font-size: 1.1rem;
}
.tour-big {
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1.1;
    color: #ff6a3d !important;
}
.tour-actions {
    margin-top: 14px !important;
}
.tour-small,
.tour-fine {
    font-size: 0.85rem;
}
.tour-slide .tour-small a {
    color: #9ecbff;
}
.tour-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
}
.tour-list li {
    position: relative;
    margin: 0 0 9px;
    padding-left: 1.7em;
    line-height: 1.4;
    color: #e8eefb;
}
.tour-list li::before {
    content: "\2713";
    position: absolute;
    left: 0;
    font-weight: 800;
    color: #3ddc97;
}
.tour-fine {
    max-width: 46rem;
    margin: 6px auto 20px;
}
@media (min-width: 800px) {
    .tour-h1 {
        font-size: 2.8rem;
    }
    .tour-split {
        display: grid;
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
        align-items: center;
    }
    .tour-split-flip > img {
        order: 2;
    }
    .tour-body {
        padding: 26px 28px;
    }
}
@media (max-width: 639px) {
    .aff-tour {
        padding-bottom: 96px;
    }
}
.tour-slide img[src*="icon-512"] {
    max-width: 220px;
    margin: 18px auto 0;
    border-radius: 44px;
}
.tour-num {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0 0 10px !important;
    border-radius: 50%;
    background: #ff6a3d;
    color: #fff !important;
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1;
}
.tour-center .tour-num {
    margin: 0 auto 10px !important;
}
.tour-shot {
    padding: 0 14px 18px;
}
.tour-shot img {
    border-radius: 10px;
    background: #fff;
}
.tour-shot-cream img {
    width: auto;
    max-width: 100%;
    margin: 0 auto;
}
.tour-zoom {
    display: block;
    cursor: zoom-in;
}

/* ---------- Marketing tab (partials/affiliate_marketing.php) ---------- */
.mk-rows {
    display: grid;
    gap: 14px;
}
.mk-row {
    display: grid;
    gap: 6px;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft, #e4ecf5);
}
.mk-row:first-child {
    padding-top: 0;
    border-top: 0;
}
.mk-row-text b {
    display: block;
}
.mk-row .kd-copy {
    flex-wrap: wrap;
}
.mk-row .kd-copy input {
    min-width: 0;
    flex: 1 1 220px;
}
.mk-dest {
    max-width: 360px;
    margin-bottom: 6px;
}
.mk-dest select {
    width: 100%;
}
.mk-group {
    margin: 22px 0 10px;
}
.mk-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.mk-tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 10px;
    background: var(--bg-surface, #fff);
    border: 1px solid var(--border, #d9e2ec);
    border-radius: 12px;
}
.mk-thumb {
    display: grid;
    place-items: center;
    min-height: 110px;
    padding: 6px;
    background: repeating-conic-gradient(#e9eef6 0 25%, #f7f9fc 0 50%) 0 0 / 16px 16px;
    border-radius: 8px;
    overflow: hidden;
}
.mk-thumb img {
    display: block;
    max-width: 100%;
    max-height: 160px;
    width: auto;
    height: auto;
    object-fit: contain;
}
.mk-tile figcaption {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.9rem;
}
.mk-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}
.mk-actions .kd-btn {
    width: auto;
}
