:root {
  --base: #0a0a0b;
  --elevated: #131316;
  --elevated-2: #17171b;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --primary: #fafafa;
  --muted: rgba(250, 250, 250, 0.46);
  --muted-2: rgba(250, 250, 250, 0.28);
  --accent: #ff3b30;
  --accent-soft: rgba(255, 59, 48, 0.12);
  --success: #34c759;
  --warn: #ffcc00;
  --info: #5ac8fa;
  --danger: #ff453a;
  --radius: 20px;
  --radius-sm: 12px;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--base);
  color: var(--primary);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(255, 59, 48, 0.35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.09); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.boot-splash { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--base); }
.boot-splash img { animation: bootfade 1.1s ease infinite alternate; }
@keyframes bootfade { from { opacity: .4; transform: scale(.98); } to { opacity: 1; transform: scale(1); } }

.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

/* ------------------------------- sidebar ------------------------------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: #0b0b0d; padding: 18px 14px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand img { border-radius: 9px; }
.brand-name { font-weight: 600; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding-bottom: 10px; }
.nav-group-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted-2); padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 11px;
  color: rgba(250,250,250,.7); transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--primary); }
.nav-item.active { background: rgba(255,255,255,.07); color: var(--primary); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { width: 18px; text-align: center; color: var(--muted-2); font-size: 13px; }
.nav-item.locked { color: rgba(250,250,250,.55); }
.nav-item.locked .nav-icon { opacity: .65; }
.nav-lock { margin-left: auto; font-size: 11px; opacity: .65; filter: grayscale(1); }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; gap: 10px; align-items: center; padding: 2px 4px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 600;
  background: linear-gradient(145deg, #26262c, #141417); border: 1px solid var(--border);
}
.user-name { font-weight: 500; font-size: 13px; }
.user-sub { font-size: 11px; color: var(--muted); }

/* ------------------------------- content ------------------------------- */
.content { min-width: 0; padding: 26px 30px 60px; max-width: 1480px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-body { display: flex; flex-direction: column; gap: 16px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-tight { display: flex; gap: 6px; align-items: center; }
.grow { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.split { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } .split { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .content { padding: 18px 16px 48px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* -------------------------------- panels ------------------------------- */
.panel { background: var(--elevated); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0; }
.panel-head h3 { font-size: 15px; font-weight: 600; }
.panel-body { padding: 16px 18px 18px; }
.panel-body.tight { padding: 10px 0; }
.error-panel { padding: 18px; color: var(--danger); }

/* -------------------------------- stats -------------------------------- */
.stat { background: var(--elevated); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; }
.stat-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.stat-value { font-family: var(--mono); font-size: 25px; font-weight: 500; margin-top: 6px; letter-spacing: -0.02em; }
.stat-hint { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }
.stat.success .stat-value { color: var(--success); }
.stat.danger .stat-value { color: var(--danger); }
.stat.accent .stat-value { color: var(--accent); }
.stat.info .stat-value { color: var(--info); }

/* -------------------------------- table -------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
.table tbody tr:hover { background: rgba(255,255,255,.02); }
.table .align-right { text-align: right; }
.table .align-center { text-align: center; }
.table tr:last-child td { border-bottom: 0; }
/* Кнопки в таблицах не должны уезжать за край: переносим их на новую строку. */
.table .row-tight { flex-wrap: wrap; gap: 5px; max-width: 300px; }
.table .table-actions { justify-content: flex-end; max-width: 280px; }
/* В «Клиентах» колонка действий всегда видна, даже при горизонтальной прокрутке. */
.clients-table th:last-child,
.clients-table td:last-child {
  position: sticky;
  right: 0;
  background: var(--elevated);
  z-index: 1;
}
.clients-table th:last-child { z-index: 2; }
.clients-table td:last-child { box-shadow: -10px 0 14px -14px rgba(0,0,0,.95); }

/* На узком экране таблица клиентов заменяется карточками — без горизонтальной прокрутки. */
.clients-cards-view { display: none; }
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.client-card {
  border: 1px solid var(--border); border-radius: 14px; padding: 12px;
  background: rgba(255,255,255,.025); display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.client-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.client-card-head > div { min-width: 0; }
.client-card-title { font-weight: 600; overflow-wrap: anywhere; }
.client-card-meta { color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }
.client-card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.client-card-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.client-card .row-tight { flex-wrap: wrap; }
.client-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.client-card-block { background: rgba(255,255,255,.03); border-radius: 10px; padding: 8px 9px; min-width: 0; }
.client-card-block .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.client-card-block .v { font-size: 14px; margin-top: 3px; }
.client-card-block .s { font-size: 11px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
@media (max-width: 1260px) {
  .clients-table-view { display: none; }
  .clients-cards-view { display: block; }
}
@media (max-width: 520px) {
  .client-card-grid { grid-template-columns: 1fr; }
}

/* -------------------------------- forms -------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field-label { font-size: 12px; color: var(--muted); }
.field-hint { font-size: 11px; color: var(--muted-2); }
.input {
  width: 100%; background: #0e0e11; border: 1px solid var(--border-strong); border-radius: 11px;
  padding: 9px 11px; outline: none; transition: border-color .15s, background .15s;
}
.input:focus { border-color: rgba(255,255,255,.28); background: #101014; }
.textarea { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; }
.variant-editor { display: flex; flex-direction: column; gap: 8px; }
.variant-list { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; padding-right: 4px; }
.variant-row { display: flex; gap: 8px; align-items: flex-start; }
.variant-row .textarea { flex: 1; min-height: 76px; resize: vertical; }
.variant-row .btn { flex: none; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: rgba(250,250,250,.82); }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* ------------------------------- buttons ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 11px; padding: 8px 14px; cursor: pointer; border: 1px solid var(--border-strong);
  background: rgba(255,255,255,.04); color: var(--primary); font-size: 13px; font-weight: 500;
  transition: background .15s, border-color .15s, transform .05s; white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,.08); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #ff5147; }
.btn.danger { background: rgba(255,69,58,.14); border-color: rgba(255,69,58,.35); color: #ff8a80; }
.btn.danger:hover { background: rgba(255,69,58,.22); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 9px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; padding: 4px 6px; border-radius: 8px; }
.icon-btn:hover { color: var(--primary); background: rgba(255,255,255,.06); }

/* -------------------------------- misc --------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; border: 1px solid transparent; white-space: nowrap; }
.badge-success { background: rgba(52,199,89,.12); color: #6ee7a0; border-color: rgba(52,199,89,.22); }
.badge-danger { background: rgba(255,69,58,.12); color: #ff8a80; border-color: rgba(255,69,58,.24); }
.badge-warn { background: rgba(255,204,0,.1); color: #ffd75e; border-color: rgba(255,204,0,.22); }
.badge-info { background: rgba(90,200,250,.1); color: #8fd8ff; border-color: rgba(90,200,250,.22); }
.badge-accent { background: rgba(255,59,48,.12); color: #ff8f88; border-color: rgba(255,59,48,.28); }
.badge-neutral { background: rgba(255,255,255,.06); color: var(--muted); border-color: var(--border); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.04); border: 1px solid var(--border); font-size: 12px; cursor: pointer; }
.chip.active { background: rgba(255,59,48,.12); border-color: rgba(255,59,48,.34); color: #ff9d95; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; background: rgba(255,255,255,.03); padding: 4px; border-radius: 12px; width: fit-content; max-width: 100%; }
.tab { background: transparent; border: 0; padding: 6px 12px; border-radius: 9px; cursor: pointer; color: var(--muted); font-size: 12.5px; }
.tab.active { background: rgba(255,255,255,.08); color: var(--primary); }
.hub-tabs { margin-bottom: 14px; }

.progress { position: relative; height: 22px; background: rgba(255,255,255,.05); border-radius: 8px; overflow: hidden; min-width: 120px; }
.progress-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, rgba(255,59,48,.5), rgba(255,59,48,.8)); transition: width .3s; }
.progress-text { position: relative; font-size: 11px; font-family: var(--mono); display: grid; place-items: center; height: 100%; }

.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 18px 4px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.18); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty-icon { font-size: 22px; color: var(--muted-2); }

/* ------------------------------- modals -------------------------------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 18px; z-index: 60; opacity: 0; transition: opacity .18s; }
.overlay.in { opacity: 1; }
.modal { width: min(560px, 100%); max-height: 88vh; display: flex; flex-direction: column; background: #141418; border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: 0 30px 80px rgba(0,0,0,.5); transform: translateY(8px); transition: transform .18s; }
.overlay.in .modal { transform: none; }
.modal-wide { width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-title { font-weight: 600; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); }
.actions-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions-list .btn { width: 100%; }

/* -------------------------------- toasts ------------------------------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { display: flex; align-items: center; gap: 9px; background: #1a1a1f; border: 1px solid var(--border-strong); border-radius: 12px; padding: 10px 14px; font-size: 13px; box-shadow: 0 16px 40px rgba(0,0,0,.4); opacity: 0; transform: translateY(8px); transition: all .2s; max-width: 380px; }
.toast.in { opacity: 1; transform: none; }
.toast-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--info); flex: none; }
.toast-success .toast-dot { background: var(--success); }
.toast-danger .toast-dot { background: var(--danger); }
.toast-warn .toast-dot { background: var(--warn); }

/* -------------------------------- auth --------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(800px 400px at 50% -10%, rgba(255,59,48,.1), transparent 70%), var(--base); }
.auth-card { width: min(420px, 100%); background: var(--elevated); border: 1px solid var(--border); border-radius: 24px; padding: 26px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.auth-title { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; margin-bottom: 4px; }
.auth-sub { color: var(--muted); margin-bottom: 20px; font-size: 13px; }
.auth-foot { margin-top: 14px; text-align: center; color: var(--muted); font-size: 12.5px; }
.auth-foot a { color: var(--primary); }

/* ------------------------------ log console ---------------------------- */
.console { background: #0b0b0d; border: 1px solid var(--border); border-radius: 14px; padding: 6px 8px; font-family: var(--mono); font-size: 12px; line-height: 1.55; max-height: 420px; overflow-y: auto; }
.console .ln { white-space: pre-wrap; word-break: break-word; }
.console .dim { color: var(--muted-2); }
.console .ok { color: #6ee7a0; }
.console .warn { color: #ffd75e; }
.console .error { color: #ff8a80; }
.console .step { color: #8fd8ff; }
.console .info { color: rgba(250,250,250,.72); }
.log-row {
  display: grid; grid-template-columns: 70px 14px minmax(0, 1fr); gap: 8px;
  padding: 7px 6px; border-radius: 10px;
  border-bottom: 1px solid rgba(255,255,255,.035);
  color: rgba(250,250,250,.82);
}
.log-row:last-child { border-bottom: 0; }
.log-row:hover { background: rgba(255,255,255,.022); }
.log-time { font-size: 10px; color: var(--muted-2); font-variant-numeric: tabular-nums; padding-top: 2px; line-height: 1.35; }
.log-mark { font-size: 12px; line-height: 1.45; text-align: center; color: var(--muted-2); }
.log-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.log-meta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.log-login { font-size: 10px; color: #8fd8ff; background: rgba(90,200,250,.09); border: 1px solid rgba(90,200,250,.15); padding: 1px 6px; border-radius: 999px; }
.log-step { font-size: 9px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.06); padding: 1px 6px; border-radius: 999px; }
.log-thread { font-size: 10px; color: #c9b6ff; background: rgba(150,120,255,.10); border: 1px solid rgba(150,120,255,.18); padding: 1px 6px; border-radius: 999px; }
.log-msg { font-size: 12px; color: rgba(250,250,250,.82); white-space: pre-wrap; word-break: break-word; }
.log-row.error { background: rgba(255,69,58,.055); }
.log-row.error .log-mark { color: #ff8a80; }
.log-row.error .log-msg { color: #ffb3ad; }
.log-row.ok { background: rgba(90,220,140,.045); }
.log-row.ok .log-mark { color: #6ee7a0; }
.log-row.ok .log-msg { color: #b9f5cf; }
.log-row.success .log-mark { color: #6ee7a0; }
.log-row.success .log-msg { color: #b9f5cf; }
.log-row.warn { background: rgba(255,204,0,.04); }
.log-row.warn .log-mark { color: #ffd75e; }
.log-row.warn .log-msg { color: #ffe9a3; }
.log-row.step .log-mark { color: #8fd8ff; }
.log-row.step .log-msg { color: #c8ecff; }
.log-row.info .log-mark { color: var(--muted); }

/* --------------------- логи: правая закреплённая панель ---------------- */
.autofill-shell { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.autofill-settings { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 16px; align-items: start; }
.reg-shell { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; align-items: start; }
.log-panel {
  position: sticky; top: 12px; display: flex; flex-direction: column;
  height: calc(100vh - 120px); min-height: 420px;
  background: linear-gradient(180deg, rgba(20,20,24,.98) 0%, rgba(10,10,12,.99) 100%);
  border: 1px solid rgba(255,255,255,.10); border-radius: 18px;
  overflow: hidden; box-shadow: 0 18px 48px rgba(0,0,0,.38);
}
.log-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.025);
}
.log-panel-title { font-size: 13px; font-weight: 600; letter-spacing: -.01em; }
.log-panel-sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.log-panel .console { flex: 1; min-height: 0; max-height: none; border: 0; border-radius: 0; padding: 6px 8px; background: transparent; }
.log-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); display: inline-block; flex: 0 0 8px; }
.log-live-dot.live { background: #34c759; box-shadow: 0 0 0 0 rgba(52,199,89,.6); animation: logPulse 1.6s infinite; }
@keyframes logPulse {
  0% { box-shadow: 0 0 0 0 rgba(52,199,89,.5); }
  70% { box-shadow: 0 0 0 7px rgba(52,199,89,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,199,89,0); }
}
.table tbody tr.row-active { background: rgba(90,200,250,.075); box-shadow: inset 2px 0 0 #5ac8fa; }
.table tbody tr.row-active:hover { background: rgba(90,200,250,.10); }
.queue-card {
  border: 1px solid var(--border); border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.015));
  padding: 12px; margin-bottom: 12px;
}
.queue-card .progress { margin-top: 9px; }
.queue-stats { flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* Главная карточка активного пакета регистрации */
.reg-page { display: flex; flex-direction: column; gap: 14px; }
.reg-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.reg-summary .stat { padding: 12px 14px; }
.batch-monitor { overflow: hidden; }
.batch-monitor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 14px 16px 10px; }
.batch-monitor-title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.batch-monitor-title h3 { margin: 0; font-size: 15px; }
.batch-monitor-sub { color: var(--muted); font-size: 11px; margin-top: 4px; }
.batch-monitor-body { padding: 0 16px 16px; }
.batch-monitor-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.batch-monitor-console { margin-top: 12px; }
.batch-monitor-console .console { height: 360px; max-height: 360px; }
.batch-monitor-console-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.batch-monitor-console-head .muted { font-size: 11px; }
@media (max-width: 1100px) { .reg-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { .reg-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } .batch-monitor-head { flex-direction: column; } }

/* Один пакет — одна строка; логи всех потоков раскрываются внутри */
.batch-table tbody tr.batch-row { cursor: pointer; }
.batch-table tbody tr.batch-row.row-active { background: rgba(90,200,250,.075); box-shadow: inset 2px 0 0 #5ac8fa; }
.batch-pkg-id { font-family: var(--mono); font-size: 11px; color: #8fd8ff; }
.batch-exp-row > td { padding: 0 !important; background: rgba(0,0,0,.18); }
.batch-exp-body { padding: 11px 12px 13px; border-top: 1px solid rgba(255,255,255,.06); }
.batch-exp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.batch-exp-head b { font-size: 12px; }
.batch-run-chips { gap: 4px; flex-wrap: wrap; }
.batch-run-chips .btn { padding: 2px 7px; font-size: 10px; }
.batch-exp-logs .console { height: 320px; max-height: 320px; }
.batch-exp-meta { font-size: 10px; margin-top: 5px; text-align: right; }
@media (max-width: 800px) {
  .batch-table thead { display: none; }
  .batch-table tbody tr.batch-row { display: grid; grid-template-columns: 1fr 1fr; }
  .batch-table tbody tr.batch-row td { display: block; border: 0; padding: 4px 8px; }
  .batch-table tbody tr.batch-row td:last-child { grid-column: 1 / -1; }
}

/* ---------------------- порядок запуска автозалива --------------------- */
.guide { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.guide-step {
  display: flex; align-items: flex-start; gap: 9px; text-align: left;
  padding: 10px; border: 1px solid var(--border); border-radius: 12px;
  background: rgba(255,255,255,.02); color: inherit; cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.guide-step:hover { border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.04); }
.guide-step.done { border-color: rgba(52,199,89,.28); background: rgba(52,199,89,.05); }
.guide-num {
  flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.06); font-size: 11px; color: var(--muted);
}
.guide-step.done .guide-num { background: rgba(52,199,89,.16); color: #6ee7a0; }
.guide-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.guide-body b { font-size: 12px; font-weight: 600; }
.guide-desc { font-size: 10.5px; color: var(--muted); line-height: 1.35; }
@media (max-width: 1200px) { .guide { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .guide { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1200px) {
  .autofill-shell, .reg-shell { grid-template-columns: minmax(0, 1fr); }
  .log-panel { position: static; height: 420px; min-height: 420px; }
}
@media (max-width: 900px) {
  .autofill-settings { grid-template-columns: minmax(0, 1fr); }
}

/* --------------------------- media / gallery --------------------------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 9 / 16; border-radius: 12px; overflow: hidden; background: #0e0e11; border: 1px solid var(--border); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb .thumb-x { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.65); border-radius: 8px; padding: 2px 6px; }
.thumb .play-badge {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 22px; color: #fff; background: rgba(0,0,0,.22);
  text-shadow: 0 2px 10px rgba(0,0,0,.8); pointer-events: none;
}
.dropzone { border: 1px dashed var(--border-strong); border-radius: 16px; padding: 26px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.02); }

.list-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; cursor: pointer; }
.list-item:hover { background: rgba(255,255,255,.04); }
.list-item.active { background: rgba(255,255,255,.07); }
.list-item .meta { font-size: 11.5px; color: var(--muted); }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13px; }
.kv .k { color: var(--muted); }
.scroll-y { max-height: 420px; overflow-y: auto; }
.hint-box { background: rgba(90,200,250,.06); border: 1px solid rgba(90,200,250,.16); border-radius: 12px; padding: 10px 12px; font-size: 12px; color: rgba(250,250,250,.7); }
.warn-box { background: rgba(255,204,0,.06); border: 1px solid rgba(255,204,0,.18); border-radius: 12px; padding: 10px 12px; font-size: 12px; color: rgba(250,250,250,.72); }

/* ============================== MOBILE ============================== */
.mobile-topbar, .nav-overlay { display: none; }

@media (max-width: 820px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  body.nav-open { overflow: hidden; }

  .app { display: block; min-height: 100dvh; }

  .mobile-topbar {
    display: flex; align-items: center; gap: 9px;
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    height: calc(54px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 12px 0;
    background: rgba(10,10,11,.92); backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
  }
  .mobile-menu-btn {
    width: 42px; height: 42px; flex: none; border-radius: 12px;
    border: 1px solid var(--border-strong); background: rgba(255,255,255,.04);
    color: var(--primary); font-size: 19px; line-height: 1;
  }
  .mobile-brand { display: flex; align-items: center; gap: 7px; font-weight: 600; letter-spacing: -.02em; }
  .mobile-brand img { border-radius: 8px; }
  .mobile-title {
    flex: 1; min-width: 0; text-align: center; font-size: 12.5px; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .mobile-user {
    width: 34px; height: 34px; flex: none; border-radius: 50%;
    border: 1px solid var(--border-strong); background: linear-gradient(145deg,#26262c,#141417);
    font-weight: 600; font-size: 12px;
  }

  body .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 70;
    width: min(300px, 86vw); height: 100dvh; max-height: 100dvh;
    padding: calc(14px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
    transform: translateX(-102%); transition: transform .22s ease;
    box-shadow: 26px 0 60px rgba(0,0,0,.55);
    border-right: 1px solid var(--border-strong); overflow-y: auto;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .nav-overlay {
    display: block; position: fixed; inset: 0; z-index: 60;
    background: rgba(0,0,0,.62); backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.nav-open .nav-overlay { opacity: 1; pointer-events: auto; }
  .sidebar .nav { gap: 8px; overflow: visible; }
  .sidebar .nav-item { min-height: 44px; padding: 11px 12px; font-size: 14px; }
  .sidebar .nav-more { margin-top: 4px; }

  .content {
    padding: calc(66px + env(safe-area-inset-top)) 14px calc(30px + env(safe-area-inset-bottom));
    max-width: 100%;
  }
  .page-head { flex-direction: column; gap: 10px; margin-bottom: 14px; }
  .page-head h1 { font-size: 22px; line-height: 1.2; }
  .page-head p { font-size: 12.5px; }
  .page-head-actions { width: 100%; display: flex; gap: 8px; flex-wrap: wrap; }
  .page-head-actions > * { flex: 1 1 calc(50% - 4px); }
  .page-head-actions .btn { width: 100%; }

  .row { gap: 8px; align-items: stretch; }
  .row-tight { flex-wrap: wrap; max-width: 100%; }
  .row > .input, .row > select.input, .row > textarea.input { flex: 1 1 100%; min-width: 0; }
  .btn { white-space: normal; max-width: 100%; }
  .badge { white-space: normal; max-width: 100%; }
  .table td, .log-msg, .hint-box, .warn-box { overflow-wrap: anywhere; }
  .panel { border-radius: 16px; }
  .panel-head { padding: 13px 14px 0; flex-wrap: wrap; gap: 8px; }
  .panel-body { padding: 12px 14px 14px; }
  .panel-body.tight { padding: 8px 0; }
  .split { display: flex; flex-direction: column; gap: 12px; }
  .split > .panel { width: 100%; }
  .accounts-split > .panel:first-child .panel-body { max-height: 190px; overflow-y: auto; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 10px; }
  .stat-value { font-size: 22px; }

  .tabs { width: 100%; display: flex; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; min-height: 36px; padding: 8px 12px; }

  .btn { min-height: 40px; padding: 9px 13px; }
  .btn.small { min-height: 34px; }
  .icon-btn { min-width: 38px; min-height: 38px; }
  input, select, textarea { font-size: 16px; }
  .input, select.input, textarea.input { font-size: 16px; min-height: 44px; }
  .textarea { font-size: 13px; }
  .check input { width: 18px; height: 18px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv .k { margin-top: 6px; }

  .table-wrap { overflow: visible; }
  .table:not(.clients-table):not(.batch-table) { display: block; width: 100%; }
  .table:not(.clients-table):not(.batch-table) thead { display: none; }
  .table:not(.clients-table):not(.batch-table) tbody,
  .table:not(.clients-table):not(.batch-table) tr,
  .table:not(.clients-table):not(.batch-table) td { display: block; width: 100%; }
  .table:not(.clients-table):not(.batch-table) tr {
    margin: 0 0 10px; padding: 9px 11px; border: 1px solid var(--border);
    border-radius: 14px; background: rgba(255,255,255,.025);
  }
  .table:not(.clients-table):not(.batch-table) tr:last-child { margin-bottom: 0; }
  .table:not(.clients-table):not(.batch-table) td {
    display: flex; gap: 10px; align-items: flex-start; justify-content: space-between;
    border: 0; padding: 5px 0; min-width: 0; text-align: left !important;
  }
  .table:not(.clients-table):not(.batch-table) td::before {
    content: attr(data-label); flex: 0 0 42%; color: var(--muted);
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; padding-top: 2px;
  }
  .table:not(.clients-table):not(.batch-table) td[data-label=""]:not(:last-child) { order: -1; justify-content: flex-start; }
  .table:not(.clients-table):not(.batch-table) td[data-label="#"] { order: -2; justify-content: flex-start; font-size: 11px; color: var(--muted); padding-bottom: 2px; }
  .table:not(.clients-table):not(.batch-table) td[data-label=""]::before,
  .table:not(.clients-table):not(.batch-table) td[data-label="#"]::before,
  .table:not(.clients-table):not(.batch-table) td:last-child::before { display: none; }
  .table:not(.clients-table):not(.batch-table) td:last-child {
    margin-top: 5px; padding-top: 8px; border-top: 1px solid var(--border);
  }
  .table:not(.clients-table):not(.batch-table) td .row-tight,
  .table:not(.clients-table):not(.batch-table) td .table-actions { justify-content: flex-start; max-width: none; width: 100%; }
  .table:not(.clients-table):not(.batch-table) td .btn { flex: 1 1 auto; }
  .table:not(.clients-table):not(.batch-table) td > div { min-width: 0; }

  .account-toolbar { flex-wrap: wrap; }
  .account-toolbar > .row { width: 100%; }
  .account-toolbar .btn { flex: 1 1 calc(50% - 4px); }
  .list-item { min-height: 44px; }

  .overlay { padding: 0; place-items: end stretch; }
  .overlay .modal, .overlay .modal-wide {
    width: 100%; max-width: 100%; max-height: 100dvh;
    border-radius: 18px 18px 0 0; transform: translateY(100%);
  }
  .overlay.in .modal { transform: none; }
  .modal-head {
    padding: 13px 14px; padding-top: calc(13px + env(safe-area-inset-top));
    position: sticky; top: 0; background: #141418; z-index: 2;
  }
  .modal-body { padding: 14px; -webkit-overflow-scrolling: touch; }
  .modal-actions {
    padding: 11px 14px calc(11px + env(safe-area-inset-bottom));
    position: sticky; bottom: 0; background: #141418; z-index: 2; flex-wrap: wrap;
  }
  .modal-actions .btn { flex: 1 1 calc(50% - 4px); min-height: 44px; }
  .actions-list { grid-template-columns: 1fr; }

  .console { height: 45vh !important; max-height: 45vh !important; font-size: 11.5px; }
  .console .ln { overflow-wrap: anywhere; }
  canvas { max-width: 100%; height: auto; }
  .toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .toast { max-width: 100%; }
  .auth-card { padding: 20px; border-radius: 20px; }
  .hint-box, .warn-box { font-size: 12px; }
  .client-card-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  /* Логи: дата/уровень сверху, сообщение — на всю ширину. */
  .console .ln { flex-wrap: wrap; row-gap: 2px; align-items: flex-start; }
  .console .ln > span:last-child { flex: 1 1 100%; white-space: normal; }
  .log-row { grid-template-columns: 48px 10px minmax(0, 1fr); gap: 6px; padding: 6px 4px; }
  .log-row .log-time { font-size: 9px; }
  .log-row .log-msg { font-size: 11.5px; }
}

@media (max-width: 420px) {
  .content { padding-left: 10px; padding-right: 10px; }
  .page-head-actions > * { flex: 1 1 100%; }
  .mobile-brand span { display: none; }
  .table:not(.clients-table):not(.batch-table) td::before { flex-basis: 38%; }
}
