/* ==========================================================================
   Klickstar TrafficPro – Stylesheet
   Farben aus dem Klickstar-Logo: Teal #00B08C, Navy #00101F
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@500;600;700&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=JetBrains+Mono:wght@500;600&display=swap');

:root {
    --brand: #00B08C;
    --brand-600: #009475;
    --brand-700: #007A61;
    --brand-100: #D5F3EA;
    --brand-50: #EDFAF5;
    --navy: #00101F;
    --navy-800: #0B1B2E;
    --navy-700: #182B41;
    --navy-500: #3F5066;
    --ink: #0B1B2E;
    --muted: #64748B;
    --muted-2: #94A3B8;
    --canvas: #F2F5F4;
    --surface: #FFFFFF;
    --surface-2: #F8FAF9;
    --line: #E2E8E6;
    --line-strong: #CBD5D1;
    --amber: #F0A32E;
    --amber-100: #FDF0D6;
    --red: #E5484D;
    --red-100: #FBE1E2;
    --blue: #2F6FED;
    --blue-100: #DDE7FC;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(11, 27, 46, 0.04), 0 8px 24px -12px rgba(11, 27, 46, 0.12);
    --shadow-lg: 0 24px 60px -24px rgba(11, 27, 46, 0.35);
    --sidebar-w: 252px;
    --font-display: 'Sora', 'DM Sans', system-ui, sans-serif;
    --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;

    /* Legacy-Aliase (ältere Skripte referenzieren diese Namen) */
    --text-primary: var(--ink);
    --text-secondary: var(--muted);
    --border-color: var(--line);
    --bg-primary: var(--surface);
    --bg-secondary: var(--canvas);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
ul { list-style: none; }

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-4 { margin-bottom: 16px; }
.mb-8 { margin-bottom: 32px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 22px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.brand {
    display: flex;
    align-items: center;
    padding: 4px 6px 0;
}
.brand img { height: 38px; width: auto; }
.brand-tag {
    margin: 8px 6px 0;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--brand-700);
}

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted-2);
    padding: 10px 12px 6px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--navy-500);
    font-weight: 500;
    position: relative;
    transition: background .15s ease, color .15s ease;
}
.nav-link svg { width: 18px; height: 18px; flex: none; stroke: currentColor; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-link.active { background: var(--brand-50); color: var(--brand-700); }
.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 9px; bottom: 9px;
    width: 3px;
    border-radius: 3px;
    background: var(--brand);
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--line);
    padding-top: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand-700));
    color: #fff;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 13px;
    display: grid; place-items: center;
    flex: none;
}
.sidebar-user-name { font-weight: 600; font-size: 13.5px; line-height: 1.2; }
.sidebar-user-role { font-size: 12px; color: var(--muted); }

.main-content {
    padding: 34px 40px 60px;
    min-width: 0;
}

/* --------------------------------------------------------------------------
   Page header & toolbar
   -------------------------------------------------------------------------- */

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.page-header h1 {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--navy);
    line-height: 1.15;
}
.page-sub { color: var(--muted); margin-top: 6px; font-size: 14px; }
.eyebrow {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--brand-700);
    margin-bottom: 6px;
}

.toolbar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.toolbar-group { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.control { display: flex; flex-direction: column; gap: 5px; }
.control-label {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

/* legacy header names */
.content-header { composes: page-header; }
.content-header, .content-header--actions { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; flex-wrap: wrap; }
.content-header h1 { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: -0.02em; color: var(--navy); }
.content-header p { color: var(--muted); margin-top: 6px; }
.header-actions { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Form controls & buttons
   -------------------------------------------------------------------------- */

.form-group { margin-bottom: 16px; }
.form-label, .label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy-700);
    margin-bottom: 6px;
}
.form-input, .input, .select, select.form-input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
    appearance: none;
    -webkit-appearance: none;
}
select.form-input, .select {
    padding-right: 34px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
}
.form-input:focus, .input:focus, .select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-100);
}
.form-input::placeholder { color: var(--muted-2); }
input[type="date"].form-input { font-family: var(--font-mono); font-size: 13px; }
.form-help, .help { font-size: 12.5px; color: var(--muted); margin-top: 6px; min-height: 16px; }
.form-help.success, .help.success { color: var(--brand-700); }
.form-help.error, .help.error { color: var(--red); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.input-with-action { display: flex; gap: 10px; align-items: center; }
.input-with-action .form-input { flex: 1; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .08s ease, background .15s, border-color .15s, box-shadow .15s;
    text-decoration: none !important;
}
.btn svg { width: 16px; height: 16px; stroke: currentColor; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-700); }
.btn-brand { background: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-600); }
.btn-secondary { background: var(--surface); color: var(--navy-700); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--navy-500); background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--navy-500); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 36px; padding: 0; }

/* Segmented control (Quelle) */
.segmented, .source-toggle {
    display: inline-flex;
    padding: 3px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    height: 40px;
}
.segmented button, .toggle-btn {
    border: 0;
    background: transparent;
    padding: 0 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: background .15s, color .15s;
}
.segmented button:hover, .toggle-btn:hover { color: var(--ink); }
.segmented button.active, .toggle-btn.active { background: var(--navy); color: #fff; box-shadow: 0 2px 8px -2px rgba(0,16,31,.5); }
.segmented .src-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .7; }

/* Dropdown (Zeitraum / Vergleich) */
.dropdown { position: relative; }
.dropdown-toggle {
    height: 40px;
    padding: 0 12px 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    cursor: pointer;
    min-width: 200px;
    justify-content: space-between;
}
.dropdown-toggle:hover { border-color: var(--navy-500); }
.dropdown-toggle svg { width: 16px; height: 16px; stroke: var(--muted); }
.dropdown-toggle .dropdown-value { font-weight: 600; color: var(--ink); }
.dropdown-toggle .dropdown-hint { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-left: 6px; }
.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 280px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
    z-index: 50;
    display: none;
    animation: pop .14s ease-out;
}
.dropdown.open .dropdown-menu { display: block; }
.menu-item {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 8px;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-weight: 500;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.active { background: var(--brand-50); color: var(--brand-700); }
.menu-item .menu-hint { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.menu-divider { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-custom { padding: 8px 10px 4px; }
.menu-custom .form-row { gap: 8px; }
.menu-custom .btn { width: 100%; margin-top: 10px; }

/* --------------------------------------------------------------------------
   KPI cards
   -------------------------------------------------------------------------- */

.stats-grid, .kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.stat-card, .kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    animation: rise .45s ease-out both;
}
.kpi-grid .kpi:nth-child(2) { animation-delay: .04s; }
.kpi-grid .kpi:nth-child(3) { animation-delay: .08s; }
.kpi-grid .kpi:nth-child(4) { animation-delay: .12s; }
.kpi-grid .kpi:nth-child(5) { animation-delay: .16s; }
.kpi-grid .kpi:nth-child(6) { animation-delay: .20s; }
.kpi-grid .kpi:nth-child(7) { animation-delay: .24s; }
.kpi-grid .kpi:nth-child(8) { animation-delay: .28s; }
.kpi::after {
    content: '';
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 3px;
    background: var(--kpi-accent, var(--brand));
    opacity: .9;
}
.kpi[data-source="ga4"] { --kpi-accent: var(--navy); }
.kpi[data-source="gsc"] { --kpi-accent: var(--brand); }
.kpi[data-source="bing"] { --kpi-accent: var(--amber); }
.kpi[data-source="all"] { --kpi-accent: linear-gradient(90deg, var(--navy), var(--brand)); }

.stat-header, .kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.stat-title, .kpi-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.02em;
}
.kpi-src {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 3px 7px;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--muted);
}
.kpi[data-source="ga4"] .kpi-src { background: #E6EAF0; color: var(--navy-700); }
.kpi[data-source="gsc"] .kpi-src { background: var(--brand-100); color: var(--brand-700); }
.kpi[data-source="bing"] .kpi-src { background: var(--amber-100); color: #9A5F0C; }
.stat-value, .kpi-value {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--navy);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.kpi-value .unit { font-size: 16px; color: var(--muted); margin-left: 2px; font-weight: 500; }
.stat-change, .kpi-foot { margin-top: 10px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.delta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.delta.up, .stat-change.positive { background: var(--brand-100); color: var(--brand-700); }
.delta.down, .stat-change.negative { background: var(--red-100); color: #B42328; }
.delta.flat { background: var(--surface-2); color: var(--muted); }
.delta svg { width: 12px; height: 12px; stroke: currentColor; }
.stat-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); }

@media (min-width: 1280px) {
    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
    .kpi-grid.kpi-grid--5 { grid-template-columns: repeat(5, 1fr); }
    .kpi-grid.kpi-grid--3 { grid-template-columns: repeat(3, 1fr); }
}
.source-badges { display: flex; gap: 6px; flex-wrap: nowrap; white-space: nowrap; }

/* --------------------------------------------------------------------------
   Panels, charts, tables
   -------------------------------------------------------------------------- */

.panel, .chart-container, .table-container {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-bottom: 22px;
}
.panel-head, .chart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.panel-title, .chart-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    color: var(--navy);
    letter-spacing: -0.01em;
}
.panel-sub, .chart-subtitle { font-size: 13px; color: var(--muted); margin-top: 3px; }
.panel-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.chart-wrap { position: relative; height: 340px; }
.chart-wrap canvas { width: 100% !important; }
.chart-container canvas { max-height: 340px; }
.chart-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--navy-500); font-weight: 500; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); flex: none; }
.legend-dot.dashed { background: transparent; border: 2px dashed currentColor; width: 12px; height: 0; border-width: 0 0 2px 0; border-radius: 0; }

.table-scroll { overflow-x: auto; }
.data-table, .table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.data-table th, .table th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    position: sticky;
    top: 0;
    white-space: nowrap;
}
.data-table td, .table td { padding: 12px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:last-child td, .table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td, .table tbody tr:hover td { background: var(--surface-2); }
.table th.num, .table td.num, .data-table th.num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.num { font-family: var(--font-mono); font-size: 12.5px; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable::after { content: '↕'; margin-left: 5px; opacity: .35; font-size: 10px; }
th.sorted-asc::after { content: '↑'; opacity: 1; color: var(--brand-700); }
th.sorted-desc::after { content: '↓'; opacity: 1; color: var(--brand-700); }
.table td:first-child, .data-table td:first-child { min-width: 220px; }
.cell-primary { font-weight: 600; color: var(--ink); }
.cell-secondary { font-size: 12px; color: var(--muted); margin-top: 1px; }
.cell-rank { font-family: var(--font-mono); color: var(--muted-2); font-size: 12px; width: 32px; }
.bar-cell { position: relative; }
.bar-cell .bar { position: absolute; left: 0; top: 50%; transform: translateY(-50%); height: 22px; background: var(--brand-50); border-radius: 4px; z-index: 0; }
.bar-cell span { position: relative; z-index: 1; }
.table-search { max-width: 260px; }
.table-empty { padding: 36px; text-align: center; color: var(--muted); }
.table-more-row td { padding: 14px; background: var(--surface-2); }
.table-more-row td .btn + .btn { margin-left: 8px; }

.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: var(--surface-2);
    color: var(--navy-500);
    border: 1px solid var(--line);
}
.tag.corporate { background: #E6EAF0; color: var(--navy-700); border-color: transparent; }
.tag.news { background: var(--blue-100); color: #1D4FB8; border-color: transparent; }
.tag.ecommerce { background: var(--amber-100); color: #9A5F0C; border-color: transparent; }
.tag.blog { background: var(--brand-100); color: var(--brand-700); border-color: transparent; }
.tag.other { background: var(--surface-2); color: var(--muted); }
.tag.ok { background: var(--brand-100); color: var(--brand-700); border-color: transparent; }
.tag.off { background: var(--red-100); color: #B42328; border-color: transparent; }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
    padding: 3px 8px; border-radius: 6px;
}
.badge-ga4 { background: #E6EAF0; color: var(--navy-700); }
.badge-gsc { background: var(--brand-100); color: var(--brand-700); }
.badge-bing { background: var(--amber-100); color: #9A5F0C; }
.badge-muted { background: var(--surface-2); color: var(--muted-2); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.notice {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--navy-700);
    margin-bottom: 16px;
}
.notice.success, .crawler-status.success { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }
.notice.error, .crawler-status.error, .error-message { background: var(--red-100); border-color: transparent; color: #B42328; }
.crawler-status { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; }
.crawler-status:empty { display: none; }
.error-message { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; display: none; }

.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--muted);
}
.empty-state strong { display: block; color: var(--ink); font-family: var(--font-display); font-size: 15px; margin-bottom: 6px; }

/* Skeleton / loading */
.is-loading .kpi-value, .is-loading .skeleton {
    color: transparent !important;
    background: linear-gradient(90deg, var(--surface-2) 25%, #EEF2F0 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
    border-radius: 6px;
}
.loader-bar {
    position: fixed; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--brand), var(--navy));
    transform: scaleX(0); transform-origin: left;
    transition: transform .3s ease, opacity .3s ease;
    z-index: 100; opacity: 0;
}
.loader-bar.active { transform: scaleX(.85); opacity: 1; }
.loader-bar.done { transform: scaleX(1); opacity: 0; }

.panel-grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 22px; }
.panel-grid-2 .panel { margin-bottom: 0; min-width: 0; }
.country-list { display: flex; flex-direction: column; gap: 8px; }
.country-row { display: grid; grid-template-columns: 150px 1fr 70px; align-items: center; gap: 12px; font-size: 13.5px; }
.country-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.country-bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.country-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--red), #F08A8D); border-radius: 5px; }
.country-value { text-align: right; font-family: var(--font-mono); font-size: 12.5px; }
@media (max-width: 1100px) { .panel-grid-2 { grid-template-columns: 1fr; } .panel-grid-2 .panel { margin-bottom: 22px; } }

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */

.modal {
    position: fixed; inset: 0;
    background: rgba(0, 16, 31, 0.55);
    backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-content {
    background: var(--surface);
    border-radius: 18px;
    padding: 28px;
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: pop .18s ease-out;
}
.modal-content h2 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 18px;
    letter-spacing: -0.01em;
}
.modal-section-title {
    font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--muted); margin: 22px 0 10px; padding-top: 16px; border-top: 1px solid var(--line);
}
.modal-actions { display: flex; gap: 10px; margin-top: 22px; justify-content: flex-end; }

/* --------------------------------------------------------------------------
   Crawler log
   -------------------------------------------------------------------------- */

.log-toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.log-viewer {
    background: var(--navy);
    color: #C9D6E2;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.6;
    border-radius: 12px;
    padding: 16px 18px;
    height: 520px;
    overflow: auto;
    border: 1px solid var(--navy-700);
}
.log-viewer.empty { display: grid; place-items: center; color: var(--muted-2); }
.log-line { white-space: pre-wrap; word-break: break-word; }
.log-line-critical { color: #FF8A8E; }
.log-line-warning { color: #FFC66D; }
.log-line-site { color: var(--brand); font-weight: 600; margin-top: 6px; }
.progress-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.progress-item { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.progress-item .k { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.progress-item .v { font-weight: 600; margin-top: 3px; }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-right: 8px; animation: pulse 1.4s infinite; vertical-align: middle; }

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */

.login-container {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}
.login-hero {
    background: radial-gradient(1200px 600px at 20% 10%, rgba(0, 176, 140, 0.35), transparent 60%),
                radial-gradient(800px 500px at 90% 90%, rgba(0, 176, 140, 0.18), transparent 60%),
                var(--navy);
    color: #fff;
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}
.login-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(circle at 30% 30%, #000 20%, transparent 75%);
}
.login-hero .mark { width: 88px; height: 88px; opacity: .95; position: relative; }
.login-hero h2 {
    font-family: var(--font-display);
    font-size: 40px;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
    max-width: 520px;
    position: relative;
}
.login-hero h2 em { font-style: normal; color: var(--brand); }
.login-hero p { color: rgba(255,255,255,.7); max-width: 460px; margin-top: 16px; font-size: 15px; position: relative; }
.login-hero .hero-meta { display: flex; gap: 28px; position: relative; }
.login-hero .hero-meta div { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.55); }
.login-hero .hero-meta strong { display: block; font-family: var(--font-display); font-size: 22px; color: #fff; letter-spacing: 0; text-transform: none; margin-top: 4px; }
.login-hero .big-mark { position: absolute; right: -120px; bottom: -140px; width: 520px; opacity: .06; pointer-events: none; }
.login-panel { display: grid; place-items: center; padding: 40px 24px; background: var(--canvas); }
.login-box { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 36px; box-shadow: var(--shadow); }
.login-header { margin-bottom: 26px; }
.login-header img { height: 40px; margin-bottom: 18px; }
.login-header h1 { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--navy); letter-spacing: -0.01em; }
.login-header p { color: var(--muted); margin-top: 4px; font-size: 14px; }
.btn-login { width: 100%; margin-top: 6px; height: 44px; }

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.7); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1100px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: 16px;
        padding: 12px 18px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .brand img { height: 30px; }
    .brand-tag, .nav-section-title { display: none; }
    .nav { flex-direction: row; flex-wrap: wrap; gap: 2px; }
    .nav-link { padding: 8px 10px; }
    .nav-link.active::before { display: none; }
    .sidebar-footer { margin: 0 0 0 auto; border: 0; padding: 0; }
    .sidebar-user-role, .sidebar-user-name { display: none; }
    .main-content { padding: 24px 20px 48px; }
    .login-container { grid-template-columns: 1fr; }
    .login-hero { min-height: 260px; padding: 32px; }
    .login-hero h2 { font-size: 28px; }
    .login-hero .hero-meta, .login-hero .big-mark { display: none; }
}

@media (max-width: 720px) {
    .page-header h1, .content-header h1 { font-size: 22px; }
    .kpi-grid, .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .kpi-value, .stat-value { font-size: 24px; }
    .panel, .chart-container, .table-container { padding: 16px; }
    .chart-wrap { height: 260px; }
    .dropdown-menu { right: auto; left: 0; min-width: 260px; }
    .form-row { grid-template-columns: 1fr; }
    .toolbar, .toolbar-group { width: 100%; }
    .dropdown-toggle { min-width: 0; width: 100%; }
    .main-content { padding: 18px 16px 40px; }
}
