:root {
    --primary: #4f46e5;
    /* Indigo 600 */
    --primary-hover: #4338ca;
    /* Indigo 700 */
    --bg-body: #f3f4f6;
    /* Gray 100 */
    --bg-sidebar: #111827;
    /* Gray 900 */
    --text-sidebar: #d1d5db;
    /* Gray 300 */
    --text-sidebar-hover: #ffffff;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    /* Gray 800 */
    --text-muted: #6b7280;
    /* Gray 500 */
    --border-color: #e5e7eb;
    /* Gray 200 */
    --success-bg: #d1fae5;
    --success-text: #065f46;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --danger-bg: #fee2e2;
    --danger-text: #b91c1c;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 50;
    /* Ensure sidebar is below modal */
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--text-sidebar);
    text-decoration: none;
    border-radius: 6px;
    margin-bottom: 5px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-sidebar-hover);
}

.nav-items {
    margin-top: 10px;
}

/* Client Section in Sidebar */
.client-section {
    padding: 15px;
    background: #1f2937;
    border-radius: 8px;
    margin-top: auto;
    border: 1px solid #374151;
    margin-bottom: 20px;
}

.client-section .label {
    font-size: 0.7rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.client-selector select {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #374151;
    background-color: #111827;
    color: white;
    font-size: 0.95em;
    outline: none;
    cursor: pointer;
}

.client-selector select:focus {
    border-color: var(--primary);
}


/* Main Content */
.main-content {
    margin-left: 290px;
    /* Sidebar width + padding */
    flex: 1;
    padding: 40px;
    max-width: 1200px;
}

/* Header */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    color: #111827;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 24px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    margin-top: 8px;
    color: var(--text-main);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    color: #374151;
}

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    color: #111827;
    transition: all 0.2s;
    box-sizing: border-box;
    background: #fff;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.helper-text {
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.25;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    border: 1px solid transparent;
}

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

.btn-secondary {
    background-color: white;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background-color: #f9fafb;
    border-color: #9ca3af;
}

.btn-danger {
    background-color: transparent;
    color: var(--danger-text);
    border: 1px solid var(--danger-text);
    padding: 6px 12px;
    font-size: 0.85rem;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    background: #f9fafb;
    padding: 12px 24px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
    vertical-align: middle;
}

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

tr:hover td {
    background-color: #f9fafb;
}

/* Compact Table */
table.compact th,
table.compact td {
    padding: 8px 12px;
    font-size: 0.85rem;
}

table.compact th {
    font-size: 0.75rem;
}

table.compact td a {
    font-size: 0.85rem;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.bg-pending {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.bg-queued {
    background: #f3e8ff;
    color: #6b21a8;
    border: 1px solid #d8b4fe;
}

.bg-processing {
    background: #dbeafe;
    color: #1e40af;
}

.bg-completed {
    background: var(--success-bg);
    color: var(--success-text);
}

.bg-failed {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.active-client-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background-color: #ecfdf5;
    color: #047857;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 10px;
    border: 1px solid #a7f3d0;
}


/* Utilities */
.flex-split {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 40px;
}

.text-sm {
    font-size: 0.85rem;
}

/* Log Details */
.log-details summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 500;
    font-size: 0.85rem;
    outline: none;
}

.log-details summary:hover {
    text-decoration: underline;
}

.log-details pre {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 10px;
    border-radius: 6px;
    margin-top: 5px;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8rem;
    color: #334155;
}

/* Modal - Overlay */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    /* High z-index */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

/* Modal Content Box */
.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border: 1px solid #888;
    width: 80%;
    max-width: 900px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

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

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

.modal-header h3 {
    margin: 0;
    color: var(--text-main);
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

#modalLogContent {
    background: #1e293b;
    color: #f8fafc;
    padding: 15px;
    border-radius: 8px;
    white-space: pre-wrap;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.5;
}