/* =========================================================================
   Tori School — Платформа (broadcast/leads/probniki)
   Стиль: Brutalist Neo — duovision, hard borders, pop shadows.
   Палитра и приёмы синхронизированы с 1-2-MVP/product-mvp (проверка пробников).
   ВНИМАНИЕ: все имена классов сохранены — HTML и JS трогать не нужно.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@500;700;800;900&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  /* Brand palette (синхр. с product-mvp/globals.css) */
  --cream: #FBFBF9;
  --white: #FFFFFF;
  --black: #000000;
  --ink: #0A0A14;
  --ink-soft: #21223A;
  --muted: #6B6E84;
  --line: rgba(10, 10, 20, 0.10);
  --violet: #9A86FF;
  --violet-deep: #7B65EB;
  --violet-soft: #BFB3FB;
  --violet-ghost: #EAE4FF;
  --cyan: #A4E8FF;
  --cyan-soft: #D0EFFA;
  --warm-orange: #C97A1F;
  --hot: #FF4D2E;

  /* Тени — спокойные, серые, слегка размытые. Для «акцентных» поверхностей
     (hero, активная кнопка) остаются версии «pop», но мягче и серее. */
  --shadow-soft:   0 1px 2px rgba(10,10,20,0.06), 0 2px 6px rgba(10,10,20,0.05);
  --shadow-soft-lg:0 2px 4px rgba(10,10,20,0.07), 0 8px 20px rgba(10,10,20,0.08);
  --shadow-pop:    3px 3px 0 rgba(10,10,20,0.12);
  --shadow-pop-lg: 5px 5px 0 rgba(10,10,20,0.14);
  --shadow-pop-sm: 2px 2px 0 rgba(10,10,20,0.10);

  --font-display: 'Unbounded', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;

  /* Совместимость со старыми именами переменных — на случай если где-то остались */
  --bg: var(--cream);
  --panel: var(--white);
  --border: var(--ink);
  --text: var(--ink);
  --accent: var(--violet);
  --accent-hover: var(--violet-deep);
  --danger: var(--hot);
  --ok: #1F9D55;
  --warn: var(--warm-orange);
  --radius: 0px;
  --shadow: var(--shadow-pop-sm);
}

* { box-sizing: border-box; }

/* Атрибут [hidden] должен скрывать всегда, даже если у элемента есть display:flex/grid. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Заголовки — у нас Unbounded для display. Веса понижаем чтобы не «давили». */
h1, h2, h3, h4 { color: var(--ink); }

::selection { background: var(--violet); color: var(--ink); }

a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; text-decoration-color: var(--violet); }
a:hover { color: var(--violet-deep); text-decoration-color: var(--ink); }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--ink);
  margin: 0 0 12px;
}

/* =========================================================================
   ШАПКА
   ========================================================================= */
header.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--ink);
  color: var(--cream);
  border-bottom: 2px solid var(--violet);
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 60px;
}

header.top .back {
  color: var(--cream);
  font-size: 22px;
  line-height: 1;
  padding: 6px 12px;
  border: 2px solid var(--cream);
  background: transparent;
  text-decoration: none;
  font-weight: 700;
  transition: transform .15s ease, background .15s ease;
}
header.top .back:hover {
  background: var(--violet);
  color: var(--ink);
  border-color: var(--violet);
  text-decoration: none;
  transform: translate(-2px, -2px);
}

header.top .brand {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 18px;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--cream);
}
header.top .brand a { color: inherit; text-decoration: none; }

header.top .logout {
  border: 2px solid var(--cream);
  background: transparent;
  color: var(--cream);
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, color .15s ease;
}
header.top .logout:hover {
  background: var(--hot);
  border-color: var(--hot);
  color: var(--white);
  transform: translate(-2px, -2px);
}

/* =========================================================================
   ОСНОВНОЙ МАКЕТ
   ========================================================================= */
main {
  max-width: 1200px;
  margin: 28px auto;
  padding: 0 24px;
}

/* =========================================================================
   HOME — главная с плитками
   ========================================================================= */
.home-main {
  max-width: 1200px;
}

.home-hero {
  position: relative;
  overflow: hidden;
  border: 2px solid var(--ink);
  background:
    radial-gradient(700px 400px at 80% 20%, rgba(154,134,255,.45), transparent 60%),
    radial-gradient(500px 400px at 10% 110%, rgba(164,232,255,.4), transparent 60%),
    var(--ink);
  color: var(--cream);
  padding: 40px 36px;
  margin-bottom: 36px;
  box-shadow: var(--shadow-pop);
}
.home-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 100% 38px;
  pointer-events: none;
  opacity: 0.5;
}
.home-hero > * { position: relative; z-index: 1; }

.home-hero .kicker {
  color: var(--cream);
  margin-bottom: 14px;
}
.home-hero h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 56px;
  letter-spacing: -0.035em;
  line-height: 0.95;
  text-transform: uppercase;
  color: var(--cream);
  margin: 0 0 14px;
}
.home-hero p {
  font-size: 16px;
  color: rgba(255,255,255,.78);
  max-width: 640px;
  margin: 0;
}
.home-hero .grad {
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

.home-main > p.muted { margin: 0 0 18px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
  margin-top: 8px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--white);
  border: 2px solid var(--ink);
  padding: 28px 26px;
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-pop);
  transition: transform .18s ease, box-shadow .18s ease;
  min-height: 220px;
}
.tile:hover {
  text-decoration: none;
  transform: translate(-3px, -3px);
  box-shadow: var(--shadow-pop-lg);
}
.tile.tile-violet { background: var(--violet); }
.tile.tile-cyan { background: var(--cyan); }
.tile.tile-ink { background: var(--ink); color: var(--cream); }
.tile.tile-ink .tile-sub { color: rgba(255,255,255,.7); }

.tile-emoji {
  font-size: 44px;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  background: var(--white);
  line-height: 1;
}
.tile.tile-ink .tile-emoji { background: var(--violet); color: var(--ink); }

.tile-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 28px;
  text-transform: uppercase;
  letter-spacing: -0.025em;
  line-height: 1;
  margin: 0;
}
.tile-sub {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
  margin-top: -4px;
}

/* =========================================================================
   KICKER (мини-метка)
   ========================================================================= */
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
}
.kicker::before {
  content: "";
  width: 24px;
  height: 2px;
  background: var(--violet);
  display: inline-block;
}

/* =========================================================================
   PANEL — основной контейнер контента
   ========================================================================= */
.panel {
  background: var(--white);
  border: 2px solid var(--ink);
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-pop);
}
.panel h2 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: -0.02em;
}
.panel .row { display: flex; gap: 12px; flex-wrap: wrap; }
.panel .row > * { flex: 1; min-width: 220px; }

.muted { color: var(--muted); }
.small { font-size: 12px; font-family: var(--font-mono); letter-spacing: 0.02em; }

/* =========================================================================
   SUBNAV (вкладки рассылок)
   ========================================================================= */
.subnav {
  max-width: 1200px;
  margin: 22px auto 0;
  padding: 0 24px;
}
.subnav .tabs {
  display: flex;
  gap: 0;
  border: 2px solid var(--ink);
  background: var(--white);
  box-shadow: var(--shadow-pop-sm);
  overflow-x: auto;
}
.subnav .tabs a {
  display: inline-block;
  padding: 12px 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
  text-decoration: none;
  border-right: 2px solid var(--ink);
  background: var(--white);
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.subnav .tabs a:last-child { border-right: none; }
.subnav .tabs a:hover { background: var(--violet-ghost); text-decoration: none; }
.subnav .tabs a.active { background: var(--violet); color: var(--ink); }

/* =========================================================================
   FORM CONTROLS
   ========================================================================= */
label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

input[type="text"], input[type="password"], input[type="number"],
input[type="tel"], input[type="email"], input[type="date"], input[type="time"],
textarea, select {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--ink);
  background: var(--white);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  border-radius: 0;
  outline: none;
  transition: box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  box-shadow: 4px 4px 0 var(--violet);
}
textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.5;
}
input::placeholder, textarea::placeholder { color: var(--muted); }

/* =========================================================================
   BUTTONS
   ========================================================================= */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 2px solid var(--ink);
  background: var(--violet);
  color: var(--ink);
  box-shadow: var(--shadow-pop-sm);
  cursor: pointer;
  border-radius: 0;
  transition: transform .15s ease, box-shadow .15s ease;
}
button:hover, .btn:hover {
  background: var(--violet);
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--ink);
}
button:active, .btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}
button:disabled, .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow-pop-sm);
}
button.secondary, .btn.secondary {
  background: var(--white);
  color: var(--ink);
}
button.secondary:hover, .btn.secondary:hover { background: var(--cyan-soft); }
button.danger, .btn.danger {
  background: var(--hot);
  color: var(--white);
}

/* =========================================================================
   CHIPLIST (legacy)
   ========================================================================= */
.chiplist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px;
  border: 2px solid var(--ink);
  background: var(--cream);
}
.chiplist label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: var(--white);
  padding: 6px 12px;
  border: 2px solid var(--ink);
  font-weight: 600;
  font-family: var(--font-body);
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
  color: var(--ink);
}
.chiplist label input { margin: 0; }
.chiplist label.has { background: var(--violet); }

/* =========================================================================
   RECIPIENTS / SUMMARY BARS
   ========================================================================= */
.recipients-summary {
  padding: 12px 16px;
  background: var(--cyan-soft);
  border: 2px solid var(--ink);
  margin: 12px 0;
  font-weight: 600;
  font-size: 14px;
}
.recipients-summary.warn { background: #FFE6A2; }
.recipients-summary.ok { background: var(--violet-ghost); }

/* =========================================================================
   TABLE
   ========================================================================= */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th, table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--ink);
}
table th {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink);
  background: var(--violet-ghost);
  position: sticky;
  top: 0;
}
table tr:hover td { background: var(--cream); }

.status-sent { color: #1F9D55; font-weight: 700; }
.status-skipped { color: var(--warm-orange); font-weight: 700; }
.status-failed { color: var(--hot); font-weight: 700; }

/* =========================================================================
   PREVIEW BOX
   ========================================================================= */
.preview-box {
  background: var(--cream);
  border: 2px dashed var(--ink);
  padding: 14px;
  max-height: 360px;
  overflow-y: auto;
}
.preview-box .preview-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.preview-box .preview-item:last-child { border-bottom: none; }
.preview-box .preview-item .who {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}
.preview-box .preview-item .text { white-space: pre-wrap; margin-top: 6px; }
.preview-box .preview-item.not-linked .who::after { content: " — нет привязки"; color: var(--hot); }

.actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* =========================================================================
   FILTER BAR (broadcast)
   ========================================================================= */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 14px 0;
  flex-wrap: wrap;
}
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
}
.search-wrap input {
  width: 100%;
  padding: 10px 36px 10px 36px;
  font-size: 15px;
  border: 2px solid var(--ink);
  background: var(--white);
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink);
  pointer-events: none;
  font-size: 14px;
}
.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  color: var(--ink);
  border: 2px solid transparent;
  font-size: 18px;
  padding: 2px 8px;
  cursor: pointer;
  box-shadow: none;
}
.search-clear:hover {
  color: var(--hot);
  background: transparent;
  transform: translateY(-50%);
  box-shadow: none;
}

.filter-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn {
  background: var(--white);
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}
.filter-btn:hover {
  background: var(--violet-ghost);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
}
.filter-btn.has-filter {
  background: var(--violet);
  color: var(--ink);
}
.filter-btn .count {
  background: var(--ink);
  color: var(--cream);
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 0;
}

/* Активные чипы */
.active-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  min-height: 0;
}
.active-chips:empty { display: none; }
.active-chips .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--violet);
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: 4px 6px 4px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.active-chips .chip button {
  background: transparent;
  color: var(--ink);
  border: none;
  padding: 0 6px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  text-transform: none;
}
.active-chips .chip button:hover {
  color: var(--hot);
  background: transparent;
  transform: none;
  box-shadow: none;
}
.active-chips .clear-all {
  background: transparent;
  color: var(--ink-soft);
  border: 2px solid transparent;
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: none;
}
.active-chips .clear-all:hover {
  color: var(--hot);
  background: transparent;
  transform: none;
  box-shadow: none;
}

/* =========================================================================
   POPOVER
   ========================================================================= */
.popover {
  position: absolute;
  z-index: 100;
  background: var(--white);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-pop);
  width: 300px;
  max-height: 400px;
  display: flex;
  flex-direction: column;
}
.popover-header {
  padding: 10px;
  border-bottom: 2px solid var(--ink);
}
.popover-header input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 2px solid var(--ink);
}
.popover-list { flex: 1; overflow-y: auto; padding: 4px 0; min-height: 80px; }
.popover-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  margin: 0;
  cursor: pointer;
}
.popover-list label:hover { background: var(--cream); }
.popover-list label input { margin: 0; }
.popover-list .empty {
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.popover-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-top: 2px solid var(--ink);
}
.small-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 14px;
  letter-spacing: 0.06em;
}

/* =========================================================================
   MODAL
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--white);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-pop-lg);
  padding: 24px 26px;
  width: 420px;
  max-width: 100%;
}
.modal h3 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: -0.02em;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.modal input {
  padding: 10px 12px;
  font-size: 15px;
  border: 2px solid var(--ink);
}

/* =========================================================================
   STUDENTS TABLE (broadcast)
   ========================================================================= */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  flex-wrap: wrap;
}
.table-wrap {
  border: 2px solid var(--ink);
  overflow: auto;
  max-height: 520px;
  box-shadow: var(--shadow-pop-sm);
}
.students-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}
.students-table thead {
  position: sticky;
  top: 0;
  background: var(--violet-ghost);
  z-index: 5;
}
.students-table th {
  padding: 11px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: left;
  border-bottom: 2px solid var(--ink);
  color: var(--ink);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.students-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.students-table tbody tr:last-child td { border-bottom: none; }
.students-table tr.selected td { background: var(--violet-ghost); }
.students-table tr:hover td { background: var(--cream); }
.students-table .col-check { width: 32px; }
.students-table .col-class, .students-table .col-chat { width: 78px; }
.students-table .col-status { width: 90px; }
.students-table .col-group, .students-table .col-subject { width: 140px; }
.students-table .col-teacher { width: 160px; }
.students-table .col-name { font-weight: 600; }
.students-table .chip {
  display: inline-block;
  padding: 2px 10px;
  margin: 1px 2px 1px 0;
  background: var(--violet-ghost);
  border: 1px solid var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.students-table .chip.archive {
  background: #FFD8D2;
  color: #B83232;
  border-color: #B83232;
}

/* =========================================================================
   EDITOR (rich-text для рассылки)
   ========================================================================= */
.editor-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px;
  border: 2px solid var(--ink);
  border-bottom: none;
  background: var(--violet-ghost);
  align-items: center;
  flex-wrap: wrap;
}
.editor-toolbar button {
  background: var(--white);
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: 6px 12px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  box-shadow: 2px 2px 0 var(--ink);
}
.editor-toolbar button:hover {
  background: var(--violet);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
}
.editor-toolbar .divider {
  color: var(--ink-soft);
  margin: 0 4px;
  font-weight: 700;
}

.editor {
  min-height: 180px;
  padding: 14px;
  border: 2px solid var(--ink);
  background: var(--white);
  font-size: 15px;
  outline: none;
  line-height: 1.55;
}
.editor:focus { box-shadow: inset 0 0 0 0 transparent, 4px 4px 0 var(--violet); }
.editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

/* =========================================================================
   MISC
   ========================================================================= */
.warn { color: var(--warm-orange); font-weight: 700; }
.discovered-row {
  padding: 12px 14px;
  border: 2px solid var(--ink);
  background: var(--cream);
  margin-bottom: 10px;
}
.discovered-row select { max-width: 280px; }

/* =========================================================================
   LOGIN
   ========================================================================= */
.login-wrap {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(600px 400px at 80% 10%, rgba(154,134,255,.35), transparent 60%),
    radial-gradient(500px 400px at 10% 100%, rgba(164,232,255,.35), transparent 60%),
    var(--cream);
}
.login-card {
  background: var(--white);
  padding: 32px 32px 28px;
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-pop-lg);
  width: 380px;
  max-width: 100%;
  box-sizing: border-box;
}
.login-card h1 {
  margin: 0 0 22px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 26px;
  text-transform: uppercase;
  letter-spacing: -0.025em;
  line-height: 1;
}
.login-card .field input {
  width: 100%;
  box-sizing: border-box;
  padding: 14px 96px 14px 14px;
  border: 2px solid var(--ink);
  font-size: 16px;
  background: var(--white);
}
.login-card .field input:focus {
  box-shadow: 4px 4px 0 var(--violet);
  outline: none;
}
.login-card button[type="submit"] {
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  width: 100%;
}
.login-card .error {
  color: var(--hot);
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 600;
}

/* =========================================================================
   LEADS (формы и история)
   ========================================================================= */
.lead-form .row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.lead-form label { margin-bottom: 4px; }
.lead-form .hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}
.lead-form .actions { display: flex; gap: 10px; margin-top: 16px; }
.lead-form .actions button { padding: 14px 22px; }
.lead-form .row-inline {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: end;
}
.lead-form .chip {
  padding: 12px 16px;
  border: 2px solid var(--ink);
  background: var(--white);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  color: var(--ink);
  white-space: nowrap;
  box-shadow: 2px 2px 0 var(--ink);
}
.lead-form .chip:hover {
  background: var(--cyan);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
}
.lead-form .time-range {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
}
.lead-form .time-range .sep {
  color: var(--ink-soft);
  text-align: center;
  font-weight: 700;
}

.leads-history .lead-card {
  border: 2px solid var(--ink);
  padding: 16px 18px;
  margin-bottom: 12px;
  background: var(--white);
  box-shadow: var(--shadow-pop-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.leads-history .lead-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--ink);
}
.lead-card .lc-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}
.lead-card .lc-id {
  font-family: var(--font-mono);
  color: var(--ink-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.lead-card .lc-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  text-transform: uppercase;
  letter-spacing: -0.015em;
}
.lead-card .lc-meta {
  color: var(--ink-soft);
  font-size: 14px;
  margin-top: 10px;
  line-height: 1.6;
}
.lead-card .lc-warn {
  color: var(--warm-orange);
  font-family: var(--font-mono);
  font-size: 11px;
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.leads-empty {
  color: var(--muted);
  padding: 28px 20px;
  text-align: center;
  border: 2px dashed var(--ink-soft);
  background: var(--cream);
  font-family: var(--font-mono);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* =========================================================================
   LEADS · DELETE (раздел /leads/delete)
   ========================================================================= */
.lead-status-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
}
.lead-status-filter .status-chip {
  background: var(--white);
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}
.lead-status-filter .status-chip:hover {
  background: var(--violet-ghost);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
}
.lead-status-filter .status-chip.active {
  background: var(--violet);
}

/* Бейдж текущего статуса лида в карточке */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 2px solid var(--ink);
  background: var(--violet-ghost);
  color: var(--ink);
  margin-left: 6px;
  vertical-align: middle;
}
.status-badge.status-1 { background: var(--cyan-soft); }       /* Установлен контакт */
.status-badge.status-2 { background: var(--cyan); }            /* Назначено пробное */
.status-badge.status-3 { background: var(--violet-soft); }     /* Проведено пробное */
.status-badge.status-6 { background: var(--violet); }          /* Внесён абонемент */
.status-badge.status-4 { background: #BFEAC2; }                /* Получена оплата */
.status-badge.status-5 { background: #FFD8D2; color: #B83232; }/* Клиент отказался */
.status-badge.status-unknown { background: var(--cream); color: var(--muted); }

/* Карточка лида в списке удаления — кнопки действий */
.lead-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.lead-actions .small-btn {
  padding: 6px 12px;
  font-size: 11px;
}
.lead-alfa-link {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lead-alfa-link a { color: var(--ink-soft); }

/* Раскрывающаяся панель действия (смена статуса / архив) */
.lead-action-panel {
  margin-top: 14px;
  padding: 14px;
  border: 2px dashed var(--ink);
  background: var(--cream);
}
.lead-action-panel label {
  margin-bottom: 8px;
}
.lead-action-panel select {
  margin-bottom: 12px;
}
.lead-action-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.lead-action-actions .btn { padding: 8px 16px; font-size: 12px; }

/* Toast */
.toast {
  position: fixed;
  right: 20px;
  top: 20px;
  padding: 14px 20px;
  border: 2px solid var(--ink);
  background: var(--white);
  color: var(--ink);
  font-weight: 700;
  z-index: 100;
  box-shadow: var(--shadow-pop);
  max-width: calc(100vw - 32px);
}
.toast.ok { background: var(--violet); }
.toast.err { background: var(--hot); color: var(--white); }

/* Placeholder block (заглушки разделов) */
.placeholder-block {
  padding: 40px 24px;
  text-align: center;
  border: 2px dashed var(--ink);
  background: var(--cream);
  color: var(--ink-soft);
}
.placeholder-block .em {
  font-size: 38px;
  margin-bottom: 12px;
}

.leads-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

/* =========================================================================
   МОБИЛЬНЫЙ АДАПТИВ
   ========================================================================= */
@media (max-width: 900px) {
  .leads-layout { grid-template-columns: 1fr; gap: 16px; }
  .leads-history { order: 2; }
}

@media (max-width: 640px) {
  html, body { font-size: 15px; }
  header.top { padding: 10px 14px; gap: 8px; min-height: 52px; }
  header.top .brand { font-size: 14px; }
  header.top .logout { padding: 6px 10px; font-size: 11px; }

  main { padding: 0 14px; margin-top: 18px; }
  .panel { padding: 18px 16px; }
  .panel h2 { font-size: 17px; }

  .home-hero { padding: 28px 22px; }
  .home-hero h1 { font-size: 34px; }
  .home-hero p { font-size: 15px; }

  .tile { padding: 22px 20px; min-height: 180px; }
  .tile-title { font-size: 22px; }
  .tile-emoji { width: 54px; height: 54px; font-size: 34px; }

  .subnav { padding: 0 14px; }
  .subnav .tabs a { padding: 10px 14px; font-size: 11px; }

  /* iOS не зумит инпуты при font-size >= 16px */
  input, select, textarea, button, .btn { font-size: 16px !important; }
  input[type="text"], input[type="password"], input[type="tel"], input[type="email"],
  input[type="date"], input[type="time"], select, textarea {
    padding: 12px 14px !important;
  }
  button, .btn { padding: 12px 16px !important; }

  .lead-form .row-inline { grid-template-columns: 1fr; }
  .lead-form .row-inline .chip { width: 100%; text-align: center; }
  .lead-form .time-range { grid-template-columns: 1fr 1fr; }
  .lead-form .time-range .sep { display: none; }

  .filter-bar { gap: 8px; }
  .filter-btn { padding: 7px 10px; font-size: 11px; }
}

@media (max-width: 480px) {
  .login-wrap { padding: 16px; align-items: flex-start; padding-top: 8vh; }
  .login-card { width: 100%; max-width: 380px; padding: 26px 22px 22px; }
  .login-card h1 { font-size: 22px; }
}

/* ────────────── Назначение пробного ────────────── */
.trial-leads-results {
  border: 1px solid var(--ink, #1d1818);
  background: var(--white, #fff);
  max-height: 280px;
  overflow-y: auto;
  margin-top: 6px;
  box-shadow: 4px 4px 0 var(--ink, #1d1818);
}
.trial-leads-header {
  padding: 8px 12px;
  background: #f6f1f1;
  border-bottom: 1px solid #e7e1e1;
  font-size: 11px;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  z-index: 1;
}
.trial-lead-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #e7e1e1;
}
.trial-lead-item:last-child { border-bottom: none; }
.trial-lead-item:hover { background: #faf5ff; }

/* Стрелочка-toggle комбобокса лидов */
.search-wrap { position: relative; }
.search-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 16px;
  color: #555;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: transform 0.15s ease;
  user-select: none;
}
.search-toggle.open { transform: translateY(-50%) rotate(180deg); color: var(--violet, #7c3aed); }
.search-toggle:hover { color: var(--ink, #1d1818); }
/* Сдвигаем clear-кнопку левее, чтобы не перекрывать toggle */
.search-wrap .search-clear { right: 36px; }
.trial-lead-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.trial-lead-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: #555; }
.trial-leads-empty, .trial-leads-loading {
  padding: 14px;
  text-align: center;
  color: #888;
  font-size: 13px;
}
.trial-lead-selected {
  margin-top: 8px;
  padding: 10px 12px;
  background: #f3e8ff;
  border: 2px solid var(--violet, #7c3aed);
  border-radius: 4px;
}
.trial-lead-selected-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.trial-lead-selected-name { font-weight: 700; font-size: 15px; }
.trial-lead-deselect {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
  color: #555;
}
.trial-lead-deselect:hover { color: #000; }
.trial-fields[disabled] { opacity: 0.45; pointer-events: none; }
.trial-fields { border: none; padding: 0; margin: 0; }
.trial-templates {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 4px;
}
.trial-template-chip { cursor: pointer; }
.trial-template-chip.active {
  background: var(--violet, #7c3aed) !important;
  color: var(--white, #fff) !important;
  border-color: var(--ink, #1d1818) !important;
}
.trial-progress {
  padding: 14px;
  background: #fff8e1;
  border: 1px dashed #d4b500;
  border-radius: 4px;
  font-size: 13px;
}
.trial-result-ok {
  padding: 10px 14px;
  background: #e6f9ed;
  border-left: 4px solid #27a35a;
  margin-bottom: 8px;
  font-weight: 600;
}
.trial-result-partial {
  padding: 10px 14px;
  background: #fff8e1;
  border-left: 4px solid #d4b500;
  margin-bottom: 8px;
  font-weight: 600;
}
.trial-result-err {
  padding: 10px 14px;
  background: #fee;
  border-left: 4px solid #c33;
  margin-bottom: 8px;
}
.trial-result-links {
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-all;
}
.trial-result-links a { color: var(--violet, #7c3aed); text-decoration: underline; }
.trial-steps {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  font-size: 13px;
}
.trial-steps li {
  padding: 3px 0;
  color: #2a7a45;
}
.trial-steps li.trial-step-err { color: #c33; }


/* === ДОБАВЛЕНИЕ ПРИЧИНЫ В АРХИВ === */
.reason-row { display: flex; gap: 8px; align-items: stretch; }
.reason-row select { flex: 1; }
.reason-row .plus-btn {
  flex: 0 0 auto;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 52px;
  padding: 12px 16px !important;
  font-size: 22px !important;
  line-height: 1;
}
/* Гарантируем 1:1 высоту с соседним select */
.reason-row select { box-sizing: border-box; height: auto; }
