/* ===========================================================
   RM Agent UI — фирменные цвета ОТП Банк (otpbank.ru)
   - лайм   #D4FF00  — основные CTA-кнопки
   - фиолетовый #7B4AE8 — акценты, ссылки, чипы
   - оранжевый #FF6B2C — подсветки, статусы, заголовки
   - шрифт Manrope
   =========================================================== */

:root {
  --otp-lime: #D4FF00;
  --otp-lime-hover: #BFE600;
  --otp-lime-soft: #F7FFD6;

  --otp-purple: #7B4AE8;
  --otp-purple-dark: #5C32B8;
  --otp-purple-soft: #F3EEFF;
  --otp-purple-line: #DDD0FF;

  --otp-orange: #FF6B2C;
  --otp-orange-dark: #E25420;
  --otp-orange-soft: #FFF1EB;

  --ink: #1A1A1A;
  --ink-muted: #4D4D4D;
  --ink-faint: #8A8A8A;
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --line: #E8E8EC;
  --danger: #C8323E;
  --danger-soft: #FDECEE;
  --warn: #B8860B;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--otp-purple); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  user-select: none;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn--primary {
  background: var(--otp-lime);
  color: var(--ink);
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 15px;
}
.btn--primary:hover:not(:disabled) { background: var(--otp-lime-hover); }

.btn--ghost {
  background: transparent;
  color: var(--otp-purple);
  border-color: var(--otp-purple-line);
  border-radius: var(--radius-pill);
}
.btn--ghost:hover:not(:disabled) { background: var(--otp-purple-soft); }

.btn--block { width: 100%; }

/* ---------- Brand ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__mark { display: inline-flex; }

.brand__title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.brand__subtitle {
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* ---------- Login ---------- */

.login-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 90% -10%, rgba(212, 255, 0, 0.35), transparent 50%),
    radial-gradient(circle at 10% 100%, rgba(123, 74, 232, 0.12), transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(255, 107, 44, 0.06), transparent 60%),
    var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.login-shell {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-card__title {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-card__hint {
  margin: 0 0 24px;
  color: var(--ink-muted);
  font-size: 14px;
}

.login-form { display: flex; flex-direction: column; gap: 18px; }

.login-footer {
  text-align: center;
  font-size: 12px;
  color: var(--ink-faint);
}

/* ---------- Fields ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }

.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
}

.field__input {
  font-family: var(--font);
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field__input::placeholder { color: var(--ink-faint); }

.field__input:focus {
  border-color: var(--otp-purple);
  box-shadow: 0 0 0 3px rgba(123, 74, 232, 0.2);
}

.field__input:invalid:not(:placeholder-shown) {
  border-color: var(--danger);
}

/* ---------- Alerts ---------- */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}

.alert--error {
  background: var(--danger-soft);
  border-color: rgba(200, 50, 62, 0.3);
  color: var(--danger);
}

/* ---------- Top bar ---------- */

.topbar {
  background-color: var(--surface);
  background-image: linear-gradient(
    90deg,
    var(--otp-lime),
    var(--otp-purple),
    var(--otp-orange)
  );
  background-size: 100% 3px;
  background-position: bottom;
  background-repeat: no-repeat;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__brand { display: flex; align-items: center; gap: 12px; }

.topbar__title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.topbar__subtitle {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 1px;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--otp-purple-soft);
  color: var(--otp-purple-dark);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--otp-purple-line);
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 48px;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- Sidebar (form) ---------- */

.sidebar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  align-self: start;
  position: sticky;
  top: 92px;
}

@media (max-width: 900px) {
  .sidebar { position: static; }
}

.sidebar__title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--otp-purple-dark);
}

.sidebar__hint {
  margin: 0 0 18px;
  color: var(--ink-muted);
  font-size: 13px;
}

.form { display: flex; flex-direction: column; gap: 14px; }

.form__note {
  font-size: 12px;
  color: var(--ink-faint);
  margin: 4px 0 0;
}

/* ---------- Content ---------- */

.content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 26px;
  box-shadow: var(--shadow-sm);
  min-height: 70vh;
  display: flex;
  flex-direction: column;
}

.content__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.content__title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ---------- Status pill ---------- */

.status-pill {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-pill--idle {
  color: var(--ink-muted);
  background: #F1F2F1;
  border-color: var(--line);
}

.status-pill--working {
  color: var(--otp-orange-dark);
  background: var(--otp-orange-soft);
  border-color: rgba(255, 107, 44, 0.35);
}

.status-pill--working::before {
  animation: pulse 1.2s ease-in-out infinite;
}

.status-pill--done {
  color: var(--ink);
  background: var(--otp-lime);
  border-color: var(--otp-lime);
}

.status-pill--error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(200, 50, 62, 0.3);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* ---------- Progress log ---------- */

.progress-log {
  background: var(--otp-purple-soft);
  border: 1px solid var(--otp-purple-line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--otp-purple-dark);
  max-height: 160px;
  overflow-y: auto;
  display: none;
}

.progress-log.is-visible { display: block; }

.progress-log__item {
  display: flex;
  gap: 10px;
  padding: 4px 0;
}

.progress-log__time {
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

/* ---------- Dossier (Markdown render) ---------- */

.dossier {
  flex: 1;
  padding: 4px 2px 8px;
  overflow-x: auto;
}

.dossier--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 360px;
}

.dossier__empty {
  text-align: center;
  color: var(--ink-muted);
  max-width: 360px;
}

.dossier__empty p { margin-top: 12px; font-size: 15px; }

/* Markdown типографика */
.dossier h1, .dossier h2, .dossier h3, .dossier h4 {
  font-family: var(--font);
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.25;
}

.dossier h1 {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--otp-orange);
}

.dossier h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 28px 0 12px;
  color: var(--otp-purple-dark);
}

.dossier h2::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 16px;
  background: var(--otp-lime);
  margin-right: 10px;
  vertical-align: -2px;
  border-radius: 2px;
}

.dossier h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 20px 0 8px;
}

.dossier p {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--ink);
}

.dossier ul, .dossier ol {
  margin: 0 0 14px;
  padding-left: 22px;
}

.dossier li {
  margin-bottom: 6px;
  font-size: 15px;
}

.dossier ul li::marker { color: var(--otp-orange); }

.dossier strong { color: var(--ink); font-weight: 700; }
.dossier em { color: var(--ink-muted); }

.dossier blockquote {
  border-left: 3px solid var(--otp-purple);
  margin: 14px 0;
  padding: 6px 14px;
  background: var(--otp-purple-soft);
  color: var(--ink-muted);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.dossier code {
  background: #F0F1F0;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.dossier pre {
  background: #F7F8F7;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 13px;
}

.dossier pre code { background: none; padding: 0; }

.dossier table {
  border-collapse: collapse;
  margin: 12px 0;
  width: 100%;
  font-size: 14px;
}

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

.dossier th {
  background: var(--otp-lime-soft);
  color: var(--otp-purple-dark);
  font-weight: 700;
}

.dossier hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

.dossier a {
  color: var(--otp-purple);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}

.dossier-actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* печать — чистый А4 */
@media print {
  .topbar, .sidebar, .dossier-actions, .progress-log, .content__header > .status-pill { display: none !important; }
  .layout { display: block; padding: 0; }
  .content { box-shadow: none; border: none; padding: 0; }
  body { background: #fff; }
}
