:root {
    --bg: #0f1419;
    --surface: #1a2332;
    --surface2: #243044;
    --border: #2d3f56;
    --text: #e8edf4;
    --muted: #8b9cb3;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --ok: #22c55e;
    --denied: #ef4444;
    --pending: #f59e0b;
    --unknown: #6b7280;
    --selected: #1e3a5f;
    --radius: 10px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --mono: 'Cascadia Code', 'Consolas', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.35rem;
    font-weight: 600;
}

header p {
    color: var(--muted);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-top: 1rem;
}

.auth-status {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
}

.auth-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    background: var(--surface2);
    border: 1px solid var(--border);
}

.auth-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--unknown);
}

.auth-badge.ok .dot { background: var(--ok); }
.auth-badge.fail .dot { background: var(--denied); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover { background: var(--border); }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.filter-bar input,
.filter-bar select {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 0.875rem;
}

.filter-bar input { flex: 1; min-width: 200px; }

.stats {
    padding: 0.75rem 2rem;
    font-size: 0.8rem;
    color: var(--muted);
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.stats strong { color: var(--text); }

main { padding: 1.5rem 2rem 3rem; max-width: 1400px; }

.category {
    margin-bottom: 2rem;
}

.category h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.dataset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 0.75rem;
}

.dataset-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    transition: border-color 0.15s, background 0.15s;
}

.dataset-card:hover { border-color: #3d5270; }
.dataset-card.selected {
    border-color: var(--accent);
    background: var(--selected);
}

.card-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.card-header input[type="checkbox"] {
    margin-top: 0.2rem;
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.card-title {
    flex: 1;
    min-width: 0;
}

.card-title h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.card-title .id {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--muted);
    word-break: break-all;
    margin-top: 0.15rem;
}

.status-pill {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    flex-shrink: 0;
    white-space: nowrap;
}

.status-pill.unknown { background: #374151; color: #9ca3af; }
.status-pill.checking { background: #422006; color: var(--pending); }
.status-pill.ok { background: #14532d; color: #86efac; }
.status-pill.denied { background: #450a0a; color: #fca5a5; }

.card-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.6rem;
}

.tag {
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    background: var(--surface2);
    color: var(--muted);
    border: 1px solid var(--border);
}

.card-desc {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.5rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.card-actions .btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
}

.preview-panel {
    margin-top: 0.75rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    display: none;
}

.preview-panel.open { display: block; }

.preview-panel pre {
    font-family: var(--mono);
    font-size: 0.72rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    overflow: auto;
    max-height: 320px;
    white-space: pre-wrap;
    word-break: break-word;
}

.preview-meta {
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.selection-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.85rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transform: translateY(100%);
    transition: transform 0.2s;
    z-index: 200;
}

.selection-bar.visible { transform: translateY(0); }

.selection-bar .count { font-size: 0.9rem; }

.selection-list {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--muted);
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.progress-bar {
    height: 3px;
    background: var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 300;
    display: none;
}

.progress-bar.active { display: block; }

.progress-bar .fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.2s;
}

.hidden { display: none !important; }

@media (max-width: 640px) {
    header, .filter-bar, main, .stats { padding-left: 1rem; padding-right: 1rem; }
    .dataset-grid { grid-template-columns: 1fr; }
}
