/* ═══════════════════════════════
   DESIGN TOKENS
═══════════════════════════════ */
:root {
    --bg: #07090f;
    --s1: #0d1117;
    --s2: #131a24;
    --s3: #1a2332;
    --border: #1e2d42;
    --border2: #243448;
    --accent: #0ea5e9;
    --accent2: #38bdf8;
    --green: #22c55e;
    --yellow: #f59e0b;
    --red: #ef4444;
    --text: #e2e8f0;
    --text2: #94a3b8;
    --text3: #64748b;
    --mono: 'IBM Plex Mono', monospace;
    --sans: 'Poppins', sans-serif;
}

/* ═══════════════════════════════
   RESET & BASE
═══════════════════════════════ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(14, 165, 233, .025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(14, 165, 233, .025) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    z-index: 0;
}

.hidden {
    display: none !important;
}

.fade {
    animation: fadeIn .2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════
   AUTH SCREEN
═══════════════════════════════ */
#authScreen {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    background: #fff;
    border-radius: 20px;
    padding: 48px 44px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .5);
}

.auth-logo {
    height: 34px;
    display: block;
    margin: 0 auto 28px;
}

.auth-title {
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 8px;
}

.auth-sub {
    font-size: 13px;
    color: #64748b;
    line-height: 1.6;
    margin-bottom: 28px;
}

.auth-err {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 11px 14px;
    font-size: 13px;
    color: #dc2626;
    margin-bottom: 14px;
    text-align: left;
    display: none;
}

.auth-err.show {
    display: block;
}

.auth-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
    color: #64748b;
    padding: 16px;
}

.auth-loading.show {
    display: flex;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e2e8f0;
    border-top-color: #0ea5e9;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.terms-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    text-align: left;
    margin-bottom: 16px;
    padding: 13px 14px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.terms-row input[type=checkbox] {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: #0ea5e9;
    cursor: pointer;
}

.terms-row label {
    font-size: 12px;
    color: #475569;
    line-height: 1.6;
    cursor: pointer;
}

.terms-row label a {
    color: #0ea5e9;
    text-decoration: none;
    font-weight: 600;
}

.google-btn {
    width: 100%;
    height: 50px;
    border: 1px solid #dadce0;
    background: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-family: var(--sans);
    font-size: 15px;
    font-weight: 600;
    color: #3c4043;
    cursor: pointer;
    transition: all .2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.google-btn:hover:not(:disabled) {
    box-shadow: 0 2px 10px rgba(0, 0, 0, .14);
    transform: translateY(-1px);
}

.google-btn:disabled {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
    border-color: #e2e8f0;
    box-shadow: none;
    transform: none;
}

.google-btn img {
    width: 20px;
    height: 20px;
}

.auth-footer {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 16px;
    font-size: 12px;
    color: #94a3b8;
}

.auth-footer a {
    color: #0ea5e9;
    text-decoration: none;
}

/* ═══════════════════════════════
   MODE PICKER
═══════════════════════════════ */
#modeScreen {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
}

.mode-wrap {
    width: 100%;
    max-width: 680px;
}

.mode-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 14px;
}

.mode-title {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 8px;
    text-align: center;
}

.mode-sub {
    font-size: 13px;
    color: var(--text2);
    text-align: center;
    margin-bottom: 28px;
}

.mode-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.mode-card {
    background: var(--s1);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 28px 24px;
    cursor: pointer;
    transition: all .22s;
    position: relative;
    overflow: hidden;
}

.mode-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(14, 165, 233, .25), transparent);
}

.mode-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(14, 165, 233, .12);
}

.mode-icon {
    font-size: 36px;
    margin-bottom: 14px;
}

.mode-name {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 10px;
}

.mode-desc {
    font-size: 13px;
    color: var(--text2);
    line-height: 1.6;
    margin-bottom: 18px;
}

.mode-cta {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

/* ═══════════════════════════════
   SHARED WIZARD / BULK CHROME
═══════════════════════════════ */
.wiz-wrap {
    max-width: 780px;
    margin: 0 auto;
    padding: 32px 20px 100px;
    position: relative;
    z-index: 1;
}

.wiz-hdr {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.wiz-logo {
    height: 26px;
}

.wiz-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text2);
}

.step-ctr {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text3);
}

.btn-mode-switch {
    margin-left: auto;
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 500;
    color: var(--text3);
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 12px;
    cursor: pointer;
    transition: all .15s;
}

.btn-mode-switch:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ═══════════════════════════════
   USER BADGE
═══════════════════════════════ */
.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--s2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.u-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #020c14;
    flex-shrink: 0;
    background: var(--accent);
    overflow: hidden;
}

.u-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.u-info {
    flex: 1;
    min-width: 0;
}

.u-name {
    font-size: 13px;
    font-weight: 600;
}

.u-email {
    font-size: 11px;
    color: var(--text3);
    font-family: var(--mono);
}

.u-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.u-chip {
    font-family: var(--mono);
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--s3);
    border: 1px solid var(--border2);
    color: var(--text3);
    white-space: nowrap;
}

.u-chip b {
    color: var(--accent2);
}

.btn-signout {
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 500;
    color: var(--text3);
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 11px;
    cursor: pointer;
    transition: all .15s;
}

.btn-signout:hover {
    color: var(--red);
    border-color: var(--red);
}

/* ═══════════════════════════════
   PROGRESS STEPS
═══════════════════════════════ */
.progress {
    display: flex;
    margin-bottom: 32px;
    position: relative;
}

.progress::after {
    content: '';
    position: absolute;
    top: 15px;
    left: 16px;
    right: 16px;
    height: 1px;
    background: var(--border);
    z-index: 0;
}

.sp {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    position: relative;
    z-index: 1;
    cursor: pointer;
}

.sd {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    background: var(--s2);
    border: 1px solid var(--border);
    color: var(--text3);
    transition: all .25s;
}

.sl {
    font-size: 10px;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: .05em;
    text-align: center;
    white-space: nowrap;
}

.sp.active .sd {
    background: var(--accent);
    border-color: var(--accent);
    color: #020c14;
    box-shadow: 0 0 14px rgba(14, 165, 233, .35);
}

.sp.active .sl {
    color: var(--text);
}

.sp.done .sd {
    background: var(--green);
    border-color: var(--green);
    color: #021a0a;
}

/* ═══════════════════════════════
   CARD
═══════════════════════════════ */
.card {
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 26px;
    margin-bottom: 18px;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(14, 165, 233, .2), transparent);
}

.c-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.c-sub {
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 20px;
}

.bulk-step-num {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--accent);
    margin-bottom: 8px;
}

/* ═══════════════════════════════
   GRID
═══════════════════════════════ */
.g2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.g3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
}

/* ═══════════════════════════════
   FIELD
═══════════════════════════════ */
.f {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.fl {
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    display: flex;
    align-items: center;
    gap: 6px;
}

.fstar {
    color: var(--yellow);
    font-size: 11px;
}

.ftag {
    font-family: var(--mono);
    font-size: 9px;
    color: var(--accent);
    background: rgba(14, 165, 233, .1);
    border: 1px solid rgba(14, 165, 233, .2);
    padding: 1px 5px;
    border-radius: 3px;
}

.fhint {
    font-size: 11px;
    color: var(--text3);
    line-height: 1.4;
}

.ferr {
    font-size: 11px;
    color: var(--red);
    display: none;
}

.ferr.show {
    display: block;
}

.field-hint {
    font-size: 11px;
    color: var(--text3);
    line-height: 1.5;
}

input,
textarea,
select {
    background: var(--s2);
    border: 1px solid var(--border2);
    border-radius: 7px;
    padding: 9px 12px;
    font-family: var(--sans);
    font-size: 13px;
    color: var(--text);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    width: 100%;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, .1);
}

input.locked {
    background: var(--s3);
    color: var(--accent2);
    cursor: default;
    border-style: dashed;
    font-family: var(--mono);
    font-size: 12px;
}

input.err,
select.err,
textarea.err {
    border-color: var(--red);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

select option {
    background: var(--s2);
}

/* ═══════════════════════════════
   SEARCHABLE SELECT
═══════════════════════════════ */
.ss-wrap {
    position: relative;
}

.ss-drop {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 60;
    background: var(--s2);
    border: 1px solid var(--border2);
    border-radius: 8px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}

.ss-drop.open {
    display: block;
}

.ss-opt {
    padding: 9px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background .1s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ss-opt:hover {
    background: var(--s3);
}

.opt-id {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text3);
}

.opt-tag {
    font-family: var(--mono);
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 3px;
}

.te {
    background: rgba(14, 165, 233, .12);
    color: var(--accent);
}

.tr {
    background: rgba(34, 197, 94, .1);
    color: var(--green);
}

.tx {
    background: rgba(167, 139, 250, .12);
    color: #a78bfa;
}

.tm {
    background: rgba(245, 158, 11, .12);
    color: var(--yellow);
}

/* ═══════════════════════════════
   TYPE CARDS
═══════════════════════════════ */
.tc-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 4px;
}

.tc {
    border: 2px solid var(--border2);
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    transition: all .2s;
    background: var(--s2);
    text-align: center;
}

.tc:hover {
    border-color: var(--accent);
    background: rgba(14, 165, 233, .05);
}

.tc.sel {
    border-color: var(--accent);
    background: rgba(14, 165, 233, .08);
    box-shadow: 0 0 18px rgba(14, 165, 233, .12);
}

.tc-icon {
    font-size: 26px;
    margin-bottom: 8px;
}

.tc-name {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 3px;
}

.tc-desc {
    font-size: 11px;
    color: var(--text2);
    line-height: 1.4;
}

/* ═══════════════════════════════
   TOGGLE
═══════════════════════════════ */
.tg-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--s2);
    border: 1px solid var(--border2);
    border-radius: 7px;
}

.tg-lbl {
    font-size: 13px;
    font-weight: 500;
}

.tg-sub {
    font-size: 11px;
    color: var(--text3);
    margin-top: 1px;
}

.tg {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.tg input {
    display: none;
}

.tg-track {
    position: absolute;
    inset: 0;
    border-radius: 11px;
    background: var(--border2);
    transition: background .2s;
    cursor: pointer;
}

.tg-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text3);
    transition: all .2s;
    pointer-events: none;
}

.tg input:checked+.tg-track {
    background: var(--accent);
}

.tg input:checked~.tg-thumb {
    left: 21px;
    background: #fff;
}

/* ═══════════════════════════════
   PILLS (TAGS)
═══════════════════════════════ */
.pill-g {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.pill {
    font-family: var(--mono);
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--s3);
    border: 1px solid var(--border2);
    color: var(--text3);
    cursor: pointer;
    transition: all .15s;
    user-select: none;
}

.pill:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.pill.on {
    background: rgba(14, 165, 233, .12);
    border-color: var(--accent);
    color: var(--accent2);
}

/* ═══════════════════════════════
   SECTION LABEL
═══════════════════════════════ */
.slbl {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text3);
    margin: 18px 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.slbl::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ═══════════════════════════════
   CONDITIONAL BLOCK
═══════════════════════════════ */
.cb {
    display: none;
    border-left: 2px solid rgba(14, 165, 233, .25);
    padding-left: 18px;
    margin-top: 12px;
}

.cb.show {
    display: block;
}

/* ═══════════════════════════════
   ALERT
═══════════════════════════════ */
.al {
    display: flex;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 14px;
}

.al-w {
    background: rgba(245, 158, 11, .08);
    border: 1px solid rgba(245, 158, 11, .22);
    color: #fbbf24;
}

.al-ok {
    background: rgba(34, 197, 94, .08);
    border: 1px solid rgba(34, 197, 94, .22);
    color: #86efac;
}

.al-err {
    background: rgba(239, 68, 68, .08);
    border: 1px solid rgba(239, 68, 68, .22);
    color: #fca5a5;
}

.al-i {
    flex-shrink: 0;
}

/* ═══════════════════════════════
   REVIEW TABLE
═══════════════════════════════ */
.rv-row {
    display: flex;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(30, 45, 66, .7);
    font-size: 13px;
}

.rv-row:last-child {
    border-bottom: none;
}

.rv-key {
    color: var(--text2);
    width: 200px;
    flex-shrink: 0;
    font-family: var(--mono);
    font-size: 11px;
}

.rv-val {
    color: var(--text);
    word-break: break-all;
}

.rv-val.empty {
    color: var(--text3);
    font-style: italic;
}

.rv-g-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text3);
    margin: 14px 0 8px;
}

/* ═══════════════════════════════
   BUTTONS
═══════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all .18s;
    text-decoration: none;
}

.btn-g {
    background: transparent;
    border: 1px solid var(--border2);
    color: var(--text2);
}

.btn-g:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-p {
    background: var(--accent);
    color: #020c14;
    box-shadow: 0 0 18px rgba(14, 165, 233, .2);
}

.btn-p:hover {
    background: var(--accent2);
    box-shadow: 0 0 26px rgba(14, 165, 233, .35);
    transform: translateY(-1px);
}

.btn-s {
    background: var(--green);
    color: #021a0a;
    box-shadow: 0 0 18px rgba(34, 197, 94, .18);
}

.btn-s:hover {
    box-shadow: 0 0 28px rgba(34, 197, 94, .3);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn:disabled {
    background: var(--s3) !important;
    color: var(--text3) !important;
    box-shadow: none !important;
    cursor: not-allowed;
    transform: none !important;
    border-color: var(--border) !important;
}

.nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 22px;
}

/* ═══════════════════════════════
   PROGRESS BAR
═══════════════════════════════ */
.pb-wrap {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.pb-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    width: 0%;
    transition: width .4s ease;
}

/* ═══════════════════════════════
   BULK CSV UPLOAD SPECIFIC
═══════════════════════════════ */
.bulk-template-meta {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tmeta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tmeta-key {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text3);
    font-family: var(--mono);
}

.tmeta-val {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.drop-zone {
    border: 2px dashed var(--border2);
    border-radius: 12px;
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: var(--s2);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(14, 165, 233, .05);
}

.dz-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.dz-text {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
}

.dz-sub {
    font-size: 13px;
    color: var(--text3);
    margin-bottom: 14px;
}

#uploadStatus {
    margin-top: 14px;
}

/* Validation table */
.val-table-wrap {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-top: 14px;
}

.val-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.val-table th {
    background: var(--s2);
    padding: 8px 12px;
    text-align: left;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text3);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.val-table td {
    padding: 9px 12px;
    border-bottom: 1px solid rgba(30, 45, 66, .5);
    vertical-align: top;
}

.val-table tr:last-child td {
    border-bottom: none;
}

.val-table tr.row-ok td {
    background: rgba(34, 197, 94, .03);
}

.val-table tr.row-err td {
    background: rgba(239, 68, 68, .04);
}

.val-table tr.row-skip td {
    background: rgba(100, 116, 139, .04);
    opacity: .6;
}

.row-status {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
}

.rs-ok {
    background: rgba(34, 197, 94, .12);
    color: var(--green);
}

.rs-err {
    background: rgba(239, 68, 68, .12);
    color: var(--red);
}

.rs-skip {
    background: rgba(100, 116, 139, .12);
    color: var(--text3);
}

.rs-sub {
    background: rgba(14, 165, 233, .12);
    color: var(--accent);
}

.rs-done {
    background: rgba(34, 197, 94, .2);
    color: var(--green);
}

.rs-fail {
    background: rgba(239, 68, 68, .2);
    color: var(--red);
}

.rs-wait {
    background: rgba(100, 116, 139, .12);
    color: var(--text3);
}

.row-errs {
    font-size: 11px;
    color: var(--red);
    margin-top: 3px;
    line-height: 1.5;
}

.row-name {
    font-weight: 600;
    color: var(--text);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-type {
    font-family: var(--mono);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--s3);
    color: var(--text3);
}

.row-api-msg {
    font-size: 11px;
    color: var(--text3);
    margin-top: 3px;
}

.row-api-id {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--accent2);
    margin-top: 2px;
}

.bulk-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
    align-items: center;
}

.bulk-actions-info {
    font-size: 13px;
    color: var(--text2);
    margin-left: auto;
}

.bulk-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
}

/* ═══════════════════════════════
   SUCCESS SCREEN
═══════════════════════════════ */
.success-screen {
    text-align: center;
    padding: 56px 20px;
}

.suc-icon {
    font-size: 60px;
    margin-bottom: 18px;
}

.suc-title {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 8px;
}

.suc-sub {
    font-size: 14px;
    color: var(--text2);
    margin-bottom: 32px;
    line-height: 1.6;
}

/* ═══════════════════════════════
   TOAST
═══════════════════════════════ */
.toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    max-width: 360px;
    background: var(--s2);
    border: 1px solid var(--border2);
    border-radius: 10px;
    padding: 14px 18px;
    font-size: 13px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
    transform: translateY(16px);
    opacity: 0;
    transition: all .28s;
    z-index: 200;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.tok {
    border-color: rgba(34, 197, 94, .35);
    color: #86efac;
}

.toast.terr {
    border-color: rgba(239, 68, 68, .35);
    color: #fca5a5;
}

/* ═══════════════════════════════
   SCROLLBAR
═══════════════════════════════ */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: var(--s1);
}

::-webkit-scrollbar-thumb {
    background: var(--border2);
    border-radius: 3px;
}

/* ═══════════════════════════════
   RESPONSIVE
═══════════════════════════════ */
@media (max-width: 600px) {
    .tc-grid {
        grid-template-columns: 1fr;
    }

    .g2,
    .g3 {
        grid-template-columns: 1fr;
    }

    .mode-cards {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 32px 20px;
    }
}

/* ── BADGE TWO-ROW LAYOUT FIX */
.user-badge {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.u-badge-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.u-badge-top .u-info {
    flex: 1;
    min-width: 0;
}

.u-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-left: 42px;
}

/* ── WIDEN MODE SCREEN + BADGE */
.mode-wrap {
    max-width: 780px;
}

.user-badge {
    width: 100%;
}

.u-badge-top {
    width: 100%;
}

.u-badge-top .u-info {
    flex: 1;
}

.u-badge-top .btn-signout {
    margin-left: auto;
    flex-shrink: 0;
}

/* ════════════════════════════════════════════
   HELP BUTTON
════════════════════════════════════════════ */
.btn-help {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .18);
    color: var(--text2);
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
    margin-left: auto;
}

.btn-help:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(14, 165, 233, .08);
}

/* ════════════════════════════════════════════
   MODAL OVERLAY + BOX
════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, .65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform .2s;
    overflow: hidden;
}

.modal-overlay.open .modal-box {
    transform: translateY(0);
}

.modal-hdr {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text1);
    flex: 1;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text3);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    transition: color .2s, background .2s;
}

.modal-close:hover {
    color: var(--text1);
    background: rgba(255, 255, 255, .08);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

/* ════════════════════════════════════════════
   CONNECTION DROPDOWN + INFO
════════════════════════════════════════════ */
.conn-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text2);
    padding: 8px 0;
}

.spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .12);
    border-top-color: var(--accent);
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.conn-info {
    background: rgba(14, 165, 233, .07);
    border: 1px solid rgba(14, 165, 233, .2);
    border-radius: 8px;
    padding: 10px 14px;
    margin-top: 4px;
    margin-bottom: 6px;
}

.conn-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.conn-info-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text1);
}

/* ════════════════════════════════════════════
   MARKDOWN TOOLBAR
════════════════════════════════════════════ */
.md-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 5px 8px;
}

.md-toolbar+textarea,
.md-toolbar+textarea+.md-preview {
    border-radius: 0 0 8px 8px !important;
}

.md-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text2);
    border-radius: 5px;
    padding: 3px 7px;
    font-size: 12px;
    font-family: var(--mono);
    cursor: pointer;
    transition: all .15s;
    line-height: 1.4;
}

.md-btn:hover {
    background: rgba(255, 255, 255, .08);
    color: var(--text1);
    border-color: var(--border);
}

.md-btn.md-sep {
    margin-left: 4px;
}

.md-spacer {
    flex: 1;
}

.md-preview-btn {
    color: var(--accent);
    border-color: rgba(14, 165, 233, .3);
}

.md-preview-btn.active {
    background: rgba(14, 165, 233, .12);
    color: var(--accent);
}

.md-preview {
    min-height: 160px;
    background: rgba(255, 255, 255, .03);
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text1);
    overflow-y: auto;
}

.md-preview h1 {
    font-size: 20px;
    margin: 0 0 10px;
}

.md-preview h2 {
    font-size: 16px;
    margin: 14px 0 8px;
    color: var(--text1);
}

.md-preview h3 {
    font-size: 14px;
    margin: 12px 0 6px;
    color: var(--text2);
}

.md-preview p {
    margin: 0 0 10px;
}

.md-preview ul {
    padding-left: 18px;
    margin: 0 0 10px;
}

.md-preview li {
    margin-bottom: 4px;
}

.md-preview code {
    background: rgba(255, 255, 255, .08);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 12px;
}

.md-preview pre {
    background: rgba(0, 0, 0, .3);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0 0 10px;
}

.md-preview pre code {
    background: none;
    padding: 0;
}

.md-preview a {
    color: var(--accent);
    text-decoration: underline;
}

.md-preview strong {
    font-weight: 700;
}

.md-preview em {
    font-style: italic;
}

/* ════════════════════════════════════════════
   WIDEN MODE SCREEN + BADGE (override earlier rule)
════════════════════════════════════════════ */
.mode-wrap {
    max-width: 780px !important;
}

.mode-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.user-badge {
    width: 100%;
}

.u-badge-top {
    width: 100%;
}

.u-badge-top .u-info {
    flex: 1;
}

.u-badge-top .btn-signout {
    margin-left: auto;
    flex-shrink: 0;
}

/* ════════════════════════════════════════════
   CONNECTION CONTEXT BAR (step 3 reminder)
════════════════════════════════════════════ */
.conn-context-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(14, 165, 233, .07);
    border: 1px solid rgba(14, 165, 233, .18);
    border-radius: 10px;
    padding: 8px 14px;
    margin-bottom: 4px;
    font-size: 13px;
    flex-wrap: wrap;
}

/* ════════════════════════════════════════════
   CREATE CONNECTION MODAL — WIDER + CREDENTIAL PANEL
════════════════════════════════════════════ */
.modal-box-lg {
    max-width: 780px;
}

.cc-divider {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text3);
    text-align: center;
    position: relative;
    margin: 6px 0 14px;
}

.cc-divider::before,
.cc-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 42%;
    height: 1px;
    background: var(--border);
}

.cc-divider::before {
    left: 0;
}

.cc-divider::after {
    right: 0;
}

.btn-copy-sample {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text2);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
    transition: all .15s;
}

.btn-copy-sample:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Reference panel (sample JSON + permissions) */
.cc-ref-panel {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 4px;
}

.cc-ref-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, .03);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text2);
    user-select: none;
    transition: background .15s;
}

.cc-ref-toggle:hover {
    background: rgba(255, 255, 255, .06);
    color: var(--text1);
}

.cc-ref-body {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, .15);
}

.cc-ref-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 8px;
}

.cc-ref-hint {
    font-size: 12px;
    color: var(--text3);
    margin-bottom: 8px;
    line-height: 1.5;
}

.cc-sample-pre {
    background: rgba(0, 0, 0, .3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--accent2);
    overflow-x: auto;
    white-space: pre;
    max-height: 220px;
    overflow-y: auto;
    margin: 0;
}

.cc-perms-list {
    list-style: none;
    padding: 0;
    margin: 0 0 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.cc-perms-list li code {
    display: inline-block;
    background: rgba(14, 165, 233, .1);
    border: 1px solid rgba(14, 165, 233, .2);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 11px;
    font-family: var(--mono);
    color: var(--accent);
}

.cc-perms-warning {
    font-size: 11px;
    color: var(--warning, #f59e0b);
    margin-bottom: 6px;
    line-height: 1.4;
}

.cc-perms-error {
    font-size: 11px;
    color: var(--danger, #ef4444);
    background: rgba(239, 68, 68, .08);
    border: 1px solid rgba(239, 68, 68, .2);
    border-radius: 6px;
    padding: 6px 9px;
    line-height: 1.4;
}

@media (max-width: 600px) {
    .cc-ref-body>div {
        grid-template-columns: 1fr !important;
    }
}

/* ════════════════════════════════════════════
   STEP 4 — PROGRESSIVE DISCLOSURE
════════════════════════════════════════════ */
.s4-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 18px 0;
}

.s4-sub-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text1);
    margin-bottom: 10px;
}

/* Commission calculator */
.commission-calc {
    background: rgba(0, 0, 0, .2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    width: 100%;
}

.cc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text2);
    padding: 3px 0;
}

.cc-earn {
    border-top: 1px solid var(--border);
    margin-top: 6px;
    padding-top: 8px;
    font-weight: 700;
    font-size: 14px;
    color: var(--text1);
}

/* Price history chips */
.price-chip {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    max-width: 220px;
}

.price-chip:hover {
    border-color: var(--accent);
    background: rgba(14, 165, 233, .08);
}

/* ── Approval checkbox (Step 4) ── */
.approval-check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    margin-top: 2px;
}

.approval-check:hover {
    border-color: rgba(14, 165, 233, .4);
}

.approval-check--on {
    border-color: rgba(34, 197, 94, .5);
    background: rgba(34, 197, 94, .05);
}

.approval-check input[type="checkbox"] {
    display: none;
}

.approval-check-box {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 5px;
    margin-top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    background: transparent;
}

.approval-check--on .approval-check-box {
    background: #22c55e;
    border-color: #22c55e;
}

.approval-check--on .approval-check-box::after {
    content: '✓';
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}