/* =====================================================================
   CRM в стиле iOS — слой поверх style.css.
   Подключается на страницах CRM ПОСЛЕ style.css. Чтобы вернуть прежний
   вид, достаточно убрать строку <link rel="stylesheet" href="/ios.css" />.

   Ориентиры — системные элементы iPhone: шрифт San Francisco, синий
   #007AFF, серый фон #F2F2F7, «залитые» поля ввода, скругления 10–20 px,
   тонкие разделители, сегментированный переключатель, модальные окна-шторки
   с размытием фона. На Windows вместо San Francisco — Inter (очень близок).
   ===================================================================== */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --border: #e5e5ea;
  --separator: rgba(60, 60, 67, 0.14);
  --text: #1c1c1e;
  --text-muted: #8e8e93;
  --primary: #007aff;
  --primary-hover: #0066d6;
  --danger: #ff3b30;
  --danger-hover: #e0352b;
  --success: #34c759;
  --orange: #ff9500;
  --purple: #af52de;
  --teal: #30b0c7;
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { background: var(--bg); color: var(--text); letter-spacing: -0.01em; }
a { color: var(--primary); }
::selection { background: rgba(0, 122, 255, 0.2); }

/* ---------- Кнопки ---------- */
.btn {
  min-height: 40px;
  padding: 0 18px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  transition: background 0.15s ease, transform 0.12s ease, opacity 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: scale(0.97); opacity: 0.85; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.3); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { background: #a8cdfb; color: #fff; }

/* «серая» кнопка iOS: заливка, синий текст */
.btn-secondary { background: var(--fill); color: var(--primary); border: none; }
.btn-secondary:hover { background: var(--fill-strong); }

/* удаление: красный текст на бледно-красной заливке */
.btn-danger { background: rgba(255, 59, 48, 0.12); color: var(--danger); border: none; }
.btn-danger:hover { background: rgba(255, 59, 48, 0.2); }

/* маленькая кнопка — «капсула» */
.btn-sm { min-height: 30px; padding: 0 14px; font-size: 13px; border-radius: 999px; }

.btn-add-link { color: var(--primary); font-weight: 600; }

/* ---------- Карточки ---------- */
.page { padding-top: clamp(20px, 2vw, 32px); }
.card {
  border: none;
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.card__header { padding: 18px 22px; border-bottom: 0.5px solid var(--separator); }
.card__header h1, .card__header h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.025em; }

/* ---------- Таблицы (как список iOS) ---------- */
th, td { border-bottom: 0.5px solid var(--separator); }
th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.02em;
  background: transparent;
}
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: #f7f7fa; }

/* ---------- Поля ввода ---------- */
.field input, .field select, .field textarea,
.field-group input, .field-group select, .field-group textarea,
.picker__toggle, .picker__search,
.deal-line-item-row input, .deal-line-item-row select {
  background: var(--fill);
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 15px;
  color: var(--text);
  transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus,
.field-group input:focus, .field-group select:focus, .field-group textarea:focus,
.picker__search:focus,
.deal-line-item-row input:focus, .deal-line-item-row select:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.18);
}
.field label, .field-group label { color: #3c3c43; font-weight: 500; font-size: 13px; }
.li-field--amount { background: var(--fill); border: none; border-radius: 10px; }
input::placeholder, textarea::placeholder { color: #a1a1a6; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 18px; height: 18px; }
.field-invalid, .field input.field-invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.15) !important; }

/* ---------- Выбор пользователей (пикер) ---------- */
.picker__panel {
  border: none;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}
.picker__option:hover { background: #f2f2f7; }

/* ---------- Чипы и бейджи (капсулы в системных цветах) ---------- */
.chip { background: rgba(0, 122, 255, 0.12); color: var(--primary); font-weight: 500; }
.badge { padding: 3px 10px; font-weight: 600; font-size: 12px; letter-spacing: 0; }
.badge-admin { background: rgba(0, 122, 255, 0.12); color: #0062cc; }
.badge-moderator,
.badge-pending { background: rgba(255, 149, 0, 0.14); color: #c26e00; }
.badge-director,
.badge-revision { background: rgba(175, 82, 222, 0.14); color: #8e3fb8; }
.badge-sb,
.badge-inactive,
.badge-rejected,
.badge-lost { background: rgba(255, 59, 48, 0.12); color: #d70015; }
.badge-active,
.badge-approved,
.badge-done,
.badge-delivered { background: rgba(52, 199, 89, 0.15); color: #248a3d; }
.badge-user,
.badge-created,
.badge-closed { background: var(--fill); color: #636366; }
.badge-noticed,
.badge-received,
.badge-in_progress,
.badge-with_signer { background: rgba(48, 176, 199, 0.15); color: #1d7f91; }

/* ---------- Канбан ---------- */
.kanban-col { background: #ececf1; border-radius: 16px; padding: 10px; }
.kanban-col__header { color: #636366; font-weight: 600; font-size: 13px; }
.kanban-card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  padding: 12px 14px;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}
.kanban-card:hover { border: none; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1); transform: translateY(-1px); }
.kanban-card__title { font-weight: 600; font-size: 14px; }

/* ---------- Сегментированный переключатель «Канбан / Список» ---------- */
div:has(> #deals-view-kanban-btn) {
  background: var(--fill) !important;
  border: none !important;
  border-radius: 10px !important;
  padding: 2px;
  gap: 2px !important;
}
div:has(> #deals-view-kanban-btn) > .btn {
  border-radius: 8px !important;
  border: none !important;
  min-height: 28px;
  background: transparent;
  color: var(--text);
  font-weight: 500;
}
div:has(> #deals-view-kanban-btn) > .btn-primary {
  background: #fff;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}

/* ---------- Модальные окна — «шторка» iOS ---------- */
.modal-overlay {
  background: rgba(0, 0, 0, 0.28);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.modal-overlay:not(.hidden) .modal { animation: ios-sheet-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes ios-sheet-in {
  from { transform: translateY(24px) scale(0.98); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.modal.card, .modal { border-radius: 22px; }
.modal__fixed-title { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.modal__close {
  background: var(--fill);
  border: none;
  color: #6e6e73;
  font-size: 13px;
  font-weight: 700;
}
.modal__close:hover { background: var(--fill-strong); }

/* ---------- Сообщения, пустые состояния ---------- */
.alert { border-radius: 12px; border: none; }
.alert-error { background: rgba(255, 59, 48, 0.1); color: #d70015; }
.alert-success { background: rgba(52, 199, 89, 0.12); color: #248a3d; }
.empty-state { color: var(--text-muted); }

/* ---------- Загрузка файлов ---------- */
.dropzone {
  border: 1.5px dashed #c7c7cc;
  border-radius: 14px;
  background: #fafafc;
}

/* ---------- Чат ---------- */
.chat-send-btn { border-radius: 50%; background: var(--primary); }

/* ---------- Уведомления ---------- */
.notif-popup {
  border: none;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}
.notif-badge { background: var(--danger); }

/* ---------- Вход и смена пароля ---------- */
.auth-shell { background: var(--bg); }
.auth-card { border-radius: 24px; padding: 36px 32px; }
.auth-card h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.auth-card .btn { min-height: 48px; font-size: 17px; border-radius: 14px; }
.auth-card .field input { min-height: 46px; font-size: 16px; }

/* Кнопка «Выйти» в общей шапке остаётся в стиле шапки сайта */
.header-user .btn,
.header-user .btn:hover {
  background: #fff;
  color: #1c1f26;
  border: 1px solid #d6dbe3 !important;
  border-radius: 6px;
  min-height: 0;
  transform: none;
  opacity: 1;
}

/* Поиск над таблицами (стили у полей заданы прямо в разметке — перекрываем) */
.page input[placeholder^="Поиск"]:not(.picker__search) {
  background: var(--fill) !important;
  border: 1px solid transparent !important;
  border-radius: 10px !important;
  padding: 10px 12px 10px 36px !important;
  font-size: 15px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: 12px center !important;
}
.page input[placeholder^="Поиск"]:not(.picker__search):focus {
  outline: none;
  background-color: #fff !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.18);
}

/* Канбан: отступ от заголовка карточки */
#deals-kanban { padding-top: 16px !important; }

/* Таблица внизу карточки — скруглённые нижние углы */
.card > .table-scroll-outer:last-child,
.card > div:last-child > .table-scroll-outer:last-child { border-radius: 0 0 20px 20px; overflow: hidden; }
