:root {
  --bg: #0c0c0f;
  --bg-elevated: #131316;
  --bg-card: #18181c;
  --bg-hover: #1f1f24;
  --border: #27272a;
  --border-focus: #3f3f46;
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-subtle: rgba(16, 185, 129, 0.12);
  --clicks: #3b82f6;
  --clicks-subtle: rgba(59, 130, 246, 0.12);
  --impressions: #8b5cf6;
  --impressions-subtle: rgba(139, 92, 246, 0.12);
  --ctr: #06b6d4;
  --ctr-subtle: rgba(6, 182, 212, 0.12);
  --position: #f59e0b;
  --position-subtle: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'DM Sans', system-ui, sans-serif;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --transition: 0.2s ease;
}

* { box-sizing: border-box; }
.skip-link { position: absolute; left: -9999px; z-index: 999; padding: 0.75rem 1rem; background: var(--accent); color: #fff; font-weight: 500; border-radius: var(--radius-sm); }
.skip-link:focus { left: 1rem; top: 1rem; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; font-family: var(--font); font-size: 15px; background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .summary-card:hover { transform: none; }
  .btn-star:hover { transform: none; }
}
.app { max-width: 1280px; margin: 0 auto; padding: clamp(1rem, 3vw, 1.75rem); padding-bottom: 3rem; }
.main-content { animation: contentFadeIn 0.3s ease; }
@keyframes contentFadeIn { from { opacity: 0; } to { opacity: 1; } }
.screen { min-height: 85vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.loader-wrap { display: flex; flex-direction: column; align-items: center; gap: 1.25rem; padding: 1rem; }
.spinner { width: 44px; height: 44px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }
.spinner-sm { width: 18px; height: 18px; border-width: 2px; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--text-muted); font-size: 0.95rem; margin: 0; }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.5rem; max-width: 420px; width: 100%; text-align: center; box-shadow: var(--shadow); }
.login-icon { width: 56px; height: 56px; margin: 0 auto 1.25rem; background: var(--accent-subtle); color: var(--accent); font-size: 1.75rem; line-height: 56px; border-radius: var(--radius); }
.login-title { font-size: 1.5rem; font-weight: 600; margin: 0 0 0.5rem; }
.login-desc { color: var(--text-secondary); font-size: 0.95rem; margin: 0 0 1.5rem; }
.login-card .alert { margin-bottom: 1.25rem; text-align: left; }
.btn-login { width: 100%; padding: 0.85rem 1.5rem; font-size: 1rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.55rem 1rem; font-family: var(--font); font-size: 0.9rem; font-weight: 500; border-radius: var(--radius-sm); border: none; cursor: pointer; text-decoration: none; color: inherit; transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-focus); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--bg-hover); }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary); font-size: 1.1rem; }
.btn-icon:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.btn-preset { padding: 0.4rem 0.75rem; font-size: 0.85rem; background: transparent; color: var(--text-secondary); border: 1px solid transparent; }
.btn-preset:hover { color: var(--accent); background: var(--accent-subtle); }
.btn-preset.active { color: var(--accent); background: var(--accent-subtle); border-color: var(--accent); }
.date-inputs { display: inline-flex; align-items: center; gap: 0.35rem; }
.date-inputs-active .input-date { border-color: var(--accent); background: var(--accent-subtle); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); margin-left: 0.75rem; }
.btn-outline:hover { border-color: var(--border-focus); color: var(--text); }
.header { margin-bottom: 1.5rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; background: var(--bg); backdrop-filter: blur(8px); }
.header-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.page-title { font-size: 1.35rem; font-weight: 600; margin: 0; }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.date-block { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.date-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; }
.input-date { padding: 0.45rem 0.6rem; font-family: var(--font); font-size: 0.9rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); transition: border-color var(--transition); }
.input-date:hover { border-color: var(--border-focus); }
.input-date:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.date-sep { color: var(--text-muted); }
.date-presets { display: inline-flex; gap: 0.25rem; }
.alert { padding: 1rem 1.25rem; border-radius: var(--radius-sm); margin-bottom: 1rem; display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.alert-error { background: var(--danger-subtle); border: 1px solid rgba(239, 68, 68, 0.35); color: #fca5a5; }
.text-error { color: #f87171; }
.empty-state { text-align: center; padding: 3rem 2rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
.empty-icon { font-size: 3rem; color: var(--text-muted); margin-bottom: 1rem; opacity: 0.7; line-height: 1; }
.empty-title { font-size: 1.1rem; font-weight: 600; margin: 0 0 0.35rem; }
.empty-desc { color: var(--text-secondary); font-size: 0.95rem; margin: 0 0 1.25rem; }
.empty-state-compact { padding: 2rem; }
.digest-block { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.5rem; }
.digest-title { margin: 0 0 0.75rem; font-size: 1rem; font-weight: 600; }
.digest-item { font-size: 0.9rem; margin-bottom: 0.5rem; }
.digest-item:last-child { margin-bottom: 0; }
.digest-item .site-link { margin-right: 0.25rem; }
.digest-warn { color: var(--text); }
.digest-warn .site-link { color: var(--danger); }
.digest-ok .site-link { color: var(--accent); }
.digest-loading, .digest-neutral { color: var(--text-muted); }
.pagination-full { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.pagination-full .pagination-size { display: inline-flex; align-items: center; gap: 0.25rem; margin-left: 0.5rem; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.summary-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: 0.35rem; transition: border-color var(--transition), transform var(--transition); }
.summary-card:hover { border-color: var(--border-focus); transform: translateY(-1px); }
.summary-icon { font-size: 0.85rem; opacity: 0.7; }
.summary-card-sites .summary-icon { color: var(--text-secondary); }
.summary-card-clicks .summary-icon { color: var(--clicks); }
.summary-card-impressions .summary-icon { color: var(--impressions); }
.summary-card-ctr .summary-icon { color: var(--ctr); }
.summary-card-position .summary-icon { color: var(--position); }
.summary-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }
.summary-value { font-size: 1.4rem; font-weight: 600; }
.table-toolbar { margin-bottom: 0.75rem; }
.search-label { display: inline-flex; align-items: center; gap: 0.5rem; max-width: 320px; width: 100%; }
.search-icon { color: var(--text-muted); }
.input-search { flex: 1; padding: 0.5rem 0.75rem 0.5rem 0.5rem; font-family: var(--font); font-size: 0.9rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); transition: border-color var(--transition); }
.input-search::placeholder { color: var(--text-muted); }
.input-search:hover { border-color: var(--border-focus); }
.input-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.refreshing-bar { position: absolute; top: 0; left: 0; right: 0; padding: 0.4rem 0; font-size: 0.85rem; color: var(--accent); text-align: center; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); margin-top: 0.25rem; }
.sites-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.sites-table th, .sites-table td { padding: 0.8rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.sites-table th { font-weight: 600; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; white-space: nowrap; background: var(--bg-elevated); }
.th-sort { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.2rem 0; font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.th-sort:hover { color: var(--text); }
.th-num, .td-num { text-align: right; white-space: nowrap; }
.th-site { min-width: 200px; }
.sites-table tbody tr:hover { background: var(--bg-hover); }
.sites-table tbody tr:last-child td { border-bottom: none; }
.sites-table tbody tr.row-error td { color: #f87171; }
.td-site { max-width: 0; width: 100%; min-width: 180px; }
.site-link { color: var(--accent); text-decoration: none; word-break: break-all; transition: color var(--transition); }
.site-link:hover { color: var(--accent-hover); text-decoration: underline; }
.site-url-text { word-break: break-all; }
.app-footer { margin-top: 1.75rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--text-muted); }
.btn:focus-visible, .input-date:focus-visible, .input-search:focus-visible, .th-sort:focus-visible, .site-link:focus-visible, .select-site:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.btn-icon.btn-copy-ok { color: var(--accent); border-color: var(--accent); background: var(--accent-subtle); }
@media (max-width: 768px) { .header-top { flex-direction: column; } .date-block { flex-direction: column; } .summary { grid-template-columns: repeat(2, 1fr); } }
.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tabs .btn { border-radius: var(--radius-sm) var(--radius-sm) 0 0; border: 1px solid transparent; margin-bottom: -1px; }
.tabs .btn.active { background: var(--bg-card); border-color: var(--border); border-bottom-color: var(--bg-card); color: var(--text); }
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.toolbar-row label { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--text-secondary); cursor: pointer; }
.pagination { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; font-size: 0.9rem; color: var(--text-secondary); }
.pagination .btn:disabled { opacity: 0.4; cursor: default; }
.pagination .btn:not(:disabled):hover { background: var(--accent-subtle); color: var(--accent); }
.delta-up { color: var(--accent); }
.delta-down { color: var(--danger); }
.delta-neutral { color: var(--text-muted); }
.chart-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; height: 320px; }
.chart-wrap .charts-grid { display: grid; gap: 1rem; }
.chart-wrap .charts-grid-cols-1 { grid-template-columns: 1fr; }
.chart-wrap .charts-grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.chart-wrap .charts-grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.chart-wrap .charts-grid-cols-auto { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.chart-wrap.chart-wrap-all { height: auto; }
.chart-block { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; }
.chart-block-title { margin: 0 0 0.5rem; font-size: 0.9rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-block-inner { position: relative; height: 200px; }
@media (max-width: 900px) { .chart-wrap .charts-grid-cols-2 { grid-template-columns: 1fr; } .chart-wrap .charts-grid-cols-3 { grid-template-columns: 1fr; } }
.select-site { padding: 0.5rem 2rem 0.5rem 0.75rem; font-family: var(--font); font-size: 0.9rem; background-color: var(--bg-card); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2371717a' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.6rem center; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); min-width: 200px; cursor: pointer; appearance: none; transition: border-color var(--transition); }
.select-site:hover { border-color: var(--border-focus); }
.select-site:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.btn-star { padding: 0.25rem; background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1.1rem; transition: color var(--transition), transform var(--transition); }
.btn-star:hover { color: var(--position); transform: scale(1.15); }
.btn-star.is-fav { color: var(--position); }
[data-theme="light"] { --bg: #f8fafc; --bg-elevated: #f1f5f9; --bg-card: #fff; --bg-hover: #f1f5f9; --border: #e2e8f0; --text: #0f172a; --text-secondary: #475569; --text-muted: #64748b; }
[data-theme="light"] .site-link { color: var(--accent-hover); }
[data-theme="light"] .delta-up { color: #059669; }
[data-theme="light"] .delta-down { color: #dc2626; }
.goals-block { margin-bottom: 1rem; padding: 1rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
.goal-row { margin-top: 0.5rem; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.goal-bar-wrap { flex: 1; min-width: 100px; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.goal-bar { height: 100%; background: var(--accent); border-radius: 4px; }
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.pie-card, .topbars-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.pie-title { margin: 0 0 0.75rem; font-size: 0.95rem; }
.pie-wrap { height: 220px; }
.topbar-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; font-size: 0.9rem; }
.topbar-label { flex: 0 0 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-wrap { flex: 1; min-width: 60px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.topbar-fill { height: 100%; background: var(--clicks); border-radius: 3px; }
.topbar-num { flex: 0 0 50px; text-align: right; }
.sites-table tbody tr.row-anomaly { background: var(--danger-subtle); }
.col-visibility { color: var(--text-muted); font-size: 0.9rem; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1rem; animation: modalFadeIn 0.2s ease; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; max-width: 420px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); animation: modalSlideIn 0.25s ease; }
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideIn { from { opacity: 0; transform: scale(0.96) translateY(-8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal h3 { margin: 0 0 1rem; }
.modal-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.modal-list li { padding: 0.35rem 0; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.modal-list kbd { background: var(--bg-hover); padding: 0.2rem 0.4rem; border-radius: 4px; font-size: 0.9rem; }
.notes-block { margin-top: 1rem; padding: 1rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
.notes-title { margin: 0 0 0.5rem; font-size: 0.95rem; }
.notes-add { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.notes-list { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; }
@media print { .no-print { display: none !important; } body { background: #fff; color: #000; } }
