:root {
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --bg: #f8fafc;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

header {
    background: var(--primary);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
}
header h1 { font-size: 1.4rem; font-weight: 600; }
header span { font-size: .85rem; opacity: .8; }

.container { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }

/* Search Form */
.search-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}
.form-group input,
.form-group select {
    padding: .6rem .8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .95rem;
    transition: border-color .2s;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: .8rem;
    align-items: center;
}
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .9rem;
    cursor: pointer;
    text-transform: none;
    font-weight: 500;
}

.btn-row {
    display: flex;
    gap: .8rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: .5rem;
}

.btn {
    padding: .6rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #16a34a; }
.btn-outline {
    background: white;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline:hover { background: #eff6ff; }

/* Progress */
.progress-area {
    background: #f1f5f9;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Consolas', monospace;
    font-size: .85rem;
    line-height: 1.8;
    display: none;
}
.progress-area.active { display: block; }
.progress-area .msg { color: var(--text-muted); }
.progress-area .msg:last-child { color: var(--text); font-weight: 600; }

/* Results Table */
.results-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    overflow-x: auto;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: .5rem;
}
.results-header h2 { font-size: 1.1rem; }
.results-count {
    background: var(--primary);
    color: white;
    padding: .2rem .8rem;
    border-radius: 20px;
    font-size: .85rem;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
thead th {
    background: #f1f5f9;
    padding: .6rem .5rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
tbody td {
    padding: .5rem;
    border-bottom: 1px solid var(--border);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
tbody tr:hover { background: #f8fafc; }

.pagination {
    display: flex;
    justify-content: center;
    gap: .5rem;
    margin-top: 1rem;
}
.pagination button {
    padding: .4rem .8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: .85rem;
}
.pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* History */
.history-list {
    list-style: none;
    margin-top: 1rem;
}
.history-list li {
    padding: .6rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .9rem;
}
.history-list li:hover { background: #f8fafc; }

.status-badge {
    padding: .2rem .6rem;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 600;
}
.status-completed { background: #dcfce7; color: #166534; }
.status-running { background: #fef9c3; color: #854d0e; }
.status-error { background: #fecaca; color: #991b1b; }
.status-pending { background: #e2e8f0; color: #475569; }

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .container { padding: 1rem; }
    header { padding: .8rem 1rem; }
}
