/* Кассовый контур — оформление.

   Палитра заказчика: серый (база, ~60%), оранжевый (действия, ~30%),
   зелёный (успех и подтверждение, ~10%). Композиция по правилу 60-30-10:
   серые поверхности не спорят с акцентом, зелёный показывает только
   «всё сошлось».

   Движение: короткие микроанимации (hover 150–200 мс, нажатие <100 мс),
   анимируются только transform и opacity, уважается prefers-reduced-motion. */

:root {
  /* --- серая база */
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #fbfbfa;
  --border: #e4e4e0;
  --border-strong: #cfcfc9;
  --text: #1c1c1a;
  --muted: #6b6b66;

  /* --- оранжевый: действия, активная вкладка */
  --accent: #e2600f;
  --accent-hover: #c24f08;
  --accent-active: #a34307;
  --accent-soft: #fef3ea;
  --accent-ring: rgba(226, 96, 15, 0.3);

  /* --- зелёный: успех, подтверждение */
  --ok: #2e7d4f;
  --ok-soft: #edf7f1;

  /* --- состояния */
  --bad: #c0392b;
  --bad-soft: #fdeeec;
  --warn: #b7791f;
  --warn-soft: #fdf6e7;

  --shadow-sm: 0 1px 2px rgba(28, 28, 26, 0.06);
  --shadow-md:
    0 6px 16px -4px rgba(28, 28, 26, 0.1), 0 2px 6px -2px rgba(28, 28, 26, 0.06);
  --shadow-lg: 0 14px 30px -8px rgba(28, 28, 26, 0.16);

  --r-field: 10px;
  --r-card: 16px;
  --r-pill: 9999px;

  --ease: cubic-bezier(0.25, 0.8, 0.5, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 16px;
}

/* --------------------------------------------------- появление контента */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

main.wrap > * {
  animation: rise 0.28s var(--ease) both;
}

main.wrap > *:nth-child(2) {
  animation-delay: 0.04s;
}

main.wrap > *:nth-child(3) {
  animation-delay: 0.08s;
}

/* ------------------------------------------------------------- шапка */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}

.brand::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), #f59e0b);
  box-shadow: 0 2px 6px var(--accent-ring);
}

/* --- навигация */

.menu-toggle {
  display: none;
}

.menu-button {
  display: none;
  margin-left: auto;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-field);
  background: var(--surface);
  cursor: pointer;
}

.menu-button span,
.menu-button span::before,
.menu-button span::after {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  transition:
    transform 0.2s var(--ease),
    opacity 0.2s var(--ease);
}

.menu-button span::before,
.menu-button span::after {
  content: "";
  position: relative;
}

.menu-button span::before {
  top: -6px;
}

.menu-button span::after {
  top: 4px;
}

.topbar nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.topbar nav a {
  position: relative;
  padding: 9px 14px;
  border-radius: var(--r-field);
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  transition:
    color 0.15s var(--ease),
    background-color 0.15s var(--ease);
}

.topbar nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.topbar nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* активная вкладка — «таблетка» цвета действия */
.topbar nav a.active {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 4px 12px -4px var(--accent-ring);
}

.topbar nav a.active:hover {
  color: #ffffff;
  background: var(--accent-hover);
}

/* ------------------------------------------------------------- текст */

h1 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
}

h3 {
  font-size: 16px;
  margin: 0 0 8px;
}

p {
  margin: 0 0 16px;
}

a {
  color: var(--accent-active);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.ok {
  color: var(--ok);
  font-weight: 600;
}

.bad {
  color: var(--bad);
  font-weight: 600;
}

/* ------------------------------------------------------------- карточки */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    border-color 0.18s var(--ease);
}

.card::after {
  content: "";
  position: absolute;
  inset: auto 20px 0 20px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.22s var(--ease);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.card:hover::after {
  transform: scaleX(1);
}

.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  margin-top: 8px;
}

.card-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.row:first-of-type {
  border-top: none;
}

table.kv {
  width: 100%;
  border-collapse: collapse;
}

table.kv td {
  padding: 10px 0;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

table.kv td:first-child {
  color: var(--muted);
  width: 34%;
}

/* ------------------------------------------------------------- формы */

label {
  display: block;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

input[type="text"],
input:not([type]),
input[type="password"],
input[type="date"],
input[type="file"],
select {
  display: block;
  width: 100%;
  min-height: 46px;
  margin-top: 6px;
  padding: 11px 13px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-field);
  transition:
    border-color 0.15s var(--ease),
    box-shadow 0.15s var(--ease);
}

input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
}

input:hover:not([readonly]),
select:hover {
  border-color: #b3b3ac;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

input::placeholder {
  color: #a3a39c;
}

.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.three {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.item {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 20px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}

.check input {
  width: auto;
  min-height: 0;
  margin: 0;
}

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

button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 11px 20px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--r-field);
  box-shadow: 0 2px 6px -2px var(--accent-ring);
  cursor: pointer;
  transition:
    background-color 0.18s var(--ease),
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    transform 0.12s var(--ease);
}

button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 8px 18px -6px var(--accent-ring);
  transform: translateY(-2px);
}

button:active {
  background: var(--accent-active);
  border-color: var(--accent-active);
  transform: translateY(0);
  box-shadow: 0 2px 6px -2px var(--accent-ring);
}

button:focus-visible {
  outline: 2px solid var(--accent-active);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* вторичная */
button.ghost {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

button.ghost:hover {
  background: var(--surface-2);
  border-color: #b3b3ac;
  box-shadow: var(--shadow-md);
}

button.ghost:active {
  background: #f0f0ec;
}

/* опасная */
button.danger {
  color: var(--bad);
  background: var(--surface);
  border-color: #e8b7b0;
  box-shadow: var(--shadow-sm);
}

button.danger:hover {
  background: var(--bad-soft);
  border-color: var(--bad);
}

button.danger:active {
  background: #fadfdb;
}

/* состояние «идёт работа» — со вращающимся индикатором */
button.loading {
  color: transparent;
  pointer-events: none;
}

button.loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

button.ghost.loading::after,
button.danger.loading::after {
  border-color: rgba(28, 28, 26, 0.25);
  border-top-color: var(--text);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------------- оповещения */

.alert {
  background: var(--bad-soft);
  border: 1px solid #e8b7b0;
  border-left-width: 4px;
  border-radius: var(--r-field);
  padding: 16px 20px;
  margin-bottom: 24px;
  color: #8e2b20;
  animation: rise 0.24s var(--ease) both;
}

.alert ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.alert:empty,
.alert[hidden] {
  display: none;
}

.draft {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--ok-soft);
  border: 1px solid #bcdcc9;
  border-left-width: 4px;
  border-radius: var(--r-field);
  padding: 14px 20px;
  margin-bottom: 24px;
  animation: rise 0.24s var(--ease) both;
}

.draft[hidden] {
  display: none;
}

.draft .actions {
  display: flex;
  gap: 8px;
}

.note {
  background: var(--warn-soft);
  border: 1px solid #ecd9a7;
  border-left-width: 4px;
  border-radius: var(--r-field);
  padding: 14px 18px;
  margin: 0 0 16px;
  font-size: 15px;
}

/* ------------------------------------------------------------- позиции */

.positions {
  margin-bottom: 16px;
  overflow: hidden;
  max-height: 9000px;
  transition: max-height 0.32s var(--ease), opacity 0.22s var(--ease);
}

/* плавное сворачивание списка позиций */
.positions.collapsed {
  max-height: 0;
  opacity: 0;
}

/* ------------------------------------------------- скелетон загрузки */

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton {
  height: 44px;
  margin-bottom: 8px;
  border-radius: var(--r-field);
  background: linear-gradient(
    90deg,
    #efefec 25%,
    #f8f8f6 50%,
    #efefec 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}

.skeleton-note {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
}

/* ------------------------------------------------- галочка успеха */

.checkmark {
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  margin-right: 6px;
}

.checkmark path {
  fill: none;
  stroke: var(--ok);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 32;
  stroke-dashoffset: 32;
  animation: draw 0.45s var(--ease) forwards;
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

.cheque-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-field);
  padding: 10px 14px;
  margin-bottom: 16px;
}

.cheque-summary .cs-toggle {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 14px;
}

.pos-row {
  display: grid;
  grid-template-columns: 1fr 140px 44px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.pos-row input {
  margin-top: 0;
}

.pos-row .del-pos {
  padding: 10px 0;
  font-size: 18px;
  line-height: 1;
}

.ophead {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  color: #ffffff;
}

.badge.in {
  background: var(--ok);
}

.badge.out {
  background: var(--accent);
}

/* ------------------------------------------------------------- таблицы */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

table.data th,
table.data td {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

table.data thead th {
  border-top: none;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

table.data tbody tr {
  transition: background-color 0.14s var(--ease);
}

table.data tbody tr:hover {
  background: var(--surface-2);
}

table.data .num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- вход */

.login-card {
  max-width: 420px;
  margin: 48px auto;
}

.login-card h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

/* ------------------------------------------------------------- помощь */

.shot {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-field);
  box-shadow: var(--shadow-sm);
}

.shot-caption {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 20px;
}

.steps {
  counter-reset: step;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  position: relative;
  padding: 0 0 20px 48px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #ffffff;
  background: var(--accent);
  border-radius: var(--r-pill);
  box-shadow: 0 4px 10px -4px var(--accent-ring);
}

.steps li strong {
  display: block;
  margin-bottom: 4px;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.toc a {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  text-decoration: none;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.15s var(--ease),
    box-shadow 0.15s var(--ease),
    border-color 0.15s var(--ease);
}

.toc a:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ------------------------------------------------------------- подвал */

footer {
  padding: 32px 16px 48px;
}

/* ======================================================== мобильная версия */

@media (max-width: 720px) {
  .menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* меню раскрывается по флажку — без JavaScript */
  .topbar nav {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 12px;
  }

  .menu-toggle:checked ~ nav {
    display: flex;
  }

  .topbar nav a {
    padding: 12px 14px;
    font-size: 16px;
  }

  /* «крестик» у кнопки меню, когда оно открыто */
  .menu-toggle:checked ~ .menu-button span {
    background: transparent;
  }

  .menu-toggle:checked ~ .menu-button span::before {
    transform: rotate(45deg);
    top: -1px;
  }

  .menu-toggle:checked ~ .menu-button span::after {
    transform: rotate(-45deg);
    top: -1px;
  }

  .topbar .wrap {
    min-height: 58px;
    gap: 8px;
  }

  .two,
  .three {
    grid-template-columns: 1fr;
  }

  /* карточки на телефоне — по две в ряд, а не по одной длинной */
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
  }

  .card {
    padding: 16px;
  }

  .pos-row {
    grid-template-columns: 1fr 104px 44px;
  }

  h1 {
    font-size: 23px;
  }

  .panel {
    padding: 18px;
    border-radius: 14px;
  }

  .card-value {
    font-size: 26px;
  }

  button {
    width: 100%;
  }

  button.ghost,
  button.danger {
    width: auto;
    flex: 1 1 auto;
  }

  .actions button {
    width: auto;
  }

  .pos-row .del-pos {
    width: auto;
  }
}

/* Кто просил меньше движения — получит его меньше */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
