@import url('css/views/days.css');
@import url('css/views/request.css');
@import url('css/views/purchase.css');
@import url('css/views/receiving.css');
@import url('css/views/summary.css');
@import url('css/views/history.css');
@import url('css/views/users.css');

/* ==========================================================================
   Закупки — design system. Tokens, base, shell, components.
   View-specific rules live in css/views/*.css (imported above).
   ========================================================================== */

:root {
  --canvas: #F4F2ED;
  --surface: #FBFAF7;
  --tile: #EEEAE1;
  --tile-strong: #E5E0D4;
  --line: #E3DED3;
  --ink: #1B1F1C;
  --ink-2: #5E625B;
  --ink-3: #8A8C84;
  --green: #1E6A4E;
  --green-press: #16553E;
  --green-soft: #E3F0E8;
  --green-line: #BFDCCB;
  --green-ink: #1D5A41;
  --amber-soft: #FBF0CC;
  --amber-line: #EED88C;
  --amber-ink: #7A5600;
  --red-soft: #FBE8E5;
  --red-line: #F0C3BC;
  --red-ink: #9E3226;
  --blue-soft: #E4EEF6;
  --blue-ink: #245B82;

  --card-amber: #FFF8E1;
  --card-green: #EEF6F0;

  --font-ui: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-num: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;

  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-sheet: 16px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --shadow-float: 0 10px 30px rgba(27, 31, 28, 0.08);

  --pad-x: 16px;
  --nav-h: 64px;
  --rail-w: 232px;
  --content-w: 880px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--canvas);
}

html.is-scroll-locked {
  overflow: hidden;
  padding-right: var(--scrollbar-comp, 0px);
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 22px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4, p, figure, ul, ol, dl, dd {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

h1, h2, h3, h4 {
  text-wrap: balance;
  font-weight: 600;
}

a {
  color: inherit;
  text-decoration: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  margin: 0;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

table {
  border-collapse: collapse;
}

[hidden] {
  display: none !important;
}

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

::selection {
  background: var(--green-soft);
}

/* --------------------------------------------------------------------------
   Typography helpers and utilities
   -------------------------------------------------------------------------- */

.eyebrow {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: var(--ink-2);
}

.micro-label {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: var(--ink-2);
}

.section-title {
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.small {
  font-size: 13px;
  line-height: 18px;
}

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

.mono {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 0.95em;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack--sm { gap: 8px; }
.stack--md { gap: 12px; }
.stack--lg { gap: 20px; }
.stack--xl { gap: 28px; }

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.row--tight { gap: 8px; }
.row--end { justify-content: flex-end; }

.spacer {
  flex: 1 1 auto;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.app {
  min-height: 100dvh;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 60;
  transform: translateY(-200%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-weight: 600;
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.shell {
  min-height: 100dvh;
}

.shell__main {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--canvas);
  border-bottom: 1px solid var(--line);
  padding: 10px var(--pad-x) 10px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}

.topbar__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'titles user'
    'day day';
  align-items: center;
  gap: 8px 12px;
  margin: 0 auto;
  width: 100%;
  max-width: var(--content-w);
}

.topbar__titles {
  grid-area: titles;
  min-width: 0;
}

.topbar__title {
  font-size: 28px;
  line-height: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
}

.topbar__user {
  grid-area: user;
  display: flex;
  justify-content: flex-end;
}

.topbar__day {
  grid-area: day;
  min-width: 0;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  color: var(--green-ink);
  font-weight: 600;
  font-size: 15px;
}

.avatar--lg {
  width: 52px;
  height: 52px;
  font-size: 20px;
}

.avatar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
}

.avatar-btn:hover .avatar {
  border-color: var(--green);
}

.day-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  max-width: 100%;
}

.day-chip__date {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-chip__icon,
.day-chip__chevron {
  flex: 0 0 auto;
  color: var(--ink-2);
}

.day-chip:hover {
  border-color: var(--green);
}

.day-chip:hover .day-chip__chevron {
  transform: translateY(2px);
}

.day-chip__chevron {
  transition: transform 160ms var(--ease-out);
}

.content {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 16px var(--pad-x) calc(var(--nav-h) + 32px + var(--safe-bottom));
  outline: none;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view:not(:empty) + .view-loading {
  display: none;
}

/* Navigation: floating bottom bar on phones, left rail from 1024px. */

.nav {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(8px + var(--safe-bottom));
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sheet);
  box-shadow: var(--shadow-float);
}

.nav__brand {
  display: none;
}

.nav__list {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav__list::-webkit-scrollbar {
  display: none;
}

.nav__item {
  flex: 1 1 0;
  min-width: 46px;
}

.nav__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  padding: 4px 2px;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-size: 11px;
  line-height: 14px;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
}

.nav__icon {
  display: block;
  color: inherit;
}

.nav__link.is-active {
  background: var(--green-soft);
  color: var(--green-ink);
  font-weight: 600;
}

.nav__link:hover {
  background: var(--tile);
  color: var(--ink);
}

.nav__link.is-active:hover {
  background: var(--green-soft);
  color: var(--green-ink);
}

/* Boot and fatal screens */

.boot,
.fatal {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
  padding: 48px var(--pad-x);
  max-width: 520px;
  margin: 0 auto;
}

.boot__text {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-2);
}

.noscript {
  max-width: 520px;
  margin: 48px auto;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.noscript__title {
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 8px;
}

/* Brand mark */

.brand-mark__bg { fill: var(--green); }
.brand-mark__line { fill: var(--surface); }
.brand-mark__track { fill: var(--green-press); }
.brand-mark__bought { fill: var(--green-line); }
.brand-mark__received { fill: var(--surface); }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  white-space: nowrap;
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), transform 120ms var(--ease-out);
}

.btn__icon {
  flex: 0 0 auto;
  transition: transform 160ms var(--ease-out);
}

.btn__label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn--sm {
  height: 40px;
  padding: 0 14px;
  font-size: 14px;
}

/* Small buttons keep a 44px touch target. An absolutely positioned child is offset from the
   padding box, so a negative inset would only give 40px − borders + 4px; a fixed 44px centred
   band is exact whatever the border width. */
.btn--sm::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 44px;
  transform: translateY(-50%);
}

.btn--block {
  width: 100%;
}

.btn--icon-only {
  width: 48px;
  padding: 0;
}

.btn--primary {
  background: var(--green);
  color: #FFFFFF;
}

.btn--primary:hover {
  background: var(--green-press);
}

.btn--primary:hover .btn__icon {
  transform: translateX(2px);
}

.btn--secondary {
  background: var(--tile);
  color: var(--ink);
}

.btn--secondary:hover {
  background: var(--tile-strong);
}

.btn--secondary:hover .btn__icon {
  transform: translateX(2px);
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
}

.btn--ghost:hover {
  background: var(--tile);
}

.btn--ghost:hover .btn__label {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn--danger {
  background: var(--red-soft);
  color: var(--red-ink);
  border-color: var(--red-line);
}

.btn--danger:hover {
  background: #F6DCD7;
}

.btn--danger:hover .btn__icon {
  transform: translateX(2px);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.45;
  pointer-events: none;
}

.btn.is-loading {
  color: transparent;
}

.btn.is-loading .btn__icon {
  visibility: hidden;
}

.btn.is-loading .spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -9px 0 0 -9px;
}

.btn--primary.is-loading .spinner {
  border-color: rgba(255, 255, 255, 0.4);
  border-top-color: #FFFFFF;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  color: var(--ink-2);
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), color 160ms var(--ease-out);
}

.icon-btn--tile {
  background: var(--tile);
  color: var(--ink);
}

.icon-btn--tile:hover {
  background: var(--tile-strong);
  border-color: var(--line);
}

.icon-btn--ghost:hover {
  background: var(--tile);
  color: var(--ink);
}

.icon-btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid var(--tile-strong);
  border-top-color: var(--green);
  animation: spin 800ms linear infinite;
}

.spinner--light {
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #FFFFFF;
}

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

/* --------------------------------------------------------------------------
   Badges, chips, notes, banners
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  white-space: nowrap;
}

.badge__icon {
  flex: 0 0 auto;
}

.badge--neutral {
  background: var(--tile);
  color: var(--ink-2);
}

.badge--outline {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-2);
}

.badge--amber {
  background: var(--amber-soft);
  border-color: var(--amber-line);
  color: var(--amber-ink);
}

.badge--green {
  background: var(--green-soft);
  border-color: var(--green-line);
  color: var(--green-ink);
}

.badge--green-soft {
  background: var(--green-soft);
  color: var(--green-ink);
}

.badge--red {
  background: var(--red-soft);
  border-color: var(--red-line);
  color: var(--red-ink);
}

.badge--blue {
  background: var(--blue-soft);
  color: var(--blue-ink);
}

.comment-chip {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: var(--tile);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 18px;
  white-space: pre-line;
}

.comment-chip__icon {
  flex: 0 0 auto;
  margin-top: 1px;
}

.note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--tile);
  font-size: 14px;
  line-height: 20px;
}

.note__icon {
  flex: 0 0 auto;
  margin-top: 1px;
}

.note--info {
  background: var(--blue-soft);
  border-color: #C9DCEA;
  color: var(--blue-ink);
}

.note--amber {
  background: var(--amber-soft);
  border-color: var(--amber-line);
  color: var(--amber-ink);
}

.note--red {
  background: var(--red-soft);
  border-color: var(--red-line);
  color: var(--red-ink);
}

.note--green {
  background: var(--green-soft);
  border-color: var(--green-line);
  color: var(--green-ink);
}

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--tile);
  color: var(--ink-2);
}

.banner__icon {
  flex: 0 0 auto;
  display: inline-flex;
  color: var(--ink-2);
}

.banner__text {
  font-size: 14px;
  line-height: 20px;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-2);
}

.meta-line__sep {
  color: var(--ink-3);
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 4px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}

.chip__count {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--ink-3);
}

.chip:hover {
  border-color: var(--ink-3);
  background: var(--tile);
}

.chip[aria-pressed='true'] {
  background: var(--green-soft);
  border-color: var(--green-line);
  color: var(--green-ink);
  font-weight: 600;
}

.chip[aria-pressed='true'] .chip__count {
  color: var(--green-ink);
}

.role-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* --------------------------------------------------------------------------
   Cards, tiles, tally strip, product head
   -------------------------------------------------------------------------- */

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.card.tone-amber {
  background: var(--card-amber);
  border-color: var(--amber-line);
}

.card.tone-green {
  background: var(--card-green);
  border-color: var(--green-line);
}

.card.is-current {
  border-color: var(--green);
  border-width: 2px;
  padding: 13px;
}

.card--link {
  text-align: left;
  width: 100%;
}

.card--link:hover {
  border-color: var(--ink-3);
}

.card__row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tiles {
  display: grid;
  gap: 8px;
}

.tiles--1 { grid-template-columns: 1fr; }
.tiles--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tiles--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles--4,
.tiles--5,
.tiles--6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  background: var(--tile);
  min-width: 0;
}

.tile--amber {
  background: var(--amber-soft);
  color: var(--amber-ink);
}

.tile--green {
  background: var(--green-soft);
  color: var(--green-ink);
}

.tile--red {
  background: var(--red-soft);
  color: var(--red-ink);
}

.tile__label {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: var(--ink-2);
}

.tile--amber .tile__label { color: var(--amber-ink); }
.tile--green .tile__label { color: var(--green-ink); }
.tile--red .tile__label { color: var(--red-ink); }

.tile__value {
  font-size: 17px;
  line-height: 24px;
  font-weight: 600;
  overflow-wrap: break-word;
  hyphens: none;
}

.tile__value--num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

/* Words are longer than numbers: keep them on one line inside a narrow tile. */
.tile__value--text {
  font-size: 15px;
  line-height: 20px;
}

.tally {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tally__track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--tile-strong);
  overflow: hidden;
}

.tally__fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-origin: left center;
  transition: transform 300ms var(--ease-out);
}

.tally__fill--bought {
  background: var(--green-line);
  transform: scaleX(var(--bought, 0));
}

.tally__fill--received {
  background: var(--green);
  transform: scaleX(var(--received, 0));
}

.tally__cap {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 10px;
  border-radius: 0 999px 999px 0;
  background: var(--amber-line);
  display: none;
}

.tally--over .tally__cap {
  display: block;
}

.tally__caption {
  font-size: 12px;
  line-height: 16px;
  color: var(--ink-2);
}

/* Photo | name | aside. With an aside (usually a status badge) the phone layout puts the badge
   above the name instead of beside it: in one flex row the name column collapsed to ~120px and
   Russian words broke mid-syllable. The `--aside` modifier is set by productHead(). */
.product-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  column-gap: 12px;
  row-gap: 6px;
}

.product-head > .thumb {
  grid-column: 1;
  grid-row: 1;
}

.product-head__main {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.product-head--aside > .thumb {
  grid-row: 1 / span 2;
}

.product-head--aside > .product-head__main {
  grid-row: 2;
}

@media (min-width: 560px) {
  .product-head--aside {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .product-head--aside > .thumb {
    grid-row: 1;
  }

  .product-head--aside > .product-head__main {
    grid-row: 1;
  }

  .product-head--aside > .product-head__aside {
    grid-column: 3;
  }
}

.product-head__name {
  font-size: 16px;
  line-height: 22px;
  font-weight: 600;
  /* break-word, not anywhere: an overlong article code still breaks, but ordinary Russian
     words keep their min-content width and wrap between words. */
  overflow-wrap: break-word;
}

.product-head__article {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-2);
}

.product-head__aside {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
}

.section-count {
  margin-left: 8px;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-3);
}

.page-intro {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

.page-intro__text {
  color: var(--ink-2);
  max-width: 62ch;
}

.disclosure {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.disclosure__summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.disclosure__summary::-webkit-details-marker {
  display: none;
}

.disclosure__label {
  flex: 1 1 auto;
  min-width: 0;
}

.disclosure__count {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink-3);
}

.disclosure__chevron {
  flex: 0 0 auto;
  color: var(--ink-2);
  transition: transform 200ms var(--ease-out);
}

.disclosure[open] > .disclosure__summary .disclosure__chevron {
  transform: rotate(180deg);
}

.disclosure__summary:hover {
  background: var(--tile);
  border-radius: var(--r-lg);
}

.disclosure__body {
  padding: 0 14px 14px;
}

/* --------------------------------------------------------------------------
   Thumbnails
   -------------------------------------------------------------------------- */

.thumb {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--tile);
  color: var(--ink-3);
  overflow: hidden;
}

/* 44px, not 40: every thumb is a button that opens the viewer, and .thumb clips overflow,
   so the touch minimum has to come from the box itself. */
.thumb--sm { width: 44px; height: 44px; }
.thumb--md { width: 64px; height: 64px; }
.thumb--lg { width: 96px; height: 96px; }

.thumb__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

button.thumb {
  cursor: zoom-in;
  transition: border-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}

button.thumb:hover {
  border-color: var(--green);
  transform: scale(1.02);
}

.thumb--empty,
.thumb--broken {
  background: var(--tile);
}

/* Small thumbs in a row keep 8px gaps. */
.thumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: var(--ink-2);
}

.field__req {
  color: var(--ink-3);
  font-weight: 400;
}

.field__hint {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-2);
}

.field__error {
  font-size: 13px;
  line-height: 18px;
  color: var(--red-ink);
}

.form-error {
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--red-soft);
  border: 1px solid var(--red-line);
  color: var(--red-ink);
  font-size: 14px;
  line-height: 20px;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  line-height: 22px;
  appearance: none;
  transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}

.input::placeholder {
  color: var(--ink-3);
}

.input:hover {
  border-color: var(--ink-3);
}

.input:focus {
  border-color: var(--green);
  outline: none;
}

.input:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}

.input:disabled,
.input[readonly] {
  background: var(--tile);
  color: var(--ink-2);
}

.input--area {
  min-height: 84px;
  resize: vertical;
  line-height: 22px;
}

.input--date {
  min-width: 0;
}

.is-invalid .input,
.input[aria-invalid='true'] {
  border-color: var(--red-line);
  background: #FFF9F8;
}

.select {
  position: relative;
  display: block;
}

.select__control {
  padding-right: 42px;
  cursor: pointer;
}

.select__icon {
  position: absolute;
  right: 12px;
  top: 50%;
  margin-top: -10px;
  pointer-events: none;
  color: var(--ink-2);
}

.password {
  position: relative;
  display: flex;
  align-items: center;
}

.password__input {
  padding-right: 52px;
}

.password__toggle {
  position: absolute;
  right: 2px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search__icon {
  position: absolute;
  left: 13px;
  color: var(--ink-3);
  pointer-events: none;
}

.search__input {
  padding-left: 44px;
  padding-right: 48px;
}

.search__input::-webkit-search-cancel-button,
.search__input::-webkit-search-decoration {
  appearance: none;
  display: none;
}

.search__clear {
  position: absolute;
  right: 2px;
}

.qty {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--tile);
  color: var(--ink);
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}

.qty__btn:hover {
  background: var(--tile-strong);
  border-color: var(--ink-3);
}

.qty__btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.qty__input {
  flex: 1 1 auto;
  text-align: center;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.qty--lg .qty__btn {
  width: 56px;
  height: 56px;
}

.qty--lg .qty__input {
  min-height: 56px;
  font-size: 24px;
  line-height: 32px;
}

.money {
  position: relative;
  display: flex;
  align-items: center;
}

.money__input {
  padding-right: 42px;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.money__suffix {
  position: absolute;
  right: 14px;
  color: var(--ink-2);
  font-weight: 600;
  pointer-events: none;
}

.store-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.store-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  min-width: 0;
}

.store-cell.has-value {
  border-color: var(--green-line);
  background: var(--green-soft);
}

.store-cell__name {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-cell__input {
  text-align: center;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.store-cell__hint {
  font-size: 11px;
  line-height: 15px;
  color: var(--ink-2);
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--tile);
  border-radius: var(--r-md);
}

.segmented__option {
  flex: 1 1 0;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out);
}

.segmented__option:hover {
  background: var(--tile-strong);
  color: var(--ink);
}

.segmented__option[aria-checked='true'] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 10px 0;
  cursor: pointer;
}

.check-row__input {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--green);
  flex: 0 0 auto;
}

.check-row__label {
  font-size: 14px;
  line-height: 22px;
}

.check-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}

.check-card:hover {
  border-color: var(--ink-3);
  background: var(--tile);
}

.check-card__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.check-card__box {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: transparent;
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}

.check-card__input:checked + .check-card__box {
  background: var(--green);
  border-color: var(--green);
  color: #FFFFFF;
}

.check-card__input:focus-visible + .check-card__box {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.check-card:has(.check-card__input:checked) {
  border-color: var(--green-line);
  background: var(--green-soft);
}

/* A locked role (an admin cannot take «Администратор» off their own account): still readable,
   but it no longer invites a tap. */
.check-card:has(.check-card__input:disabled) {
  cursor: default;
  opacity: 0.72;
}

.check-card:has(.check-card__input:disabled):hover {
  border-color: var(--line);
  background: var(--surface);
}

.check-card:has(.check-card__input:checked:disabled):hover {
  border-color: var(--green-line);
  background: var(--green-soft);
}

.check-card__lock {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  line-height: 16px;
  color: var(--ink-2);
}

.check-card__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.check-card__title {
  font-weight: 600;
}

.check-card__desc {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-2);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
}

.toggle__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.toggle__track {
  position: relative;
  width: 46px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--tile-strong);
  transition: background-color 160ms var(--ease-out);
}

.toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(27, 31, 28, 0.2);
  transition: transform 200ms var(--ease-out);
}

.toggle__input:checked + .toggle__track {
  background: var(--green);
}

.toggle__input:checked + .toggle__track .toggle__thumb {
  transform: translateX(18px);
}

.toggle__input:focus-visible + .toggle__track {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.toggle__input:disabled + .toggle__track {
  opacity: 0.45;
}

.toggle__label {
  font-size: 14px;
  line-height: 20px;
}

/* --------------------------------------------------------------------------
   Overflow menu
   -------------------------------------------------------------------------- */

.menu {
  position: relative;
  display: inline-flex;
}

.menu__popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 25;
  min-width: 212px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-float);
}

.menu--up .menu__popover {
  top: auto;
  bottom: calc(100% + 6px);
}

.menu--start .menu__popover {
  right: auto;
  left: 0;
}

.menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

.menu__icon {
  flex: 0 0 auto;
  color: var(--ink-2);
}

.menu__item:hover {
  background: var(--tile);
}

.menu__item--danger {
  color: var(--red-ink);
}

.menu__item--danger .menu__icon {
  color: inherit;
}

.menu__item--danger:hover {
  background: var(--red-soft);
}

.menu__item:disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Dialogs: bottom sheet under 640px, centered modal above
   -------------------------------------------------------------------------- */

.dialog-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(27, 31, 28, 0.42);
  animation: fade-in 200ms var(--ease-out);
}

.dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 92dvh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: var(--shadow-float);
  animation: sheet-in 260ms var(--ease-out);
  outline: none;
}

.dialog__grip {
  width: 40px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: 999px;
  background: var(--tile-strong);
}

.dialog__head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 12px 8px 16px;
}

.dialog__titles {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 6px;
}

.dialog__title {
  font-size: 20px;
  line-height: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.dialog__subtitle {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-2);
}

.dialog__body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 16px;
}

.dialog__step {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dialog__step--forward {
  animation: step-forward 200ms var(--ease-out);
}

.dialog__step--back {
  animation: step-back 200ms var(--ease-out);
}

.dialog__message {
  font-size: 15px;
  line-height: 22px;
}

.dialog__foot {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  justify-content: flex-end;
}

.dialog__actions .btn {
  flex: 1 1 auto;
}

.dialog-layer.is-closing .dialog {
  animation: sheet-out 180ms var(--ease-out) forwards;
}

.dialog-layer.is-closing .dialog-backdrop {
  animation: fade-out 180ms var(--ease-out) forwards;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sheet-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(24px); }
}

@keyframes step-forward {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes step-back {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(var(--nav-h) + 24px + var(--safe-bottom));
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  max-width: 440px;
  padding: 12px 8px 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-float);
  animation: toast-in 240ms var(--ease-out);
}

.toast--success {
  background: var(--green-soft);
  border-color: var(--green-line);
  color: var(--green-ink);
}

.toast--error {
  background: var(--red-soft);
  border-color: var(--red-line);
  color: var(--red-ink);
}

.toast__icon {
  flex: 0 0 auto;
  margin-top: 1px;
}

.toast__text {
  flex: 1 1 auto;
  font-size: 14px;
  line-height: 20px;
}

.toast__close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -12px 0 -12px 0;
  border-radius: var(--r-sm);
  color: inherit;
  opacity: 0.7;
}

.toast__close:hover {
  opacity: 1;
  background: rgba(27, 31, 28, 0.06);
}

.toast.is-leaving {
  animation: toast-out 180ms var(--ease-out) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(8px); }
}

/* --------------------------------------------------------------------------
   Photo viewer
   -------------------------------------------------------------------------- */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: #0C0E0C;
  color: #FBFAF7;
  animation: fade-in 200ms var(--ease-out);
}

.viewer.is-closing {
  animation: fade-out 180ms var(--ease-out) forwards;
}

.viewer :focus-visible {
  outline-color: #FBFAF7;
}

.viewer__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
}

.viewer__counter {
  padding-left: 10px;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: rgba(251, 250, 247, 0.8);
}

.viewer__tools {
  display: flex;
  gap: 8px;
}

.viewer__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(251, 250, 247, 0.12);
  color: #FBFAF7;
  transition: background-color 160ms var(--ease-out);
}

.viewer__btn:hover {
  background: rgba(251, 250, 247, 0.26);
}

.viewer__btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

.viewer__stage {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
}

.viewer__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: translate3d(var(--tx, 0px), var(--ty, 0px), 0) scale(var(--scale, 1));
  transition: transform 240ms var(--ease-out);
  cursor: zoom-in;
  -webkit-user-drag: none;
}

.viewer.is-zoomed .viewer__img {
  cursor: grab;
}

.viewer.is-dragging .viewer__img {
  transition: none;
}

.viewer__loading {
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -12px 0 0 -12px;
  display: none;
}

.viewer.is-loading .viewer__loading {
  display: block;
}

.viewer__nav {
  position: absolute;
  top: 50%;
  margin-top: -22px;
}

.viewer__nav--prev { left: 8px; }
.viewer__nav--next { right: 8px; }

.viewer__foot {
  min-height: 28px;
  padding: 8px 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.viewer__caption {
  font-size: 14px;
  line-height: 20px;
  color: rgba(251, 250, 247, 0.85);
}

.viewer__error {
  margin-top: 4px;
  font-size: 13px;
  line-height: 18px;
  color: #F0C3BC;
}

/* --------------------------------------------------------------------------
   Photo picker
   -------------------------------------------------------------------------- */

.photo-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.photo-picker__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.photo-picker__count {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--ink-3);
}

.photo-picker__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.photo-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 96px;
}

.photo-tile__visual {
  position: relative;
}

.photo-tile__badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(27, 31, 28, 0.45);
  color: #FBFAF7;
}

.photo-tile__badge--error {
  background: rgba(251, 232, 229, 0.86);
  color: var(--red-ink);
}

.photo-tile__progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(27, 31, 28, 0.18);
}

.photo-tile__bar {
  display: block;
  height: 100%;
  background: var(--green);
  transform-origin: left center;
  transform: scaleX(var(--progress, 0));
  transition: transform 160ms linear;
}

.photo-tile__actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.photo-tile.is-error .thumb {
  border-color: var(--red-line);
}

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

.photo-picker__actions .btn {
  flex: 1 1 180px;
}

.photo-picker__status {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-2);
}

.photo-picker__status.is-error {
  color: var(--red-ink);
}

.photo-picker.is-invalid .photo-picker__grid {
  outline: 1px solid var(--red-line);
  outline-offset: 6px;
  border-radius: var(--r-sm);
}

/* --------------------------------------------------------------------------
   Empty, error and loading states
   -------------------------------------------------------------------------- */

.empty,
.state-error {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px dashed var(--tile-strong);
}

.state-error {
  border-style: solid;
  border-color: var(--red-line);
  background: #FFFBFA;
}

.empty__icon,
.state-error__icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--tile);
  color: var(--ink-2);
}

.state-error__icon {
  background: var(--red-soft);
  color: var(--red-ink);
}

.empty__body,
.state-error__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.empty__title,
.state-error__title {
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
}

.empty__text,
.state-error__text {
  color: var(--ink-2);
  max-width: 54ch;
}

.skeletons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.skeleton-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.skeleton-card__lines {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-card__tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.sk {
  display: block;
  background: var(--tile);
  border-radius: var(--r-sm);
  animation: sk-pulse 1.6s ease-in-out infinite;
}

.sk--thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--r-md);
}

.sk--line { height: 14px; width: 70%; }
.sk--short { width: 42%; }
.sk--tile { height: 46px; border-radius: var(--r-md); }
.sk--bar { height: 6px; border-radius: 999px; }

@keyframes sk-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* --------------------------------------------------------------------------
   Tables and record lines
   -------------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.table {
  width: 100%;
  min-width: 560px;
  font-size: 14px;
}

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

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--tile);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--ink-2);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table .num {
  text-align: right;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.table .is-negative {
  color: var(--red-ink);
}

.table tr.is-expandable {
  cursor: pointer;
}

.table tr.is-expandable:hover td {
  background: var(--tile);
}

.table__detail td {
  white-space: normal;
  background: var(--canvas);
}

.line-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.line-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--canvas);
}

.line-item__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.line-item__title {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Profile dialog
   -------------------------------------------------------------------------- */

.profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile__main {
  min-width: 0;
}

.profile__name {
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
}

.profile__login {
  font-size: 13px;
  color: var(--ink-2);
}

.profile__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* --------------------------------------------------------------------------
   Login and first-run screens
   -------------------------------------------------------------------------- */

.view--auth {
  gap: 0;
}

.auth {
  display: grid;
  gap: 28px;
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px var(--pad-x) calc(40px + var(--safe-bottom));
  grid-template-areas:
    'brand'
    'panel'
    'flow';
}

.auth__brand {
  grid-area: brand;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

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

.auth__mark-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.auth__title {
  font-size: 30px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  max-width: 20ch;
}

.auth__lead {
  color: var(--ink-2);
  max-width: 48ch;
}

.auth__panel {
  grid-area: panel;
}

.auth__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.auth__form-title {
  font-size: 18px;
  line-height: 24px;
}

.auth__help {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-2);
}

.auth__flow {
  grid-area: flow;
  display: grid;
  gap: 14px;
}

.auth__step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.auth__step-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--green-soft);
  color: var(--green-ink);
}

.auth__step-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.auth__step-title {
  font-weight: 600;
}

.auth__step-desc {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-2);
}

/* --------------------------------------------------------------------------
   Breakpoints
   -------------------------------------------------------------------------- */

@media (min-width: 560px) {
  .store-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tiles--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tiles--5,
  .tiles--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 640px) {
  .dialog-layer {
    align-items: center;
    padding: 24px;
  }

  .dialog {
    max-width: 520px;
    max-height: 86dvh;
    border-radius: var(--r-sheet);
    padding-bottom: 0;
    animation: sheet-in 260ms var(--ease-out);
  }

  .dialog--lg {
    max-width: 720px;
  }

  .dialog__grip {
    display: none;
  }

  .dialog__head {
    padding-top: 16px;
  }

  .dialog__actions .btn {
    flex: 0 0 auto;
  }

  .page-intro {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .card {
    padding: 16px;
  }

  .card.is-current {
    padding: 15px;
  }
}

@media (min-width: 880px) {
  .auth {
    grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
    grid-template-areas:
      'brand panel'
      'flow panel';
    align-content: center;
    column-gap: 48px;
    min-height: 100dvh;
    padding-block: 48px;
  }

  .auth__title {
    font-size: 40px;
    line-height: 46px;
  }

  .auth__form {
    padding: 24px;
  }
}

@media (min-width: 1024px) {
  .nav {
    top: 0;
    left: 0;
    right: auto;
    bottom: 0;
    width: var(--rail-w);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    background: var(--canvas);
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
  }

  .nav__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 16px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
  }

  .nav__list {
    flex-direction: column;
    gap: 4px;
    padding: 0;
    overflow: visible;
  }

  .nav__item {
    flex: 0 0 auto;
    min-width: 0;
  }

  .nav__link {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    min-height: 48px;
    padding: 0 12px;
    font-size: 15px;
    line-height: 20px;
    text-align: left;
  }

  .shell__main {
    margin-left: var(--rail-w);
  }

  .topbar {
    padding-inline: 24px;
  }

  .topbar__inner {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: 'titles day user';
    gap: 16px;
  }

  .content {
    padding-inline: 24px;
    padding-bottom: 48px;
  }

  .toasts {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: 440px;
    align-items: flex-end;
  }

  .tiles--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .tiles--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* --------------------------------------------------------------------------
   Reduced motion: opacity only, 120ms
   -------------------------------------------------------------------------- */

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

  .dialog,
  .dialog__step--forward,
  .dialog__step--back,
  .toast,
  .viewer {
    animation-name: fade-in;
  }

  .dialog-layer.is-closing .dialog,
  .toast.is-leaving,
  .viewer.is-closing {
    animation-name: fade-out;
  }

  .spinner {
    animation-duration: 1200ms !important;
    animation-iteration-count: infinite !important;
  }

  .sk {
    animation: none;
  }

  .btn:active:not(:disabled),
  button.thumb:hover,
  .btn:hover .btn__icon,
  .day-chip:hover .day-chip__chevron {
    transform: none;
  }

  .tally__fill,
  .viewer__img,
  .toggle__thumb {
    transition: none;
  }
}
