/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #16a34a;
    --danger: #dc2626;
    --bg: #f1f5f9;
    --card-bg: #fff;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #4f46e5;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ── Login ──────────────────────────────────────────────── */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: #fff;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-logo { font-size: 3rem; margin-bottom: .5rem; }
.login-card h1 { font-size: 1.5rem; margin-bottom: .25rem; }
.login-subtitle { color: var(--text-muted); margin-bottom: 1.5rem; }
.error-text { color: var(--danger); font-size: .85rem; margin-top: .75rem; }

/* ── Layout ─────────────────────────────────────────────── */
#app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo { font-size: 1.5rem; }
.sidebar-title { font-weight: 600; font-size: 1rem; color: #fff; }

.sidebar-nav {
    flex: 1;
    padding: .75rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .9rem;
    transition: background .15s, color .15s;
}

.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; border-radius: 0; }
.nav-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
}

.content {
    flex: 1;
    margin-left: 240px;
    padding: 2rem;
}

/* ── Pages ──────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }
.page h2 { margin-bottom: 1.25rem; font-size: 1.4rem; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.page-header h2 { margin-bottom: 0; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon { font-size: 2rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-label { font-size: .8rem; color: var(--text-muted); }

.actions-row { display: flex; gap: .75rem; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border: none;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, opacity .15s;
}

.btn:hover { opacity: .9; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: .35rem .5rem; font-size: 1rem; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: .35rem;
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    transition: border-color .15s;
}

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

.form-row { display: flex; gap: 1rem; align-items: flex-end; }

.input-with-toggle { display: flex; gap: .5rem; align-items: center; }
.input-with-toggle input { flex: 1; }

.text-muted { color: var(--text-muted); font-size: .8rem; }

.result-box {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
}
.result-box.success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.result-box.error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.result-box.info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ── Table ──────────────────────────────────────────────── */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    padding: .65rem .75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: .875rem;
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.table tr:last-child td { border-bottom: none; }
.text-center { text-align: center; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 { font-size: 1.1rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.modal-body { padding: 1.5rem; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* ── Logs ───────────────────────────────────────────────── */
.logs-pre {
    background: #0f172a;
    color: #a5f3fc;
    padding: 1rem;
    border-radius: var(--radius);
    font-size: .8rem;
    line-height: 1.6;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ── Badge ──────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 9999px;
    font-size: .75rem;
    font-weight: 600;
}

.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef9c3; color: #854d0e; }

/* ── Toast ──────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: .75rem 1.25rem;
    border-radius: var(--radius);
    color: #fff;
    font-size: .875rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    z-index: 200;
    animation: slideIn .3s ease-out;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-title, .nav-item span:not(.nav-icon) { display: none; }
    .nav-item { justify-content: center; padding: .75rem; }
    .content { margin-left: 60px; padding: 1rem; }
    .cards-grid { grid-template-columns: 1fr 1fr; }
    .form-row { flex-direction: column; gap: 0; }
}
