:root{
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-2: #cbd5e1;

  --primary: #4f46e5;
  --primary-2: #4338ca;
  --success: #16a34a;
  --warning: #d97706;
  --error: #dc2626;
  --info: #2563eb;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow-md: 0 10px 30px rgba(15,23,42,.10);

  /* Compatibility vars (existing pages/styles) */
  --bg-primary: var(--bg);
  --bg-secondary: var(--surface);
  --text-primary: var(--text);
  --text-secondary: var(--text-2);
  --text-muted: var(--muted);
  --border-light: var(--border-2);
  --primary-dark: var(--primary-2);
  --primary-light: #6366f1;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.5;
}

a{ color: var(--primary); text-decoration: none; }
a:hover{ text-decoration: underline; }

.skip-link{
  position:absolute;
  left:-9999px;
  top:auto;
  width:1px;
  height:1px;
  overflow:hidden;
}
.skip-link:focus{
  left: 12px;
  top: 12px;
  width:auto;
  height:auto;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  z-index: 9999;
}

.container{
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 18px;
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(248,250,252,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 14px;
  padding: 12px 0;
}
.brand{
  display:flex;
  align-items:center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: .2px;
}
.brand:hover{ text-decoration:none; }
.brand__mark{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-size: 13px;
}
.brand__text{ font-size: 15px; }

.nav-toggle{
  display:none;
  align-items:center;
  gap: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  cursor:pointer;
}
.nav-toggle__icon{
  width: 18px;
  height: 12px;
  display:inline-block;
  position:relative;
}
.nav-toggle__icon::before,
.nav-toggle__icon::after{
  content:"";
  position:absolute;
  left:0;
  right:0;
  height:2px;
  background: var(--text);
  border-radius: 2px;
}
.nav-toggle__icon::before{ top:0; box-shadow: 0 5px 0 var(--text); }
.nav-toggle__icon::after{ bottom:0; }
.nav-toggle__text{ font-weight: 700; font-size: 13px; }

.nav{
  display:flex;
  align-items:center;
  gap: 14px;
}
.nav__group{
  display:flex;
  align-items:center;
  gap: 6px;
  flex-wrap: wrap;
}
.nav__group--right{
  margin-left: 10px;
  gap: 10px;
}
.nav__link{
  display:inline-flex;
  align-items:center;
  padding: 9px 12px;
  border-radius: 12px;
  color: var(--text-2);
  text-decoration:none;
  border: 1px solid transparent;
}
.nav__link:hover{
  background: var(--surface);
  border-color: var(--border);
  text-decoration:none;
}
.nav__link.is-active{
  background: rgba(79,70,229,.10);
  border-color: rgba(79,70,229,.18);
  color: var(--primary-2);
  font-weight: 700;
}
.nav__meta{
  display:inline-flex;
  max-width: 260px;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.main{
  padding: 26px 0 34px;
}

.footer{
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer__inner{
  display:flex;
  justify-content:space-between;
  gap: 18px;
  padding: 22px 0;
  flex-wrap: wrap;
}
.footer__brand{ font-weight: 800; }
.footer__muted{ color: var(--muted); font-size: 13px; margin-top: 6px; max-width: 520px; }
.footer__right{
  display:flex;
  align-items:center;
  gap: 14px;
  flex-wrap: wrap;
}
.footer__right a{
  color: var(--muted);
  text-decoration:none;
  font-weight: 600;
}
.footer__right a:hover{ color: var(--text); text-decoration:none; }

/* Components */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card + .card{ margin-top: 14px; }
.card-header{ margin-bottom: 12px; }
.card-header h3{ margin: 0 0 4px; }
.card-subtitle{ margin: 0; color: var(--muted); font-size: 13px; }

.h1{ font-size: 34px; line-height: 1.15; margin: 0 0 12px; }
.h2{ font-size: 26px; line-height: 1.2; margin: 0 0 8px; }
.muted, .text-muted{ color: var(--muted); }

.btn,
.btn-primary,
.btn-secondary,
.btn-danger{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 8px;
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid transparent;
  font-weight: 800;
  font-size: 14px;
  cursor:pointer;
  user-select:none;
  text-decoration:none;
}
.btn:hover,
.btn-primary:hover,
.btn-secondary:hover,
.btn-danger:hover{ text-decoration:none; }
.btn:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled{ opacity:.6; cursor:not-allowed; }

.btn-primary{
  background: var(--primary);
  border-color: rgba(79,70,229,.22);
  color:#fff;
}
.btn-primary:hover{ background: var(--primary-2); }

.btn-secondary{
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover{ border-color: var(--border-2); background: var(--surface-2); }

.btn-danger{
  background: var(--error);
  color:#fff;
  border-color: rgba(220,38,38,.18);
}
.btn-danger:hover{ background: #b91c1c; }

.form-group{ margin-bottom: 14px; }
.form-label{ display:block; margin-bottom: 6px; font-weight: 800; font-size: 13px; color: var(--text-2); }
.form-input{
  width:100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}
.form-input, textarea, select, input[type="text"], input[type="email"], input[type="password"], input[type="date"]{
  font-family: inherit;
}
textarea, select, input[type="text"], input[type="email"], input[type="password"], input[type="date"]{
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}
textarea:focus, select:focus, input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, input[type="date"]:focus{
  outline:none;
  border-color: rgba(79,70,229,.35);
  box-shadow: 0 0 0 4px rgba(79,70,229,.10);
}
textarea{ width: 100%; min-height: 120px; }
select{ width: 100%; }
.form-input:focus{
  outline:none;
  border-color: rgba(79,70,229,.35);
  box-shadow: 0 0 0 4px rgba(79,70,229,.10);
}
.form-checkbox{
  display:flex;
  gap: 10px;
  align-items:flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 14px;
}
.form-checkbox input{ margin-top: 3px; }
.form-checkbox a{ font-weight: 800; }

.grid{ display:grid; gap: 14px; }
.grid-2{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4{ grid-template-columns: repeat(4, minmax(0, 1fr)); }

.alert{
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-top: 12px;
}
.alert-error{ border-color: rgba(220,38,38,.25); background: rgba(220,38,38,.06); color: #991b1b; }
.alert-success{ border-color: rgba(22,163,74,.22); background: rgba(22,163,74,.06); color: #166534; }
.alert-info{ border-color: rgba(37,99,235,.20); background: rgba(37,99,235,.06); color: #1e40af; }

.badge{
  display:inline-flex;
  align-items:center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
}
.badge-google{ background: rgba(37,99,235,.07); border-color: rgba(37,99,235,.18); color: #1e40af; }
.badge-yandex{ background: rgba(217,119,6,.08); border-color: rgba(217,119,6,.18); color: #92400e; }
.badge-wait{ background: rgba(217,119,6,.08); border-color: rgba(217,119,6,.18); color: #92400e; }
.badge-paid{ background: rgba(22,163,74,.06); border-color: rgba(22,163,74,.18); color: #166534; }

.pill{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 800;
}
.actions{
  display:flex;
  gap: 10px;
  align-items:center;
  flex-wrap: wrap;
}
.spinner{
  display:inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(15,23,42,.18);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: la_spin .8s linear infinite;
}
@keyframes la_spin { to { transform: rotate(360deg); } }

.table-wrap, .table-wrapper{
  overflow:auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
table{ width:100%; border-collapse: collapse; }
th,td{
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  text-align:left;
}
th{
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 900;
}
tr:hover td{ background: rgba(15,23,42,.02); }

.kpis{ display:grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.kpi{ border:1px solid var(--border); border-radius: var(--radius-md); padding: 14px; background: var(--surface); }
.kpi .t{ font-size: 12px; color: var(--muted); font-weight: 800; }
.kpi .v{ font-size: 18px; font-weight: 900; margin-top: 4px; }

.stat{
  border:1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 16px;
}
.stat-value{ font-size: 24px; font-weight: 900; }
.stat-label{ color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Progress */
.progress-container{
  display:none;
  border:1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 10px;
}
.progress-header{
  display:flex;
  justify-content:space-between;
  gap: 12px;
  align-items:center;
}
.progress-bar-wrapper{
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow:hidden;
  margin-top: 10px;
}
.progress-bar{
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width .2s ease;
}

/* Filters / small layout helpers */
.filters{
  display:flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.filters label{ color: var(--text-2); font-weight: 800; font-size: 13px; }
.filters select{ width: auto; min-width: 200px; }

/* Pagination buttons (indexation) */
.page-btn{
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 6px 10px;
  font-weight: 900;
  cursor: pointer;
}
.page-btn:hover{ background: var(--surface-2); }
.page-btn.active{
  background: rgba(79,70,229,.10);
  border-color: rgba(79,70,229,.20);
  color: var(--primary-2);
}
.page-btn.disabled{ opacity: .45; cursor: default; }
.page-ellipsis{ color: var(--muted); font-weight: 900; padding: 6px 10px; }

/* Results list (indexation) */
.result-item{
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 12px;
}
.result-item.success{ border-color: rgba(22,163,74,.18); background: rgba(22,163,74,.05); }
.result-item.error{ border-color: rgba(220,38,38,.18); background: rgba(220,38,38,.05); }
.result-item-url{ font-weight: 900; }
.result-item-message{ color: var(--text-2); margin-top: 4px; font-size: 13px; }

/* Pagination */
.pagination{
  display:flex;
  gap: 8px;
  justify-content:center;
  flex-wrap: wrap;
  margin-top: 14px;
}
.pagination button{
  border:1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 8px 10px;
  font-weight: 800;
  cursor:pointer;
}
.pagination button:hover{ background: var(--surface-2); }

/* Modal (generic) */
.modal-overlay,
.chart-modal{
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  display:none;
  align-items:center;
  justify-content:center;
  padding: 18px;
  z-index: 2000;
}
.modal-overlay.active{ display:flex; }
.chart-modal.active{ display:flex; }

.modal-window,
.chart-modal-content{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: min(860px, 100%);
  max-height: 86vh;
  overflow:auto;
  padding: 16px;
}
.modal-header,
.chart-modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.content-page h1{ margin: 0 0 12px; }
.content-page h2{ margin: 18px 0 10px; }
.content-page h3{ margin: 14px 0 8px; }
.content-page p, .content-page li{ color: var(--text-2); }
.content-page ul, .content-page ol{ padding-left: 18px; }

.docs{ display:block; }
.docs__header{ margin-bottom: 14px; }
.docs__grid{
  display:grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 14px;
  align-items:start;
}
.docs__toc{
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 110px);
  overflow:auto;
}
.docs__tocTitle{
  font-weight: 900;
  color: var(--text);
  margin-bottom: 10px;
  font-size: 14px;
}
.docs__tocNav{
  display:flex;
  flex-direction: column;
  gap: 6px;
}
.docs__tocNav a{
  display:block;
  padding: 8px 10px;
  border-radius: 12px;
  color: var(--text-2);
  border: 1px solid transparent;
}
.docs__tocNav a:hover{
  background: var(--surface-2);
  border-color: var(--border);
  text-decoration:none;
}
.docs__tocFooter{ margin-top: 12px; }
.docs__content .h2{ scroll-margin-top: 90px; }
.docs__content .card{ margin-bottom: 14px; }
.docs__list{ margin: 10px 0 0; padding-left: 18px; color: var(--text-2); }
.docs__note{
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(217,119,6,.18);
  background: rgba(217,119,6,.06);
  color: #92400e;
}
.docs__split{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 12px;
}
.docs__h3{ margin: 0 0 8px; font-size: 16px; }
.docs__img{
  width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.docs__code{
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  overflow:auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  color: var(--text);
}
.docs__faq{ display:flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.docs__qa{
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 12px 14px;
}
.docs__q{ font-weight: 900; }
.docs__a{ margin-top: 6px; color: var(--text-2); }

@media (max-width: 980px){
  .grid-4{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kpis{ grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 760px){
  .nav-toggle{ display:inline-flex; }
  .nav{
    display:none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 0 4px;
    border-top: 1px solid var(--border);
  }
  .nav.is-open{ display:flex; }
  .topbar__inner{ flex-wrap: wrap; }
  .nav__group, .nav__group--right{ width: 100%; }
  .nav__link{ width: 100%; justify-content:flex-start; }
  .nav__meta{ width: 100%; max-width: none; }
  .grid-2,.grid-3{ grid-template-columns: 1fr; }
  .kpis{ grid-template-columns: 1fr; }

  .docs__grid{ grid-template-columns: 1fr; }
  .docs__toc{ position: static; max-height: none; }
  .docs__split{ grid-template-columns: 1fr; }
}

