:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --text: #1c1d1b;
  --muted: #6b6d68;
  --line: #e3e1db;
  --accent: #1f4d3a;
  --accent-hover: #173b2c;
  --accent-soft: #e3eee8;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --warn-soft: #fff4dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 4px 16px rgb(0 0 0 / 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121412;
    --surface: #1b1e1b;
    --surface-2: #232723;
    --text: #ecede9;
    --muted: #9da19a;
    --line: #2e322e;
    --accent: #7cc4a0;
    --accent-hover: #93d3b2;
    --accent-soft: #1f3329;
    --on-accent: #0d1a13;
    --danger: #f2867e;
    --warn-soft: #3a3020;
    --shadow: none;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

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

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 8px;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 16px;
}

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

.wrap.wide {
  max-width: 960px;
}

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

.small {
  font-size: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

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

.row.between {
  justify-content: space-between;
}

.stack > * + * {
  margin-top: 12px;
}

.grow {
  flex: 1;
  min-width: 0;
}

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  background: var(--surface-2);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

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

.btn.block {
  width: 100%;
}

.btn.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}

.btn.danger {
  color: var(--danger);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

label.field {
  display: block;
}

label.field > span {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 4px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input[type='checkbox'] {
  width: 22px;
  min-height: 22px;
  height: 22px;
  accent-color: var(--accent);
  flex: none;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 420px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ---------- шапка мастера ---------- */
.hero {
  padding: 8px 0 16px;
}

.hero .tag {
  display: inline-block;
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 10px;
}

/* ---------- категории ---------- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 10px;
  scrollbar-width: none;
}

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

.chip {
  flex: none;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.chip[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.chip .count {
  margin-left: 6px;
  font-weight: 700;
}

/* ---------- позиции ---------- */
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.item:first-child {
  border-top: 0;
}

.item .name {
  font-weight: 500;
}

.item .price {
  font-size: 14px;
  color: var(--muted);
}

.stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  flex: none;
}

.stepper button {
  width: 40px;
  height: 40px;
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

.stepper output {
  min-width: 36px;
  text-align: center;
  font-weight: 600;
}

.stepper.active {
  border-color: var(--accent);
}

/* ---------- итог ---------- */
.totalbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  z-index: 10;
}

.totalbar .inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.totalbar .sum {
  font-size: 22px;
  font-weight: 700;
}

.breakdown {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.breakdown td {
  padding: 6px 0;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.breakdown td:last-child {
  text-align: right;
  white-space: nowrap;
  padding-left: 12px;
}

.breakdown tr.total td {
  font-weight: 700;
  font-size: 16px;
}

.notice {
  background: var(--warn-soft);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.error {
  color: var(--danger);
  font-size: 14px;
}

/* ---------- фото ---------- */
.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.thumbs img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: block;
}

/* ---------- статусы ---------- */
.badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.badge.new {
  background: var(--warn-soft);
  color: var(--text);
}

.badge.confirmed,
.badge.scheduled {
  background: var(--accent-soft);
  color: var(--accent);
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline li {
  position: relative;
  padding: 0 0 14px 28px;
  color: var(--muted);
}

.timeline li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--surface);
}

.timeline li.done {
  color: var(--text);
}

.timeline li.done::before {
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------- кабинет ---------- */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.tabs button {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tabs button[aria-selected='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.req {
  cursor: pointer;
}

.req:hover {
  border-color: var(--accent);
}

.price-row {
  display: grid;
  grid-template-columns: 22px 1fr 110px 92px 36px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.price-row .cat {
  grid-column: 2 / -1;
  font-size: 14px;
  min-height: 36px;
  padding: 6px 10px;
}

@media (max-width: 520px) {
  .price-row {
    grid-template-columns: 22px 1fr 92px 36px;
  }
  .price-row .n {
    grid-column: 2 / 4;
    grid-row: 1;
  }
  .price-row .icon-btn {
    grid-column: 4;
    grid-row: 1;
  }
  .price-row .p {
    grid-column: 2;
    grid-row: 2;
  }
  .price-row .u {
    grid-column: 3;
    grid-row: 2;
  }
  .price-row .cat {
    grid-row: 3;
  }
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

dialog {
  width: min(640px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  padding: 0;
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
}

dialog .body {
  padding: 16px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 100;
}

.hidden {
  display: none !important;
}
