/* Верстак — учёт обращений фабрики «Ясень».
   Design tokens: the exact palette declared in the brief (warm workbench). */

:root {
  color-scheme: light;

  /* Surface hierarchy — warm paper. */
  --surface:        #f4efe6;
  --surface-2:      #fffcf4;
  --surface-sunken: #ede5d6;
  --surface-3:      #f7f1e6;

  /* Ink — text_primary #221c15. */
  --ink:       #221c15;
  --ink-muted: #66594c;

  --line: #ddd2bf;

  /* Accent — brand amber #c07a2a. Accent ink is dark: 4.86:1 on the accent. */
  --accent:        #c07a2a;
  --accent-hover:  #a96a20;
  --accent-active: #8f5a1a;
  --accent-ink:    #221c15;
  --accent-soft:   #f3e2c8;

  --focus: #1f6fd0;
  --danger: #b3261e;
  --danger-ink: #ffffff;

  /* Status colours — left edge + text of each inquiry state. */
  --status-new:      #c07a2a;
  --status-new-ink:  #7a4a12;
  --status-work:     #5a6b7d;
  --status-work-ink: #3a4752;
  --status-done:     #4f8257;
  --status-done-ink: #2f5238;

  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --shadow: 0 1px 2px rgba(34, 28, 21, 0.06), 0 4px 14px rgba(34, 28, 21, 0.06);
  --shadow-lift: 0 2px 6px rgba(34, 28, 21, 0.08), 0 10px 28px rgba(34, 28, 21, 0.10);

  --font-body: Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-head: "Golos Text", Inter, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface:        #17130d;
    --surface-2:      #201a12;
    --surface-sunken: #121009;
    --surface-3:      #1c1710;
    --ink:            #f1e9db;
    --ink-muted:      #bfb3a0;
    --line:           #3a3225;
    --accent:         #d89a45;
    --accent-hover:   #e2a857;
    --accent-active:  #ca8c38;
    --accent-ink:     #221c15;
    --accent-soft:    #3a2f1e;
    --focus:          #6fa8e8;
    --danger:         #e0574f;
    --status-new:      #d89a45;
    --status-new-ink:  #f0c27e;
    --status-work:     #7d92a8;
    --status-work-ink: #b6c6d6;
    --status-done:     #6fa47c;
    --status-done-ink: #b2d3bb;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.35);
    --shadow-lift: 0 2px 8px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.45);
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --surface: #17130d;
  --surface-2: #201a12;
  --surface-sunken: #121009;
  --surface-3: #1c1710;
  --ink: #f1e9db;
  --ink-muted: #bfb3a0;
  --line: #3a3225;
  --accent: #d89a45;
  --accent-hover: #e2a857;
  --accent-active: #ca8c38;
  --accent-ink: #221c15;
  --accent-soft: #3a2f1e;
  --focus: #6fa8e8;
  --danger: #e0574f;
  --status-new: #d89a45; --status-new-ink: #f0c27e;
  --status-work: #7d92a8; --status-work-ink: #b6c6d6;
  --status-done: #6fa47c; --status-done-ink: #b2d3bb;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 2px 8px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--surface);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------------ layout */
.container {
  width: 100%;
  max-width: 1040px;
  margin-inline: auto;
  padding-inline: 20px;
}
.container--narrow { max-width: 640px; }

.page__main { flex: 1 1 auto; padding-block: 28px 56px; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__inner {
  max-width: 1040px;
  margin-inline: auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand__mark {
  width: 30px; height: 30px;
  color: var(--accent);
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.brand__mark--lg { width: 52px; height: 52px; }
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__name { font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; color: var(--ink); }
.brand__sub { font-size: 0.75rem; color: var(--ink-muted); }

.topbar__actions { display: flex; align-items: center; gap: 10px; }
.logout-form { margin: 0; display: flex; }

/* ------------------------------------------------------------------ buttons */
.btn {
  --btn-bg: var(--surface-3);
  --btn-ink: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  background: var(--btn-bg);
  color: var(--btn-ink);
  transition: background 140ms var(--ease), transform 140ms var(--ease), box-shadow 140ms var(--ease), border-color 140ms var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn--accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--accent:hover { background: var(--accent-hover); }
.btn--accent:active { background: var(--accent-active); }
.btn--ghost { background: transparent; color: var(--ink-muted); border-color: var(--line); }
.btn--ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn .ico { width: 18px; height: 18px; }

.ico {
  width: 20px; height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ------------------------------------------------------------------ toolbar */
.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.toolbar__title h1 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.6rem;
  line-height: 1.15;
}
.toolbar__meta { margin: 6px 0 0; color: var(--ink-muted); font-size: 0.9rem; }

.search { position: relative; flex: 0 1 340px; min-width: 240px; }
.search__icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
}
.search__input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px 10px 40px;
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
.search__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent), transparent 78%); }
.search__input::placeholder { color: var(--ink-muted); }

/* ------------------------------------------------------------------ cards */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }

.card {
  --status-color: var(--status-new);
  --status-ink: var(--status-new-ink);
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--status-color);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow);
  transition: box-shadow 160ms var(--ease), transform 160ms var(--ease), border-left-color 200ms var(--ease);
}
.card[data-status="В работе"] { --status-color: var(--status-work); --status-ink: var(--status-work-ink); }
.card[data-status="Готово"]   { --status-color: var(--status-done); --status-ink: var(--status-done-ink); }

.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }

/* perforated "цеховой ярлык" line */
.card::before {
  content: "";
  display: block;
  margin: -8px 0 10px;
  border-top: 1px dashed var(--line);
}

.card__name {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.3;
}
.card__phone {
  margin: 6px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}
.card__phone .ico { width: 17px; height: 17px; color: var(--ink-muted); }
.card__phone a { color: inherit; text-decoration: none; }
.card__phone a:hover { text-decoration: underline; }
.card__desc {
  margin: 10px 0 0;
  color: var(--ink-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.card__desc--empty { font-style: italic; }

.card__foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card__updated { color: var(--ink-muted); font-size: 0.8rem; white-space: nowrap; }

/* ------------------------------------------------------------------ status segments */
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}
.seg__btn {
  min-height: 40px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.seg__btn + .seg__btn { border-left: 1px solid var(--line); }
.seg__btn:hover { color: var(--ink); background: var(--surface-3); }
.seg__btn.is-active {
  background: color-mix(in oklab, var(--status-color), transparent 82%);
  color: var(--status-ink);
}
.seg__btn.is-pending { opacity: 0.55; pointer-events: none; }

/* ------------------------------------------------------------------ empty state */
.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--ink-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.empty__leaf { width: 132px; height: 132px; color: var(--accent); opacity: 0.75; }
.empty__title { margin: 0; font-size: 1.05rem; }

/* ------------------------------------------------------------------ auth */
.page--auth { justify-content: center; }
.auth {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}
.auth__card {
  width: 100%;
  max-width: 400px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: 32px 28px;
}
.auth__brand { text-align: center; margin-bottom: 24px; }
.auth__title {
  margin: 12px 0 4px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.7rem;
}
.auth__sub { margin: 0; color: var(--ink-muted); font-size: 0.95rem; }
.auth__form { display: grid; gap: 16px; }
.auth__hint { margin: 16px 0 0; text-align: center; color: var(--ink-muted); font-size: 0.85rem; }

/* ------------------------------------------------------------------ page head */
.page-head { margin-bottom: 24px; }
.page-head h1 {
  margin: 10px 0 6px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.6rem;
  line-height: 1.2;
}
.page-head__sub { margin: 0; color: var(--ink-muted); }
.back { display: inline-block; color: var(--ink-muted); text-decoration: none; font-size: 0.9rem; }
.back:hover { color: var(--ink); }

/* ------------------------------------------------------------------ forms */
.form--card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: grid;
  gap: 18px;
}
.field { display: grid; gap: 7px; }
.field__label { font-weight: 600; font-size: 0.92rem; }
.field__input {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
.field__textarea { min-height: 108px; resize: vertical; line-height: 1.45; }
.field__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent), transparent 78%); }
.field__input::placeholder { color: var(--ink-muted); }

.form-error {
  margin: 0;
  color: var(--danger-ink);
  background: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.92rem;
}
.form-error[hidden] { display: none; }
.form__actions { margin-top: 4px; }

/* ------------------------------------------------------------------ footer */
.foot {
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 0.85rem;
  padding: 16px 0;
}

/* ------------------------------------------------------------------ focus */
:where(a, button, input, textarea, select):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--surface);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift);
  font-size: 0.92rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  z-index: 100;
  max-width: calc(100vw - 40px);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); color: var(--danger-ink); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 640px) {
  .topbar__inner { flex-wrap: wrap; gap: 8px 12px; }
  .logout-form__name { display: none; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search { flex: 1 1 auto; width: 100%; min-width: 0; }
  .container { padding-inline: 14px; }
  .page__main { padding-block: 20px 40px; }
  .seg { width: 100%; }
  .seg__btn { flex: 1; }
  .card__foot { flex-direction: column; align-items: stretch; }
  .card__updated { text-align: right; }
}

/* ------------------------------------------------------------------ motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .card--flash { animation: flash 900ms var(--ease); }
  @keyframes flash {
    0% { background: var(--accent-soft); }
    100% { background: var(--surface-2); }
  }
}
