/* ==================================================================
   MAXBOT Studio — базовые стили и дизайн-система
   ================================================================== */
:root {
  --brand: #6b5cff;
  --brand-2: #4c8dff;
  --brand-3: #45c4ff;
  --grad: linear-gradient(135deg, #7b5cff 0%, #4c8dff 55%, #45c4ff 100%);
  --grad-soft: linear-gradient(135deg, rgba(123, 92, 255, .12), rgba(69, 196, 255, .12));
  --ink: #0b1020;
  --ink-2: #151b2e;
  --ink-3: #253050;
  --text: #1a2138;
  --muted: #66708c;
  --muted-2: #8b93a9;
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #fafbff;
  --border: #e6e9f3;
  --border-strong: #d3d8e8;
  --success: #12a874;
  --success-soft: #e6f7f1;
  --warning: #e8960c;
  --warning-soft: #fdf3e0;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --violet-soft: #f0edff;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow: 0 12px 32px -12px rgba(23, 32, 64, .18), 0 2px 8px rgba(23, 32, 64, .05);
  --shadow-lg: 0 32px 80px -24px rgba(23, 32, 64, .32);
  --font: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Consolas, "Courier New", monospace;
  --header-h: 72px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.55;
  font-size: 16px;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

::selection { background: rgba(107, 92, 255, .22); }

/* ---------------------------- layout ---------------------------- */
.container { width: min(1180px, 100% - 48px); margin: 0 auto; }
.container-wide { width: min(1320px, 100% - 48px); margin: 0 auto; }

/* ---------------------------- buttons --------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 44px;
  padding: 0 20px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  font-weight: 600;
  font-size: .94rem;
  line-height: 1;
  white-space: nowrap;
  transition: transform .16s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease, color .2s;
  user-select: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn:focus-visible, .input:focus-visible, .textarea:focus-visible, .select:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 10px 24px -10px rgba(92, 104, 255, .85), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.btn-primary:hover { box-shadow: 0 16px 32px -12px rgba(92, 104, 255, .95), inset 0 1px 0 rgba(255, 255, 255, .22); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #1b2440; }
.btn-light { background: #fff; color: var(--ink); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-light:hover { border-color: var(--border-strong); }
.btn-ghost { color: var(--text); }
.btn-ghost:hover { background: rgba(16, 24, 40, .05); }
.btn-outline { border-color: var(--border-strong); color: var(--text); background: #fff; }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fbdcdc; }
.btn-sm { height: 36px; padding: 0 14px; font-size: .85rem; border-radius: 10px; }
.btn-lg { height: 54px; padding: 0 28px; font-size: 1rem; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 10px; }
.btn-link { background: none; border: 0; color: var(--brand); font-weight: 600; padding: 0; height: auto; }
.btn-link:hover { text-decoration: underline; }

/* ---------------------------- badges ---------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.badge-brand { background: var(--violet-soft); border-color: transparent; color: var(--brand); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------------------------- forms ----------------------------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.input, .textarea, .select {
  width: 100%;
  min-height: 44px;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  font-size: .93rem;
  transition: border-color .18s, box-shadow .18s;
  outline: none;
}
.input:hover, .textarea:hover, .select:hover { border-color: #b9c0d6; }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(107, 92, 255, .14);
}
.input::placeholder, .textarea::placeholder { color: #a4abc0; }
.textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2366708c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
.hint { font-size: .78rem; color: var(--muted-2); line-height: 1.45; }
.error-text { font-size: .82rem; color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox { display: flex; align-items: center; gap: 9px; font-size: .88rem; color: var(--muted); cursor: pointer; }

/* ---------------------------- cards ----------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

/* ---------------------------- utilities ------------------------- */
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: var(--mono); }
.flex { display: flex; }
.between { display: flex; align-items: center; justify-content: space-between; }
.center { display: flex; align-items: center; justify-content: center; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; }
.gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.grow { flex: 1; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* ---------------------------- toast ----------------------------- */
.toast-wrap {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  border-radius: 13px;
  background: #10162a;
  color: #fff;
  font-size: .88rem;
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
  animation: toast-in .25s ease both;
}
.toast.out { animation: toast-out .2s ease both; }
.toast-success { background: #0d2b22; }
.toast-error { background: #341418; }
.toast-icon { flex: 0 0 auto; margin-top: 1px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------------------------- modal ----------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 15, 30, .55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade-in .18s ease both;
}
.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  animation: modal-in .22s cubic-bezier(.2, .8, .3, 1) both;
}
.modal-lg { width: min(760px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 0; }
.modal-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.modal-sub { font-size: .84rem; color: var(--muted); margin-top: 3px; }
.modal-body { padding: 20px 24px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 24px 24px; }
.modal-close { width: 34px; height: 34px; border-radius: 9px; border: 0; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; }
.modal-close:hover { background: #eef0f7; color: var(--ink); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

/* ---------------------------- misc ------------------------------ */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.spinner-dark { border-color: rgba(11, 16, 32, .15); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, #eef0f6 25%, #f7f8fc 37%, #eef0f6 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 10px;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------------------------- логотип --------------------------- */
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .02em; font-size: 1.06rem; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--grad);
  display: grid; place-items: center;
  box-shadow: 0 6px 18px -6px rgba(107, 92, 255, .9);
  flex: 0 0 auto;
}
.logo-mark svg { width: 20px; height: 20px; }
.logo small { display: block; font-size: .58rem; font-weight: 600; letter-spacing: .22em; color: var(--muted-2); margin-top: -2px; line-height: 1.2; }
