@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');

:root {
    --color-bg: #f4f6fb;
    --color-surface: #ffffff;
    --color-border: #e5e8f0;
    --color-text: #1f2330;
    --color-muted: #6f7585;
    --color-primary: #4f46e5;
    --color-secondary: #0ea5e9;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --radius: 20px;
}

* {
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
}

/* --- Auth --- */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, #dbeafe, var(--color-bg));
    padding: 1rem;
}

.auth-wrapper { max-width: 420px; width: 100%; }

.auth-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 15px 45px rgba(15, 23, 42, 0.12);
}

.auth-brand {
    flex-direction: column;
    text-align: center;
}

.auth-logo {
    width: 80px;
    height: auto;
    object-fit: contain;
    margin-bottom: 0.8rem;
}

.logo-circle {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: #fff;
    font-weight: 600;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-brand h1 { font-size: 1.4rem; margin-bottom: 0.2rem; }
.auth-brand span { font-size: 0.9rem; color: var(--color-muted); }

/* --- Main layout --- */
.main-body {
    min-height: 100vh;
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
}

.topbar-slim {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 2rem;
    border-bottom: 1px solid var(--color-border);
    background: #fff;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.logo-img {
    width: 48px;
    height: auto;
    object-fit: contain;
}

.admin-links {
    margin-left: auto;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.admin-links a {
    text-decoration: none;
    color: var(--color-muted);
    font-weight: 500;
}

.admin-links a:hover { color: var(--color-text); }

.topbar-right {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.user-info {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 16px;
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-name { font-weight: 600; }
.user-role { font-size: 0.85rem; color: var(--color-muted); }

.primary-nav {
    display: flex;
    gap: 1.2rem;
    padding: 0.8rem 2rem;
    background: #fff;
    border-bottom: 1px solid #e8ecf5;
    overflow-x: auto;
}

.primary-nav a {
    text-decoration: none;
    color: var(--color-muted);
    font-weight: 600;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    position: relative;
}

.primary-nav a.active { color: var(--color-primary); }

.primary-nav a.active ::after,
.primary-nav a.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -0.6rem;
    height: 3px;
    border-radius: 999px;
    background: var(--color-primary);
}

.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.content-full { flex: 1; padding: 2rem; }

.footer {
    text-align: center;
    padding: 1rem;
    color: var(--color-muted);
    font-size: 0.9rem;
}

.alerts { padding: 1rem 2rem 0; }

/* --- Generic components --- */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.8rem;
}

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

.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--color-border);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.06);
}

.card-label { color: var(--color-muted); font-size: 0.9rem; margin-bottom: 0.6rem; }
.card h3 { font-size: 1.6rem; margin-bottom: 0.3rem; }
.card-delta { font-size: 0.85rem; color: var(--color-muted); }

.panel {
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    padding: 1.5rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.2rem;
    align-items: center;
}

.pipeline-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pipeline-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    padding: 1rem;
    border-radius: 14px;
}

.badge {
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    background: var(--color-primary);
    color: #fff;
    font-weight: 500;
}

.btn {
    border: none;
    border-radius: 999px;
    padding: 0.6rem 1.4rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: #fff;
}

.btn-secondary {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-muted);
}

.btn:hover { opacity: 0.9; }

.form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

label span {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    padding: 0.9rem;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    background: #f8fafc;
    font-size: 1rem;
}

textarea { resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(79, 70, 229, 0.2);
}

.alert {
    padding: 0.9rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: rgba(16,185,129,0.15);
    color: #047857;
}

.alert-error {
    background: rgba(239,68,68,0.12);
    color: #b91c1c;
}

.alert-info {
    background: rgba(14,165,233,0.12);
    color: #0369a1;
}

.alert-warning {
    background: rgba(245,158,11,0.18);
    color: #92400e;
}

.muted { color: var(--color-muted); }

/* Tables */
.table-card {
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
    padding: 0;
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table thead { background: #f8f9ff; }

.data-table th {
    text-align: left;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 1rem 1.5rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.data-table td {
    padding: 1rem 1.5rem;
    border-top: 1px solid #f0f2f8;
}

.data-table tbody tr:hover { background: #f5f7ff; }

.data-table tbody tr:first-child td { border-top: none; }

.badge-pill {
    padding: 0.2rem 0.8rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-block;
}

.badge-pill.secondary { background: rgba(79, 70, 229, 0.12); color: var(--color-primary); }
.badge-pill.success   { background: rgba(16, 185, 129, 0.15); color: var(--color-success); }
.badge-pill.warning   { background: rgba(245, 158, 11, 0.18); color: var(--color-warning); }
.badge-pill.neutral   { background: #eef2ff; color: #4c4f6b; }

@media (max-width: 992px) {
    .topbar-slim { flex-direction: column; align-items: flex-start; }
    .admin-links { margin-left: 0; margin-right: 0; }
    .topbar-right { width: 100%; justify-content: flex-start; }

    .data-table thead { display: none; }
    .data-table tbody tr {
        display: block;
        border-bottom: 1px solid #eef2ff;
    }
    .data-table td {
        display: flex;
        justify-content: space-between;
        font-size: 0.95rem;
    }
    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-muted);
        margin-right: 1rem;
    }
}

.table-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.btn-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: none;
    background: #eef2ff;
    color: var(--color-primary);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
}

.btn-icon:hover { background: rgba(79, 70, 229, 0.18); }

.btn-icon.danger { background: rgba(239, 68, 68, 0.12); color: #b91c1c; }
.btn-icon.danger:hover { background: rgba(239, 68, 68, 0.25); }

.table-actions form { margin: 0; }

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.chip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: #fff;
    cursor: pointer;
}

.chip input {
    width: auto;
}

.switch-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}