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

/* ── VARIABLES ──────────────────────────────── */
:root {
    --sidebar-w: 252px;
    --sidebar-bg: #0f172a;
    --sidebar-border: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #0ea5e9;
    --sidebar-active-bg: rgba(14,165,233,.12);

    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --ink: #0f172a;
    --muted: #64748b;

    --accent: #0ea5e9;
    --accent-dark: #0284c7;
    --success: #10b981;
    --warn: #f59e0b;
    --danger: #ef4444;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,.10);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 14px;
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── APP SHELL ──────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 200;
    transition: transform .25s ease;
    scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--sidebar-border);
    text-decoration: none;
}
.sidebar-brand-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}
.sidebar-brand-text {
    font-size: 13.5px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: .2px;
    line-height: 1.2;
}
.sidebar-brand-sub {
    font-size: 10.5px;
    color: var(--sidebar-text);
    font-weight: 400;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #475569;
    padding: 14px 8px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, color .15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #e2e8f0; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 600; }

.nav-icon {
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    opacity: .85;
}

/* Dropdown group */
.nav-group { position: relative; }

.nav-group > summary {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    list-style: none;
    transition: background .15s, color .15s;
    user-select: none;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-group[open] > summary { color: #e2e8f0; }

.nav-chevron {
    margin-left: auto;
    font-size: 11px;
    color: #475569;
    transition: transform .2s;
}
.nav-group[open] .nav-chevron { transform: rotate(90deg); }

.nav-sub {
    padding: 2px 0 4px 29px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.nav-sub a {
    display: block;
    padding: 7px 10px;
    border-radius: 6px;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.nav-sub a:hover { background: rgba(255,255,255,.05); color: #cbd5e1; text-decoration: none; }
.nav-sub a.active { color: var(--sidebar-active); background: var(--sidebar-active-bg); font-weight: 600; }

.nav-divider { border-top: 1px solid var(--sidebar-border); margin: 8px 0; }

.nav-logout { color: #ef4444 !important; }
.nav-logout:hover { background: rgba(239,68,68,.1) !important; color: #fca5a5 !important; }

/* Sidebar footer */
.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--sidebar-border);
    font-size: 11.5px;
    color: #475569;
}

/* ── MAIN AREA ──────────────────────────────── */
.main-area {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 28px;
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.sidebar-toggle {
    display: none;
    width: 34px; height: 34px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 8px;
    font-size: 18px;
    color: var(--muted);
    align-items: center;
    justify-content: center;
    transition: background .15s;
    padding: 0;
}
.sidebar-toggle:hover { background: var(--bg); }

.topbar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    flex: 1;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
}
.topbar-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    color: #fff;
    font-weight: 700;
}

/* Content */
.content {
    padding: 28px 32px 48px;
    flex: 1;
}

/* ── AUTH LAYOUT ────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    padding: 24px;
}
.auth-content { width: 100%; max-width: 420px; }

.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}
.auth-logo-icon {
    width: 52px; height: 52px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    border-radius: 16px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 24px;
    margin-bottom: 12px;
}
.auth-logo-text {
    font-size: 18px;
    font-weight: 700;
    color: #f1f5f9;
}
.auth-logo-sub { font-size: 13px; color: #64748b; margin-top: 2px; }

/* ── CARDS ──────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}

/* ── STAT CARDS ─────────────────────────────── */
.stat-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin-bottom: 8px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent);
}
.stat-card.green::before  { background: var(--success); }
.stat-card.yellow::before { background: var(--warn); }
.stat-card.red::before    { background: var(--danger); }

.stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--muted);
    margin-bottom: 8px;
}
.stat-number {
    font-size: 30px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1;
}
.stat-number.blue   { color: var(--accent); }
.stat-number.green  { color: var(--success); }
.stat-number.yellow { color: var(--warn); }
.stat-number.red    { color: var(--danger); }

/* ── MODULE SECTION ─────────────────────────── */
.module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 28px 0 12px;
}
.module-header:first-child { margin-top: 0; }

.module-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--muted);
}
.module-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}
.module-dot.green  { background: var(--success); }
.module-dot.yellow { background: var(--warn); }

/* ── PAGE HEADER ────────────────────────────── */
.page-header {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header-left h1 { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.page-header-left p  { color: var(--muted); font-size: 13.5px; margin: 0; }

/* ── SECTION HEADER ─────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 10px;
}
.section-header h1, .section-header h2 { margin: 0; font-size: 18px; }

/* ── GRID ───────────────────────────────────── */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* 12-col row */
.row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; align-items: start; }
.col-4 { grid-column: span 4; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-12 { grid-column: span 12; }

/* ── TYPOGRAPHY ─────────────────────────────── */
h1 { font-size: 20px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }

/* ── FORMS ──────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    margin-bottom: 16px;
}

label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(14,165,233,.12);
}
textarea { min-height: 88px; resize: vertical; }
input[type="file"] { padding: 7px 10px; background: var(--bg); }

input::placeholder, textarea::placeholder { color: #94a3b8; }

/* ── BUTTONS ────────────────────────────────── */
.btn, button[type="submit"], button[type="button"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: background .15s, opacity .15s, transform .1s;
    line-height: 1;
    white-space: nowrap;
    background: var(--accent);
    color: #fff;
}
.btn:hover, button:hover { opacity: .88; text-decoration: none; }
.btn:active, button:active { transform: scale(.98); }
.btn:hover { color: #fff; }

.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }

.btn-secondary { background: #334155; }
.btn-success   { background: var(--success); }
.btn-warn      { background: var(--warn); }
.btn-danger    { background: var(--danger); }
.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
}
.btn-outline:hover { background: var(--accent); color: #fff; }
.btn-ghost {
    background: var(--bg);
    color: var(--ink);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--border); color: var(--ink); }

/* ── TABLE ──────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.table th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }

.table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--ink);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }

/* ── BADGES ─────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
}
.badge::before { content: '●'; font-size: 7px; }
.badge.sent    { background: #d1fae5; color: #065f46; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.failed  { background: #fee2e2; color: #991b1b; }

/* ── ALERTS ─────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    line-height: 1.5;
    margin-bottom: 18px;
    border-left: 4px solid;
}
.alert.success { background: #f0fdf4; color: #166534; border-color: var(--success); }
.alert.error   { background: #fef2f2; color: #991b1b; border-color: var(--danger); }
.alert.info    { background: #f0f9ff; color: #0c4a6e; border-color: var(--accent); }
.alert div + div { margin-top: 4px; }

/* ── FILTER BAR ─────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.filter-bar a {
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 500;
    border: 1.5px solid var(--border);
    color: var(--muted);
    background: var(--surface);
    text-decoration: none;
    transition: all .15s;
}
.filter-bar a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.filter-bar a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── INFO BOX ───────────────────────────────── */
.info-box {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: 13px;
    color: #0c4a6e;
    line-height: 1.6;
}
.info-box ol { padding-left: 18px; margin: 8px 0 0; }
.info-box li { margin-bottom: 4px; }

/* ── QUICK LINKS ────────────────────────────── */
.quick-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-decoration: none;
    color: var(--ink);
    transition: box-shadow .2s, transform .2s, border-color .2s;
    box-shadow: var(--shadow);
}
.quick-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--accent); text-decoration: none; color: var(--ink); }
.quick-card-icon { font-size: 26px; margin-bottom: 10px; }
.quick-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.quick-card p  { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.5; }

/* ── MOBILE OVERLAY ─────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 199;
}
.sidebar-overlay.visible { display: block; }

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0,0,0,.25);
    }
    .main-area { margin-left: 0; }
    .sidebar-toggle { display: inline-flex; }
    .content { padding: 18px 16px 40px; }
    .topbar { padding: 0 16px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .col-4, .col-8, .col-6 { grid-column: span 12; }
}

@media (max-width: 500px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .col-4, .col-8, .col-6 { grid-column: span 12; }
    .page-header { flex-direction: column; }
    .section-header { flex-direction: column; align-items: flex-start; }
    .table td, .table th { padding: 8px 10px; }
}
