@font-face {
    font-family: 'Montserrat';
    src: url('/assets/fonts/Montserrat-Regular.woff2') format('woff2');
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('/assets/fonts/Montserrat-Medium.woff2') format('woff2');
    font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('/assets/fonts/Montserrat-SemiBold.woff2') format('woff2');
    font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('/assets/fonts/Montserrat-Bold.woff2') format('woff2');
    font-weight: 700; font-style: normal; font-display: swap;
}

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

:root {
    --blue:    #1a5cff;
    --blue-dk: #1247cc;
    --navy:    #0a1628;
    --navy-2:  #0f1f3d;
    --slate:   #1e2d4a;
    --accent:  #00c2a8;
    --gray:    #6b7a99;
    --gray-lt: #e8edf5;
    --white:   #ffffff;
    --red:     #e53e3e;
    --yellow:  #f6ad55;
    --green:   #38a169;
    --radius:  10px;
    --shadow:  0 2px 12px rgba(10,22,40,.10);
    --shadow-lg: 0 8px 32px rgba(10,22,40,.15);
}

body {
    font-family: 'Montserrat', sans-serif;
    background: #f0f4fb;
    color: var(--navy);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 240px; height: 100vh;
    background: var(--navy);
    display: flex; flex-direction: column;
    z-index: 100;
    padding: 0;
}

.sidebar-logo {
    display: flex; align-items: center; gap: 10px;
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo svg { width: 28px; height: 28px; flex-shrink: 0; }
.sidebar-logo span {
    font-size: 15px; font-weight: 700; color: var(--white);
    letter-spacing: -.2px;
}
.sidebar-logo small {
    display: block; font-size: 10px; font-weight: 400;
    color: rgba(255,255,255,.4); letter-spacing: .5px; text-transform: uppercase;
}

.sidebar-site-selector {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-site-selector select {
    width: 100%; background: rgba(255,255,255,.06);
    color: var(--white); border: 1px solid rgba(255,255,255,.12);
    border-radius: 6px; padding: 8px 10px;
    font-family: inherit; font-size: 12px; cursor: pointer;
    appearance: none;
}

.sidebar-nav { flex: 1; padding: 10px 10px; overflow-y: auto; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 7px;
    color: rgba(255,255,255,.6); text-decoration: none;
    font-size: 13px; font-weight: 500;
    transition: all .15s;
    margin-bottom: 2px;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(255,255,255,.09); color: var(--white);
}
.sidebar-nav a.active { background: var(--blue); color: var(--white); }
.sidebar-nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .8; }
.sidebar-nav .nav-section {
    font-size: 10px; font-weight: 600; color: rgba(255,255,255,.28);
    letter-spacing: 1px; text-transform: uppercase;
    padding: 14px 12px 6px;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.07);
    display: flex; align-items: center; gap: 10px;
}
.sidebar-footer .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--blue); display: flex; align-items: center;
    justify-content: center; font-size: 12px; font-weight: 700; color: var(--white);
    flex-shrink: 0;
}
.sidebar-footer .name { font-size: 12px; color: rgba(255,255,255,.7); font-weight: 500; flex: 1; }
.sidebar-footer a { color: rgba(255,255,255,.4); font-size: 11px; text-decoration: none; }
.sidebar-footer a:hover { color: rgba(255,255,255,.8); }

/* ── Main Layout ── */
.main {
    margin-left: 240px;
    min-height: 100vh;
    display: flex; flex-direction: column;
}

.topbar {
    background: var(--white); border-bottom: 1px solid var(--gray-lt);
    padding: 0 28px;
    height: 60px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow);
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--navy); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.date-picker {
    display: flex; align-items: center; gap: 6px;
    background: var(--gray-lt); border-radius: 7px; padding: 6px 10px;
}
.date-picker input[type=date] {
    border: none; background: transparent; font-family: inherit;
    font-size: 12px; color: var(--navy); font-weight: 500; cursor: pointer;
}
.date-picker span { font-size: 11px; color: var(--gray); }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 7px; font-family: inherit;
    font-size: 12px; font-weight: 600; cursor: pointer; border: none;
    text-decoration: none; transition: all .15s;
}
.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-dk); }
.btn-secondary { background: var(--gray-lt); color: var(--navy); }
.btn-secondary:hover { background: #dde3ee; }
.btn-sm { padding: 5px 10px; font-size: 11px; }

/* ── Content ── */
.content { padding: 24px 28px; flex: 1; }

/* ── KPI Cards ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow);
    position: relative; overflow: hidden;
}
.kpi-card::before {
    content: ''; position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: var(--blue);
}
.kpi-card.accent::before { background: var(--accent); }
.kpi-card.yellow::before { background: var(--yellow); }
.kpi-card.green::before  { background: var(--green); }
.kpi-card.red::before    { background: var(--red); }
.kpi-label { font-size: 11px; font-weight: 600; color: var(--gray); text-transform: uppercase; letter-spacing: .5px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--navy); margin: 6px 0 2px; line-height: 1; }
.kpi-meta  { font-size: 11px; color: var(--gray); }
.kpi-icon  {
    position: absolute; right: 18px; top: 50%;
    transform: translateY(-50%);
    width: 38px; height: 38px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    background: var(--gray-lt);
}
.kpi-icon svg { width: 20px; height: 20px; }

/* ── Charts / Tables ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 20px; }

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-lt);
    display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 13px; font-weight: 700; color: var(--navy); }
.card-body  { padding: 16px 20px; }

/* Chart wrapper */
.chart-wrap { position: relative; height: 220px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    font-size: 10px; font-weight: 600; color: var(--gray);
    text-transform: uppercase; letter-spacing: .5px;
    padding: 8px 10px; text-align: left;
    border-bottom: 1px solid var(--gray-lt);
    background: #fafbfe;
}
.data-table td {
    padding: 10px 10px; font-size: 12px; color: var(--navy);
    border-bottom: 1px solid #f3f5f9;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f7f9fd; }
.data-table .num { text-align: right; font-weight: 600; }
.bar-bg {
    height: 5px; border-radius: 3px; background: var(--gray-lt);
    margin-top: 4px; overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 3px; background: var(--blue); transition: width .3s; }

/* Badge */
.badge {
    display: inline-block; padding: 2px 7px; border-radius: 20px;
    font-size: 10px; font-weight: 600; text-transform: uppercase;
}
.badge-blue   { background: #e8edff; color: var(--blue); }
.badge-green  { background: #e6f4ef; color: var(--green); }
.badge-yellow { background: #fff5e6; color: #c07030; }
.badge-gray   { background: var(--gray-lt); color: var(--gray); }

/* Device Doughnut */
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut-legend { flex: 1; }
.donut-legend-item {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--navy); margin-bottom: 8px;
}
.donut-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* Snippet box */
.snippet-box {
    background: var(--navy); border-radius: 8px; padding: 16px;
    font-family: 'Courier New', monospace; font-size: 11px;
    color: #7ec8e3; line-height: 1.7; overflow-x: auto;
    white-space: pre;
}
.copy-btn {
    background: rgba(255,255,255,.1); color: rgba(255,255,255,.8);
    border: 1px solid rgba(255,255,255,.2); border-radius: 5px;
    padding: 4px 10px; font-size: 11px; cursor: pointer;
    font-family: inherit; transition: all .15s;
}
.copy-btn:hover { background: rgba(255,255,255,.2); }

/* Login page */
.auth-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--navy);
    padding: 20px;
}
.auth-card {
    background: var(--white);
    border-radius: 14px; padding: 40px;
    width: 100%; max-width: 380px;
    box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo h1 { font-size: 20px; font-weight: 700; color: var(--navy); }
.auth-logo p  { font-size: 12px; color: var(--gray); margin-top: 4px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 11px; font-weight: 600; color: var(--navy); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .3px; }
.form-control {
    width: 100%; padding: 10px 12px; border: 1.5px solid var(--gray-lt);
    border-radius: 7px; font-family: inherit; font-size: 13px;
    color: var(--navy); transition: border-color .15s; outline: none;
}
.form-control:focus { border-color: var(--blue); }
.alert { padding: 10px 14px; border-radius: 7px; font-size: 12px; margin-bottom: 16px; }
.alert-error { background: #fee2e2; color: var(--red); }
.alert-success { background: #e6f4ef; color: var(--green); }

/* Responsive */
@media (max-width: 900px) {
    .sidebar { display: none; }
    .main { margin-left: 0; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
}
