/* =========================================
   Product UI Refresh — Unified style.css
   ========================================= */

/* ===== Light Theme (default) ===== */
:root {
  --bg: #f5f8fd;
  --bg-grad-a: #f6f9fd;
  --bg-grad-b: #e8effa;

  --brand: #173f63;      /* header/footer left */
  --brand-600: #2a6896;  /* header/footer right + buttons */

  --text: #111827;
  --muted: #4b5563;
  --surface: #ffffff;
  --surface-1: #f5f8fd;
  --surface-2: #f8fbff;
  --border: #dbe3ef;
  --line: #dbe3ef;

  --primary: #2563eb;
  --primary-300: #93c5fd;

  --success: #16a34a;
  --danger: #dc2626;

  --shadow-1: 0 6px 18px rgba(0,0,0,0.08);
  --shadow-2: 0 10px 24px rgba(0,0,0,0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;

  --font-sans: 'Manrope', -apple-system, system-ui, "Segoe UI", Arial, sans-serif;
  --font-heading: 'IBM Plex Sans', 'Manrope', sans-serif;
  --font-size-sm: 0.9rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.1rem;
  --font-size-xl: 1.5rem;
}

/* ===== Dark Theme ===== */
html[data-theme="dark"],
body.dark {
  --bg: #101c30;
  --bg-grad-a: #122037;
  --bg-grad-b: #1a3150;

  --surface: #182844;
  --surface-1: #1e3354;
  --surface-2: #244062;

  --text: #eef3fb;
  --muted: #b6c4d9;
  --border: #34506f;
  --line: #34506f;

  --brand: #16385f;
  --brand-600: #2a6aa0;

  --primary: #8bb9ff;
  --primary-300: #b7d3ff;

  --shadow-1: 0 8px 18px rgba(0,0,0,0.45);
  --shadow-2: 0 16px 30px rgba(0,0,0,0.55);

  --font-size-base: 1.03rem;
  --font-size-sm: 0.95rem;
}

/* Bold text should remain visible in dark mode */
html[data-theme="dark"] strong,
body.dark strong {
  color: #e5e7eb;
}

/* Improve form field readability in dark mode */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
body.dark input,
body.dark select,
body.dark textarea {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] input::file-selector-button,
body.dark input::file-selector-button {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

/* ===== Base Layout ===== */
*,
*::before,
*::after { box-sizing: border-box; }
html, body {
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden; /* Не даём интерфейсу "уезжать" вправо */
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-grad-a), var(--bg-grad-b));
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto; /* header | content | footer */
}

html[data-theme="dark"] body,
body.dark {
  background: linear-gradient(135deg, var(--bg-grad-a), var(--bg-grad-b)) !important;
  color: var(--text) !important;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
html[data-theme="dark"] {
  color: var(--text) !important;
  background: linear-gradient(135deg, var(--bg-grad-a), var(--bg-grad-b)) !important;
}

/* Keep native `hidden` behavior even if class selectors set display. */
[hidden] { display: none !important; }

main { padding: 0 var(--space-4) var(--space-6); }

h1, h2, h3 {
  font-family: var(--font-heading);
  letter-spacing: 0.01em;
}

a {
  color: var(--primary);
}

a:hover {
  filter: saturate(1.08);
}

.centered {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}
.centered.centered--top {
  justify-content: flex-start;
  padding: var(--space-4);
}

/* ===== Layout Helpers ===== */
.page-wrap {
  --page-max: 1200px;
  width: min(var(--page-max), 96vw);
  margin: var(--space-6) auto;
  display: grid;
  gap: var(--space-4);
}

.page-wrap--wide { --page-max: 1400px; }
.page-wrap--medium { --page-max: 960px; }
.page-wrap--narrow { --page-max: 760px; }

.page-hero {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-hero__main {
  flex: 1 1 320px;
  min-width: 260px;
}

.page-hero__actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: clamp(1.4rem, 2.2vw, 1.9rem);
}

.page-subtitle {
  margin: var(--space-2) 0 0;
  color: var(--muted);
}

.meta-row {
  margin-top: var(--space-2);
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
}

.meta-item {
  margin: 0;
  color: var(--muted);
}

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  margin: 0;
  color: var(--muted);
}

.toggle-inline input {
  accent-color: var(--brand-600);
}

.card-title,
.section-title {
  margin: 0 0 var(--space-3);
  font-size: var(--font-size-xl);
}

.card-subtitle {
  margin: 0;
  color: var(--muted);
}

.content-block {
  display: grid;
  gap: var(--space-3);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.text-center { text-align: center; }
.text-pre-wrap { white-space: pre-wrap; word-break: break-word; }
.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: var(--space-2) !important; }
.mt-12 { margin-top: var(--space-3) !important; }

.form-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

.form-actions .btn-primary,
.form-actions .nav-btn,
.form-actions .btn-danger {
  width: min(260px, 100%);
  margin: 0;
}

.form-divider {
  border-top: 1px solid var(--line);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
}

.auth-card {
  width: min(520px, 96vw);
}

.auth-card--sm {
  width: min(420px, 96vw);
}

.auth-card--md {
  width: min(560px, 100%);
}

.agent-card-modal {
  max-width: 700px;
  width: 100%;
}

.agent-card-title {
  margin: 0 0 var(--space-3);
  font-size: var(--font-size-lg);
}

.agent-card-label {
  width: 30%;
  text-align: right;
  white-space: nowrap;
  vertical-align: top;
  font-weight: 600;
}

.agent-card-value {
  width: 70%;
  text-align: left;
}

.table-shell-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.btn-danger {
  background: linear-gradient(135deg, #8a1f28, #b42332);
  color: #fff;
  border: none;
}

.btn-danger:hover {
  filter: saturate(1.05);
}

.btn-report {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  margin: 0;
  padding: 9px 14px;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  box-shadow: var(--shadow-1);
}

.btn-report:hover {
  filter: saturate(1.05);
  box-shadow: var(--shadow-2);
}

.btn-flat {
  width: auto;
  margin: 0;
}

.btn-equal {
  width: 160px;
  height: 40px;
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #dbe7f9;
  color: #16324e;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.badge-error {
  background: #fee2e2;
  color: #7f1d1d;
}

.badge-historical {
  margin-left: 6px;
  background: #e5e7eb;
  color: #374151;
}

html[data-theme="dark"] .badge,
body.dark .badge {
  background: #1d3555;
  color: #e8f2ff;
}

html[data-theme="dark"] .badge-error,
body.dark .badge-error {
  background: #4f1f2b;
  color: #ffd9dd;
}

html[data-theme="dark"] .badge-historical,
body.dark .badge-historical {
  background: #334155;
  color: #e2e8f0;
}

/* ===== Header / Nav ===== */
header nav {
  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-1);
  border-bottom: 1px solid rgba(255,255,255,0.16);
  color: #fff;
  overflow-x: auto;
}
header nav .nav-menu {
  width: 100%;
}
header nav .nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
header nav .nav-toggle:focus-visible {
  outline: 3px solid rgba(255,255,255,0.5);
  outline-offset: 2px;
}
header nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: nowrap;
  width: 100%;
  min-width: max-content;
}
header nav li { margin: 0; }
header nav li a {
  color: #fff;
  text-decoration: none;
  padding: 9px 14px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .15s ease, background-color .2s ease, box-shadow .2s ease;
}
header nav li a:hover {
  background-color: rgba(255,255,255,0.12);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.15);
}
header nav li a.is-active {
  background: rgba(255,255,255,0.2);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.34);
}

/* ===== Sticky Header (page-level) ===== */
header {
  position: sticky;
  top: 0;
  z-index: 2000; /* выше таблиц, модалок с z<2000 */
}

/* Правый блок с кнопками */
header nav li.nav-right {
  margin-left: auto;
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

/* Стиль кнопок в навигации (и для <a>, и для <button>) */
.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  min-height: 40px;
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  width: auto;
  margin: 0;

  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  color: #fff;
  border: none;
  box-shadow: var(--shadow-1);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}
.nav-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
  filter: saturate(1.05);
}
.nav-btn:active { transform: translateY(0); }
.nav-btn.is-danger {
  background: linear-gradient(135deg, #8a1f28, #b42332);
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: var(--space-6);
  color: var(--text);
}

/* ===== Forms ===== */
label { display: block; margin: 10px 0 6px; font-weight: 600; color: var(--text); }
input[type="file"],
input[type="text"],
input[type="password"],
input[type="email"],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::file-selector-button{
  margin-right:10px;
  padding:8px 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-1);
  cursor:pointer;
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}
input::file-selector-button:hover{
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
  filter: saturate(1.05);
}
input::file-selector-button:active{ transform: translateY(0); }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary-300);
  box-shadow: 0 0 0 4px rgba(59,130,246,0.25);
}

/* ===== Primary Buttons (в формах) ===== */
button, .button, .btn-primary {
  display: inline-flex; justify-content: center; align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 15px;
  padding: 12px 16px;
  min-height: 44px;

  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  color: #fff;

  border: none;
  border-radius: 12px;
  font-weight: 700; letter-spacing: .2px;
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}
button:hover, .button:hover, .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
  filter: saturate(1.05);
}
button:active, .button:active, .btn-primary:active { transform: translateY(0); }

button:disabled,
.btn:disabled,
.button:disabled,
.btn-primary:disabled,
.nav-btn:disabled,
.btn-danger:disabled,
.decision-btn:disabled,
.restore-rejected-btn:disabled,
.dt-button.disabled,
.dt-button:disabled {
  opacity: 0.55 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  transform: none !important;
  box-shadow: none !important;
  filter: saturate(0.6) !important;
}

/* ===== Tables ===== */
.table-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 12px;
  overflow: auto;
}
table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface);
}
table th, table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  color: var(--text);
}
table th {
  background: #f3f4f6;
  font-weight: 600;
}
table tr:nth-child(even) td { background: #f9fafb; }
table tr:hover td { background: #f1f5f9; }

html[data-theme="dark"] table th,
body.dark table th { background: #1e293b; color: #f9fafb; }
html[data-theme="dark"] table tr:nth-child(even) td,
body.dark table tr:nth-child(even) td { background: #162032; }
html[data-theme="dark"] table tr:hover td,
body.dark table tr:hover td { background: #1e2a40; }

#agents-table th.check-col, #agents-table td.check-col {
  width: 40px; text-align: center; white-space: nowrap;
}

/* ===== Compact Tables ===== */
.table-shell.compact { padding: 8px; border-radius: 10px; }
.table-compact { font-size: 0.92rem; border-spacing: 0; }
.table-compact th, .table-compact td { padding: 6px 8px; line-height: 1.25; }
.table-compact tr:nth-child(even) td { background: #f5f7fb; }
.table-compact tr:hover td { background: #eef2f7; }
html[data-theme="dark"] .table-compact tr:nth-child(even) td,
body.dark .table-compact tr:nth-child(even) td { background: #162032; }
html[data-theme="dark"] .table-compact tr:hover td,
body.dark .table-compact tr:hover td { background: #1e2a40; }

/* ===== DataTables: Column Visibility ===== */
.dt-button.buttons-colvis,
button.dt-button.buttons-colvis,
a.dt-button.buttons-colvis,
.dt-button.buttons-collection,
button.dt-button.buttons-collection,
a.dt-button.buttons-collection {
  background-image: none !important;
  background: linear-gradient(135deg, var(--brand), var(--brand-600)) !important;
  color: #f8fafc !important;
  border: 1px solid rgba(255,255,255,0.18) !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow-1) !important;
  text-shadow: none !important;
}
.dt-button.buttons-colvis:hover,
.dt-button.buttons-collection:hover {
  filter: saturate(1.05) !important;
  box-shadow: var(--shadow-2) !important;
}
.dt-button.buttons-colvis span.dt-down-arrow,
.dt-button.buttons-collection span.dt-down-arrow {
  color: currentColor !important;
  opacity: 0.85;
}
.dt-button.buttons-columnVisibility {
  background-color: #eef2ff !important;
  color: #1f2937 !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  padding: 8px 10px !important;
  margin: 0 6px 6px 0 !important;
}
.dt-button.buttons-columnVisibility.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-600)) !important;
  color: #fff !important;
  border-color: transparent !important;
}

/* выпадающее меню */
div.dt-button-collection {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow-2) !important;
  padding: 8px !important;
}

/* пункты (не активны — светлые) */
div.dt-button-collection button.dt-button,
div.dt-button-collection a.dt-button,
div.dt-button-collection .dt-button {
  display: block !important;
  width: 100% !important;
  text-align: left !important;
  margin: 4px 0 !important;
  padding: 10px 12px !important;

  border-radius: 10px !important;
  border: 1px solid var(--border) !important;

  background-image: none !important;
  box-shadow: none !important;
  text-shadow: none !important;

  background: #f3f4f6 !important;
  color: var(--text) !important;
}
div.dt-button-collection button.dt-button:not(.active):not([aria-pressed="true"]):hover,
div.dt-button-collection a.dt-button:not(.active):not([aria-pressed="true"]):hover {
  background: #e5e7eb !important;
}

/* активные — тёмно-синие */
div.dt-button-collection .dt-button.active,
div.dt-button-collection .dt-button[aria-pressed="true"] {
  background-image: none !important;
  background: linear-gradient(135deg, var(--brand), var(--brand-600)) !important;
  color: #fff !important;
  border-color: transparent !important;
  box-shadow: var(--shadow-1) !important;
}

/* дарк */
html[data-theme="dark"] div.dt-button-collection,
body.dark div.dt-button-collection {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}
html[data-theme="dark"] div.dt-button-collection .dt-button,
body.dark div.dt-button-collection .dt-button {
  background: #162032 !important;
  color: var(--text) !important;
  border-color: #22314d !important;
}
html[data-theme="dark"] div.dt-button-collection .dt-button:hover,
body.dark div.dt-button-collection .dt-button:hover {
  background: #1e2a40 !important;
}

/* ===== Messages ===== */
.message {
  margin-top: 10px; padding: 12px 14px;
  background: #ecfdf5; border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm); color: #064e3b;
}
.error {
  margin-top: 10px; padding: 12px 14px;
  background: #fef2f2; border: 1px solid #fecaca;
  border-radius: var(--radius-sm); color: #7f1d1d;
}
html[data-theme="dark"] .message, body.dark .message { background: #064e3b; border-color: #10b981; color: #d1fae5; }
html[data-theme="dark"] .error, body.dark .error { background: #7f1d1d; border-color: #fecaca; color: #fee2e2; }

.hint {
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-size: var(--font-size-sm);
}

/* ===== Progress Bar ===== */
.progress-bar {
  width: 100%; height: 16px;
  background: var(--surface-1); border-radius: 999px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-bar div,
.progress-inner {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--brand-600));
  transition: width 0.45s ease;
}

.progress-card {
  width: min(760px, 96vw);
}

.progress-percent {
  margin: var(--space-2) 0 0;
  font-weight: 700;
  text-align: center;
}

.progress-meta {
  margin-top: var(--space-3);
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: var(--space-2);
}

.progress-meta > :last-child {
  text-align: right;
}

.progress-actions {
  margin-top: var(--space-4);
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

.progress-actions .nav-btn {
  width: min(260px, 100%);
  margin: 0;
}

/* Dark theme: progress page (progress.html) has light inline styles. Override them. */
html[data-theme="dark"] .progress-legend-item,
body.dark .progress-legend-item {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
  color: var(--muted);
}
html[data-theme="dark"] .progress-item,
body.dark .progress-item {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
html[data-theme="dark"] .progress-item.is-waiting,
body.dark .progress-item.is-waiting {
  background: var(--surface-2);
  border-left-color: #7f97b0;
}
html[data-theme="dark"] .progress-item.is-running,
body.dark .progress-item.is-running {
  background: var(--surface-2);
  border-left-color: var(--brand-600);
}
html[data-theme="dark"] .progress-item.is-paused,
body.dark .progress-item.is-paused {
  background: var(--surface-2);
  border-left-color: #6f8cb0;
}
html[data-theme="dark"] .progress-item.is-done,
body.dark .progress-item.is-done {
  background: var(--surface-2);
  border-left-color: #3f8a62;
}
html[data-theme="dark"] .progress-item.is-failed,
body.dark .progress-item.is-failed {
  background: var(--surface-2);
  border-left-color: #c46a6a;
}
html[data-theme="dark"] .progress-item.is-cancelled,
body.dark .progress-item.is-cancelled {
  background: var(--surface-2);
  border-left-color: #8794a8;
}
html[data-theme="dark"] .progress-item-status,
body.dark .progress-item-status {
  border: 1px solid var(--border);
  color: var(--text);
}
html[data-theme="dark"] .progress-item-status.status-waiting,
body.dark .progress-item-status.status-waiting {
  background: rgba(127, 151, 176, 0.22);
  border-color: rgba(127, 151, 176, 0.35);
}
html[data-theme="dark"] .progress-item-status.status-running,
body.dark .progress-item-status.status-running {
  background: rgba(42, 106, 160, 0.22);
  border-color: rgba(42, 106, 160, 0.45);
}
html[data-theme="dark"] .progress-item-status.status-paused,
body.dark .progress-item-status.status-paused {
  background: rgba(111, 140, 176, 0.22);
  border-color: rgba(111, 140, 176, 0.38);
}
html[data-theme="dark"] .progress-item-status.status-done,
body.dark .progress-item-status.status-done {
  background: rgba(63, 138, 98, 0.22);
  border-color: rgba(63, 138, 98, 0.38);
}
html[data-theme="dark"] .progress-item-status.status-failed,
body.dark .progress-item-status.status-failed {
  background: rgba(196, 106, 106, 0.22);
  border-color: rgba(196, 106, 106, 0.38);
}
html[data-theme="dark"] .progress-item-status.status-cancelled,
body.dark .progress-item-status.status-cancelled {
  background: rgba(135, 148, 168, 0.22);
  border-color: rgba(135, 148, 168, 0.38);
}

/* ===== Modal ===== */
.modal { display: none; position: fixed; inset: 0; z-index: 3000;
  background: rgba(0,0,0,0.45); }
.modal-content {
  background: var(--surface);
  margin: 5% auto; padding: 20px;
  border-radius: var(--radius);
  max-width: 600px;
  box-shadow: var(--shadow-2);
  position: relative;
  border: 1px solid var(--border);
  color: var(--text);
  max-height: 80vh;
  overflow-y: auto;
  z-index: 3001;
}
.modal-content .close {
  position: absolute; top: 10px; right: 10px;
  font-size: 22px; cursor: pointer; color: var(--muted);
}
.modal-content .close:hover { color: var(--text); }

/* Презентабельный вид модалки карточки в списке */
#agentModal {
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  background: rgba(12, 22, 38, 0.5);
}
#agentModal .modal-content {
  width: min(980px, 94vw);
  max-width: min(980px, 94vw);
  max-height: 88vh;
  margin: 3vh auto;
  padding: 18px 18px 16px;
  border-radius: 18px;
  border: 1px solid #c9d7ea;
  box-shadow: 0 22px 54px rgba(7, 25, 48, 0.3);
}
#agentModal .modal-content .close {
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  z-index: 2;
}
#agentModal .modal-content .close:hover {
  background: #f1f5f9;
  color: #0f172a;
}
#agentModal .agent-card-modal {
  max-width: none;
  border-radius: 14px;
  border: 1px solid #d7e2f1;
  box-shadow: none;
  padding: 18px;
}
#agentModal .agent-card-title {
  font-size: clamp(1.55rem, 2.3vw, 2rem);
  line-height: 1.15;
  margin: 0 40px 12px 0; /* оставляем место под кнопку закрытия */
}
#agentModal .table-shell {
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(180deg, #f8fbff 0%, #f4f8fe 100%);
}
#agentModal .agent-card-label {
  width: 34%;
  color: #0f172a;
  font-weight: 700;
}
#agentModal .agent-card-value {
  width: 66%;
}
#agentModal .table-compact th,
#agentModal .table-compact td {
  padding: 10px 12px;
  line-height: 1.3;
  border-bottom-color: #d5deeb;
}
#agentModal .table-compact tr:last-child th,
#agentModal .table-compact tr:last-child td {
  border-bottom: none;
}
@media (max-width: 760px) {
  #agentModal .modal-content {
    width: 96vw;
    max-width: 96vw;
    margin: 2vh auto;
    max-height: 92vh;
    padding: 12px;
  }
  #agentModal .agent-card-modal {
    padding: 12px;
  }
  #agentModal .agent-card-label,
  #agentModal .agent-card-value {
    width: auto;
    display: block;
    text-align: left;
    white-space: normal;
  }
}
html[data-theme="dark"] #agentModal .modal-content,
body.dark #agentModal .modal-content {
  border-color: #2b3d55;
  background: #0f1c2c;
}
html[data-theme="dark"] #agentModal .modal-content .close,
body.dark #agentModal .modal-content .close {
  background: #13263a;
  border-color: #2d435f;
  color: #dbe8f8;
}
html[data-theme="dark"] #agentModal .modal-content .close:hover,
body.dark #agentModal .modal-content .close:hover {
  background: #1a3049;
  color: #ffffff;
}
html[data-theme="dark"] #agentModal .agent-card-modal,
body.dark #agentModal .agent-card-modal {
  border-color: #2b3d55;
  background: #122235;
}
html[data-theme="dark"] #agentModal .table-shell,
body.dark #agentModal .table-shell {
  background: linear-gradient(180deg, #102339 0%, #0f2237 100%);
  border-color: #2b3d55;
}
html[data-theme="dark"] #agentModal .table-compact th,
html[data-theme="dark"] #agentModal .table-compact td,
body.dark #agentModal .table-compact th,
body.dark #agentModal .table-compact td {
  border-bottom-color: #2c3f57;
}

/* ===== Footer ===== */
.site-footer {
  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  color: #fff;
  padding: 12px 20px;
  box-shadow: 0 -6px 18px rgba(0,0,0,0.12);
  font-size: 14px;
}
.site-footer p { margin: 0; color: #fff; }
.footer-line {
  height: 4px; background: rgba(255,255,255,0.65);
  border-radius: 999px; margin-bottom: 8px;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 8px;
}
.footer-links a {
  color: #e7f0ff;
  text-decoration: none;
  font-weight: 600;
}
.footer-links a:hover {
  color: #fff;
}

/* ===== Breadcrumbs ===== */
.breadcrumbs {
  max-width: 1200px;
  margin: 18px auto 0;
  padding: 0 8px;
  font-size: 0.9rem;
}
.breadcrumbs ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
}
.breadcrumbs li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.breadcrumbs li::after {
  content: "›";
  color: var(--muted);
}
.breadcrumbs li:last-child::after {
  content: "";
}
.breadcrumbs a {
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
}
.breadcrumbs span {
  color: var(--muted);
  font-weight: 600;
}

/* ===== Nav extras ===== */
.nav-btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.45);
  color: #fff;
}

/* ===== Landing page ===== */
.landing-hero {
  max-width: 1200px;
  margin: 32px auto 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 28px;
  align-items: center;
}
.landing-hero--minimal {
  margin: 36px auto 32px;
  gap: 24px;
}
.landing-hero-content h1 {
  margin: 10px 0 0;
  font-size: clamp(2rem, 4vw, 3rem);
}
.landing-title {
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 6px;
}
.landing-tagline {
  margin: 6px 0 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}
.landing-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
}
.landing-subtitle {
  font-size: 1.05rem;
  color: var(--muted);
  margin-top: 12px;
}
.landing-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 22px;
  border-radius: 12px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  color: #fff;
  box-shadow: var(--shadow-1);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  padding: 10px 4px;
}
.btn-text:hover {
  color: var(--primary);
}
.cta-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}
.landing-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.95rem;
}
.landing-meta span {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}
.report-card {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.report-screenshot {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 22px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  background: var(--surface);
}
html[data-theme="dark"] .report-screenshot {
  box-shadow: var(--shadow-1);
}
.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-warning { background: #fde68a; color: #7c2d12; }
.badge-success { background: #bbf7d0; color: #14532d; }
.badge-neutral { background: #e2e8f0; color: #334155; }

.landing-section {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 8px;
}
.landing-section h2 {
  margin-bottom: 18px;
}
.landing-compact {
  margin: 28px auto 36px;
}
.landing-compact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.landing-compact-item {
  background: var(--surface);
  border-radius: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
}
.landing-compact-item p {
  margin: 6px 0 0;
  color: var(--muted);
}
.compact-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.compact-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow: 0 8px 16px rgba(17, 24, 39, 0.12);
  flex: 0 0 auto;
}
.compact-icon {
  width: 22px;
  height: 22px;
  color: #fff;
}
.compact-title {
  font-weight: 700;
  font-size: 0.95rem;
}
.landing-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}
.landing-step {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}
.step-number {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  margin-bottom: 10px;
}
.landing-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  align-items: center;
}
.landing-list-bullets {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.landing-list-bullets li {
  padding-left: 20px;
  position: relative;
}
.landing-list-bullets li::before {
  content: "●";
  position: absolute;
  left: 0;
  color: var(--primary);
}
.landing-panel {
  background: linear-gradient(130deg, var(--brand), var(--brand-600));
  color: #fff;
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}
.landing-panel p {
  color: rgba(255,255,255,0.85);
}
.landing-panel .btn-secondary {
  background: #fff;
  color: #0f2340;
  border-color: transparent;
}
.landing-cta-bottom {
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 30px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}
.landing-cta .btn-primary {
  width: auto;
  min-width: 220px;
}
.btn-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  min-height: 44px;
  font-weight: 700;
  text-decoration: none;
  color: var(--brand-600);
}
.btn-text:hover {
  text-decoration: underline;
}
.cta-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: var(--font-size-sm);
}
.faq-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-1);
}
.faq-item h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}
.faq-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

/* ===== Utilities ===== */
.muted { color: var(--muted); }
.small-text { font-size: var(--font-size-sm); }
.full-width { width: 100%; }
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ===== FIX: навбарные кнопки не должны наследовать стилы кнопок форм ===== */
header nav .nav-right .nav-btn {
  width: auto !important;
  margin: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  height: 40px;
  line-height: 1;
  padding: 0 14px;
  border-radius: 10px;
  box-sizing: border-box;
  flex: 0 0 auto;
}
header nav .nav-right a.nav-btn {
  height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Responsive ===== */
@media (max-width: 980px) {
  header nav {
    overflow-x: visible;
  }
  header nav ul {
    flex-wrap: wrap;
    min-width: 0;
    row-gap: 6px;
  }
  header nav li.nav-right {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }
  header nav li a,
  header nav .nav-right .nav-btn,
  header nav .nav-right a.nav-btn {
    padding: 8px 12px;
    font-size: 0.95rem;
  }
  header nav .nav-right a.nav-btn {
    max-width: 100%;
  }
  .centered {
    justify-content: flex-start;
    padding-top: var(--space-4);
    padding-bottom: var(--space-4);
  }
  .meta-grid {
    grid-template-columns: 1fr;
  }
  .actions-row {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  header nav {
    padding: 8px 12px;
  }
  header nav .nav-toggle {
    display: inline-flex;
  }
  header nav .nav-menu {
    display: none;
    width: 100%;
    margin-top: var(--space-2);
  }
  header nav.is-open .nav-menu {
    display: block;
  }
  header nav ul {
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
  }
  header nav li.nav-right {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  header nav li a,
  header nav .nav-right .nav-btn,
  header nav .nav-right a.nav-btn {
    min-height: 44px;
    padding: 10px 14px;
    width: 100%;
    justify-content: flex-start;
  }
  .nav-btn {
    min-height: 44px;
  }
  main {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }
  .card {
    padding: var(--space-4);
  }
  .page-wrap {
    margin-top: var(--space-4);
  }
  .page-hero__actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }
  .table-shell {
    padding: 8px;
    -webkit-overflow-scrolling: touch;
  }
  .table-shell.compact {
    padding: 6px;
  }
  .table-compact {
    font-size: 0.86rem;
  }
  .table-compact th,
  .table-compact td {
    padding: 5px 7px;
  }
  .dataTables_wrapper .dt-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
  }
  .dataTables_wrapper .dt-buttons .dt-button {
    margin: 0 !important;
  }
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    float: none !important;
    text-align: left !important;
    width: 100%;
    margin: 6px 0;
  }
  .dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.25em 0.45em !important;
    margin-left: 2px !important;
  }
  .progress-meta {
    grid-template-columns: 1fr;
  }
  .progress-meta > :last-child {
    text-align: left;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ===== In-Page Tabs (auto) ===== */
.page-tabs {
  max-width: 1200px;
  margin: 10px auto 0;
  padding: 0 8px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  flex-wrap: nowrap;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: thin;
}
.page-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px 6px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #eef1f6;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  position: relative;
  top: 1px;
  white-space: nowrap;
}
.page-tab:hover {
  filter: saturate(1.02);
}
.page-tab.is-active {
  background: var(--surface);
  top: 0;
  box-shadow: 0 -1px 0 var(--surface), 0 -2px 0 var(--surface);
}
html[data-theme="dark"] .page-tab,
body.dark .page-tab {
  background: var(--surface-1);
  color: var(--muted);
}
html[data-theme="dark"] .page-tab:hover,
body.dark .page-tab:hover {
  background: var(--surface-2);
  color: var(--text);
}
html[data-theme="dark"] .page-tab.is-active,
body.dark .page-tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 -1px 0 var(--surface), 0 -2px 0 var(--surface);
}
.card[id],
.table-shell[id],
.page-hero[id] {
  scroll-margin-top: 84px;
}

/* ===== Back To Top ===== */
.back-to-top {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  box-shadow: 0 3px 10px rgba(17, 24, 39, 0.10);
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  opacity: 0.55;
  transition: opacity 120ms ease, transform 120ms ease, background 120ms ease;
}
.back-to-top:hover { opacity: 0.9; }
.back-to-top:active { transform: translateY(1px); }
html[data-theme="dark"] .back-to-top,
body.dark .back-to-top {
  background: rgba(16, 29, 47, 0.70);
}
