@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,300;12..96,400;12..96,500;12..96,600;12..96,700;12..96,800&family=Instrument+Sans:ital,wght@0,400;0,500;0,600;1,400&display=swap');

:root {
    --bg: #F7F8FA;
    --bg2: #FFFFFF;
    --bg3: #EFF1F5;
    --border: #E3E6ED;
    --border2: #D0D5E0;
    --accent: #2563EB;
    --accent-light: #EEF3FF;
    --accent2: #0EA5E9;
    --accent-g: linear-gradient(135deg, #2563EB, #0EA5E9);
    --text: #0F1117;
    --text2: #3D4557;
    --muted: #6B7694;
    --muted2: #9AA3BB;
    --heading: 'Bricolage Grotesque', sans-serif;
    --body: 'Instrument Sans', sans-serif;
    --radius: 14px;
    --radius-lg: 22px;
    --shadow: 0 2px 12px rgba(37,99,235,0.06), 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 8px 32px rgba(37,99,235,0.10), 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 24px 64px rgba(37,99,235,0.13), 0 4px 16px rgba(0,0,0,0.08);
    --sidebar-width: 260px;

    /* Legacy mappings for backward compatibility */
    --bg-main: var(--bg);
    --bg-card: var(--bg2);
    --bg-card-hover: var(--bg3);
    --border-color: var(--border);
    --text-primary: var(--text);
    --text-secondary: var(--muted);
    --accent-blue: var(--accent);
    --accent-purple: #6366F1;
    --accent-gradient: var(--accent-g);
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--body);
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}

h1, h2, h3, h4, h5 {
    font-family: var(--heading);
    letter-spacing: -0.02em;
}

/* ── GLASS UTILITY ── */
.glass {
    background: var(--bg2);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius-lg);
}

/* ── LOGIN PAGE ── */
.login-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #EEF3FF 0%, #F0F9FF 50%, #F7F8FA 100%);
}

.login-orb-1, .login-orb-2 {
    position: absolute;
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
}
.login-orb-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(37,99,235,0.10) 0%, transparent 70%);
    top: -100px;
    left: -100px;
    animation: float 10s ease-in-out infinite alternate;
}
.login-orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(14,165,233,0.08) 0%, transparent 70%);
    bottom: -150px;
    right: -150px;
    animation: float 12s ease-in-out infinite alternate-reverse;
}

@keyframes float {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(20px) scale(1.05); }
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 44px;
    z-index: 10;
    text-align: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
    font-family: var(--heading);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
}

.logo-mark {
    width: 32px;
    height: 32px;
    background: var(--accent-g);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    flex-shrink: 0;
}

.icon-gradient {
    background: var(--accent-g);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ── FORMS ── */
.form-group {
    margin-bottom: 18px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    color: var(--text2);
    margin-bottom: 7px;
    font-weight: 600;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: #fff;
    border: 1.5px solid var(--border2);
    border-radius: 10px;
    color: var(--text);
    font-family: var(--body);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    outline: none;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input::placeholder {
    color: var(--muted2);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: var(--body);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(37, 99, 235, 0.38);
}

.error-message {
    color: #dc2626;
    background: #FEF2F2;
    padding: 11px 14px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 0.85rem;
    border: 1px solid #FECACA;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: #fff;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    font-family: var(--heading);
    font-size: 1.15rem;
    font-weight: 800;
    margin-bottom: 36px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    letter-spacing: -0.03em;
    padding: 0 8px;
}

.nav-section {
    margin-bottom: 22px;
}

.nav-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    color: var(--muted2);
    letter-spacing: 0.1em;
    margin-bottom: 10px;
    font-weight: 700;
    padding: 0 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 3px;
    transition: all 0.18s;
}

.nav-link:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-link.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
    border: 1px solid rgba(37, 99, 235, 0.15);
}

.nav-link i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

/* ── MAIN CONTENT ── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px 36px;
    width: calc(100% - var(--sidebar-width));
    background: var(--bg);
    min-height: 100vh;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-title h1 {
    font-family: var(--heading);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

.page-title p {
    color: var(--muted);
    font-size: 0.875rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-secondary {
    padding: 10px 18px;
    background: #fff;
    border: 1.5px solid var(--border2);
    color: var(--text2);
    border-radius: 10px;
    font-family: var(--body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

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

.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    overflow: hidden;
    transition: all 0.25s;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-g);
    opacity: 0;
    transition: opacity 0.3s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border2);
    transform: translateY(-2px);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card.blue::before { background: var(--accent-g); opacity: 1; }
.stat-card.purple::before { background: linear-gradient(90deg, #6366F1, #8B5CF6); opacity: 1; }
.stat-card.green::before { background: linear-gradient(90deg, #10b981, #34d399); opacity: 1; }
.stat-card.orange::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); opacity: 1; }

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.stat-icon {
    font-size: 18px;
    color: var(--muted2);
}

.stat-value {
    font-family: var(--heading);
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
}

.stat-subtitle {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 500;
}

/* ── CHART CARDS ── */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 28px;
}

.chart-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    min-height: 350px;
    display: flex;
    flex-direction: column;
    transition: all 0.25s;
}

.chart-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--border2);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.chart-title {
    font-family: var(--heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.chart-body {
    flex: 1;
    position: relative;
    width: 100%;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--muted);
    gap: 10px;
    font-size: 0.875rem;
}

.empty-state i {
    font-size: 28px;
    color: var(--muted2);
}

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

table thead th {
    background: var(--bg);
    padding: 13px 18px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    text-align: left;
}

table tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--text2);
    vertical-align: middle;
}

table tbody tr:hover td {
    background: var(--bg);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* ── BADGES & TAGS ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 4px 10px;
    border-radius: 100px;
}

.badge-blue { background: var(--accent-light); color: var(--accent); }
.badge-green { background: #F0FDF4; color: #16a34a; }
.badge-orange { background: #FFFBEB; color: #d97706; }

/* ── SETTINGS PAGE CARDS ── */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.settings-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: all 0.25s;
}

.settings-card:hover {
    box-shadow: var(--shadow);
}

.settings-card-title {
    font-family: var(--heading);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    letter-spacing: -0.02em;
}

.settings-card-title i {
    color: var(--accent);
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.info-label {
    color: var(--muted);
    font-size: 0.85rem;
}

.info-value {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text);
}

.success-msg {
    color: #16a34a;
    background: #F0FDF4;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 0.85rem;
    border: 1px solid #BBF7D0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── MODALS ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 23, 0.5);
    backdrop-filter: blur(6px);
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
}

/* ── LINKS TABLE WRAPPER ── */
.links-table-wrap {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

/* ── PAGINATION ── */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1.5px solid var(--border2);
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text2);
    transition: all 0.2s;
}

.pagination a:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.pagination .current {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ── COPY BUTTON ── */
.btn-copy {
    padding: 6px 12px;
    background: var(--accent-light);
    border: 1px solid rgba(37,99,235,0.18);
    color: var(--accent);
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}

/* ── ANALYTICS SPECIFIC ── */
.analytics-header {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

/* ── TOAST NOTIFICATION ── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text);
    color: #fff;
    padding: 14px 22px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.35s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* ── MOBILE TOGGLE ── */
.mobile-toggle {
    display: none;
    font-size: 20px;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text);
    padding: 6px;
}

/* ── RESPONSIVE BREAKPOINTS ── */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 20px 16px;
    }
    .mobile-toggle {
        display: block;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
}
