:root {
    --bg: #080b11;
    --surface: rgba(16, 22, 35, 0.75);
    --surface-2: rgba(25, 33, 50, 0.8);
    --border: rgba(255,255,255,0.07);
    --primary: #45f3ff;
    --primary-dim: rgba(69,243,255,0.15);
    --primary-glow: rgba(69,243,255,0.35);
    --accent: #7c6dff;
    --success: #0df07a;
    --success-dim: rgba(13,240,122,0.12);
    --error: #ff4b4b;
    --error-dim: rgba(255,75,75,0.12);
    --warning: #ffa94d;
    --warning-dim: rgba(255,169,77,0.12);
    --text: #e9edf5;
    --text-dim: #8a94a8;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 20px 60px rgba(0,0,0,0.5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── BLOBS ── */
.blob-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.blob1, .blob2 {
    position: absolute;
    width: 700px; height: 700px;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.35;
    animation: drift 18s infinite alternate ease-in-out;
}
.blob1 { background: radial-gradient(circle, rgba(69,243,255,0.5) 0%, transparent 70%); top:-200px; left:-200px; }
.blob2 { background: radial-gradient(circle, rgba(124,109,255,0.5) 0%, transparent 70%); bottom:-200px; right:-100px; animation-delay:-8s; }
@keyframes drift { 0%{transform:translate(0,0) scale(1);} 100%{transform:translate(40px,60px) scale(1.1);} }

/* ── HEADER ── */
.site-header {
    position: sticky; top: 0; z-index: 100;
    background: rgba(8,11,17,0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}
.header-inner {
    max-width: 1200px; margin: 0 auto;
    padding: 0 2rem;
    height: 64px;
    display: flex; align-items: center; justify-content: space-between;
}
.logo-area { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 1.5rem; }
.logo-text { font-size: 1.1rem; color: var(--text-dim); letter-spacing: -0.3px; }
.logo-text strong { color: var(--primary); font-weight: 700; }

.user-info { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 0.9rem; color: var(--text-dim); }
.badge {
    background: var(--primary-dim);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid rgba(69,243,255,0.2);
}

/* ── MAIN ── */
.main-content {
    position: relative; z-index: 1;
    max-width: 1200px; margin: 0 auto;
    padding: 2rem 2rem 4rem;
}

/* ── STEP CARD ── */
.step-card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    animation: fadeUp 0.4s ease;
}
.step-card.hidden { display: none; }
.step-card.active { display: block; }

@keyframes fadeUp {
    from { opacity:0; transform:translateY(16px); }
    to { opacity:1; transform:translateY(0); }
}

.step-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.4rem; }
.step-desc { font-size: 0.9rem; color: var(--text-dim); line-height: 1.6; }

.step-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.step-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── FORM ── */
.auth-form { margin-top: 1.5rem; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
@media (max-width: 580px) { .form-row { grid-template-columns: 1fr; } }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.82rem; font-weight: 600; color: var(--text-dim); }
.form-group input {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}
.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

/* ── BUTTONS ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 0.95rem; font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), #00c8d8);
    color: #05080f;
    box-shadow: 0 4px 20px var(--primary-glow);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 24px var(--primary-glow); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

.btn-ghost-sm {
    background: transparent; color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 8px 14px; font-size: 0.82rem; border-radius: 8px;
    font-family: inherit; cursor: pointer;
    transition: all 0.2s;
}
.btn-ghost-sm:hover { border-color: var(--primary); color: var(--primary); }

/* loader inside button */
.loader {
    width: 18px; height: 18px;
    border: 2.5px solid rgba(5,8,15,0.3);
    border-top-color: #05080f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loader.hidden { display: none; }
.btn.loading .btn-label { display: none; }
.btn.loading .loader { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── ALERTS ── */
.alert {
    margin-top: 1rem; padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}
.alert.hidden { display: none; }
.alert.error { background: var(--error-dim); color: var(--error); border: 1px solid rgba(255,75,75,0.25); }
.alert.success { background: var(--success-dim); color: var(--success); border: 1px solid rgba(13,240,122,0.25); }
.alert.info { background: var(--primary-dim); color: var(--primary); border: 1px solid rgba(69,243,255,0.2); }

/* ── LOADING STATE ── */
.loading-state {
    padding: 3rem; text-align: center;
    color: var(--text-dim); font-size: 0.9rem;
    display: flex; align-items: center; justify-content: center; gap: 12px;
}
.spinner {
    display: inline-block;
    width: 22px; height: 22px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ── UC GRID ── */
.uc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.uc-grid.hidden { display: none; }

.uc-card {
    background: var(--surface-2);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.1rem 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}
.uc-card:hover { border-color: rgba(69,243,255,0.3); background: rgba(30,40,60,0.85); }
.uc-card.selected {
    border-color: var(--primary);
    background: rgba(69,243,255,0.05);
    box-shadow: 0 0 0 3px var(--primary-dim);
}
.uc-card .check-indicator {
    position: absolute; top: 12px; right: 12px;
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem;
    transition: all 0.2s;
}
.uc-card.selected .check-indicator {
    background: var(--primary);
    border-color: var(--primary);
    color: #05080f;
}
.uc-card-id {
    font-size: 1rem; font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px; margin-right: 28px;
}
.uc-card-address {
    font-size: 0.78rem; color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 8px;
}
.uc-card-status {
    display: inline-block;
    font-size: 0.72rem; font-weight: 600;
    padding: 2px 8px; border-radius: 20px;
}
.status-ok { background: var(--success-dim); color: var(--success); }
.status-alert { background: var(--error-dim); color: var(--error); }
.status-inactive { background: rgba(138, 148, 168, 0.15); color: #a1acc0; border: 1px solid rgba(138, 148, 168, 0.3); }
.status-neutral { background: var(--primary-dim); color: var(--primary); }

.uc-inactive { 
    opacity: 0.5; 
    filter: grayscale(1); 
    border-style: dashed;
    cursor: default;
}
.uc-inactive:hover { 
    opacity: 0.7; 
    filter: grayscale(0.5); 
    border-color: rgba(255,255,255,0.2);
}

/* ── RESULTS ── */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.result-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.2rem;
    animation: fadeUp 0.3s ease forwards;
}
.result-card.ok { border-left: 3px solid var(--success); }
.result-card.fail { border-left: 3px solid var(--error); }
.result-card.pending { border-left: 3px solid var(--warning); }

.result-card-id { font-size: 0.9rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.result-card-status { font-size: 0.82rem; margin-bottom: 8px; }
.result-card-status.ok { color: var(--success); }
.result-card-status.fail { color: var(--error); }
.result-card-protocol { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 10px; }

.btn-download {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--success-dim);
    color: var(--success);
    border: 1px solid rgba(13,240,122,0.25);
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 0.8rem; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
    font-family: inherit;
}
.btn-download:hover { background: rgba(13,240,122,0.2); }

/* ── PARTNER OVERRIDE ── */
.partner-override {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 1rem;
}
.partner-override label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-dim);
    white-space: nowrap;
}
.partner-override input {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    color: var(--primary);
    font-family: 'Inter', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    width: 170px;
    outline: none;
    transition: border-color 0.2s;
}
.partner-override input:focus { border-color: var(--primary); }
.partner-hint {
    font-size: 0.72rem;
    color: var(--text-dim);
    opacity: 0.7;
}

/* ── HIGHLIGHT DEBT ── */
.uc-card.has-debts {
    border-color: #ff4d4d;
    background: rgba(255, 77, 77, 0.05);
}
.uc-card.has-debts .uc-status-badge {
    background: #ff4d4d;
    color: white;
}
.uc-card.has-debts .uc-contract {
    color: #ffb3b3;
}
.debt-overlay-info {
    font-size: 0.75rem;
    color: #ffb3b3;
    margin-top: 5px;
    font-weight: 600;
}

/* ── HIDDEN UTIL ── */
.hidden { display: none !important; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .main-content { padding: 1.25rem 1rem 3rem; }
    .step-card { padding: 1.25rem; }
    .step-header { flex-direction: column; }
    .step-actions { width: 100%; justify-content: flex-start; }
    .uc-grid { grid-template-columns: 1fr; }
    .results-grid { grid-template-columns: 1fr; }
}
