:root {
  --bg: #090a0d;
  --surface: #121419;
  --line: #292d35;
  --line-strong: #414650;
  --text: #f5f7fa;
  --muted: #9aa3b2;
  --primary: #e3262e;
  --primary-strong: #ff4b52;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --ok: #1f7a4d;
  --ok-bg: #13271d;
  --warn-bg: #fff8e6;
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(9,10,13,.96);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
}

.sidebar {
  position: fixed;
  inset: 72px auto 0 0;
  width: 228px;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: #0d0f13;
  display: flex;
  flex-direction: column;
  z-index: 15;
}
.sidebar-nav { display: grid; gap: 7px; }
.sidebar-nav a { display:flex; align-items:center; gap:12px; min-height:46px; padding:0 14px; border-radius:10px; color:var(--muted); font-weight:650; }
.sidebar-nav a:hover { color:var(--text); background:#171a20; text-decoration:none; }
.sidebar-nav a.active { color:#fff; background:linear-gradient(90deg, rgba(227,38,46,.24), rgba(227,38,46,.06)); box-shadow:inset 3px 0 var(--primary); }
.nav-icon { width:22px; height:22px; color:var(--primary-strong); text-align:center; }
.nav-icon svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.sidebar-nav a:first-child .nav-icon svg { fill:currentColor; stroke:none; }
.sidebar-foot { margin-top:auto; padding:14px; color:var(--muted); font-size:12px; border-top:1px solid var(--line); }
.status-dot { display:inline-block; width:8px; height:8px; margin-right:7px; border-radius:50%; background:#26c281; box-shadow:0 0 10px rgba(38,194,129,.7); }
.page-with-sidebar { width:auto; max-width:1500px; margin-left:calc(228px + 28px); margin-right:28px; }
.page-heading { display:flex; justify-content:space-between; align-items:end; gap:20px; margin-bottom:22px; }
.page-heading h1 { margin-top:4px; font-size:30px; }
.eyebrow { color:var(--primary-strong); font-size:11px; font-weight:800; letter-spacing:.12em; text-transform:uppercase; }
.stat-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; margin-bottom:18px; }
.stat-card { padding:20px; border:1px solid var(--line); border-radius:var(--radius); background:linear-gradient(145deg,#15181e,#101216); display:grid; gap:8px; }
.stat-card span { color:var(--muted); font-weight:650; }
.stat-card strong { font-size:32px; line-height:1; }
.stat-card small { color:#6f7888; }
.text-ok { color:#38d48b; }
.text-danger { color:#ff5961; }
.domain-toolbar { display:flex; align-items:end; justify-content:space-between; gap:20px; margin-bottom:16px; }
.search-field { width:min(420px,100%); }
.domain-count { color:var(--muted); }
.row-sub { color:var(--muted); font-size:11px; margin-top:5px; max-width:330px; overflow:hidden; text-overflow:ellipsis; }
.account-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; margin-bottom:18px; }
.account-card { display:grid; grid-template-columns:46px 1fr auto; align-items:center; gap:13px; padding:17px; background:#121419; border:1px solid var(--line); border-radius:var(--radius); }
.account-card h2 { font-size:14px; }
.account-card p { font-size:12px; }
.service-logo { display:grid; place-items:center; width:44px; height:44px; border-radius:12px; font-size:20px; font-weight:900; color:#fff; }
.service-logo.yandex { background:#e3262e; }.service-logo.google { background:#4285f4; }.service-logo.bing { background:#008373; }
.live-dot { display:inline-block; width:8px; height:8px; margin-right:7px; border-radius:50%; background:#38d48b; box-shadow:0 0 9px rgba(56,212,139,.7); }
.monitor-error { max-width:190px; margin-top:5px; color:#ff7279; font-size:10px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.integration-state { display:inline-grid; place-items:center; width:25px; height:25px; border-radius:50%; color:#697283; background:#1b1e24; }
.integration-state.on { color:#38d48b; background:rgba(56,212,139,.12); }
.filter-tags { display:flex; flex-wrap:wrap; gap:9px; margin-bottom:16px; }
.filter-tag { min-height:34px; padding:6px 12px; border:1px solid var(--line); border-radius:999px; background:#111318; color:var(--muted); cursor:pointer; font:inherit; font-size:12px; font-weight:650; }
.filter-tag:hover { color:var(--text); border-color:var(--line-strong); }
.filter-tag.active { color:#fff; border-color:rgba(227,38,46,.7); background:rgba(227,38,46,.16); }
.filter-tag b { margin-left:5px; color:inherit; font-size:11px; }
.stat-unit { color:var(--muted); font-size:14px; font-weight:650; }
.domain-summary { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); margin-bottom:18px; border:1px solid var(--line); border-radius:var(--radius); background:#111318; overflow:hidden; }
.domain-summary > div { min-height:58px; padding:0 16px; display:flex; align-items:center; gap:10px; border-right:1px solid var(--line); }
.domain-summary > div:last-child { border-right:0; }
.domain-summary b { margin-left:auto; font-size:18px; }
.summary-label { color:var(--muted); }
.summary-mark { display:grid; place-items:center; width:25px; height:25px; border-radius:7px; color:#fff; font-weight:800; font-size:12px; }
.yandex-mark { background:#e3262e; }.google-mark { background:#4285f4; }.bing-mark { background:#008373; }
.mini-services { display:flex; gap:5px; }.mini-services span { display:grid; place-items:center; width:23px; height:23px; border-radius:6px; background:#1b1e24; color:#606979; font-size:10px; font-weight:800; }.mini-services span.on { background:rgba(56,212,139,.13); color:#38d48b; }
.integration-list { display:grid; gap:16px; }
.integration-panel { padding:20px; background:#121419; border:1px solid var(--line); border-radius:var(--radius); }
.integration-title { display:grid; grid-template-columns:46px 1fr auto; align-items:center; gap:14px; }
.setup-box { margin:18px 0 0 60px; padding:14px; border:1px solid var(--line); border-radius:10px; background:#0d0f13; }
.setup-box > span { display:block; margin-bottom:7px; color:var(--muted); font-size:11px; font-weight:750; text-transform:uppercase; }
.setup-box code { display:block; color:#f2b6b9; overflow-wrap:anywhere; }
.connection-meta { margin:15px 0 0 60px; color:var(--muted); }
.service-logo svg { width:28px; height:28px; fill:currentColor; }

.brand {
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand img { width: 46px; height: 46px; object-fit: cover; border-radius: 12px; box-shadow: 0 0 22px rgba(227,38,46,.35); }

.topnav {
  display: flex;
  gap: 18px;
  align-items: center;
}

.topnav form {
  margin: 0;
}

.page {
  width: min(1320px, calc(100vw - 40px));
  margin: 24px auto 48px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 16px;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.main-column,
.side-column,
.table-section,
.details-grid,
.metrics,
.job-header,
.login-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.main-column,
.side-column,
.table-section,
.details-grid,
.metrics,
.job-header {
  padding: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.section-head.compact {
  margin-bottom: 12px;
  align-items: center;
}

.work-form {
  display: grid;
  gap: 16px;
}

label,
fieldset {
  display: grid;
  gap: 7px;
  margin: 0;
  border: 0;
  padding: 0;
}

label span,
legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  color: var(--text);
  background: #0d0f13;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font: inherit;
  letter-spacing: 0;
}

textarea {
  resize: vertical;
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(23, 107, 135, 0.2);
  border-color: var(--primary);
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.grid.three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.field-row legend {
  margin-right: 8px;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.segmented input {
  width: 1px;
  height: 1px;
  opacity: 0;
  position: absolute;
}

.segmented span {
  min-width: 96px;
  text-align: center;
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  background: #0d0f13;
  color: var(--text);
  border-radius: var(--radius);
  text-transform: none;
  font-size: 14px;
}

.segmented input:checked + span {
  border-color: var(--primary);
  background: #2a1114;
  color: var(--primary-strong);
}

.main-column,.side-column,.table-section,.details-grid,.metrics,.job-header,.login-box { box-shadow: 0 14px 45px rgba(0,0,0,.24); }
.isp-selector { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:12px; align-items:end; padding:14px; border:1px solid #3a2023; border-radius:10px; background:linear-gradient(135deg,#181014,#111318); }
.isp-modal { width:min(620px,calc(100vw - 32px)); color:var(--text); background:var(--surface); border:1px solid var(--line-strong); border-radius:14px; padding:22px; box-shadow:0 30px 100px #000; }
.isp-modal::backdrop { background:rgba(0,0,0,.78); backdrop-filter:blur(5px); }
.isp-modal form { display:grid; gap:14px; }
.modal-head { display:flex; align-items:center; justify-content:space-between; }
.modal-head button { border:0; background:none; color:var(--text); font-size:28px; cursor:pointer; }
.button-primary { background:linear-gradient(135deg,#e3262e,#8f1118)!important; border-color:#e3262e!important; }
table tbody tr:hover { background:#171a20; }
@media (max-width: 760px) { .isp-selector { grid-template-columns:1fr; } .layout { grid-template-columns:1fr; } }

.segmented.danger input:checked + span {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

.upload-zone {
  display: grid;
  gap: 14px;
  align-content: start;
}

.checkline {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.checkline input {
  min-height: 0;
  width: 18px;
  height: 18px;
}

.checkline span {
  color: var(--text);
  text-transform: none;
  font-size: 14px;
  font-weight: 500;
}

.align-end {
  align-self: end;
  min-height: 40px;
}

.actions {
  display: flex;
  justify-content: flex-end;
}

.button {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  min-height: 38px;
  padding: 8px 14px;
  background: #181b21;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.button:hover {
  text-decoration: none;
}

.button-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.button-primary:hover {
  background: var(--primary-strong);
}

.button-subtle {
  background: #101217;
}

.full {
  width: 100%;
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  border: 1px solid var(--line);
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #f0b4ae;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef1f5;
  color: #435063;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.ok,
.status-pill.completed,
.status-pill.success,
.status-pill.dry-run {
  background: var(--ok-bg);
  color: var(--ok);
}

.status-pill.bad,
.status-pill.failed,
.status-pill.error,
.status-pill.invalid,
.status-pill.completed_with_errors {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-pill.running,
.status-pill.queued {
  background: var(--warn-bg);
  color: #8a5a00;
}

.kv {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px 12px;
  margin: 0;
}

.kv dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.kv dd {
  margin: 0;
  min-width: 0;
}

.break {
  overflow-wrap: anywhere;
}

.table-section {
  margin-top: 20px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: #171a20;
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.error-cell {
  color: var(--danger);
  min-width: 220px;
}

.login-wrap {
  min-height: calc(100vh - 140px);
  display: grid;
  place-items: center;
}

.login-box {
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
  display: grid;
  gap: 16px;
}

.job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.job-actions {
  display: flex;
  gap: 8px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.metrics {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metrics div {
  display: grid;
  gap: 6px;
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metrics strong {
  font-size: 20px;
}

.details-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 920px) {
  .layout,
  .grid.two,
  .grid.three,
  .details-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .page {
    width: min(100vw - 20px, 760px);
    margin-top: 12px;
  }

  .topbar {
    padding: 0 12px;
  }
  .sidebar { width:72px; padding:18px 8px; }
  .sidebar-nav a { justify-content:center; padding:0; }
  .sidebar-nav a span:last-child, .sidebar-foot { display:none; }
  .page-with-sidebar { margin-left:86px; margin-right:14px; }
  .stat-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .account-grid { grid-template-columns:1fr; }
  .domain-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .domain-summary > div:nth-child(2) { border-right:0; }
}

@media (max-width: 560px) {
  .sidebar { position:fixed; inset:auto 0 0 0; width:auto; height:64px; padding:7px 10px; border:1px solid var(--line); }
  .sidebar-nav { display:grid; grid-template-columns:repeat(4,1fr); }
  .sidebar-nav a { min-height:48px; }
  .page-with-sidebar { margin:14px 12px 84px; }
  .stat-grid { grid-template-columns:1fr; }
  .page-heading { align-items:start; flex-direction:column; }
}
.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.muted {
  color: #64748b;
  margin: -0.35rem 0 0.8rem;
}
