/* =====================================================================
   Fracto.kz — дизайн-токены и компоненты.
   Чистый CSS без препроцессора и без сборки: файл отдаётся как есть.
   Палитра — из логотипа: тёмно-синий #1B3F79, голубой #57BECF.
   ===================================================================== */

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

:root {
  --bg: 255 255 255;
  --surface: 246 248 251;
  --raised: 255 255 255;
  --line: 224 230 238;
  --ink: 15 27 46;
  --muted: 100 114 134;
  --accent: 27 63 121;       /* тёмно-синий логотипа */
  --accent-soft: 232 238 247;
  --on-accent: 255 255 255;
  --brand: 87 190 207;       /* голубой логотипа */
  --danger: 183 45 45;
  --danger-soft: 249 232 232;
  --warn: 168 114 16;
  --warn-soft: 250 240 222;
  --ok: 21 122 78;
  --ok-soft: 227 241 235;
  --radius: 12px;
  --shadow-card: 0 1px 2px rgb(16 24 40 / 0.04), 0 1px 3px rgb(16 24 40 / 0.06);
  --shadow-pop: 0 12px 32px -8px rgb(16 24 40 / 0.18), 0 4px 12px -4px rgb(16 24 40 / 0.10);
  color-scheme: light;
}

html.dark {
  --bg: 9 14 24;
  --surface: 15 22 35;
  --raised: 20 29 44;
  --line: 34 46 66;
  --ink: 226 233 243;
  --muted: 142 158 180;
  --accent: 87 190 207;      /* на тёмном ведёт голубой */
  --accent-soft: 16 44 60;
  --on-accent: 8 26 42;
  --brand: 87 190 207;
  --danger: 233 106 106;
  --danger-soft: 47 24 24;
  --warn: 214 160 60;
  --warn-soft: 46 36 18;
  --ok: 62 178 124;
  --ok-soft: 18 40 32;
  color-scheme: dark;
}

/* ---------------------------------------------------------------- Базовое */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: rgb(var(--bg));
  color: rgb(var(--ink));
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
::selection { background: rgb(var(--accent) / 0.18); }
:focus-visible { outline: 2px solid rgb(var(--accent) / 0.6); outline-offset: 2px; border-radius: 6px; }

.num { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.container-md { max-width: 860px; margin: 0 auto; padding: 0 20px; }
.container-sm { max-width: 640px; margin: 0 auto; padding: 0 20px; }

.eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em;
  color: rgb(var(--muted)); font-weight: 500;
}

/* ------------------------------------------------------------------ Сетка */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 6px; } .gap-2 { gap: 10px; } .gap-3 { gap: 14px; } .gap-4 { gap: 20px; }

/* -------------------------------------------------------------------- Card */
.card {
  background: rgb(var(--raised));
  border: 1px solid rgb(var(--line));
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 20px; }

/* ------------------------------------------------------------------ Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; font-weight: 500; transition: background-color .15s, border-color .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 6px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 15px; border-radius: 8px; }
.btn-primary { background: rgb(var(--accent)); color: rgb(var(--on-accent)); }
.btn-primary:hover { background: rgb(var(--accent) / 0.9); }
.btn-secondary { background: rgb(var(--raised)); color: rgb(var(--ink)); border-color: rgb(var(--line)); }
.btn-secondary:hover { background: rgb(var(--surface)); }
.btn-ghost { background: transparent; color: rgb(var(--muted)); }
.btn-ghost:hover { color: rgb(var(--ink)); background: rgb(var(--surface)); }
.btn-danger { background: rgb(var(--danger)); color: #fff; }
.btn-danger:hover { background: rgb(var(--danger) / 0.9); }
.btn-quiet { background: rgb(var(--accent-soft)); color: rgb(var(--accent)); }
.btn-quiet:hover { background: rgb(var(--accent-soft) / 0.7); }
.btn-block { width: 100%; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------- Поля */
.field {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 8px;
  border: 1px solid rgb(var(--line)); background: rgb(var(--bg)); color: rgb(var(--ink));
  font-size: 14px; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.field:focus { outline: none; border-color: rgb(var(--accent)); box-shadow: 0 0 0 3px rgb(var(--accent) / 0.15); }
textarea.field { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select.field { cursor: pointer; }
.label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.hint { font-size: 12px; color: rgb(var(--muted)); margin-top: 6px; }
.field-error { font-size: 12px; color: rgb(var(--danger)); margin-top: 6px; }
.form-row { margin-bottom: 16px; }

/* ------------------------------------------------------------------- Бейдж */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 6px; border: 1px solid transparent;
  padding: 2px 8px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge-neutral { background: rgb(var(--surface)); color: rgb(var(--muted)); border-color: rgb(var(--line)); }
.badge-accent { background: rgb(var(--accent-soft)); color: rgb(var(--accent)); }
.badge-ok { background: rgb(var(--ok-soft)); color: rgb(var(--ok)); }
.badge-warn { background: rgb(var(--warn-soft)); color: rgb(var(--warn)); }
.badge-danger { background: rgb(var(--danger-soft)); color: rgb(var(--danger)); }

/* --------------------------------------------------------------- Прогресс */
.progress { height: 6px; width: 100%; border-radius: 99px; background: rgb(var(--line)); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: rgb(var(--accent)); transition: width .5s; }
.progress.ok > span { background: rgb(var(--ok)); }

/* Подпись продукта: рабочая неделя из 40 ячеек — заполненные = доступные часы */
.week-grid { display: grid; grid-template-columns: repeat(20, minmax(0, 1fr)); gap: 2px; }
.week-cell { height: 6px; border-radius: 1px; background: rgb(var(--line)); }
.week-cell.on { background: rgb(var(--brand)); }

/* -------------------------------------------------------------------- Шапка */
.site-header {
  position: sticky; top: 0; z-index: 40; border-bottom: 1px solid rgb(var(--line));
  background: rgb(var(--bg) / 0.85); backdrop-filter: blur(8px);
}
.site-header .container { height: 64px; display: flex; align-items: center; gap: 24px; }
.brand-link { display: flex; align-items: center; }
.brand-link img { height: 28px; width: auto; }

.main-nav { display: flex; gap: 4px; margin-right: auto; }
.main-nav a {
  padding: 0 12px; height: 36px; display: inline-flex; align-items: center;
  border-radius: 8px; font-size: 14px; color: rgb(var(--muted));
}
.main-nav a:hover { color: rgb(var(--ink)); background: rgb(var(--surface)); }
.main-nav a.active { color: rgb(var(--ink)); background: rgb(var(--surface)); }

.header-actions { display: flex; align-items: center; gap: 8px; }
.locale-switch { display: inline-flex; align-items: center; border: 1px solid rgb(var(--line)); border-radius: 8px; padding: 2px; background: rgb(var(--raised)); }
.locale-switch button { height: 30px; padding: 0 9px; font-size: 12px; font-weight: 500; border-radius: 6px; background: transparent; color: rgb(var(--muted)); border: none; }
.locale-switch button.active { background: rgb(var(--accent-soft)); color: rgb(var(--accent)); }

.icon-btn {
  height: 36px; width: 36px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid rgb(var(--line)); color: rgb(var(--muted)); background: rgb(var(--raised));
}
.icon-btn:hover { color: rgb(var(--ink)); background: rgb(var(--surface)); }
.theme-icon-dark { display: none; }
html.dark .theme-icon-light { display: none; }
html.dark .theme-icon-dark { display: inline; }

/* Универсальное переключение светлых/тёмных версий изображений (логотип и т.п.) */
.only-dark { display: none; }
html.dark .only-light { display: none; }
html.dark .only-dark { display: inline-block; }

.mobile-toggle { display: none; }
.mobile-panel { display: none; border-top: 1px solid rgb(var(--line)); padding: 16px 20px; }
.mobile-panel.open { display: block; }
@media (max-width: 860px) {
  .main-nav, .header-actions { display: none; }
  .mobile-toggle { display: inline-flex; margin-left: auto; }
}

/* -------------------------------------------------------------------- Футер */
.site-footer { border-top: 1px solid rgb(var(--line)); margin-top: 96px; }
.site-footer .container { padding: 40px 20px; display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.footer-brand { display: flex; align-items: center; gap: 12px; color: rgb(var(--muted)); font-size: 14px; }
.footer-brand img { height: 22px; }
.footer-links { display: flex; gap: 20px; font-size: 14px; color: rgb(var(--muted)); }
.footer-links a:hover { color: rgb(var(--ink)); }

/* -------------------------------------------------------------------- Табы */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid rgb(var(--line)); margin: 0 -20px; padding: 0 20px; }
.tabs button {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  font-size: 14px; color: rgb(var(--muted)); background: transparent; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button.active { color: rgb(var(--ink)); font-weight: 500; border-bottom-color: rgb(var(--accent)); }

/* ------------------------------------------------------------------- Модалка */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgb(15 27 46 / 0.4); backdrop-filter: blur(2px); }
.modal-box {
  position: relative; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  background: rgb(var(--raised)); border: 1px solid rgb(var(--line)); border-radius: 16px;
  box-shadow: var(--shadow-pop); animation: modal-in .2s ease both;
}
.modal-box.wide { max-width: 760px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 24px 24px 12px; }
.modal-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.modal-desc { font-size: 14px; color: rgb(var(--muted)); margin-top: 6px; line-height: 1.5; }
.modal-body { padding: 0 24px 24px; }
.modal-close { height: 32px; width: 32px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: rgb(var(--muted)); background: transparent; border: none; }
.modal-close:hover { color: rgb(var(--ink)); background: rgb(var(--surface)); }

/* -------------------------------------------------------------------- Утилиты */
.hidden { display: none !important; }
.text-muted { color: rgb(var(--muted)); }
.text-sm { font-size: 13px; }
.text-lg { font-size: 18px; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 10px; } .mt-3 { margin-top: 14px; }
.mt-4 { margin-top: 20px; } .mt-6 { margin-top: 28px; } .mt-8 { margin-top: 36px; }
.leading-relaxed { line-height: 1.6; }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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