@import url('/assets/bot-test-lab.css?v=4');

:root {
  --bot-ink: #10131d;
  --bot-muted: #646a7b;
  --bot-line: #e6e9f1;
  --bot-line-strong: #d9dfeb;
  --bot-soft: #f5f7fb;
  --bot-blue: #123bd4;
  --bot-blue-dark: #0b2ba8;
  --bot-blue-soft: #eaf0ff;
  --bot-orange: #ff7a00;
  --bot-orange-soft: #fff2e6;
  --bot-success: #118a55;
  --bot-warning: #b86500;
  --bot-danger: #c62e2e;
  --bot-font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .48; cursor: not-allowed; }
:focus-visible { outline: 3px solid rgba(18, 59, 212, .18); outline-offset: 2px; }

.bot-control-body {
  min-height: 100vh;
  color: var(--bot-ink);
  background: #fff;
  font-family: var(--bot-font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.bot-topbar {
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 max(24px, calc((100vw - 1440px) / 2));
  border-bottom: 1px solid rgba(230, 233, 241, .92);
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(12px);
}

.bot-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 15px;
  color: var(--bot-ink);
  text-decoration: none;
}
.bot-brand img {
  width: 122px;
  height: auto;
  display: block;
  object-fit: contain;
  flex: 0 0 auto;
}
.bot-brand span {
  min-width: 0;
  display: grid;
  line-height: 1.1;
  font-size: 15px;
  font-weight: 850;
  letter-spacing: -.025em;
}
.bot-brand small {
  margin-bottom: 4px;
  color: var(--bot-muted);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.bot-topbar nav { display: flex; align-items: center; gap: 8px; }
.bot-topbar nav form { margin: 0; }
.bot-topbar button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--bot-muted);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: color .16s ease, background .16s ease, border-color .16s ease;
}
.bot-topbar button:hover { color: var(--bot-blue); background: var(--bot-blue-soft); }

.bot-shell {
  width: min(1440px, calc(100% - 64px));
  margin: 0 auto;
  padding: 34px 0 72px;
}

.bot-status {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--bot-line);
  color: var(--bot-muted);
  font-size: 13px;
}
.bot-status > div:first-child { min-width: 0; }
.bot-status strong {
  display: block;
  margin-bottom: 2px;
  color: var(--bot-ink);
  font-size: 15px;
  font-weight: 850;
  letter-spacing: -.015em;
}
.bot-status-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  text-align: right;
}
.bot-status-actions > span { font-size: 12px; }

.secondary,
.bot-primary,
.bot-status button,
.rule-actions button,
.test-start {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 17px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease, color .16s ease;
}
.secondary,
.bot-status button {
  border: 1px solid var(--bot-line-strong);
  color: #394152;
  background: #fff;
}
.secondary:hover,
.bot-status button:hover { border-color: #b9c7f3; color: var(--bot-blue); background: #f9fbff; }
.bot-primary {
  border: 1px solid var(--bot-blue);
  color: #fff;
  background: var(--bot-blue);
}
.bot-primary:hover { background: var(--bot-blue-dark); border-color: var(--bot-blue-dark); }
.secondary:hover:not(:disabled),
.bot-primary:hover:not(:disabled),
.rule-actions button:hover:not(:disabled),
.test-start:hover:not(:disabled) { transform: translateY(-1px); }

.monitor-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 42px;
  align-items: start;
}
.monitor-sidebar,
.monitor-panel { min-width: 0; }
.monitor-sidebar {
  position: sticky;
  top: 92px;
  padding: 4px 28px 18px 0;
  border-right: 1px solid var(--bot-line);
}
.sidebar-heading { padding: 0 4px 18px; }
.sidebar-heading h1,
.profile-header h1,
.section-heading h2 { margin: 0; }
.sidebar-heading h1 {
  font-size: 25px;
  line-height: 1.05;
  letter-spacing: -.045em;
}
.sidebar-heading p:last-child,
.profile-header p,
.section-heading p {
  margin: 9px 0 0;
  color: var(--bot-muted);
  line-height: 1.5;
}
.sidebar-heading p:last-child { font-size: 13px; }

.section-kicker {
  margin: 0 0 8px !important;
  color: var(--bot-blue) !important;
  font-size: 10px !important;
  font-weight: 900 !important;
  letter-spacing: .13em !important;
  text-transform: uppercase;
}

.profile-list { display: grid; gap: 4px; }
.profile-card {
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  color: var(--bot-ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.profile-card:hover { background: #f6f8fd; }
.profile-card.active { color: var(--bot-blue); background: var(--bot-blue-soft); }
.profile-card-title {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 850;
  letter-spacing: -.015em;
}
.profile-card-meta {
  display: block;
  color: var(--bot-muted);
  font-size: 11px;
  line-height: 1.35;
}
.profile-card.active .profile-card-meta { color: #5369b9; }

.monitor-panel { display: grid; }
.profile-header {
  padding: 0 0 32px;
  border-bottom: 1px solid var(--bot-line);
}
.profile-header h1 {
  max-width: 900px;
  font-size: clamp(38px, 4.6vw, 58px);
  line-height: 1.02;
  letter-spacing: -.055em;
}
.profile-header p {
  max-width: 760px;
  font-size: 16px;
}
.monitor-section {
  padding: 32px 0;
  border-bottom: 1px solid var(--bot-line);
}
.monitor-section:last-child { border-bottom: 0; }
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}
.section-heading > div { min-width: 0; }
.section-heading h2 {
  font-size: 27px;
  line-height: 1.08;
  letter-spacing: -.04em;
}
.section-heading p { max-width: 720px; font-size: 14px; }

.destination-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 10px;
}
.destination-row input,
.source-toolbar input,
.source-toolbar select,
.rule-row select,
.rule-row input,
.test-config-grid select,
.test-config-grid input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--bot-line-strong);
  border-radius: 10px;
  color: var(--bot-ink);
  background: #fff;
  font-size: 13px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.destination-row input,
.source-toolbar input,
.source-toolbar select,
.test-config-grid select,
.test-config-grid input { padding: 0 12px; }
.rule-row select,
.rule-row input { padding: 9px 10px; }
.destination-row input:focus,
.source-toolbar input:focus,
.source-toolbar select:focus,
.rule-row select:focus,
.rule-row input:focus,
.test-config-grid select:focus,
.test-config-grid input:focus {
  outline: 0;
  border-color: var(--bot-blue);
  box-shadow: 0 0 0 3px rgba(18, 59, 212, .10);
}

.source-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.source-toolbar input { flex: 1 1 360px; }
.source-toolbar select { min-width: 190px; }
.source-list {
  overflow: hidden;
  border-top: 1px solid var(--bot-line);
  border-bottom: 1px solid var(--bot-line);
}
.source-row {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--bot-line);
  background: #fff;
}
.source-row:last-child { border-bottom: 0; }
.source-row.unavailable { opacity: .58; }
.source-main { min-width: 0; }
.source-title {
  margin-bottom: 6px;
  overflow: hidden;
  color: var(--bot-ink);
  font-size: 14px;
  font-weight: 850;
  letter-spacing: -.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.source-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  color: var(--bot-muted);
  font-size: 11px;
}
.source-error { margin-top: 7px; color: var(--bot-danger); font-size: 11px; }
.source-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  color: var(--bot-muted);
  font-size: 11px;
  font-weight: 750;
}

.bot-badge {
  min-height: 23px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: #535b6c;
  background: var(--bot-soft);
  font-size: 10px;
  font-weight: 800;
}
.bot-badge.ok { color: var(--bot-success); background: #e8f7ef; }
.bot-badge.warn { color: var(--bot-warning); background: #fff3dc; }
.bot-badge.new { color: var(--bot-blue); background: var(--bot-blue-soft); }

.bot-switch {
  width: 46px;
  height: 26px;
  position: relative;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #cfd5df;
  cursor: pointer;
  transition: background .18s ease;
}
.bot-switch::after {
  content: "";
  width: 20px;
  height: 20px;
  position: absolute;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(16, 19, 29, .2);
  transition: transform .18s ease;
}
.bot-switch.on { background: var(--bot-blue); }
.bot-switch.on::after { transform: translateX(20px); }

.rules-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.rule-box {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--bot-line);
  border-radius: 16px;
  background: #fff;
}
.rule-box-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.rule-box-head h3 {
  margin: 0 0 5px;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: -.025em;
}
.rule-box-head p { margin: 0; color: var(--bot-muted); font-size: 12px; }
.rule-box-head > span {
  min-width: 30px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #535b6c;
  background: var(--bot-soft);
  font-size: 11px;
  font-weight: 850;
  text-align: center;
}
.rule-list {
  max-height: 520px;
  overflow: auto;
  padding-right: 3px;
  scrollbar-width: thin;
}
.rule-row {
  display: grid;
  grid-template-columns: 94px minmax(180px, 1fr) minmax(120px, 180px) 36px;
  gap: 7px;
  margin-bottom: 7px;
}
.rule-row .remove {
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  color: var(--bot-danger);
  background: #fff0f0;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}
.rule-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 13px;
}
.rule-actions .save { border: 1px solid var(--bot-blue); color: #fff; background: var(--bot-blue); }
.rule-actions .add { border: 1px solid transparent; color: var(--bot-blue); background: var(--bot-blue-soft); }
.rule-actions .reset { border: 1px solid transparent; color: #515867; background: var(--bot-soft); }

.bot-empty {
  padding: 38px 22px;
  border: 1px dashed #cbd3e1;
  border-radius: 16px;
  color: var(--bot-muted);
  background: #fff;
  text-align: center;
  font-size: 13px;
}
.bot-empty.compact { padding: 24px; }
.bot-toast {
  max-width: min(420px, calc(100vw - 32px));
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  padding: 12px 15px;
  border-radius: 11px;
  color: #fff;
  background: var(--bot-ink);
  box-shadow: 0 14px 36px rgba(16, 19, 29, .2);
  font-size: 13px;
  font-weight: 700;
}
.bot-toast.error { background: var(--bot-danger); }

.bot-login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: #fff;
}
.bot-login-card {
  width: min(430px, 100%);
  padding: 36px 0;
}
.bot-login-card img {
  width: 132px;
  max-width: 60%;
  height: auto;
  display: block;
  margin-bottom: 34px;
}
.bot-kicker {
  margin: 0 0 12px;
  color: var(--bot-blue);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.bot-login-card h1 {
  margin: 0;
  font-size: 46px;
  line-height: 1;
  letter-spacing: -.055em;
}
.bot-login-card > p {
  margin: 16px 0 0;
  color: var(--bot-muted);
  font-size: 15px;
  line-height: 1.55;
}
.bot-login-card form {
  display: grid;
  gap: 15px;
  margin-top: 30px;
}
.bot-login-card label {
  display: grid;
  gap: 7px;
  color: #3d4350;
  font-size: 12px;
  font-weight: 800;
}
.bot-login-card input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--bot-line-strong);
  border-radius: 10px;
  padding: 0 12px;
  color: var(--bot-ink);
  background: #fff;
  font-size: 14px;
}
.bot-login-card input:focus {
  outline: 0;
  border-color: var(--bot-blue);
  box-shadow: 0 0 0 3px rgba(18, 59, 212, .10);
}
.bot-login-card button {
  height: 48px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--bot-blue);
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
}
.bot-login-card button:hover { background: var(--bot-blue-dark); }
.bot-login-error {
  margin-top: 18px;
  padding: 11px 12px;
  border-radius: 9px;
  color: #a92727;
  background: #fff0f0;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .bot-shell { width: min(1180px, calc(100% - 48px)); }
  .monitor-layout { grid-template-columns: 220px minmax(0, 1fr); gap: 28px; }
  .monitor-sidebar { padding-right: 20px; }
  .rules-columns { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .bot-topbar {
    height: 60px;
    padding: 0 16px;
  }
  .bot-brand { gap: 10px; }
  .bot-brand img { width: 104px; }
  .bot-brand span { font-size: 12px; }
  .bot-brand small { display: none; }
  .bot-topbar button { min-height: 36px; padding: 0 10px; font-size: 12px; }

  .bot-shell {
    width: min(100% - 28px, 680px);
    padding: 24px 0 56px;
  }
  .bot-status {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
  }
  .bot-status-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    text-align: left;
  }
  .bot-status-actions button { width: 100%; }

  .monitor-layout { grid-template-columns: 1fr; gap: 24px; }
  .monitor-sidebar {
    position: static;
    padding: 0 0 20px;
    border-right: 0;
    border-bottom: 1px solid var(--bot-line);
  }
  .sidebar-heading { padding: 0 0 14px; }
  .sidebar-heading h1 { font-size: 29px; }
  .sidebar-heading p:last-child { max-width: 520px; }
  .profile-list {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    margin: 0 -14px;
    padding: 0 14px 3px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }
  .profile-card {
    min-width: 170px;
    min-height: 62px;
    flex: 0 0 auto;
    scroll-snap-align: start;
    border: 1px solid var(--bot-line);
    background: #fff;
  }
  .profile-card.active { border-color: #b8c7f7; }

  .profile-header { padding-bottom: 26px; }
  .profile-header h1 { font-size: clamp(38px, 12vw, 50px); }
  .profile-header p { margin-top: 12px; font-size: 15px; }
  .monitor-section { padding: 27px 0; }
  .section-heading { display: grid; gap: 12px; margin-bottom: 17px; }
  .section-heading h2 { font-size: 25px; }

  .destination-row { grid-template-columns: 1fr; }
  .destination-row > * { width: 100%; }
  .source-toolbar { display: grid; grid-template-columns: 1fr; }
  .source-toolbar input,
  .source-toolbar select { width: 100%; min-width: 0; }
  .source-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    padding: 14px 0;
  }
  .source-title {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    line-height: 1.3;
  }
  .source-toggle { align-self: center; }
  .source-toggle > span { display: none; }
  .source-meta { line-height: 1.4; }

  .rule-box { padding: 15px; }
  .rule-list { max-height: none; }
  .rule-row { grid-template-columns: 86px minmax(0, 1fr) 38px; }
  .rule-row .rule-label { grid-column: 1 / 3; }
  .rule-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .rule-actions .save { grid-column: 1 / -1; }
  .rule-actions button { width: 100%; }

  .bot-toast { right: 16px; bottom: 16px; }
  .bot-login-shell { padding: 22px; }
  .bot-login-card { padding: 22px 0; }
  .bot-login-card img { width: 118px; margin-bottom: 30px; }
  .bot-login-card h1 { font-size: 42px; }
}

@media (max-width: 480px) {
  .bot-brand span { display: none; }
  .bot-shell { width: calc(100% - 24px); padding-top: 20px; }
  .profile-header h1 { font-size: 38px; }
  .section-heading h2 { font-size: 23px; }
  .profile-card { min-width: 156px; }

  .rule-row {
    grid-template-columns: minmax(0, 1fr) 38px;
    gap: 7px;
  }
  .rule-row .rule-kind,
  .rule-row .rule-pattern,
  .rule-row .rule-label { grid-column: 1; }
  .rule-row .remove { grid-column: 2; grid-row: 1 / span 3; height: 100%; }
  .rule-actions { grid-template-columns: 1fr; }
  .rule-actions .save { grid-column: auto; }

  .source-meta span:not(.bot-badge) { font-size: 10px; }
  .bot-login-card h1 { font-size: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
