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

:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #cbd5e1;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    --primary: #3b82f6;
    --primary-soft: rgba(59, 130, 246, 0.1);
    --primary-hover: #2563eb;
    --success: #16a34a;
    --success-soft: rgba(22, 163, 74, 0.08);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.08);
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.08);
    --purple: #7c3aed;
    --purple-soft: rgba(124, 58, 237, 0.08);
    --cyan: #0891b2;
    --cyan-soft: rgba(8, 145, 178, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
    --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* ─── Layout ─── */
.dashboard-layout { display: flex; min-height: 100vh; }

/* ─── Sidebar ─── */
.sidebar {
    width: 250px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text);
    letter-spacing: -0.02em;
}
.brand-icon { color: var(--primary); font-size: 1.3rem; }
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-heading {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--text-dim);
    padding: 4px 12px;
    margin-top: 16px;
    margin-bottom: 4px;
}
.nav-heading:first-child { margin-top: 0; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
}
.nav-item i { width: 18px; text-align: center; font-size: 0.95rem; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.logout-btn { color: var(--danger) !important; }
.logout-btn:hover { background: var(--danger-soft) !important; }

/* ─── Main ─── */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ─── Topbar ─── */
.topbar {
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.topbar-search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-3);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    width: 280px;
    border: 1px solid var(--border);
    transition: var(--transition);
}
.topbar-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.topbar-search input {
    border: none; background: transparent; outline: none; width: 100%;
    font-family: inherit; font-size: 0.85rem; color: var(--text);
}
.topbar-search input::placeholder { color: var(--text-dim); }
.topbar-search i { color: var(--text-dim); font-size: 0.85rem; }
.user-profile { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 34px; height: 34px; border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
}
.user-details { display: flex; flex-direction: column; }
.user-name { font-weight: 600; font-size: 0.85rem; color: var(--text); }
.user-role { font-size: 0.72rem; color: var(--text-muted); }

/* ─── Content ─── */
.content-wrapper { padding: 24px 28px; flex: 1; overflow-y: auto; }
.page-header {
    margin-bottom: 24px;
    display: flex; justify-content: space-between; align-items: center;
}
.page-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.page-subtitle { color: var(--text-muted); font-size: 0.88rem; margin-top: 2px; }

/* ─── Cards ─── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

/* ─── Stat Cards ─── */
.stat-grid { display: grid; gap: 16px; margin-bottom: 24px; }
.stat-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: var(--transition);
    box-shadow: var(--shadow);
}
.stat-card:hover { border-color: var(--border-light); box-shadow: var(--shadow-lg); }
.stat-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-soft); color: var(--primary); }
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.red { background: var(--danger-soft); color: var(--danger); }
.stat-icon.yellow { background: var(--warning-soft); color: var(--warning); }
.stat-icon.purple { background: var(--purple-soft); color: var(--purple); }
.stat-icon.cyan { background: var(--cyan-soft); color: var(--cyan); }
.stat-info { display: flex; flex-direction: column; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text); line-height: 1.2; margin-top: 2px; }

/* ─── Tables ─── */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; padding: 10px 14px;
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
th:first-child { border-radius: var(--radius-sm) 0 0 0; }
th:last-child { border-radius: 0 var(--radius-sm) 0 0; }
td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.88rem; color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ─── Badges ─── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 6px;
    font-size: 0.72rem; font-weight: 600;
    letter-spacing: 0.02em; text-transform: uppercase;
}
.badge-success, .badge-active, .badge-sent { background: var(--success-soft); color: var(--success); }
.badge-warning, .badge-pending, .badge-paused { background: var(--warning-soft); color: var(--warning); }
.badge-danger, .badge-failed, .badge-inactive, .badge-disconnected { background: var(--danger-soft); color: var(--danger); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-secondary { background: rgba(100,116,139,0.08); color: var(--text-muted); }

/* ─── Buttons ─── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; font-family: inherit; font-weight: 600;
    font-size: 0.85rem; border-radius: var(--radius-sm);
    border: none; cursor: pointer; transition: var(--transition);
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(59,130,246,0.25); transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-light); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

/* ─── Forms ─── */
.form-group { margin-bottom: 16px; }
label {
    display: block; font-weight: 500; margin-bottom: 6px;
    color: var(--text-muted); font-size: 0.82rem;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.form-control {
    width: 100%; padding: 10px 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); font-family: inherit;
    font-size: 0.88rem; color: var(--text); transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-control::placeholder { color: var(--text-dim); }
select.form-control { cursor: pointer; }

/* ─── Alerts ─── */
.alert {
    padding: 12px 16px; border-radius: var(--radius-sm);
    margin-bottom: 16px; font-size: 0.88rem;
    display: flex; align-items: center; gap: 10px;
}
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(239,68,68,0.15); }
.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid rgba(22,163,74,0.15); }

/* ─── Login ─── */
.login-body {
    display: flex; align-items: center; justify-content: center;
    height: 100vh; background: var(--bg);
}
.login-card {
    background: var(--surface); border: 1px solid var(--border);
    padding: 36px; border-radius: 16px; width: 100%; max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand i { font-size: 2rem; color: var(--primary); margin-bottom: 10px; }
.login-brand h2 { font-weight: 800; color: var(--text); font-size: 1.4rem; }

/* ─── Section Headers ─── */
.section-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.section-title { font-size: 0.92rem; font-weight: 600; color: var(--text); }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ─── Utility ─── */
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.72rem; }
.fw-600 { font-weight: 600; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* ─── Empty State ─── */
.empty-state {
    text-align: center; padding: 40px 20px; color: var(--text-dim);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 0.88rem; }
