:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --bg: #f8fafc;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-light: #64748b;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Login ── */
.login-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.login-box {
    background: var(--card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    width: 360px;
}
.login-box h2 { margin-bottom: 1.5rem; text-align: center; }
.login-box input {
    width: 100%; padding: 0.6rem 0.8rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.95rem; margin-bottom: 0.8rem;
}
.login-box button { width: 100%; }

/* ── Layout ── */
.header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 1.5rem;
    display: flex; align-items: center; justify-content: space-between;
}
.header h1 { font-size: 1.2rem; font-weight: 600; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; }

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

/* ── Tabs ── */
.tabs {
    display: flex; gap: 0; margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}
.tab {
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    border: none; background: none;
    font-size: 0.9rem; font-weight: 500;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Cards ── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.card h3 { margin-bottom: 1rem; font-size: 1rem; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block; font-size: 0.85rem;
    font-weight: 500; margin-bottom: 0.3rem;
    color: var(--text-light);
}
.form-group input, .form-group select {
    width: 100%; padding: 0.6rem 0.8rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.9rem;
}
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

/* ── Buttons ── */
.btn {
    padding: 0.55rem 1.2rem;
    border: none; border-radius: var(--radius);
    font-size: 0.9rem; font-weight: 500;
    cursor: pointer; transition: background 0.2s;
    display: inline-flex; align-items: center; gap: 0.4rem;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-outline {
    background: transparent; color: var(--text);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table {
    width: 100%; border-collapse: collapse;
    font-size: 0.85rem;
}
th, td {
    padding: 0.5rem 0.7rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
th {
    background: var(--bg);
    font-weight: 600; font-size: 0.8rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    position: sticky; top: 0;
}
tr:hover { background: #f1f5f9; }

/* ── Filter bar ── */
.filter-bar {
    display: flex; gap: 0.8rem; margin-bottom: 1rem;
    flex-wrap: wrap; align-items: end;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 180px; }

/* ── Alerts ── */
.alert {
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Upload area ── */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}
.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: #eff6ff;
}
.upload-area input[type="file"] { display: none; }
.upload-area .icon { font-size: 2rem; margin-bottom: 0.5rem; }
.upload-area .text { color: var(--text-light); font-size: 0.9rem; }
.upload-area .filename {
    margin-top: 0.5rem; font-weight: 600;
    color: var(--primary);
}

/* ── Stats ── */
.stats { display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    flex: 1; min-width: 140px;
}
.stat-card .label { font-size: 0.75rem; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .value { font-size: 1.4rem; font-weight: 700; margin-top: 0.2rem; }

/* ── Misc ── */
.empty-state {
    text-align: center; padding: 3rem;
    color: var(--text-light);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.spinner {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid #fff; border-top-color: transparent;
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #166534; }

/* ── API Info ── */
.api-info {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem;
    overflow-x: auto;
    margin-top: 0.8rem;
}
.api-info .method { color: #34d399; font-weight: 700; }
.api-info .url { color: #93c5fd; }
.api-info .comment { color: #64748b; }
