/* ============================================
   Modern SaaS Dark Theme
   ============================================ */

:root {
    /* Primary palette */
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-muted: rgba(99, 102, 241, 0.15);

    /* Semantic colors */
    --success: #10b981;
    --success-muted: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-muted: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-hover: #f87171;
    --danger-muted: rgba(239, 68, 68, 0.15);

    /* Neutrals - refined dark palette */
    --bg-base: #0a0a0f;
    --bg-surface: #12121a;
    --bg-elevated: #1a1a24;
    --bg-hover: #22222e;

    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);

    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;
}

html {
    scroll-behavior: smooth;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-base);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   HEADER - Modern Glassmorphism Style
   ============================================ */

header {
    background: rgba(18, 18, 26, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
    padding: 0 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.025em;
}

.logo::before {
    content: '';
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.125rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.nav-links a:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 0.375rem;
    flex-shrink: 0;
}

.nav-logout {
    color: var(--text-muted) !important;
    font-size: 0.75rem !important;
}

.nav-logout:hover {
    background: var(--danger-muted) !important;
    color: var(--danger) !important;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

main {
    flex: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

/* ============================================
   PAGE HEADER
   ============================================ */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ============================================
   BUTTONS - Clean, Modern Style
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
}

.btn-sm,
.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

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

.btn-full {
    width: 100%;
}

/* Ghost buttons for cards */
.btn-edit {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-edit:hover {
    background: var(--primary-muted);
    color: var(--primary-hover);
    border-color: var(--primary);
}

.btn-warning {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-warning:hover {
    background: var(--warning-muted);
    color: var(--warning);
    border-color: var(--warning);
}

.btn-delete {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-delete:hover {
    background: var(--danger-muted);
    color: var(--danger-hover);
    border-color: var(--danger);
}

/* Preserve link button colors */
a.btn, a.btn:visited, a.btn:link { color: inherit; }
a.btn-primary, a.btn-primary:visited { color: white; }
a.btn-secondary, a.btn-secondary:visited { color: var(--text-secondary); }

/* ============================================
   ACCOUNTS GRID - Modern Card Design
   ============================================ */

.accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 0.75rem;
}

.account-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.625rem 0.875rem;
    transition: all 0.2s ease;
}

.account-card:hover {
    background: var(--bg-elevated);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.account-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

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

.account-label {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
    cursor: help;
}

.type-model-login {
    background: #e8f4fd;
    color: #2980b9;
}

.account-extracted {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.account-extracted-none {
    color: var(--danger);
}

.account-extracted-error {
    color: var(--warning);
    cursor: help;
}

/* ============================================
   STATUS BADGES - Clean Pill Design
   ============================================ */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    cursor: help;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-badge .status-icon {
    font-size: 0.75rem;
    line-height: 1;
}

.status-valid {
    background: var(--success-muted);
    color: var(--success);
}

.status-expiring {
    background: var(--warning-muted);
    color: var(--warning);
}

.status-expired {
    background: var(--danger-muted);
    color: var(--danger);
}

.status-missing {
    background: rgba(113, 113, 122, 0.15);
    color: var(--text-muted);
}

.status-error {
    background: var(--warning-muted);
    color: var(--warning);
}

/* Extraction State Badges */
.extraction-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.625rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    cursor: help;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.extraction-none { display: none; }
/* Active states — pulsing to show something is happening right now */
.extraction-active { background: rgba(59, 130, 246, 0.15); color: #3b82f6; animation: pulse-badge 2s infinite; }
.extraction-captcha { background: rgba(249, 115, 22, 0.15); color: #f97316; animation: pulse-badge 2s infinite; }
.extraction-2fa { background: rgba(168, 85, 247, 0.15); color: #a855f7; animation: pulse-badge 2s infinite; }
.extraction-rotating { background: rgba(234, 179, 8, 0.15); color: #eab308; animation: pulse-badge 2s infinite; }
/* Terminal states — persistent, no pulse */
.extraction-success { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.extraction-captcha-done { background: rgba(249, 115, 22, 0.10); color: #fb923c; }
.extraction-2fa-done { background: rgba(168, 85, 247, 0.10); color: #c084fc; }
.extraction-failed { background: var(--danger-muted); color: var(--danger); }
@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Card Actions */
.account-actions {
    display: flex;
    gap: 0.375rem;
    align-items: center;
    flex-basis: 100%;
    justify-content: flex-end;
}

.account-actions .inline-form {
    margin: 0;
    display: flex;
}

.account-actions .btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
}

/* ============================================
   SEARCH & FILTERS
   ============================================ */

.search-box input,
.status-filter {
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.search-box input {
    width: 180px;
}

.search-box input:focus,
.status-filter:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* ============================================
   FORMS - Clean Input Design
   ============================================ */

.account-form {
    max-width: 540px;
    background: var(--bg-surface);
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-base);
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group small {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.input-readonly {
    background: var(--bg-elevated);
    cursor: not-allowed;
    opacity: 0.7;
}

.form-fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    background: rgba(0, 0, 0, 0.2);
}

.form-fieldset legend {
    padding: 0 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

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

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}

/* ============================================
   TABLES
   ============================================ */

.accounts-table,
.users-table {
    width: 100%;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    border-collapse: collapse;
    overflow: hidden;
}

.accounts-table th,
.accounts-table td,
.users-table th,
.users-table td {
    padding: 0.875rem 1rem;
    text-align: left;
}

.accounts-table th,
.users-table th {
    background: var(--bg-elevated);
    font-weight: 500;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.accounts-table tbody tr,
.users-table tbody tr {
    border-top: 1px solid var(--border);
    transition: background 0.15s ease;
}

.accounts-table tbody tr:hover,
.users-table tbody tr:hover {
    background: var(--bg-hover);
}

.users-table-container {
    overflow-x: auto;
}

.actions-cell {
    display: flex;
    gap: 0.375rem;
    white-space: nowrap;
}

.inline-form {
    display: inline;
}

/* ============================================
   BADGES
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.1875rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-admin {
    background: var(--danger-muted);
    color: var(--danger-hover);
}

.badge-viewer {
    background: var(--primary-muted);
    color: var(--primary-hover);
}

.badge-current {
    background: var(--success-muted);
    color: var(--success);
    margin-left: 0.375rem;
}

.badge-info {
    background: var(--primary-muted);
    color: var(--primary-hover);
}

.badge-secondary {
    background: rgba(113, 113, 122, 0.15);
    color: var(--text-muted);
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    animation: slideIn 0.3s ease;
}

.alert.fade-out {
    animation: fadeOut 0.4s ease forwards;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-8px); }
}

.alert-success {
    background: var(--success-muted);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.alert-error {
    background: var(--danger-muted);
    color: var(--danger-hover);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.alert-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.125rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s;
    padding: 0.25rem;
}

.alert-close:hover {
    opacity: 1;
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-body {
    background: var(--bg-base);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-container {
    width: 100%;
    max-width: 380px;
}

.login-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.login-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.login-icon svg {
    width: 28px;
    height: 28px;
    color: white;
}

.login-header h1 {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
    letter-spacing: -0.025em;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-card .alert {
    margin-bottom: 1.25rem;
}

.setup-notice {
    text-align: center;
    margin-top: 1.25rem;
    padding: 0.875rem;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.setup-notice p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

.setup-notice a {
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
}

.setup-notice a:hover {
    text-decoration: underline;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.375rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    transition: color 0.15s;
    padding: 0.25rem;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-info {
    margin-bottom: 0.875rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.modal-info.small {
    font-size: 0.8125rem;
}

.csv-format {
    display: block;
    padding: 0.625rem 0.75rem;
    background: var(--bg-base);
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-family: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
    margin-bottom: 0.875rem;
    word-break: break-all;
    white-space: pre-wrap;
    color: var(--primary-hover);
    border: 1px solid var(--border);
}

.template-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.template-link:hover {
    text-decoration: underline;
}

.import-form .form-group {
    margin-bottom: 0.875rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.checkbox-group label {
    margin-bottom: 0;
    font-weight: normal;
    font-size: 0.875rem;
}

input[type="file"] {
    width: 100%;
    padding: 0.625rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--bg-base);
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: border-color 0.15s;
}

input[type="file"]:hover {
    border-color: var(--primary);
}

/* ============================================
   LOADING OVERLAY
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 15, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(8px);
}

.loading-content {
    text-align: center;
    color: var(--text-primary);
}

.loading-content h2 {
    margin: 1.25rem 0 0.375rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.loading-content p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.375rem;
}

.loading-status {
    color: var(--primary);
    font-weight: 500;
    margin-top: 0.75rem;
    font-size: 0.875rem;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

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

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 3.5rem 2rem;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.empty-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

/* ============================================
   MISC
   ============================================ */

code {
    font-family: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
    font-size: 0.8125rem;
    background: var(--bg-elevated);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    color: var(--primary-hover);
}

.table-footer {
    margin-top: 0.875rem;
    text-align: right;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.text-muted {
    color: var(--text-muted);
}

/* Account info card */
.account-info-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border);
}

.account-info-row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.account-info-row .label {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.account-info-row .value {
    font-weight: 600;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.875rem;
    color: var(--text-primary);
}

/* ============================================
   PROXY POOL
   ============================================ */

.proxy-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

.stat-available .stat-value { color: var(--success); }
.stat-assigned .stat-value { color: var(--primary-hover); }
.stat-failed .stat-value { color: var(--danger); }

.proxy-table-container {
    overflow-x: auto;
}

.proxy-table {
    width: 100%;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    border-collapse: collapse;
    overflow: hidden;
}

.proxy-table th,
.proxy-table td {
    padding: 0.875rem 1rem;
    text-align: left;
}

.proxy-table th {
    background: var(--bg-elevated);
    font-weight: 500;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.proxy-table tbody tr {
    border-top: 1px solid var(--border);
    transition: background 0.15s ease;
}

.proxy-table tbody tr:hover {
    background: var(--bg-hover);
}

.proxy-address {
    font-family: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
    font-size: 0.875rem;
    font-weight: 500;
}

.proxy-label {
    font-family: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
    font-size: 0.8125rem;
    color: var(--primary-hover);
}

.fail-count {
    color: var(--danger);
    font-weight: 600;
}

.status-proxy-available {
    background: var(--success-muted);
    color: var(--success);
}

.status-proxy-assigned {
    background: var(--primary-muted);
    color: var(--primary-hover);
}

.status-proxy-failed {
    background: var(--danger-muted);
    color: var(--danger);
}

.proxy-form .form-group {
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .proxy-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   SETTINGS PAGE
   ============================================ */

.service-control-card {
    max-width: 640px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.service-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.status-running {
    background: var(--success-muted);
    color: var(--success);
}

.status-stopped {
    background: var(--danger-muted);
    color: var(--danger);
}

.inline-form {
    display: inline;
    margin: 0;
}

.settings-form {
    max-width: 640px;
}

.settings-form .form-fieldset {
    margin-bottom: 1.5rem;
}

.restart-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    background: var(--warning-muted);
    color: var(--warning);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.setting-description {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* ============================================
   GUIDE PAGE
   ============================================ */

/* Hero */
.guide-hero {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(168, 85, 247, 0.08) 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-lg);
    padding: 2rem 2.25rem;
    margin-bottom: 2rem;
}

.guide-hero-content {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.guide-hero-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 0 24px rgba(99, 102, 241, 0.3);
}

.guide-hero h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.guide-hero p {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin: 0;
}

/* Layout: sidebar + main */
.guide-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 2rem;
    align-items: start;
}

/* Sidebar nav */
.guide-sidebar {
    position: sticky;
    top: 80px;
}

.guide-nav {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.guide-nav-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0 0.625rem;
    margin-bottom: 0.5rem;
}

.guide-nav-link {
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-sm);
    border-left: 2px solid transparent;
    transition: all 0.15s ease;
    line-height: 1.3;
}

.guide-nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.guide-nav-link.active {
    color: var(--primary-hover);
    border-left-color: var(--primary);
    background: var(--primary-muted);
}

/* Main content */
.guide-main {
    min-width: 0;
}

/* Sections */
.guide-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.25rem;
}

.guide-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.guide-section-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.guide-icon-info      { background: var(--primary-muted); color: var(--primary-hover); }
.guide-icon-accounts  { background: var(--success-muted); color: var(--success); }
.guide-icon-status    { background: var(--warning-muted); color: var(--warning); }
.guide-icon-proxy     { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.guide-icon-csv       { background: rgba(6, 182, 212, 0.15); color: #06b6d4; }
.guide-icon-extraction{ background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.guide-icon-captcha   { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.guide-icon-live      { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.guide-icon-trouble   { background: var(--danger-muted); color: var(--danger); }

.guide-section-header h2 {
    font-size: 1.1875rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin: 0;
}

.guide-section h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 0.625rem;
}

.guide-section h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.guide-section p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.65;
    margin-bottom: 0.75rem;
}

/* Admin badge */
.guide-admin-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    background: var(--danger-muted);
    color: var(--danger-hover);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
    margin-left: 0.375rem;
}

/* Cards inside sections */
.guide-card {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 0.875rem;
}

.guide-card:last-child { margin-bottom: 0; }

.guide-card-compact { padding: 1rem; }

.guide-card-highlight {
    border-left: 3px solid;
}

.guide-card-highlight-orange { border-left-color: #f97316; }
.guide-card-highlight-purple { border-left-color: #a855f7; }

/* Two-column layout */
.guide-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.875rem;
    margin-bottom: 0.875rem;
}

/* Flow / pipeline visualization */
.guide-flow {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 1rem 0 1.25rem;
}

.guide-flow-step {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.guide-flow-num {
    width: 2rem;
    height: 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.guide-flow-text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.guide-flow-text strong {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.guide-flow-text span {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.guide-flow-arrow {
    display: flex;
    justify-content: center;
    padding: 0.25rem 0;
    color: var(--text-muted);
    opacity: 0.4;
}

/* Horizontal flow variant */
.guide-flow-horizontal {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.625rem;
    margin: 1.25rem 0;
}

.guide-flow-horizontal .guide-flow-step {
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
    padding: 1.25rem 0.75rem;
}

.guide-flow-horizontal .guide-flow-text {
    align-items: center;
}

.guide-flow-horizontal .guide-flow-arrow { display: none; }

/* Numbered steps (simpler version) */
.guide-steps {
    list-style: none;
    counter-reset: step;
    padding: 0;
    margin: 0.25rem 0 0.75rem;
}

.guide-steps li {
    counter-increment: step;
    padding: 0.5rem 0 0.5rem 2rem;
    position: relative;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    line-height: 1.55;
}

.guide-steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 1.375rem;
    height: 1.375rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 50%;
    font-size: 0.625rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Bullet list */
.guide-list {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0.75rem;
}

.guide-list li {
    padding: 0.375rem 0 0.375rem 1rem;
    position: relative;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    line-height: 1.55;
}

.guide-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.6875rem;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-muted);
}

/* Callouts */
.guide-callout {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.125rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    line-height: 1.55;
    margin: 0.875rem 0;
    color: var(--text-secondary);
}

.guide-callout-sm {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    margin: 0.625rem 0 0;
}

.guide-callout-icon {
    flex-shrink: 0;
    margin-top: 0.0625rem;
}

.guide-callout-info {
    background: var(--primary-muted);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.guide-callout-info .guide-callout-icon { color: var(--primary-hover); }

.guide-callout-success {
    background: var(--success-muted);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.guide-callout-success .guide-callout-icon { color: var(--success); }

.guide-callout-warning {
    background: var(--warning-muted);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: var(--text-secondary);
}

.guide-callout-warning .guide-callout-icon { color: var(--warning); }

/* Badge list (status explainer) */
.guide-badge-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.5rem 0 1rem;
}

.guide-badge-list-compact { margin: 0; }

.guide-badge-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-base);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.guide-badge-row .status-badge,
.guide-badge-row .extraction-badge {
    flex-shrink: 0;
    min-width: 6.5rem;
    justify-content: center;
}

.guide-badge-desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* FAQ accordion */
.guide-faq {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.guide-faq-item {
    background: var(--bg-base);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.guide-faq-item[open] {
    border-color: var(--border-hover);
}

.guide-faq-item summary {
    padding: 0.875rem 1.125rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.15s ease;
    user-select: none;
}

.guide-faq-item summary::-webkit-details-marker { display: none; }

.guide-faq-item summary::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid var(--text-muted);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.guide-faq-item[open] summary::before {
    transform: rotate(90deg);
}

.guide-faq-item summary:hover {
    background: var(--bg-hover);
}

.guide-faq-body {
    padding: 0 1.125rem 1rem 2rem;
}

.guide-faq-body p {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Hint text */
.guide-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Link style */
.guide-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.guide-link:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 900px) {
    .guide-layout {
        grid-template-columns: 1fr;
    }

    .guide-sidebar {
        position: static;
        margin-bottom: 0.5rem;
    }

    .guide-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.25rem;
        padding: 0.75rem;
        background: var(--bg-surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
    }

    .guide-nav-label { display: none; }

    .guide-nav-link {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
        border-left: none;
        border-radius: var(--radius-full);
        background: var(--bg-elevated);
    }

    .guide-nav-link.active {
        border-left: none;
        background: var(--primary-muted);
    }

    .guide-columns {
        grid-template-columns: 1fr;
    }

    .guide-flow-horizontal {
        grid-template-columns: 1fr;
    }

    .guide-hero {
        padding: 1.5rem;
    }

    .guide-hero-icon {
        width: 44px;
        height: 44px;
    }

    .guide-hero-icon svg {
        width: 24px;
        height: 24px;
    }

    .guide-section {
        padding: 1.25rem;
    }
}

/* Footer */
footer {
    text-align: center;
    padding: 1.25rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    border-top: 1px solid var(--border);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    nav {
        padding: 0 1rem;
        height: auto;
        flex-wrap: wrap;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
        gap: 0.5rem;
    }

    .nav-links {
        gap: 0;
        flex-wrap: wrap;
    }

    .nav-links a {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }

    .nav-divider {
        display: none;
    }

    main {
        padding: 1.5rem 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn {
        flex: 1;
        min-width: 100px;
    }

    .accounts-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .empty-actions {
        flex-direction: column;
    }

    .search-box input {
        width: 140px;
    }
}
