* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
}
header {
    background: #16213e;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
}
.header-title {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}
h1 { color: #95FF96; font-size: 1.25rem; }
.header-subtitle { color: #888; font-size: 0.875rem; }
.logout-btn {
    background: transparent;
    border: 1px solid #666;
    color: #aaa;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
}
.logout-btn:hover { border-color: #95FF96; color: #95FF96; }
main {
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 2rem;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}
@media (max-width: 1000px) {
    main { grid-template-columns: 1fr; }
}
.panel {
    background: #16213e;
    border-radius: 8px;
    padding: 1.5rem;
}
.panel h2 {
    color: #95FF96;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}
.panel-description {
    color: #888;
    font-size: 0.8rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #333;
    line-height: 1.5;
}
.form-group { margin-bottom: 1rem; }
label { display: block; margin-bottom: 0.25rem; color: #aaa; font-size: 0.875rem; }
.label-hint { color: #666; font-size: 0.75rem; font-weight: normal; }
input, select, textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #333;
    border-radius: 4px;
    background: #0f0f1a;
    color: #fff;
    font-size: 0.875rem;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #95FF96;
}
textarea { resize: vertical; min-height: 60px; }
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #0f0f1a;
    border-radius: 4px;
    border: 1px solid #333;
}
.checkbox-group input { width: auto; }
.checkbox-group label { margin-bottom: 0; color: #ccc; }
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    border: 1px solid #333;
    color: #aaa;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}
.tab:hover { border-color: #95FF96; color: #95FF96; }
.tab.active { background: #95FF96; color: #1a1a2e; border-color: #95FF96; font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-description {
    background: #0f0f1a;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.8rem;
    color: #aaa;
    line-height: 1.5;
}
.submit-btn {
    width: 100%;
    padding: 0.75rem;
    background: #95FF96;
    color: #1a1a2e;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    font-size: 0.9rem;
}
.submit-btn:hover { background: #7deb7e; }
.submit-btn:disabled { background: #666; cursor: not-allowed; }

/* Country selector button */
.country-selector-btn {
    width: 100%;
    padding: 0.5rem;
    background: #0f0f1a;
    border: 1px solid #333;
    border-radius: 4px;
    color: #fff;
    font-size: 0.875rem;
    cursor: pointer;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.country-selector-btn:hover { border-color: #95FF96; }
.country-selector-btn .arrow { color: #666; }
.selected-countries-preview {
    color: #95FF96;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* Modal styles - Dark theme */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #16213e;
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    color: #eee;
    border: 1px solid #333;
}
.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #333;
}
.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #95FF96;
}
.region-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #0f0f1a;
    border-bottom: 1px solid #333;
}
.presets-label {
    font-size: 0.75rem;
    color: #888;
    font-weight: 500;
    margin-right: 0.25rem;
}
.preset-btn {
    padding: 0.35rem 0.75rem;
    border: 1px solid #444;
    border-radius: 4px;
    background: #1a1a2e;
    color: #ccc;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.preset-btn:hover {
    background: #95FF96;
    border-color: #95FF96;
    color: #1a1a2e;
}
.preset-btn.active {
    background: #95FF96;
    border-color: #95FF96;
    color: #1a1a2e;
}
.preset-btn.partial {
    background: #2a3a2a;
    border-color: #95FF96;
    color: #95FF96;
}
.preset-btn-global {
    background: #1a5f7a;
    border-color: #1a5f7a;
    color: #fff;
}
.preset-btn-global:hover {
    background: #0d4a5f;
    border-color: #0d4a5f;
}
.preset-btn-global.active {
    background: #0d4a5f;
    border-color: #0d4a5f;
}
.preset-btn-clear {
    background: transparent;
    border-color: #666;
    color: #888;
}
.preset-btn-clear:hover {
    background: #dc3545;
    border-color: #dc3545;
    color: #fff;
}
.modal-tabs {
    display: flex;
    border-bottom: 1px solid #333;
    background: #0f0f1a;
}
.modal-tab {
    flex: 1;
    padding: 1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #888;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}
.modal-tab:hover { color: #eee; background: #1a1a2e; }
.modal-tab.active {
    color: #95FF96;
    border-bottom-color: #95FF96;
    background: #16213e;
    font-weight: 500;
}
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    background: #16213e;
}
.select-all-row {
    padding: 0.75rem 0;
    border-bottom: 1px solid #333;
    margin-bottom: 1rem;
}
.select-all-row label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: #ccc;
    font-size: 0.9rem;
}
.select-all-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #95FF96;
}
.country-grid, .language-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem;
}
@media (max-width: 700px) {
    .country-grid, .language-grid { grid-template-columns: repeat(2, 1fr); }
}
.country-item, .language-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}
.country-item:hover, .language-item:hover { background: #1a1a2e; }
.country-item.selected, .language-item.selected { background: #2a3a2a; }
.country-item input[type="checkbox"], .language-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: #95FF96;
}
.country-flag {
    width: 24px;
    height: 16px;
    border-radius: 2px;
    object-fit: cover;
    flex-shrink: 0;
}
.country-name, .language-name {
    font-size: 0.85rem;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #333;
    display: flex;
    gap: 0.75rem;
    background: #0f0f1a;
}
.modal-btn {
    padding: 0.6rem 1.25rem;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    font-weight: 500;
}
.modal-btn-primary {
    background: #95FF96;
    color: #1a1a2e;
    border: none;
}
.modal-btn-primary:hover { background: #7deb7e; }
.modal-btn-secondary {
    background: transparent;
    color: #aaa;
    border: 1px solid #444;
}
.modal-btn-secondary:hover { background: #1a1a2e; color: #eee; }

/* Job list styles */
.job-list { list-style: none; }
.job-item {
    padding: 1rem;
    border-bottom: 1px solid #333;
}
.job-item:last-child { border-bottom: none; }
.job-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}
.job-name { font-weight: 500; }
.job-badges {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}
.job-type, .job-region {
    font-size: 0.7rem;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    background: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.job-region {
    background: #2a3a4a;
    color: #8ad;
}
.job-type.prospect { background: #2d4a3e; color: #95FF96; }
.job-type.market { background: #3d3a4a; color: #b8a9ff; }
.job-type.buyer { background: #4a3d2d; color: #ffcc96; }
.job-meta {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.job-status {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}
.status-pending { background: #555; color: #ccc; }
.status-running { background: #2980b9; color: #fff; }
.status-completed { background: #27ae60; color: #fff; }
.status-failed { background: #c0392b; color: #fff; }
.status-cancelled { background: #7f8c8d; color: #fff; }
.progress-bar {
    height: 4px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #95FF96, #7deb7e);
    transition: width 0.3s;
}
.job-error {
    color: #e74c3c;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 4px;
}
.job-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.job-actions a, .job-actions button {
    font-size: 0.75rem;
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
}
.job-actions a {
    background: #333;
    color: #95FF96;
    border: none;
}
.job-actions a:hover { background: #444; }
.job-actions .btn-cancel {
    background: #c0392b;
    border: none;
    color: #fff;
    font-weight: 500;
}
.job-actions .btn-cancel:hover { background: #e74c3c; }
.job-actions .btn-delete {
    background: transparent;
    border: 1px solid #666;
    color: #888;
}
.job-actions .btn-delete:hover { border-color: #c0392b; color: #c0392b; }
.job-actions .btn-rerun,
.job-actions .btn-duplicate {
    background: transparent;
    border: 1px solid #555;
    color: #ccc;
    font-weight: 500;
}
.job-actions .btn-rerun:hover { border-color: #95FF96; color: #95FF96; }
.job-actions .btn-duplicate:hover { border-color: #9eb9ff; color: #9eb9ff; }
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: #666;
}
.empty-state p { margin-bottom: 0.5rem; }
    
/* ==================================================================
 * Additions from the rebuild: history controls, pagination,
 * login page, capability badge, rename button, misc hints.
 * ================================================================ */

/* Login page --------------------------------------------------- */
body.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-box {
    background: #16213e;
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
}
.login-box h1 {
    color: #95FF96;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}
.login-box .error {
    color: #ff6b6b;
    margin-top: 1rem;
    display: none;
}

/* History controls (search, filters, pagination) -------------- */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}
.history-count {
    color: #666;
    font-size: 0.75rem;
}
.history-controls {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.history-search,
.history-filter {
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
}
.history-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #222;
}
.pagination-btn {
    background: transparent;
    border: 1px solid #444;
    color: #aaa;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}
.pagination-btn:hover:not(:disabled) {
    border-color: #95FF96;
    color: #95FF96;
}
.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.pagination-info {
    color: #888;
    font-size: 0.8rem;
}

/* Capability badge + rename button ---------------------------- */
.job-capability {
    background: #2d2d4a;
    color: #9eb9ff;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    border: 1px solid #3d3d5a;
}
.job-actions .btn-rename {
    background: transparent;
    border: 1px solid #555;
    color: #ccc;
    font-weight: 500;
}
.job-actions .btn-rename:hover {
    border-color: #9eb9ff;
    color: #9eb9ff;
}
.job-name[ondblclick] {
    cursor: text;
}

/* Small utility hints ----------------------------------------- */
.field-hint {
    color: #666;
    margin-top: 4px;
    display: block;
    font-size: 0.75rem;
}
.advanced-details {
    margin-bottom: 1rem;
}
.advanced-details > summary {
    color: #888;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.5rem 0;
}
.advanced-details .form-group {
    margin-top: 0.5rem;
}
.empty-hint {
    font-size: 0.8rem;
}
.language-modal {
    max-width: 600px;
}

/* Collapsible full-traceback details under a failed job ----- */
.job-error-details {
    margin-top: 0.5rem;
}
.job-error-details > summary {
    color: #e74c3c;
    cursor: pointer;
    font-size: 0.75rem;
    user-select: none;
}
.job-error-details > summary:hover {
    text-decoration: underline;
}
.job-error-details pre {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: #0f0f1a;
    border: 1px solid #3a1f24;
    border-radius: 4px;
    color: #f0cccc;
    font-size: 0.7rem;
    line-height: 1.4;
    overflow-x: auto;
    max-height: 400px;
    white-space: pre-wrap;
    word-wrap: break-word;
}
