/* Analytics Dashboard theme — local assets only (Figma: Analytics Dashboard) */
:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-muted: #f9fafb;
    --border: #e5e7eb;
    --border-light: #f0f2f5;
    --text: #111827;
    --text-secondary: #374151;
    --muted: #6b7280;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-soft: #eff6ff;
    --primary-border: #bfdbfe;
    --success: #10b981;
    --success-soft: #ecfdf5;
    --success-text: #047857;
    --danger: #ef4444;
    --danger-soft: #fef2f2;
    --danger-text: #b91c1c;
    --warning: #f59e0b;
    --warning-soft: #fffbeb;
    --info: #6366f1;
    --info-soft: #eef2ff;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(16, 24, 40, 0.08), 0 4px 6px -4px rgba(16, 24, 40, 0.05);
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --sidebar-width: 260px;
    --sidebar-width-compact: 72px;
    --header-height: 72px;
    --transition: 150ms ease;
}

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

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }

h1, h2, h3, h4, h5 { color: var(--text); font-weight: 600; line-height: 1.3; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; margin-bottom: .75rem; }
h4 { font-size: .95rem; margin-bottom: .5rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: .875rem;
    font-weight: 500;
    line-height: 1.25;
    transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
    white-space: nowrap;
}
.btn:hover { background: var(--surface-muted); border-color: #d1d5db; color: var(--text); text-decoration: none; }
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #059669; border-color: #059669; color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-muted); color: var(--text); }
.btn-sm { padding: .35rem .65rem; font-size: .8rem; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    padding: 0;
    font-weight: 500;
}
.btn-link:hover { color: var(--primary-hover); text-decoration: underline; }

/* Forms */
.form-group { margin-bottom: 1.125rem; }
.form-group label {
    display: block;
    margin-bottom: .4rem;
    font-weight: 500;
    font-size: .875rem;
    color: var(--text-secondary);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .625rem .875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: .9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: #9ca3af; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.25rem; }
.checkbox-inline {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    margin: .4rem 0;
    font-size: .875rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.checkbox-inline input { width: auto; margin-top: .15rem; }

/* Alerts */
.alert {
    display: flex;
    align-items: flex-start;
    gap: .625rem;
    padding: .875rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .875rem;
    font-weight: 500;
}
.alert-success { background: var(--success-soft); color: var(--success-text); border: 1px solid #a7f3d0; }
.alert-error { background: var(--danger-soft); color: var(--danger-text); border: 1px solid #fecaca; }

/* Cards & panels */
.card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}
.card h3 { margin-bottom: 1.25rem; font-size: 1.125rem; }
.form-card { max-width: 640px; }
.panel {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}
.panel__title { font-size: .95rem; font-weight: 600; color: var(--text); }
.panel__body { padding: 0; }
.panel__body--padded { padding: 1.25rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}
.table th,
.table td {
    padding: .875rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.table th {
    background: var(--surface-muted);
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }
.table-sm th, .table-sm td { padding: .625rem 1rem; font-size: .85rem; }
.table .actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.table .actions a { font-weight: 500; font-size: .875rem; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    background: #f3f4f6;
    color: var(--muted);
}
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warning { background: var(--warning-soft); color: #b45309; }
.badge-info { background: var(--info-soft); color: #4338ca; }
.badge-draft { background: #f3f4f6; color: var(--muted); }

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.toolbar__left, .toolbar__right { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* KPI / stat cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}
.kpi-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition), transform var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); }
.kpi-card__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    font-size: 1.35rem;
    flex-shrink: 0;
}
.kpi-card__icon--blue { background: var(--primary-soft); color: var(--primary); }
.kpi-card__icon--green { background: var(--success-soft); color: var(--success); }
.kpi-card__icon--purple { background: var(--info-soft); color: var(--info); }
.kpi-card__icon--orange { background: var(--warning-soft); color: var(--warning); }
.kpi-card__label {
    font-size: .8rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: .25rem;
}
.kpi-card__value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    letter-spacing: -0.02em;
}
.kpi-card__trend {
    font-size: .8rem;
    font-weight: 500;
    color: var(--success);
    margin-top: .25rem;
}

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1.25rem; }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}
.stat-label { font-size: .8rem; font-weight: 500; color: var(--muted); }
.stat-value { font-size: 1.75rem; font-weight: 700; margin-top: .25rem; color: var(--text); }

/* Lists */
.link-list { list-style: none; }
.link-list li { border-bottom: 1px solid var(--border-light); }
.link-list li:last-child { border-bottom: none; }
.link-list a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .875rem 0;
    color: var(--text-secondary);
    font-weight: 500;
}
.link-list a:hover { color: var(--primary); text-decoration: none; }
.link-list a i { color: var(--muted); font-size: 1.1rem; }

/* Misc */
.inline-form { display: inline; }
.mt-4 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.permission-grid {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border);
    padding: .875rem;
    border-radius: var(--radius);
    background: var(--surface-muted);
}
.permission-list { list-style: none; }
.permission-list li { padding: .35rem 0; font-size: .875rem; color: var(--text-secondary); }
.permission-list h4 {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    margin: 1rem 0 .5rem;
}
.permission-list h4:first-child { margin-top: 0; }
code {
    background: #f3f4f6;
    padding: .15rem .4rem;
    border-radius: 4px;
    font-size: .8em;
    color: #4b5563;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

/* Pagination */
.pagination { display: flex; gap: .35rem; margin-top: 1.25rem; flex-wrap: wrap; }
.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: .875rem;
    background: var(--surface);
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pagination a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}
.modal.open { display: flex; }
.modal-content {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    min-width: 360px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
}
.modal-content h3 { margin-bottom: 1.25rem; }

/* Auth (guest layout) */
.guest-layout { min-height: 100vh; background: var(--bg); }
.auth-shell {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
}
.auth-showcase {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.5rem;
    background: linear-gradient(145deg, #1e3a5f 0%, #2563eb 55%, #3b82f6 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}
.auth-showcase::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(255,255,255,.12) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255,255,255,.08) 0%, transparent 40%);
    pointer-events: none;
}
.auth-showcase > * { position: relative; z-index: 1; }
.auth-showcase__brand { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
.auth-showcase__tagline { font-size: 1.75rem; font-weight: 700; line-height: 1.25; margin-top: 3rem; max-width: 360px; }
.auth-showcase__desc { margin-top: 1rem; opacity: .85; max-width: 340px; line-height: 1.6; }
.auth-showcase__kpis {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: auto;
}
.auth-kpi {
    background: rgba(255,255,255,.12);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: var(--radius);
    padding: 1rem;
}
.auth-kpi__value { font-size: 1.5rem; font-weight: 700; }
.auth-kpi__label { font-size: .8rem; opacity: .8; margin-top: .15rem; }
.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.guest-main { width: 100%; max-width: 400px; }
.auth-card {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}
.auth-card h2 { margin-bottom: .35rem; font-size: 1.5rem; }
.auth-card__subtitle { color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }
.auth-links { margin-top: 1.25rem; text-align: center; font-size: .875rem; color: var(--muted); }

@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-showcase { display: none; }
    .auth-panel { min-height: 100vh; }
}

@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
}
