/* =========================================================
   Formula – спільна база: скидання, токени, компоненти.
   Кольори задаються змінними, тож ті самі компоненти
   працюють і в адмінці, і в тематичних формах.
   ========================================================= */

:root {
  --f-ui: "Commissioner", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-display: var(--f-ui);
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --bg: #F2F3F7;
  --surface: #FFFFFF;
  --surface-2: #F7F8FB;
  --surface-3: #EEF0F5;
  --ink: #171C33;
  --ink-2: #4B5168;
  --ink-3: #7D8299;
  --line: #E1E4EC;
  --line-2: #CDD2DE;
  --accent: #A3189B;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(163, 24, 155, .09);
  --accent-line: rgba(163, 24, 155, .38);
  --primary: #171C33;
  --primary-ink: #FFFFFF;
  --success: #1E7A55;
  --success-soft: #E3F2EA;
  --warn: #8C5B00;
  --warn-soft: #FBF0D9;
  --danger: #C0352B;
  --danger-soft: #FBE7E5;
  --info-soft: #E8EEF9;

  --r-s: 7px;
  --r: 11px;
  --r-l: 16px;
  --shadow-1: 0 1px 2px rgba(23, 28, 51, .06), 0 1px 1px rgba(23, 28, 51, .04);
  --shadow-2: 0 10px 30px -12px rgba(23, 28, 51, .28), 0 2px 6px rgba(23, 28, 51, .06);
  --focus: 0 0 0 3px rgba(163, 24, 155, .28);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--f-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-family: var(--f-display); }
p { margin: 0; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-s); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.mono { font-family: var(--f-mono); }
.nowrap { white-space: nowrap; }

/* ---------- Кнопки ---------- */

.btn {
  --btn-bg: var(--surface);
  --btn-ink: var(--ink);
  --btn-line: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--btn-line); border-radius: var(--r-s);
  background: var(--btn-bg); color: var(--btn-ink);
  font-weight: 600; font-size: 14.5px; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .08s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { --btn-bg: var(--primary); --btn-ink: var(--primary-ink); --btn-line: var(--primary); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.15); border-color: var(--primary); }
.btn-accent { --btn-bg: var(--accent); --btn-ink: var(--accent-ink); --btn-line: var(--accent); }
.btn-accent:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--accent); }
.btn-quiet { --btn-bg: transparent; --btn-line: transparent; color: var(--ink-2); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-3); border-color: transparent; color: var(--ink); }
.btn-danger { --btn-ink: var(--danger); --btn-line: rgba(192, 53, 43, .4); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.btn-danger-fill { --btn-bg: var(--danger); --btn-ink: #fff; --btn-line: var(--danger); }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: 13.5px; }
.btn-lg { min-height: 50px; padding: 12px 26px; font-size: 16px; border-radius: var(--r); }
.btn-block { width: 100%; }
.btn-icon { min-height: 36px; width: 36px; padding: 0; }
.btn-icon.btn-sm { min-height: 30px; width: 30px; }

.btn .spin { width: 16px; height: 16px; }

/* ---------- Поля ---------- */

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label, .field-label { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.field .hint, .hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }
.field .error-text { font-size: 13px; color: var(--danger); }

.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-s);
  background: var(--surface);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input.is-invalid, .textarea.is-invalid, .select.is-invalid { border-color: var(--danger); }
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%237D8299' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}
.input-sm { min-height: 34px; padding: 6px 10px; font-size: 14px; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Перемикач ---------- */

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  position: relative; width: 40px; height: 24px; flex: none;
  border-radius: 99px; background: var(--line-2);
  transition: background .18s var(--ease);
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .18s var(--ease);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
.switch input:disabled + .track { opacity: .5; }
.switch .switch-text { font-size: 14px; }

/* ---------- Сегментований вибір ---------- */

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-3); border-radius: var(--r-s);
  flex-wrap: wrap;
}
.seg button {
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 12px; border-radius: 5px; font-size: 13.5px; font-weight: 600; color: var(--ink-2);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- Мітки стану ---------- */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 99px;
  font-size: 12.5px; font-weight: 600; line-height: 20px;
  background: var(--surface-3); color: var(--ink-2);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.chip.no-dot::before { display: none; }
.chip-open { background: var(--success-soft); color: var(--success); }
.chip-scheduled { background: var(--info-soft); color: #2D5AA8; }
.chip-closed, .chip-full { background: var(--warn-soft); color: var(--warn); }
.chip-draft { background: var(--surface-3); color: var(--ink-3); }

/* ---------- Банери ---------- */

.banner {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r);
  border: 1px solid transparent; font-size: 14px; line-height: 1.5;
}
.banner strong { font-weight: 700; }
.banner-info { background: var(--info-soft); color: #23406F; border-color: rgba(45, 90, 168, .18); }
.banner-ok { background: var(--success-soft); color: var(--success); border-color: rgba(30, 122, 85, .2); }
.banner-warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(140, 91, 0, .2); }
.banner-error { background: var(--danger-soft); color: #92241C; border-color: rgba(192, 53, 43, .22); }

.demo-strip {
  position: relative; z-index: 60;
  background: #FFF4CF; color: #6A4A00;
  font-size: 13px; text-align: center; padding: 7px 14px;
  border-bottom: 1px solid #F0DD9C;
}

/* ---------- Спінер ---------- */

.spin {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; display: inline-block; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-block { display: grid; place-items: center; gap: 12px; padding: 64px 16px; color: var(--ink-3); }

/* ---------- Сповіщення (toast) ---------- */

.toast-host {
  position: fixed; z-index: 1000; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: grid; gap: 8px; width: min(440px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: #1D2238; color: #fff; border-radius: var(--r);
  padding: 11px 16px; font-size: 14px; box-shadow: var(--shadow-2);
  display: flex; gap: 10px; align-items: center;
  animation: toast-in .22s var(--ease);
}
.toast.is-error { background: #8E2018; }
.toast.is-ok::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #52D69A; flex: none; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Модальні вікна ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(16, 19, 36, .46);
  display: grid; place-items: center; padding: 16px;
  animation: fade-in .16s ease;
}
.modal {
  width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); color: var(--ink);
  border-radius: var(--r-l); box-shadow: var(--shadow-2);
  padding: 22px 22px 18px;
  animation: modal-in .2s var(--ease);
}
.modal.wide { width: min(760px, 100%); }
.modal h2 { font-size: 19px; margin-bottom: 8px; }
.modal .modal-body { color: var(--ink-2); font-size: 14.5px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }

/* ---------- Меню ---------- */

.menu {
  position: absolute; z-index: 800; min-width: 220px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-2); padding: 6px;
  animation: fade-in .12s ease;
}
.menu button, .menu a {
  display: flex; width: 100%; align-items: center; gap: 10px;
  padding: 9px 10px; border: 0; background: none; border-radius: var(--r-s);
  text-align: left; cursor: pointer; font-size: 14px; color: var(--ink); text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--surface-3); }
.menu button svg, .menu a svg { width: 17px; height: 17px; color: var(--ink-3); flex: none; }
.menu .danger { color: var(--danger); }
.menu .danger svg { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }

/* ---------- Підвал ---------- */

.site-foot {
  text-align: center; font-size: 12.5px; color: var(--ink-3);
  padding: 28px 16px 22px;
}

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