/* ===== Ferrari SaaS Web — премиальный минимализм ===== */
/* Атрибут hidden всегда скрывает элемент, даже при display:flex */
[hidden] { display: none !important; }

:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --ink: #171a2b;
  --muted: #6b7089;
  --line: #e8eaf3;
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --accent: #f59e0b;
  --ok: #10b981;
  --bad: #ef4444;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(23,26,43,.04), 0 8px 24px rgba(23,26,43,.06);
  --shadow-lg: 0 24px 60px rgba(23,26,43,.18);
  --grad: linear-gradient(135deg, #4f46e5, #7c3aed);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px;
  border: 1.5px solid var(--line); border-radius: 11px;
  padding: 10px 12px; background: #fff; color: var(--ink); width: 100%;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3.5px rgba(79,70,229,.13);
}
label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); margin: 14px 0 6px; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 11px 20px; font-size: 14.5px; font-weight: 600;
  background: var(--grad); color: #fff;
  box-shadow: 0 6px 18px rgba(79,70,229,.32);
  transition: transform .12s, box-shadow .12s, opacity .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(79,70,229,.42); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; }
.btn-ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); box-shadow: none; }
.btn-danger { background: linear-gradient(135deg, #ef4444, #f97316); box-shadow: 0 6px 18px rgba(239,68,68,.28); }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 10px; }
.icon-btn {
  background: none; border: none; font-size: 16px; color: var(--muted);
  width: 34px; height: 34px; border-radius: 9px; transition: background .15s, color .15s;
}
.icon-btn:hover { background: rgba(79,70,229,.08); color: var(--primary); }

/* ===== Логин ===== */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(124,58,237,.10), transparent 60%),
    radial-gradient(800px 500px at 90% 90%, rgba(245,158,11,.12), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 410px; max-width: 100%; background: var(--card); border-radius: 26px;
  box-shadow: var(--shadow-lg); padding: 40px 38px; border: 1px solid rgba(23,26,43,.04);
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.logo-mark {
  width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 20px;
  background: var(--grad); color: #fff; font-size: 32px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 30px rgba(79,70,229,.4);
}
.logo-mark.small { width: 38px; height: 38px; font-size: 20px; border-radius: 12px; margin: 0; }
.auth-logo h1 { font-size: 25px; letter-spacing: -.03em; }
.auth-logo h1 span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-logo p { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.auth-tabs { display: flex; background: var(--bg); border-radius: 13px; padding: 4px; margin-bottom: 8px; }
.auth-tab {
  flex: 1; border: none; background: none; padding: 10px; border-radius: 10px;
  font-weight: 600; color: var(--muted); font-size: 14px; transition: all .15s;
}
.auth-tab.active { background: #fff; color: var(--primary); box-shadow: 0 2px 10px rgba(23,26,43,.08); }
.auth-hint { margin-top: 18px; font-size: 12.5px; color: var(--muted); text-align: center; }

/* ===== Каркас приложения ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 16px; position: sticky; top: 0; height: 100vh;
}
.side-logo { display: flex; align-items: center; gap: 11px; font-weight: 800; font-size: 16.5px; padding: 4px 8px 20px; letter-spacing: -.02em; }
#nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 12px;
  border: none; background: none; font-size: 14.5px; font-weight: 600; color: var(--muted);
  text-align: left; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { background: linear-gradient(135deg, rgba(79,70,229,.1), rgba(124,58,237,.1)); color: var(--primary); }
.nav-ico { font-size: 18px; width: 24px; text-align: center; }
.side-user {
  display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line);
  padding-top: 16px; margin-top: 8px;
}
.user-avatar {
  width: 40px; height: 40px; border-radius: 13px; background: var(--grad); color: #fff;
  font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(79,70,229,.3);
}
.user-meta { flex: 1; min-width: 0; }
.user-meta strong { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { font-size: 12px; color: var(--muted); }

.content { flex: 1; padding: 32px 38px; max-width: 1240px; }

/* ===== Заголовки и карточки ===== */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 14px; flex-wrap: wrap; }
.page-head h2 { font-size: 24px; letter-spacing: -.03em; font-weight: 800; }
.page-head p { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; border: 1px solid rgba(23,26,43,.04);
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.stat-card { padding: 22px; }
.stat-card .num { font-size: 32px; font-weight: 800; letter-spacing: -.04em; }
.stat-card .lbl { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ===== Таблицы ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); padding: 10px 12px;
  border-bottom: 1.5px solid var(--line);
}
td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafaff; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.on { background: rgba(16,185,129,.13); color: #059669; }
.badge.off { background: rgba(239,68,68,.11); color: #dc2626; }
.badge.demo { background: rgba(245,158,11,.14); color: #b45309; }
.row-actions { display: flex; gap: 6px; }

/* ===== Чипы (выбор банков) ===== */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; margin: 2px 6px 2px 0;
  border: 1.5px solid var(--line); border-radius: 999px;
  background: #fff; font-size: 12.5px; font-weight: 600; color: var(--muted);
  transition: all .15s; user-select: none; white-space: nowrap; cursor: pointer;
}
.chip:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.chip.on {
  background: var(--grad); border-color: transparent; color: #fff;
  box-shadow: 0 5px 16px rgba(79,70,229,.45);
  transform: translateY(-1px);
}
.chip.on::before {
  content: "✓"; font-weight: 900; font-size: 12px; line-height: 1;
}

/* ===== Формы генератора ===== */
.step-label {
  font-size: 11.5px; font-weight: 800; color: var(--primary);
  text-transform: uppercase; letter-spacing: .09em; margin: 22px 0 10px;
}
.bank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 11px; }
.bank-card {
  position: relative; border: 2px solid var(--line); border-radius: 16px; padding: 17px 12px;
  background: #fff; font-weight: 650; font-size: 13.5px; text-align: center;
  transition: all .16s; cursor: pointer;
}
.bank-card:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: 0 10px 24px rgba(79,70,229,.14); }
.bank-card.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(79,70,229,.07), rgba(124,58,237,.1));
  box-shadow: 0 10px 26px rgba(79,70,229,.22);
}
.bank-card.selected::after {
  content: "✓"; position: absolute; top: 7px; right: 7px; width: 19px; height: 19px;
  border-radius: 50%; background: var(--grad); color: #fff; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 13px; }
.search-box { position: relative; }
.search-box input { padding-left: 38px; }
.search-box::before { content: "🔍"; position: absolute; left: 12px; top: 11px; font-size: 13px; opacity: .5; }

/* ===== Модалка ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,23,51,.5); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal {
  background: #fff; border-radius: 22px; box-shadow: var(--shadow-lg); width: 760px; max-width: 100%;
  max-height: 92vh; display: flex; flex-direction: column; border: 1px solid rgba(23,26,43,.05);
}
.modal.wide { width: 920px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; letter-spacing: -.02em; }
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-body .form-row { margin-bottom: 4px; }

/* ===== Тосты ===== */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); padding: 13px 18px;
  font-size: 14px; font-weight: 500; min-width: 240px; max-width: 380px;
  border-left: 4px solid var(--primary); animation: slideIn .25s ease;
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--bad); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Утилиты ===== */
.spin {
  width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: rot .7s linear infinite; display: inline-block;
}
@keyframes rot { to { transform: rotate(360deg); } }
.empty { color: var(--muted); text-align: center; padding: 36px 10px; font-size: 14px; }
.muted { color: var(--muted); }
.mt { margin-top: 14px; }
.gap { gap: 12px; display: flex; align-items: center; flex-wrap: wrap; }

@media (max-width: 900px) {
  .sidebar { width: 76px; padding: 16px 10px; }
  .side-logo span, .nav-item span, .user-meta { display: none; }
  .nav-item { justify-content: center; }
  .content { padding: 20px; }
}

/* ===== Агент-помощник ===== */
.agent-fab {
  position: fixed; right: 22px; bottom: 22px; width: 58px; height: 58px; border-radius: 50%;
  border: none; background: var(--grad); color: #fff; font-size: 26px; z-index: 60;
  box-shadow: 0 12px 30px rgba(79,70,229,.45); transition: transform .15s;
}
.agent-fab:hover { transform: scale(1.08); }
.agent-panel {
  position: fixed; right: 22px; bottom: 92px; width: 360px; max-width: calc(100vw - 30px);
  height: 480px; max-height: calc(100vh - 120px); background: #fff; border-radius: 18px;
  box-shadow: var(--shadow-lg); z-index: 60; display: flex; flex-direction: column;
  overflow: hidden; border: 1px solid rgba(23,26,43,.06);
}
.agent-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: linear-gradient(135deg, rgba(79,70,229,.06), rgba(124,58,237,.08));
  border-bottom: 1px solid var(--line);
}
.agent-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.agent-msg { max-width: 85%; padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; }
.agent-msg.user { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 4px; }
.agent-msg.bot { align-self: flex-start; background: #f2f3fa; border-bottom-left-radius: 4px; }
.agent-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.agent-form input { flex: 1; }
.agent-tip { font-size: 12px; color: var(--muted); padding: 0 14px 10px; }
