/* ===================================================
   Admin Page — Login Sessions Table Styles
   =================================================== */

.admin-page-body {
    padding: 1.5rem 2rem;
    max-width: 100%;
    margin: 0;
}

/* --- Toolbar (search + info) --- */
.admin-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    margin-bottom: 1.25rem;
    padding: 0 2rem;
}

.admin-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-search-wrap {
    position: relative;
    min-width: 220px;
    max-width: 360px;
}

.admin-search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary, #888);
    pointer-events: none;
}

.admin-search {
    width: 100%;
    padding: 0.55rem 0.85rem 0.55rem 2.5rem;
    border: 1px solid var(--border-color, #333);
    border-radius: 0.5rem;
    background: var(--bg-secondary, #1a1a2e);
    color: var(--text-primary, #e0e0e0);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.admin-search:focus {
    border-color: var(--accent, #6c63ff);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

.admin-pagination-info {
    font-size: 0.82rem;
    color: var(--text-secondary, #888);
    white-space: nowrap;
}

/* --- Table --- */
.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-color, #333);
    border-radius: 0.6rem;
    background: var(--bg-secondary, #1a1a2e);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    table-layout: fixed;
}

.admin-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-tertiary, #16213e);
    color: var(--text-secondary, #aaa);
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border-color, #333);
    white-space: nowrap;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Column widths */
.admin-table thead th:nth-child(1) { width: 30%; }
.admin-table thead th:nth-child(2) { width: 30%; }
.admin-table thead th:nth-child(3) { width: 18%; }
.admin-table thead th:nth-child(4) { width: 22%; }

/* Leads table */
#leads-table {
    table-layout: auto;
    width: 80%;
}

#leads-table th,
#leads-table td {
    white-space: nowrap;
    padding: 0.75rem 1rem;
}

#leads-table th:nth-child(6),
#leads-table td:nth-child(6) {
    white-space: normal;
    min-width: 100px;
}

/* Leads toolbar alignment */
#admin-panel-leads .admin-toolbar {
    justify-content: flex-start;
}

#admin-panel-leads .admin-count {
    margin-left: auto;
}

.leads-note-cell {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#leads-table tbody tr:hover {
    background: var(--bg-hover, rgba(108, 99, 255, 0.08));
}

.admin-session-row {
    transition: background 0.15s;
}

.admin-session-row:hover {
    background: var(--bg-hover, rgba(108, 99, 255, 0.08));
}

.admin-session-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}
.admin-session-row:nth-child(even):hover {
    background: var(--bg-hover, rgba(108, 99, 255, 0.08));
}

.admin-cell {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-color, #222);
    color: var(--text-primary, #e0e0e0);
    vertical-align: middle;
}

.admin-cell-email {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-cell-time {
    white-space: nowrap;
    color: var(--text-secondary, #aaa);
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
}

.admin-cell-ip {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.84rem;
    color: var(--text-secondary, #aaa);
}

.admin-cell-ua {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-tertiary, #666);
    font-size: 0.84rem;
}

/* --- Load More --- */
.admin-load-more-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding: 0.75rem;
}

.admin-load-more-btn {
    padding: 0.55rem 2rem;
    border: 1px solid var(--border-color, #333);
    border-radius: 0.5rem;
    background: var(--bg-secondary, #1a1a2e);
    color: var(--text-primary, #e0e0e0);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.admin-load-more-btn:hover:not(:disabled) {
    background: var(--bg-hover, rgba(108, 99, 255, 0.1));
    border-color: var(--accent, #6c63ff);
    transform: translateY(-1px);
}

.admin-load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Empty row --- */
.admin-empty-row td {
    border-bottom: none;
}

/* ===================================================
   Admin Tabs
   =================================================== */
.admin-tabs {
    display: flex;
    gap: 0;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border-color, #333);
    flex-shrink: 0;
}

.admin-tab {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.75rem 1.25rem;
    border: none;
    background: none;
    color: var(--text-secondary, #888);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.admin-tab:hover {
    color: var(--text-primary, #e0e0e0);
}

.admin-tab.active {
    color: var(--accent, #6c63ff);
    border-bottom-color: var(--accent, #6c63ff);
}

.admin-tab svg {
    flex-shrink: 0;
}

/* --- Tab Panels --- */
.admin-tab-panel {
    display: none;
    flex-direction: column;
    min-height: 0;
}

.admin-tab-panel.active {
    display: flex;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ===================================================
   Sample Reports Grid
   =================================================== */
.admin-reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.admin-report-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.25rem;
    border: 1px solid var(--border-color, #333);
    border-radius: 0.65rem;
    background: var(--bg-secondary, #1a1a2e);
    text-decoration: none;
    color: var(--text-primary, #e0e0e0);
    transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.admin-report-card:hover {
    border-color: var(--accent, #6c63ff);
    background: var(--bg-hover, rgba(108, 99, 255, 0.06));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.admin-report-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: rgba(108, 99, 255, 0.1);
    color: var(--accent, #6c63ff);
}

.admin-report-icon svg {
    width: 22px;
    height: 22px;
}

.admin-report-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.admin-report-title {
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-report-meta {
    font-size: 0.78rem;
    color: var(--text-secondary, #888);
}

.admin-report-arrow {
    flex-shrink: 0;
    color: var(--text-tertiary, #555);
    transition: color 0.2s, transform 0.2s;
}

.admin-report-card:hover .admin-report-arrow {
    color: var(--accent, #6c63ff);
    transform: translateX(3px);
}

.admin-reports-loading,
.admin-reports-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-secondary, #888);
    font-size: 0.9rem;
}

/* ===================================================
   Add Report Button
   =================================================== */
.admin-add-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border: 1px solid var(--accent, #6c63ff);
    border-radius: 0.5rem;
    background: rgba(108, 99, 255, 0.1);
    color: var(--accent, #6c63ff);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, transform 0.1s;
}
.admin-add-btn:hover {
    background: rgba(108, 99, 255, 0.2);
    transform: translateY(-1px);
}

/* ===================================================
   Modal Overlay + Dialog
   =================================================== */
.admin-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.admin-modal {
    width: 100%;
    max-width: 520px;
    background: var(--bg-primary, #0f0f23);
    border: 1px solid var(--border-color, #333);
    border-radius: 0.85rem;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #333);
}

.admin-modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary, #e0e0e0);
}

.admin-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary, #888);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.35rem;
    transition: color 0.2s, background 0.2s;
}
.admin-modal-close:hover {
    color: var(--text-primary, #e0e0e0);
    background: rgba(255, 255, 255, 0.06);
}

/* ===================================================
   Form inside Modal
   =================================================== */
#admin-report-form {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.admin-form-row label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary, #aaa);
    margin-bottom: 0.3rem;
}

.admin-form-row label .required {
    color: var(--danger, #ef4444);
}

.admin-form-row input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border-color, #333);
    border-radius: 0.45rem;
    background: var(--bg-secondary, #1a1a2e);
    color: var(--text-primary, #e0e0e0);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.admin-form-row input:focus {
    border-color: var(--accent, #6c63ff);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

.admin-form-row input::placeholder {
    color: var(--text-tertiary, #555);
}

.admin-form-row-half {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.admin-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    margin-top: 0.3rem;
}

.admin-form-cancel {
    padding: 0.55rem 1.2rem;
    border: 1px solid var(--border-color, #333);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-secondary, #aaa);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.admin-form-cancel:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary, #e0e0e0);
}

.admin-form-submit {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    border: none;
    border-radius: 0.5rem;
    background: var(--accent, #6c63ff);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}
.admin-form-submit:hover { opacity: 0.88; }
.admin-form-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.admin-form-error {
    color: var(--danger, #ef4444);
    font-size: 0.82rem;
    margin: 0;
    text-align: center;
}

/* ── Test Runner ─────────────────────────────── */

.test-sub-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
    padding: 0 1rem;
    background: var(--bg-secondary, rgba(255,255,255,0.02));
}

.test-sub-tab {
    padding: 0.6rem 1.25rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.test-sub-tab:hover {
    color: var(--text-primary, #e2e8f0);
}
.test-sub-tab.active {
    color: var(--accent, #f97316);
    border-bottom-color: var(--accent, #f97316);
}

.test-sub-panel {
    display: none;
}
.test-sub-panel.active {
    display: block;
}

.test-summary {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
}
.test-tz-select {
    background: var(--bg-tertiary, rgba(255,255,255,0.06));
    color: var(--text-primary, #e2e8f0);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
}
.test-tz-select:focus { border-color: var(--accent-primary, #6366f1); }
.test-summary-passed { color: #22c55e; }
.test-summary-failed { color: #ef4444; }
.test-summary-skipped { color: #f59e0b; }
.test-summary-total { color: var(--text-secondary, #94a3b8); }
.test-summary-time { color: var(--text-secondary, #94a3b8); font-weight: 400; }

.test-summary-id {
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    background: var(--bg-tertiary, rgba(255,255,255,0.04));
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    cursor: default;
}

.test-cases-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.test-category {
    margin-bottom: 0.75rem;
}

.test-category-header {
    cursor: pointer;
    user-select: none;
}

.test-category-header .toggle-icon {
    transition: transform 0.2s;
    font-size: 0.7rem;
    margin-right: 0.25rem;
}

.test-category.collapsed .test-category-header .toggle-icon {
    transform: rotate(-90deg);
}

.test-category.collapsed .test-case-row {
    display: none;
}

.test-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(59, 130, 246, 0.08));
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    margin-bottom: 0.35rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #c4b5fd;
}

.test-category:first-child .test-category-header {
    margin-top: 0;
}

.test-cat-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.test-cat-count {
    font-weight: 400;
    font-size: 0.75rem;
}

.test-play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}
.test-play-btn:hover {
    background: rgba(59, 130, 246, 0.3);
    transform: scale(1.1);
}
.test-play-btn:active { transform: scale(0.95); }

.test-case-row {
    display: grid;
    grid-template-columns: 28px 26px 1fr auto auto;
    gap: 0.5rem;
    align-items: start;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    transition: background 0.15s;
}
.test-case-row:hover {
    background: var(--bg-tertiary, rgba(255,255,255,0.04));
}

.test-check {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.test-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.test-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary, #e2e8f0);
}

.test-desc {
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    line-height: 1.4;
}

.test-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 2px 0;
}

.test-meta-tag {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.test-meta-model {
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.35);
}

.test-meta-mode {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.test-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-top: 3px;
}

.test-step {
    font-size: 0.67rem;
    color: var(--gray-500, #6b7280);
    white-space: nowrap;
}

.test-status {
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 56px;
    text-align: center;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    background: var(--bg-tertiary, rgba(255,255,255,0.04));
    color: var(--text-secondary, #94a3b8);
}
.test-status.test-pass {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}
.test-status.test-fail {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}
.test-status.test-running {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    animation: test-pulse 1s ease-in-out infinite;
}
.test-status.test-skip {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

@keyframes test-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.test-detail {
    font-size: 0.72rem;
    color: var(--text-secondary, #94a3b8);
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.test-row-pass { border-left: 3px solid #22c55e; }
.test-row-fail { border-left: 3px solid #ef4444; }
.test-row-running { border-left: 3px solid #3b82f6; }

.test-log {
    margin-top: 1rem;
    background: var(--bg-primary, #0f172a);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 8px;
    padding: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.75rem;
    line-height: 1.6;
}

.test-log-line {
    color: var(--text-secondary, #94a3b8);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ── Test History ──────────────────────────── */

.test-history {
    margin-top: 1.25rem;
}

.test-hist-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #94a3b8);
    margin-bottom: 0.5rem;
}

.test-hist-row {
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.15s;
}
.test-hist-row:hover {
    background: var(--bg-tertiary, rgba(255,255,255,0.04));
}

.test-hist-env {
    min-width: 60px;
    font-size: 0.75rem;
}

.test-hist-time {
    color: var(--text-secondary, #94a3b8);
    min-width: 150px;
    font-size: 0.75rem;
}

.test-hist-user {
    color: var(--text-secondary, #94a3b8);
    min-width: 140px;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.test-hist-empty {
    color: var(--text-secondary, #94a3b8);
    font-size: 0.8rem;
    padding: 0.5rem 0;
}

/* ── Test Results Table ───────────────────── */

.test-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.test-results-table th,
.test-results-table td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    white-space: nowrap;
}
.test-results-table th {
    color: var(--text-secondary, #94a3b8);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
}
.test-results-table td {
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.04));
    color: var(--text-primary, #e2e8f0);
}
.test-results-table tbody tr:hover td {
    background: var(--bg-tertiary, rgba(255,255,255,0.04));
}

.test-hist-expand-cell {
    width: 24px;
    text-align: center;
    padding-left: 0.5rem;
    padding-right: 0;
}

.test-hist-id {
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.test-hist-detail-row td {
    padding: 0 !important;
    background: var(--bg-primary, #0f172a);
}

.test-hist-detail-content {
    padding: 0.75rem 1rem;
}

.test-hist-details {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.test-hist-detail-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.3rem 0;
}

/* Clickable summary row */
.test-hist-row {
    cursor: pointer;
}
.test-hist-row:hover td {
    background: var(--bg-tertiary, rgba(255,255,255,0.06));
}

/* Run info block inside expanded row */
.test-hist-run-info {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1rem;
    padding: 0.5rem 0 0.75rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
    font-size: 0.8rem;
}
.test-hist-info-row {
    display: contents;
}
.test-hist-info-label {
    color: var(--text-secondary, #94a3b8);
    font-weight: 600;
    white-space: nowrap;
}
.test-hist-info-value {
    color: var(--text-primary, #e2e8f0);
    word-break: break-all;
}
.test-hist-info-value a {
    color: var(--accent-primary, #38bdf8);
    text-decoration: none;
}
.test-hist-info-value a:hover {
    text-decoration: underline;
}

/* Report link per test */
.test-report-link {
    color: var(--accent-primary, #38bdf8);
    text-decoration: none;
    font-size: 0.78rem;
    white-space: nowrap;
}
.test-report-link:hover {
    text-decoration: underline;
}

/* Expand arrow span (no longer a button) */
.test-hist-expand {
    background: none;
    border: none;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.9rem;
    padding: 0.2rem 0.4rem;
    transition: color 0.15s;
}
.test-hist-row:hover .test-hist-expand {
    color: var(--text-primary, #e2e8f0);
}

/* ══════════════════════════════════════════════
   User Access Management
   ══════════════════════════════════════════════ */

.users-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.users-modal-content {
    background: var(--bg-secondary, #1e1e2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 12px;
    padding: 1.5rem;
    width: 100%;
    max-width: 480px;
}
.users-modal-content h3 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    color: var(--text-primary, #e2e8f0);
}
.users-form-group {
    margin-bottom: 0.75rem;
}
.users-form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary, #94a3b8);
    margin-bottom: 0.25rem;
}
.users-form-group input,
.users-form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary, rgba(255,255,255,0.06));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 6px;
    color: var(--text-primary, #e2e8f0);
    font-size: 0.85rem;
}
.users-form-group input:focus,
.users-form-group select:focus {
    outline: none;
    border-color: var(--accent-primary, #6366f1);
}
.users-modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}
.users-btn-secondary {
    background: transparent !important;
    border: 1px solid var(--border-color, rgba(255,255,255,0.15)) !important;
}

.users-type-badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}
.users-type-email {
    background: rgba(99,102,241,0.15);
    color: #818cf8;
}
.users-type-domain {
    background: rgba(34,197,94,0.15);
    color: #4ade80;
}
.users-access-allow {
    color: #22c55e;
    font-weight: 500;
}
.users-access-deny {
    color: #ef4444;
    font-weight: 500;
}
.users-value-cell {
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.82rem;
}
.users-note-cell {
    color: var(--text-secondary, #94a3b8);
    font-size: 0.8rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.users-disable-btn {
    background: transparent;
    border: 1px solid var(--text-secondary, #64748b);
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    transition: all 0.15s;
    white-space: nowrap;
}
.users-disable-btn:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239,68,68,0.1);
}
.users-enable-btn {
    border-color: #4ade80;
    color: #4ade80;
}
.users-enable-btn:hover {
    color: #22c55e;
    border-color: #22c55e;
    background: rgba(34,197,94,0.1);
}
.users-loading {
    text-align: center;
    color: var(--text-secondary, #94a3b8);
    padding: 2rem !important;
}

/* User Management — form half-row & status badges */
.users-form-row-half {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.users-status-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
}
.users-status-active {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}
.users-status-warning {
    background: rgba(234, 179, 8, 0.15);
    color: #facc15;
}
.users-status-expired {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}
.users-status-disabled {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
}

.users-consumed-cell {
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

#users-table {
    table-layout: fixed;
    width: 100%;
}
#users-table th:nth-child(1) { width: 22%; }  /* Email */
#users-table th:nth-child(2) { width: 10%; }  /* First Name */
#users-table th:nth-child(3) { width: 10%; }  /* Last Name */
#users-table th:nth-child(4) { width: 10%; }  /* Daily Cap */
#users-table th:nth-child(5) { width: 14%; }  /* Total Consumed */
#users-table th:nth-child(6) { width: 12%; }  /* Active Until */
#users-table th:nth-child(7) { width: 8%; }   /* Status */
#users-table th:nth-child(8) { width: 14%; }  /* Actions */

.users-edit-btn {
    background: transparent;
    border: 1px solid var(--accent-color, #6c63ff);
    color: var(--accent-color, #6c63ff);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    transition: all 0.15s;
    white-space: nowrap;
}
.users-edit-btn:hover {
    background: rgba(108,99,255,0.15);
}

#admin-panel-users .admin-page-body {
    width: 85vw;
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem;
}
#users-table th,
#users-table td {
    padding: 0.7rem 0.85rem;
    white-space: nowrap;
}
#users-table tbody tr:hover {
    background: var(--bg-hover, rgba(108, 99, 255, 0.08));
}

/* ══════════════════════════════════════════════
   Sent Emails Tab
   ══════════════════════════════════════════════ */

#admin-panel-emails .admin-toolbar {
    justify-content: flex-start;
}
#admin-panel-emails .admin-count {
    margin-left: 0;
}

.emails-months-select {
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary, rgba(255,255,255,0.06));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 6px;
    color: var(--text-primary, #e2e8f0);
    font-size: 0.85rem;
    cursor: pointer;
}
.emails-months-select:focus {
    outline: none;
    border-color: var(--accent-primary, #6366f1);
}

#emails-table {
    table-layout: auto;
}
#emails-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary, #1a1a2e);
    z-index: 2;
    cursor: pointer;
    user-select: none;
}
#emails-table thead th:hover {
    color: var(--accent, #6c63ff);
}
#emails-table thead th .sort-arrow {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.7em;
    opacity: 0.4;
}
#emails-table thead th .sort-arrow.active {
    opacity: 1;
    color: var(--accent, #6c63ff);
}
#emails-table th,
#emails-table td {
    padding: 0.7rem 0.85rem;
    white-space: nowrap;
}
#emails-table tbody tr:hover {
    background: var(--bg-hover, rgba(108, 99, 255, 0.08));
}

.emails-cell-to {
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.emails-cell-subject {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.emails-cell-sender {
    color: var(--text-secondary, #94a3b8);
    font-size: 0.82rem;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.emails-cell-msgid {
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.78rem;
    color: var(--text-tertiary, #64748b);
}
.emails-cell-elapsed {
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.84rem;
}
.emails-cell-time {
    white-space: nowrap;
    color: var(--text-secondary, #aaa);
    font-variant-numeric: tabular-nums;
    font-size: 0.84rem;
}

.emails-status-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
}
.emails-status-ok {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}
.emails-status-fail {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    cursor: help;
}
.emails-status-other {
    background: rgba(234, 179, 8, 0.15);
    color: #facc15;
}

/* Email row clickable */
.emails-row {
    cursor: pointer;
    transition: background 0.15s;
}
.emails-row:hover {
    background: var(--bg-hover, rgba(108, 99, 255, 0.08));
}
.emails-row-selected {
    background: rgba(108, 99, 255, 0.12) !important;
}

/* ── Split layout: side panel + table ── */
.emails-split-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.emails-side-panel {
    width: 0;
    min-width: 0;
    border-left: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-secondary, #1a1a2e);
    transition: width 0.25s ease, min-width 0.25s ease, border-left 0.25s ease;
}

.emails-side-panel.open {
    width: 380px;
    min-width: 280px;
    border-left: 1px solid var(--border-color, #333);
    overflow-y: auto;
}

.emails-side-panel.resizing {
    transition: none;
}

/* Resize handle */
.emails-resize-handle {
    width: 5px;
    cursor: col-resize;
    background: transparent;
    position: relative;
    flex-shrink: 0;
    display: none;
    z-index: 10;
}
.emails-resize-handle::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 2px;
    width: 1px;
    background: var(--border-color, #333);
    transition: background 0.15s, width 0.15s;
}
.emails-resize-handle:hover::after,
.emails-resize-handle.dragging::after {
    width: 3px;
    left: 1px;
    background: var(--accent, #6c63ff);
}
.emails-side-panel.open ~ .emails-resize-handle,
.emails-resize-handle.visible {
    display: block;
}

/* Show handle when panel is open (handle is before panel in DOM, use JS) */

.emails-table-area {
    flex: 1;
    overflow: auto;
    min-width: 0;
}

.emails-side-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-tertiary, #64748b);
    gap: 0.75rem;
    padding: 2rem;
    text-align: center;
}
.emails-side-empty p {
    margin: 0;
    font-size: 0.85rem;
}

.emails-side-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.emails-side-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
}
.emails-side-header h3 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-primary, #e2e8f0);
    flex: 1;
    word-break: break-word;
    line-height: 1.4;
}
.emails-side-close {
    background: none;
    border: none;
    color: var(--text-secondary, #94a3b8);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}
.emails-side-close:hover {
    color: var(--text-primary, #e2e8f0);
    background: rgba(255,255,255,0.08);
}

.emails-side-meta {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
}
.emails-meta-row {
    display: flex;
    gap: 0.75rem;
    padding: 0.3rem 0;
    font-size: 0.82rem;
    align-items: baseline;
}
.emails-meta-label {
    color: var(--text-secondary, #94a3b8);
    font-weight: 600;
    min-width: 80px;
    flex-shrink: 0;
}
.emails-meta-value {
    color: var(--text-primary, #e2e8f0);
    word-break: break-all;
    min-width: 0;
}
.emails-meta-mono {
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.76rem;
}
.emails-meta-error {
    color: #f87171;
    background: rgba(239, 68, 68, 0.08);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.emails-side-preview-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0.75rem 1.25rem;
}
.emails-side-preview-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}
.emails-side-preview {
    flex: 1;
    overflow-y: auto;
    font-size: 0.82rem;
    color: var(--text-tertiary, #64748b);
}
.emails-preview-placeholder {
    text-align: center;
    padding: 2rem 1rem;
    line-height: 1.6;
}
.emails-preview-iframe {
    width: 100%;
    min-height: 300px;
    height: 100%;
    border: none;
    border-radius: 6px;
    background: #fff;
}