/* ============================================================
   RPTlink — Professional UI
   ============================================================ */

:root {
    /* Surfaces */
    --bg: #0a0e14;
    --bg-soft: #0e1420;
    --surface: #121a28;
    --surface-2: #1a2435;
    --surface-3: #212e44;
    --border: #233149;
    --border-soft: #1b2638;

    /* Text */
    --text: #eef2f8;
    --text-muted: #93a4be;
    --text-dim: #647590;

    /* Brand / status */
    --primary: #4285f4;
    --primary-hover: #5a98f7;
    --primary-soft: rgba(66, 133, 244, 0.12);
    --success: #34d27e;
    --success-soft: rgba(52, 210, 126, 0.12);
    --warning: #f5b942;
    --warning-soft: rgba(245, 185, 66, 0.12);
    --danger: #f0584b;
    --danger-soft: rgba(240, 88, 75, 0.12);

    /* Shape */
    --radius: 14px;
    --radius-sm: 9px;
    --radius-pill: 999px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
    --ring: 0 0 0 3px rgba(66, 133, 244, 0.25);
    --gradient: linear-gradient(135deg, #4285f4, #2f6fdc);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background:
        radial-gradient(1100px 600px at 85% -8%, rgba(66, 133, 244, 0.08), transparent 60%),
        radial-gradient(900px 500px at 0% 0%, rgba(52, 210, 126, 0.05), transparent 55%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 15px;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(66, 133, 244, 0.35); }

/* ---------- Layout ---------- */
.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 24px 64px;
}

/* ---------- Top App Bar ---------- */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border-soft);
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 46px;
    height: 46px;
    background: var(--gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 23px;
    box-shadow: 0 6px 18px rgba(66, 133, 244, 0.35);
}

.logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.logo p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.header-link {
    color: var(--text);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 9px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.18s ease;
    white-space: nowrap;
}

.header-link:hover {
    background: var(--surface-2);
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* ---------- Cards ---------- */
.card {
    background: linear-gradient(180deg, var(--surface), var(--bg-soft));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.02rem;
    font-weight: 650;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 9px;
    letter-spacing: -0.01em;
}

/* ---------- Report Config ---------- */
.report-config {
    margin-bottom: 22px;
}

.report-config h2 {
    font-size: 0.95rem;
    margin-bottom: 14px;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.config-item {
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 13px 16px;
    transition: border-color 0.18s ease;
}

.config-item:hover { border-color: var(--border); }

.config-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
    margin-bottom: 5px;
}

.config-value {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
}

/* ---------- Campaign Status Pill ---------- */
.campaign-status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 8px 18px;
    margin-bottom: 22px;
    font-size: 0.86rem;
    box-shadow: var(--shadow-sm);
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
}

.status-dot.running {
    background: var(--success);
    box-shadow: 0 0 0 4px var(--success-soft);
    animation: pulse 1.8s ease-in-out infinite;
}
.status-dot.paused {
    background: var(--warning);
    box-shadow: 0 0 0 4px var(--warning-soft);
}
.status-dot.stopped { background: var(--text-dim); }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--success-soft); }
    50% { box-shadow: 0 0 0 6px rgba(52, 210, 126, 0.05); }
}

.status-text {
    color: var(--text-muted);
    font-weight: 600;
}

/* ---------- Stats Grid ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 26px;
}

.stat-card {
    position: relative;
    background: linear-gradient(180deg, var(--surface), var(--bg-soft));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.18s ease, border-color 0.18s ease;
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--text-dim);
    border-radius: 3px;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-card.total::before { background: var(--primary); }
.stat-card.pending::before { background: var(--warning); }
.stat-card.success::before { background: var(--success); }
.stat-card.failed::before { background: var(--danger); }

.stat-card .label {
    font-size: 0.72rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.stat-card .value {
    font-size: 1.7rem;
    font-weight: 750;
    margin-top: 6px;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.stat-card.pending .value { color: var(--warning); }
.stat-card.success .value { color: var(--success); }
.stat-card.failed .value { color: var(--text); }
.stat-card.total .value { color: var(--primary); }

.stat-card .email-value {
    font-size: 1.05rem;
    word-break: break-all;
    color: var(--warning);
}

/* ---------- Grid 2 ---------- */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    margin-bottom: 22px;
}

@media (max-width: 880px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Forms ---------- */
label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 7px;
    font-weight: 500;
}

textarea, input[type="text"] {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    color: var(--text);
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.86rem;
    resize: vertical;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    line-height: 1.5;
}

textarea::placeholder { color: var(--text-dim); }

textarea:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
}

textarea { min-height: 150px; }

.form-group { margin-bottom: 16px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.16s ease;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

.btn-primary {
    background: var(--gradient);
    color: #fff;
    width: 100%;
    box-shadow: 0 4px 14px rgba(66, 133, 244, 0.3);
}
.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(66, 133, 244, 0.42);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--surface-3);
    border-color: var(--primary);
}

.btn-sm { padding: 7px 13px; font-size: 0.78rem; }

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(240, 88, 75, 0.45);
}
.btn-danger:hover:not(:disabled) { background: rgba(240, 88, 75, 0.2); }

.btn-warning {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: rgba(245, 185, 66, 0.45);
}
.btn-warning:hover:not(:disabled) { background: rgba(245, 185, 66, 0.2); }

.btn-success {
    background: var(--success-soft);
    color: var(--success);
    border-color: rgba(52, 210, 126, 0.45);
}
.btn-success:hover:not(:disabled) { background: rgba(52, 210, 126, 0.2); }

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.btn-group.compact { margin-bottom: 0; }

/* ---------- Import Row ---------- */
.import-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.import-mode {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.18s ease;
}
.import-mode:focus { outline: none; border-color: var(--primary); }

.file-label {
    cursor: pointer;
    margin: 0;
}

/* ---------- Info Box ---------- */
.info-box {
    background: var(--primary-soft);
    border: 1px solid rgba(66, 133, 244, 0.25);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 13px 16px;
    font-size: 0.83rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.6;
}

.info-box strong { color: var(--text); }
.info-box em { color: var(--primary); font-style: normal; font-weight: 600; }
.info-box a { color: var(--primary); }

/* ---------- Report Panel / Current Task ---------- */
.report-panel { margin: 22px 0; }

.current-task {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 18px;
    min-height: 120px;
}

.task-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 28px 16px;
}

.task-active .task-row { margin-bottom: 16px; }
.task-active .task-row:last-child { margin-bottom: 0; }

.task-label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 5px;
}

.task-value {
    font-size: 0.95rem;
    word-break: break-all;
}

.email-highlight { color: var(--warning); font-weight: 650; }

.url-highlight {
    color: var(--primary);
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.86rem;
}

.progress-bar {
    height: 9px;
    background: var(--surface-3);
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-top: 2px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: var(--radius-pill);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.paused-banner {
    background: var(--warning-soft);
    border: 1px solid rgba(245, 185, 66, 0.35);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    margin-bottom: 16px;
    color: var(--warning);
    font-size: 0.86rem;
    font-weight: 500;
    text-align: center;
}

/* ---------- Tabs ---------- */
.tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.tabs {
    display: flex;
    gap: 4px;
}

.tab {
    padding: 11px 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 500;
    font-family: inherit;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.18s ease;
}

.tab:hover { color: var(--text); }

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 6px;
}

.tab-count {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.tab-panel { display: none; animation: fadeIn 0.25s ease; }
.tab-panel.active { display: block; }

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

/* ---------- Tables ---------- */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th, td {
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-soft);
}

thead th {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-soft);
    position: sticky;
    top: 0;
}

tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

td.url-cell {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 11px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
    border: 1px solid transparent;
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-pending { background: var(--warning-soft); color: var(--warning); border-color: rgba(245, 185, 66, 0.3); }
.badge-processing { background: var(--primary-soft); color: var(--primary); border-color: rgba(66, 133, 244, 0.3); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: rgba(52, 210, 126, 0.3); }
.badge-failed { background: var(--danger-soft); color: var(--danger); border-color: rgba(240, 88, 75, 0.3); }

.empty-state {
    text-align: center;
    padding: 36px 16px;
    color: var(--text-dim);
    font-size: 0.88rem;
}

/* ---------- Toasts ---------- */
.toast-container {
    position: fixed;
    top: 22px;
    right: 22px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 13px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.86rem;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: slideIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    max-width: 360px;
    border: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.toast-success { background: rgba(52, 210, 126, 0.95); color: #06210f; border-color: transparent; }
.toast-error { background: rgba(240, 88, 75, 0.95); color: #2a0805; border-color: transparent; }
.toast-info { background: var(--surface-2); color: var(--text); }

@keyframes slideIn {
    from { transform: translateX(110%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ---------- Spinner ---------- */
.spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ---------- Session cell ---------- */
.session-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(5, 8, 13, 0.72);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.18s ease;
}

.modal-overlay[hidden] { display: none; }

.modal {
    width: 100%;
    max-width: 560px;
    background: linear-gradient(180deg, var(--surface), var(--bg-soft));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    padding: 22px;
    animation: modalIn 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.modal-head h3 {
    font-size: 1.02rem;
    font-weight: 650;
    line-height: 1.3;
}

.modal-email { color: var(--warning); word-break: break-all; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 6px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

.modal-help {
    background: var(--primary-soft);
    border: 1px solid rgba(66, 133, 244, 0.22);
    border-radius: var(--radius-sm);
    padding: 13px 16px;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 14px;
    line-height: 1.6;
}

.modal-help ol {
    margin: 8px 0 8px 18px;
    padding: 0;
}
.modal-help li { margin-bottom: 4px; }
.modal-help strong { color: var(--text); }
.modal-help a { color: var(--primary); }
.modal-help code {
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
}

.modal-warn {
    display: block;
    margin-top: 8px;
    color: var(--warning);
    font-size: 0.78rem;
}

.modal textarea {
    margin-bottom: 16px;
    min-height: 110px;
    font-size: 0.78rem;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.modal-spacer { flex: 1; }

/* ---------- Footer ---------- */
.app-footer {
    margin-top: 36px;
    padding-top: 22px;
    border-top: 1px solid var(--border-soft);
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    .container { padding: 20px 16px 48px; }
    .stat-card .value { font-size: 1.45rem; }
    .btn-group .btn { flex: 1; }
}
