/* ============================================================
   Catalogue design system — single source of truth for BOTH apps
   (storefront + admin). Monochrome: white paper, near-black ink,
   grey structure. The only "accent" is the solid ink button.
   Functional status colours (ok/err) appear ONLY in feedback UI
   (toasts, validation) — never decoratively.
   ============================================================ */

@import url('/shared/fonts/fonts.css');

:root {
  /* surfaces */
  --bg: #fafaf9;            /* app background — warm near-white */
  --surface: #ffffff;       /* cards, sheets, inputs */
  --surface-2: #f4f4f3;     /* wells, hovers, skeletons */

  /* ink */
  --ink: #17181a;           /* primary text, primary buttons */
  --ink-2: #54575c;         /* secondary text */
  --ink-3: #8e9297;         /* captions, placeholders, disabled */

  /* structure */
  --line: #e8e8e7;          /* hairline borders */
  --line-2: #d7d8d7;        /* emphasized borders (inputs, focus-adjacent) */

  /* functional feedback only */
  --ok: #187a48;
  --err: #b42318;
  --err-bg: #fcf1f0;

  /* type */
  --font: 'Golos Text', -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* geometry */
  --r-s: 8px;
  --r-m: 12px;
  --r-l: 18px;
  --shadow-1: 0 1px 2px rgba(23, 24, 26, .05);
  --shadow-2: 0 10px 36px rgba(23, 24, 26, .12);

  /* motion */
  --t-fast: 140ms cubic-bezier(.3, .7, .4, 1);
  --t-med: 240ms cubic-bezier(.3, .7, .4, 1);

  /* layout */
  --content-w: 1120px;      /* desktop content measure */
  --pad: 20px;              /* screen edge padding, mobile */
}
@media (min-width: 720px) { :root { --pad: 32px; } }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

/* ---------------------------------------------------- icons */
svg.ic {
  width: 20px; height: 20px; flex: 0 0 auto;
  stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.22em;
}
svg.ic.sm { width: 16px; height: 16px; stroke-width: 2; }
svg.ic.lg { width: 28px; height: 28px; stroke-width: 1.6; }
svg.ic.xl { width: 40px; height: 40px; stroke-width: 1.3; }

/* ---------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px;
  border: 1px solid transparent; border-radius: var(--r-m);
  font-size: 16px; font-weight: 500; letter-spacing: -0.01em;
  cursor: pointer; user-select: none; text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast),
              color var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
  position: relative;
}
.btn:active { transform: scale(.985); }
.btn.sm { min-height: 40px; padding: 0 16px; font-size: 15px; border-radius: var(--r-s); }

.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--ink-3); }
.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--err); border-color: var(--line-2); }
.btn-danger:hover { border-color: var(--err); background: var(--err-bg); }

.btn:disabled { opacity: .45; cursor: default; transform: none; }

/* busy: JS sets aria-busy="true" + disabled; label dims, spinner overlays.
   Width stays stable — no layout jump. */
.btn[aria-busy="true"] { pointer-events: none; }
.btn[aria-busy="true"] > :not(.btn-spin) { visibility: hidden; }
.btn .btn-spin { display: none; position: absolute; inset: 0; margin: auto; }
.btn[aria-busy="true"] .btn-spin { display: block; }

.spinner, .btn-spin {
  width: 18px; height: 18px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%;
  animation: ds-spin .7s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > .flabel {
  font-size: 13px; font-weight: 500; color: var(--ink-2); letter-spacing: .01em;
}
.field > .fhint { font-size: 13px; color: var(--ink-3); }
.field > .ferr { font-size: 13px; color: var(--err); }

.input, textarea.input, select.input {
  width: 100%; min-height: 48px; padding: 12px 14px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r-m);
  font: inherit; font-size: 16px;
  transition: border-color var(--t-fast);
  appearance: none;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { border-color: var(--ink); outline: none; }
.input[aria-invalid="true"] { border-color: var(--err); }
textarea.input { resize: vertical; line-height: 1.45; }

/* ---------------------------------------------------- cards + pills */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-1);
}

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 10px;
  border-radius: 999px; font-size: 12.5px; font-weight: 500; letter-spacing: .01em;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.pill.ink { background: var(--ink); color: #fff; }
.pill.outline { background: transparent; border: 1px solid var(--line-2); }
.pill.err { background: var(--err-bg); color: var(--err); }

/* ---------------------------------------------------- segmented control */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border-radius: var(--r-m);
}
.seg > button {
  min-height: 38px; padding: 0 14px; border: 0; border-radius: calc(var(--r-m) - 3px);
  background: transparent; color: var(--ink-2); font-size: 14.5px; font-weight: 500;
  cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
}
.seg > button[aria-pressed="true"], .seg > button.on {
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1);
}

/* ---------------------------------------------------- toasts */
#toasts {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; align-items: center; gap: 8px;
  z-index: 90; pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 16px; border-radius: var(--r-m);
  background: var(--ink); color: #fff;
  font-size: 14.5px; font-weight: 500;
  box-shadow: var(--shadow-2);
  animation: toast-in var(--t-med) both;
  max-width: 100%;
}
.toast .ic { stroke-width: 2; }
.toast.ok .ic { color: #6fd39e; }
.toast.err .ic { color: #ff9d92; }
.toast.out { animation: toast-out var(--t-med) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(.97); } }

/* ---------------------------------------------------- modal */
.modal {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: var(--pad);
  background: rgba(23, 24, 26, .4);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  animation: fade-in var(--t-fast) both;
}
.modal-card {
  width: min(420px, 100%);
  background: var(--surface); border-radius: var(--r-l);
  padding: 26px 22px 20px;
  box-shadow: var(--shadow-2);
  animation: pop-in var(--t-med) both;
  text-align: center;
}
.modal-card .m-ico {
  width: 52px; height: 52px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--surface-2); color: var(--ink);
}
.modal-card .m-ico.danger { background: var(--err-bg); color: var(--err); }
.modal-card h3 { font-size: 18px; margin-bottom: 6px; }
.modal-card .m-msg { color: var(--ink-2); font-size: 15px; }
.modal-card .m-btns { display: flex; gap: 10px; margin-top: 20px; }
.modal-card .m-btns > * { flex: 1; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }

/* ---------------------------------------------------- skeletons */
.skel {
  background: var(--surface-2);
  border-radius: var(--r-s);
  position: relative; overflow: hidden;
}
.skel::after {
  content: ''; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent);
  animation: skel-sweep 1.3s infinite;
}
@keyframes skel-sweep { to { transform: translateX(100%); } }

/* ---------------------------------------------------- empty / status states */
.state {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center; padding: 56px 24px; color: var(--ink-2);
}
.state .ic { color: var(--ink-3); }
.state h3 { font-size: 17px; color: var(--ink); }
.state p { font-size: 14.5px; max-width: 320px; }
.state .btn { margin-top: 8px; }

/* ---------------------------------------------------- utility */
.muted { color: var(--ink-3); }
.sep { height: 1px; background: var(--line); border: 0; margin: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
