/**
 * AI Visibility Tracker — App CSS
 * Lightweight design inspired by SEO Toolkit (Tailwind-like)
 * Nahrazuje: frontend.css, inline styles
 */

/* ==================== DESIGN TOKENS ==================== */
:root {
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-dark: #3730a3;
    --primary-bg: #eef2ff;
    --accent: #8b5cf6;
    --success: #059669;
    --success-bg: #dcfce7;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --info: #0891b2;
    --info-bg: #ecfeff;

    --bg: #ffffff;
    --bg-card: #ffffff;
    --border: #edf0f2;
    --border-light: #f5f6f8;
    --text: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --text-light: #6b7280;

    --sidebar-width: 224px;
    --sidebar-collapsed: 56px;
    --header-height: 56px;

    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --transition: all 0.15s ease;
}

/* ==================== BASE ==================== */
* { font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif; }

body {
    background: var(--bg);
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.5;
    min-height: 100vh;
}

h1, .h1 { font-size: 1.5rem; font-weight: 700; color: var(--text); }
h2, .h2 { font-size: 1.25rem; font-weight: 600; }
h3, .h3 { font-size: 1.0625rem; font-weight: 600; }
h4, .h4 { font-size: 0.9375rem; font-weight: 600; }
h5, .h5 { font-size: 0.875rem; font-weight: 600; }
h6, .h6 { font-size: 0.8125rem; font-weight: 600; }

code, .mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 0.85em; }

/* ==================== LAYOUT ==================== */
.app-layout { display: flex; min-height: 100vh; overflow-x: hidden; }

/* ── Sidebar ── */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}
.app-sidebar .sidebar-nav-area {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}
.app-sidebar .sidebar-nav-area::-webkit-scrollbar { width: 3px; }
.app-sidebar .sidebar-nav-area::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1rem;
    height: var(--header-height);
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    z-index: 1040;
}

.sidebar-brand i { font-size: 1.125rem; flex-shrink: 0; }
.sidebar-brand:hover { color: var(--primary-dark); }

.sidebar-section { padding: 0.25rem 0 0; }

.sidebar-heading {
    padding: 0.75rem 1rem 0.375rem;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    white-space: nowrap;
}

.sidebar-section:first-child .sidebar-heading { padding-top: 0.5rem; }

.sidebar-nav { list-style: none; padding: 0 0.5rem; margin: 0; }

.sidebar-nav li a,
.sidebar-nav li button {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    border-radius: var(--radius);
}

.sidebar-nav li a i,
.sidebar-nav li button i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav li a:hover,
.sidebar-nav li button:hover {
    color: var(--text);
    background: var(--border-light);
}

.sidebar-nav li a.active,
.sidebar-nav li button.active {
    color: #fff;
    background: var(--primary);
    font-weight: 600;
}

.sidebar-nav li a.active i,
.sidebar-nav li button.active i { color: #fff; }

.sidebar-nav .badge {
    margin-left: auto;
    font-size: 0.625rem;
    padding: 0.15em 0.45em;
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0.75rem;
}

.sidebar-footer {
    flex-shrink: 0;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border);
}

.sidebar-user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.625rem;
    flex-shrink: 0;
}

.sidebar-user-name {
    color: var(--text-muted);
}

/* ── Header ── */
.app-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 1020;
    gap: 0.75rem;
}

.app-header .breadcrumb { margin: 0; font-size: 0.8125rem; }
.app-header .breadcrumb-item a { color: var(--text-muted); text-decoration: none; }
.app-header .breadcrumb-item.active { color: var(--text); font-weight: 600; }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }

/* Header with filters (frontend) — taller, wrappable */
.app-header-filters {
    height: auto;
    min-height: var(--header-height);
    padding: 0.5rem 1.25rem;
    flex-wrap: wrap;
}

/* Global filter bar — right-aligned controls */
.global-filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    flex-shrink: 0;
}

.global-filters .filter-group {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.global-filters .filter-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.global-filters .form-select-sm {
    min-width: 120px;
    font-size: 0.8125rem;
    border-color: var(--border);
    background-color: #fff;
}

/* Period toggle buttons (Daily/Weekly/Monthly style) */
.period-toggle {
    display: flex;
    align-items: center;
    gap: 0;
    background: #f5f6f8;
    border-radius: 6px;
    padding: 2px;
}

.period-toggle .period-btn {
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.period-toggle .period-btn:hover {
    color: var(--text);
}

.period-toggle .period-btn.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    font-weight: 600;
}

.period-toggle .period-btn:hover:not(.active) {
    background: rgba(255,255,255,0.6);
    color: var(--text);
}

/* Domain favicon */
.domain-favicon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 4px;
    flex-shrink: 0;
}

/* Citation type bar */
.citation-type-bar {
    display: flex;
    height: 24px;
    border-radius: 12px;
    overflow: hidden;
    background: #f5f6f8;
}

.citation-type-bar .bar-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    min-width: 4px;
    transition: width 0.3s ease;
}

.citation-type-bar .bar-web { background: #3b82f6; }
.citation-type-bar .bar-social { background: #a3e635; }
.citation-type-bar .bar-video { background: #ef4444; }
.citation-type-bar .bar-other { background: #d1d5db; }

.citation-type-legend {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: center;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.citation-type-legend .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

/* Section title with info icon — Chatbeat style */
.section-title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 1rem;
}

.section-title .info-icon {
    width: 16px;
    height: 16px;
    border: 1px solid var(--border);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    color: var(--text-muted);
    cursor: help;
}

/* Sources: flat URL list with coverage */
.source-url-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.1s;
}

.source-url-row:hover { background: #fafbfc; }

.source-url-row .source-rank {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    min-width: 32px;
}

.source-url-row .source-url-text {
    flex: 1;
    min-width: 0;
    font-size: 0.8125rem;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.source-url-row .source-url-text:hover { color: var(--primary); }

.source-url-row .source-models {
    display: flex;
    gap: 0.25rem;
}

.source-url-row .source-coverage {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    min-width: 48px;
    text-align: right;
}

/* Domain filter dropdown — Chatbeat style */
.domain-filter-select {
    min-width: 160px;
}

@media (max-width: 767.98px) {
    .global-filters { margin-left: 0; width: 100%; justify-content: flex-start; flex-wrap: wrap; }
    .period-toggle .period-btn { padding: 0.15rem 0.45rem; font-size: 0.7rem; }
}

/* ── Main ── */
.app-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding-top: var(--header-height);
    transition: var(--transition);
    overflow-x: hidden;
}

.app-content { padding: 1.5rem 2rem; }

/* ── Mobile toggle ── */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.25rem;
    padding: 0.25rem;
    cursor: pointer;
    flex-shrink: 0;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 1025;
}

/* ==================== CARDS ==================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    font-weight: 600;
    font-size: 0.8125rem;
    padding: 0.5rem 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.card-body { padding: 1.25rem; }

/* KPI Stat Cards — clean, compact */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.stat-card:hover { border-color: #d1d5db; }

.stat-label {
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 500;
    margin-bottom: 0.125rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.15;
    letter-spacing: -0.025em;
}

.stat-card .trend-badge { margin-top: 0.25rem; }
.stat-card .mt-2 { margin-top: 0.25rem !important; }

/* KPI Strip — compact horizontal metrics row */
.kpi-strip {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0;
    margin-bottom: 1rem;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.kpi-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 0.75rem 1rem;
    min-width: 0;
    flex: 1 1 0;
    border-right: 1px solid var(--border-light);
    gap: 1px;
}

.kpi-item:last-child { border-right: none; }

.kpi-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-light);
    white-space: nowrap;
    line-height: 1.2;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.kpi-value small {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--text-light);
    letter-spacing: 0.02em;
}

.kpi-meta {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.kpi-item .trend-badge {
    margin-top: 2px;
    font-size: 0.6875rem;
    padding: 1px 6px;
}

.kpi-sep {
    width: 1px;
    background: var(--border);
    flex-shrink: 0;
    margin: 0.5rem 0;
}

.kpi-provider {
    text-decoration: none;
    color: inherit;
    border-left: 3px solid transparent;
    padding-left: 0.75rem;
    transition: background 0.12s ease;
}

.kpi-provider:hover { background: var(--border-light); color: inherit; }

/* Mobile: kpi-strip wraps */
@media (max-width: 767.98px) {
    .kpi-strip { flex-wrap: wrap; }
    .kpi-item { flex: 1 1 calc(50% - 1px); min-width: 120px; }
    .kpi-sep { width: 100%; height: 1px; margin: 0; }
}

/* Trend badges */
.trend-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
}

.trend-up { background: #dcfce7; color: #166534; }
.trend-down { background: #fee2e2; color: #991b1b; }
.trend-stable { background: #f3f4f6; color: #4b5563; }

/* ==================== WVI METRICS STRIP ==================== */
.wvi-metrics-strip {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    overflow-x: auto;
}
.wvi-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.5rem 0.75rem;
    flex: 1 1 0;
    min-width: 0;
    border-right: 1px solid var(--border-light);
}
.wvi-metric:last-child { border-right: none; }
.wvi-metric-main { flex: 1.3 1 0; }
.wvi-on-target { background: rgba(22,163,74,0.04); }
.wvi-metric-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-light);
    white-space: nowrap;
    line-height: 1.2;
}
.wvi-metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.02em;
}
.wvi-metric-sub {
    font-size: 0.6rem;
    color: var(--text-muted);
}
.wvi-target-bar { width: 100%; max-width: 100px; margin-top: 2px; }
.wvi-target-bar span { font-size: 0.58rem; color: var(--text-muted); }
@media (max-width: 767.98px) {
    .wvi-metrics-strip { flex-wrap: wrap; }
    .wvi-metric { flex: 1 1 calc(33.33% - 1px); min-width: 80px; }
}

/* ==================== KW SUGGESTION CARDS ==================== */
.kw-sug-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.375rem;
}
@media (max-width: 991.98px) { .kw-sug-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 575.98px) { .kw-sug-grid { grid-template-columns: 1fr; } }
.kw-sug-card {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg-card);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.kw-sug-card:hover { border-color: var(--primary); box-shadow: 0 1px 4px rgba(79,70,229,0.08); }
.kw-sug-hot { border-left: 3px solid #f59e0b; background: rgba(245,158,11,0.03); }
.kw-sug-card-top {
    display: flex;
    align-items: center;
    gap: 4px;
}
.kw-sug-query {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    min-width: 0;
    word-break: break-word;
}
.kw-sug-add {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid #059669;
    color: #059669;
    font-size: 0.75rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.kw-sug-add:hover { background: #059669; color: #fff; }
.kw-sug-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--text-light);
}
.kw-sug-score {
    flex: 1;
    max-width: 60px;
    height: 4px;
    background: #f1f5f9;
    border-radius: 2px;
    overflow: hidden;
}
.kw-sug-score > div {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
}

/* ==================== TABLES ==================== */
.table {
    color: var(--text);
    margin-bottom: 0;
    font-size: 0.82rem;
    line-height: 1.4;
}

.table th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0.625rem 0.75rem;
    white-space: nowrap;
}

.table td {
    border: none;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    padding: 0.625rem 0.75rem;
}

/* Kompaktní tabulka — konzistentní styl všude */
.table.table-sm th { padding: 0.5rem 0.625rem; }
.table.table-sm td { padding: 0.5rem 0.625rem; }

.table-hover tbody tr:hover { background: #f9fafb; }

.table tr.own-domain td { background: var(--primary-bg) !important; font-weight: 500; }

.table-responsive { border-radius: var(--radius); overflow: hidden; }

/* ==================== FORMS ==================== */
.form-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.8125rem;
    margin-bottom: 0.375rem;
}

.form-select, .form-control {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-select:focus, .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.form-select-sm, .form-control-sm {
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
}

.form-check-label { color: var(--text); font-weight: 500; font-size: 0.875rem; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }

/* ==================== BUTTONS ==================== */
.btn { font-size: 0.875rem; padding: 0.5rem 1rem; border-radius: var(--radius); font-weight: 500; }
.btn-sm { font-size: 0.8125rem; padding: 0.375rem 0.75rem; }
.btn-primary { background: var(--primary); border: none; color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-outline-secondary { color: var(--text-muted); border-color: var(--border); }
.btn-outline-secondary:hover { background: #f3f4f6; color: var(--text); }

/* ==================== BADGES ==================== */
.badge { font-size: 0.6875rem; padding: 0.125rem 0.5rem; font-weight: 600; border-radius: 9999px; }
.badge.bg-success { background: #059669 !important; }
.badge.bg-primary { background: var(--primary) !important; }
.badge.bg-warning { background: #d97706 !important; color: #fff !important; }
.badge.bg-danger { background: #dc2626 !important; }
.badge.bg-info { background: #0891b2 !important; }
.badge.bg-secondary { background: #6b7280 !important; }

/* ==================== ALERTS ==================== */
.alert { font-size: 0.875rem; padding: 0.75rem 1rem; border-radius: var(--radius-lg); }
.alert-danger { background: #fef2f2 !important; border: 1px solid #fecaca !important; color: #991b1b !important; }
.alert-info { background: #eff6ff !important; border: 1px solid #bfdbfe !important; color: #1e40af !important; }
.alert-success { background: #f0fdf4 !important; border: 1px solid #bbf7d0 !important; color: #166534 !important; }
.alert-warning { background: #fffbeb !important; border: 1px solid #fde68a !important; color: #92400e !important; }

/* ==================== TEXT ==================== */
.text-muted { color: var(--text-muted) !important; }
.text-success { color: #059669 !important; }
.text-danger { color: #dc2626 !important; }
.text-warning { color: #d97706 !important; }
.text-primary { color: var(--primary) !important; }
.text-info { color: #0891b2 !important; }
small.text-muted { color: #6b7280 !important; }

/* ==================== UTILITIES ==================== */
code { color: #374151; background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 0.8em; }
.fw-medium { font-weight: 500; }
.progress { background: #e5e7eb; border-radius: var(--radius); height: 6px; }
.progress-bar { background: linear-gradient(90deg, var(--primary), var(--success)); }
.row.g-4 { --bs-gutter-y: 1rem; --bs-gutter-x: 1rem; }
.row.g-3 { --bs-gutter-y: 0.75rem; --bs-gutter-x: 0.75rem; }

/* ==================== DASHBOARD ==================== */

/* AI Provider Cards (OpenAI, Gemini etc.) */
.ai-provider-card { transition: var(--transition); border-radius: var(--radius) !important; overflow: hidden; }
.ai-provider-card .card-header { border-bottom: none; padding: 0.375rem 0.75rem; font-size: 0.75rem; text-transform: none; letter-spacing: 0; color: #fff; }
.ai-provider-card .card-body { padding: 0.625rem 0.75rem; }
.ai-provider-card .card-body .h5 { font-size: 0.8125rem !important; }
.ai-provider-card .card-body small { font-size: 0.625rem; }
.ai-provider-card .progress { height: 4px; margin-top: 0.375rem; }
.ai-provider-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }

/* Viewport-fit overview layout */
.overview-viewport {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--header-height) - 2rem);
}
.overview-viewport > .row:first-child {
    flex: 1 1 0;
    min-height: 0;
}
.overview-viewport > .row:last-child {
    flex: 0 0 auto;
}
.overview-viewport .chart-canvas-wrap {
    position: relative;
    height: clamp(180px, calc(45vh - 80px), 500px);
}
.overview-viewport .chart-canvas-wrap-sm {
    position: relative;
    height: clamp(120px, calc(25vh - 20px), 300px);
}
.overview-viewport .chart-canvas-wrap-pie {
    position: relative;
    height: clamp(140px, calc(25vh - 20px), 260px);
}

/* Chart container */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.chart-container h5 { color: var(--text); font-weight: 600; font-size: 1rem; margin-bottom: 0.375rem !important; }
.chart-container h5 i { margin-right: 0.2rem; }

/* Heatmap */
.heatmap-cell { display: inline-flex; min-width: 48px; height: 24px; border-radius: 4px; align-items: center; justify-content: center; font-weight: 600; font-size: 0.6875rem; padding: 0 6px; }
.heat-0 { background: #fee2e2; color: #991b1b; }
.heat-1 { background: #fef3c7; color: #92400e; }
.heat-2 { background: #fef9c3; color: #854d0e; }
.heat-3 { background: #ecfccb; color: #3f6212; }
.heat-4 { background: #dcfce7; color: #166534; }

/* Domain pills */
.domain-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; }
.domain-pill.own { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.domain-pill.competitor { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* Gap cards */
.gap-card { background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius-lg); padding: 0.75rem; }
.gap-score { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8125rem; }
.gap-critical { background: #fee2e2; color: #991b1b; }
.gap-moderate { background: #fef3c7; color: #92400e; }
.gap-minor { background: #ecfccb; color: #3f6212; }

/* Filter card */
.filter-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.75rem 1rem; }
.filter-card label { color: var(--text-muted); font-weight: 500; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.03em; }

/* Tab navigation (pills) */
.nav-tabs-custom { border: none; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; margin-bottom: 1rem; }
.nav-tabs-custom .nav-link { border: none; border-radius: 6px; color: var(--text-muted); padding: 0.375rem 0.875rem; font-weight: 500; font-size: 0.875rem; transition: var(--transition); }
.nav-tabs-custom .nav-link:hover { color: var(--text); background: #f3f4f6; }
.nav-tabs-custom .nav-link.active { background: var(--primary); color: #fff; }

/* Domain legend */
.domain-legend-btn { font-size: 0.75rem; padding: 0.25rem 0.5rem; transition: var(--transition); }
.domain-legend-btn.active { font-weight: 600; }

/* Keyword detail rows */
.keyword-detail-row:hover { background: #f9fafb !important; }
.keyword-detail-row:hover i.bi-chevron-right { opacity: 1 !important; color: var(--primary) !important; }

/* Competitor checkboxes */
.competitor-check .form-check-input:checked { border-color: currentColor; }

/* Suggestion card */
.suggestion-card { background: var(--primary-bg); border: 1px dashed var(--primary-light); border-radius: var(--radius); padding: 0.625rem 0.875rem; font-size: 0.875rem; }

/* ==================== ADMIN ==================== */
.admin-nav { background: white; border-bottom: 1px solid var(--border); }
.admin-nav .nav-link { color: var(--text-muted); padding: 0.625rem 1rem; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; font-size: 0.875rem; transition: var(--transition); }
.admin-nav .nav-link:hover { color: var(--primary); }
.admin-nav .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.admin-nav .nav-link i { margin-right: 0.375rem; }
.admin-nav .dropdown-menu { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,0.08); padding: 0.375rem; min-width: 180px; z-index: 1050; background: white; }
.admin-nav .dropdown-menu.show { display: block; }
.admin-nav .dropdown-item { padding: 0.5rem 0.75rem; border-radius: 6px; font-size: 0.875rem; color: var(--text); display: block; text-decoration: none; }
.admin-nav .dropdown-item:hover { background: #f3f4f6; color: var(--primary); }
.admin-nav .dropdown-item.active { background: var(--primary); color: white; }
.admin-nav .dropdown-item i { margin-right: 0.375rem; width: 16px; }

/* Navbar dropdown */
.navbar .dropdown-menu { background: white; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,0.08); padding: 0.375rem; min-width: 160px; }
.navbar .dropdown-item { padding: 0.5rem 0.75rem; border-radius: 6px; color: var(--text); font-size: 0.875rem; }
.navbar .dropdown-item:hover { background: #f3f4f6; color: var(--primary); }
.navbar .dropdown-item.active { background: var(--primary); color: white; }
.navbar .dropdown-item i { margin-right: 0.375rem; }

/* ==================== LOGIN ==================== */
.login-body {
    min-height: 100vh;
    margin: 0;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-wrapper { width: 100%; max-width: 400px; padding: 1.5rem; }
.login-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem 2rem 2rem;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}
.login-brand { text-align: center; margin-bottom: 2rem; }
.login-logo { margin-bottom: 0.75rem; }
.login-logo svg { width: 44px; height: 44px; filter: drop-shadow(0 2px 8px rgba(99,102,241,0.25)); }
.login-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.25rem;
    letter-spacing: -0.02em;
}
.login-subtitle { color: var(--text-muted); font-size: 0.85rem; margin: 0; }
.login-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 0.625rem 0.875rem;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
}
.login-error i { margin-right: 0.375rem; }
.login-field { margin-bottom: 1.25rem; }
.login-field label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.login-input-wrap i {
    position: absolute;
    left: 0.875rem;
    color: #9ca3af;
    font-size: 1rem;
    pointer-events: none;
    transition: color 0.2s;
}
.login-input-wrap input {
    width: 100%;
    padding: 0.7rem 0.875rem 0.7rem 2.5rem;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    outline: none;
}
.login-input-wrap input::placeholder { color: #9ca3af; }
.login-input-wrap input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.login-input-wrap:focus-within i { color: var(--primary); }
.login-btn {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(99,102,241,0.3); }
.login-btn:active { transform: translateY(0); }
.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.login-footer a { color: var(--text-muted); font-size: 0.8rem; text-decoration: none; transition: color 0.2s; }
.login-footer a:hover { color: var(--primary); }
.login-lang {
    display: flex;
    gap: 2px;
    background: #f3f4f6;
    border-radius: 6px;
    padding: 2px;
}
.login-lang a {
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}
.login-lang a.active {
    background: var(--primary);
    color: #fff !important;
}

/* ==================== OLD NAVBAR (compat) ==================== */
.navbar { background: var(--primary); padding: 0.5rem 0; }
.navbar-brand { font-weight: 700; color: #fff !important; font-size: 1rem; }
.navbar-brand i { margin-right: 0.375rem; }
.navbar .nav-link { color: rgba(255,255,255,0.8) !important; padding: 0.5rem 0.75rem; border-radius: var(--radius); transition: var(--transition); font-weight: 500; font-size: 0.875rem; }
.navbar .nav-link i { margin-right: 0.25rem; }
.navbar .nav-link:hover { color: #fff !important; background: rgba(255,255,255,0.15); }
.navbar .nav-link.active { color: #fff !important; background: rgba(255,255,255,0.25); }

/* ==================== COMPACT UTILITIES ==================== */

/* Extra small button — sidebar controls, inline mini-actions */
.btn-xs { font-size: 0.7rem; line-height: 1; padding: 0.2rem 0.4rem; }

/* Scrollable table wrapper */
.table-scroll { max-height: 400px; overflow-y: auto; }
.table-scroll-lg { max-height: 70vh; overflow-y: auto; }

/* Compact row spacing for dashboard overview */
.row.g-compact { --bs-gutter-y: 0.5rem; --bs-gutter-x: 0.625rem; }

/* ==================== RESPONSIVE ==================== */

/* Mobile */
@media (max-width: 767.98px) {
    .sidebar-brand { display: none; }
    .app-sidebar { transform: translateX(-100%); top: 0; background: var(--bg-card); }
    .app-sidebar.show { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; }
    .app-main { margin-left: 0; }
    .app-header { left: 0; }
    .sidebar-toggle { display: block; }
    .app-content { padding: 0.75rem; }
    .stat-value { font-size: 1.5rem; }

    /* Compact tables on mobile */
    .table { font-size: 0.73rem; }
    .table th { font-size: 0.63rem; padding: 0.25rem 0.35rem; }
    .table td { padding: 0.25rem 0.35rem; }
    .table.table-sm th { padding: 0.2rem 0.3rem; }
    .table.table-sm td { padding: 0.2rem 0.3rem; }

    /* Hide low-priority columns on small screens */
    .table .d-mobile-none { display: none !important; }

    /* Badges smaller */
    .badge { font-size: 0.6rem; padding: 0.1rem 0.35rem; }
    .btn-sm { font-size: 0.7rem; padding: 0.25rem 0.5rem; }

    /* Charts smaller */
    .chart-container { padding: 0.75rem; }

    /* Cards stack tighter */
    .chart-container.mt-4 { margin-top: 1rem !important; }

    /* Table horizontal scroll hint */
    .table-responsive { -webkit-overflow-scrolling: touch; }
    .table-responsive::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 20px;
        background: linear-gradient(to right, transparent, rgba(255,255,255,0.8));
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s;
    }
    .table-responsive.is-scrollable::after { opacity: 1; }

    /* Filter form on mobile */
    .app-header .d-flex { gap: 0.25rem !important; }
    .app-header .form-select-sm { font-size: 0.75rem; padding: 0.25rem 0.5rem; }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .app-sidebar { width: var(--sidebar-collapsed); top: var(--header-height); }
    .sidebar-brand { width: var(--sidebar-collapsed); justify-content: center; padding: 0 0.5rem; }
    .sidebar-brand span { display: none; }
    .app-sidebar .sidebar-heading,
    .app-sidebar .sidebar-nav li a span,
    .app-sidebar .sidebar-nav li button span { display: none; }
    .app-sidebar .sidebar-nav { padding: 0 0.25rem; }
    .app-sidebar .sidebar-nav li a,
    .app-sidebar .sidebar-nav li button { justify-content: center; padding: 0.5rem; }
    /* Tooltip on hover */
    .app-sidebar .sidebar-nav li { position: relative; }
    .app-sidebar .sidebar-nav li a::after,
    .app-sidebar .sidebar-nav li button::after {
        content: attr(title);
        position: absolute;
        left: calc(var(--sidebar-collapsed) - 4px);
        top: 50%;
        transform: translateY(-50%);
        background: var(--text);
        color: #fff;
        padding: 4px 10px;
        border-radius: 6px;
        font-size: 0.75rem;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.15s;
        z-index: 1060;
    }
    .app-sidebar .sidebar-nav li a:hover::after,
    .app-sidebar .sidebar-nav li button:hover::after { opacity: 1; }
    .app-main { margin-left: var(--sidebar-collapsed); }
    .app-header { left: var(--sidebar-collapsed); }
    .app-sidebar .sidebar-user-name { display: none; }
    .app-sidebar .sidebar-footer { padding: 0.5rem 0.375rem; }
    .app-sidebar .sidebar-footer .d-flex { justify-content: center; }
    .sidebar-divider { margin: 0.375rem 0.5rem; }
}

/* Desktop */
@media (min-width: 1200px) {
    .app-sidebar { width: var(--sidebar-width); }
    .app-main { margin-left: var(--sidebar-width); }
    .app-header { left: var(--sidebar-width); }
    .sidebar-brand { width: var(--sidebar-width); }
}

/* ==================== PRINT ==================== */
@media print {
    .app-sidebar, .app-header, .sidebar-toggle, .sidebar-backdrop, .sidebar-brand { display: none !important; }
    .app-main { margin-left: 0 !important; padding-top: 0 !important; }
}
