:root {
  --bg: #fbf7f4;
  --card: #ffffff;
  --text: #2b211d;
  --muted: #8a7b74;
  --line: #eee3dc;
  --accent: #e0674c;
  --accent-text: #ffffff;
  --accent-soft: #fbe3da;
  --danger: #c0392b;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1715;
    --card: #27201d;
    --text: #f3ebe6;
    --muted: #a8988f;
    --line: #3a2f2a;
    --accent: #f08a6c;
    --accent-text: #1c1715;
    --accent-soft: #4a2c23;
    --danger: #ff7b6b;
  }
}

:root[data-theme="dark"] {
  --bg: #1c1715;
  --card: #27201d;
  --text: #f3ebe6;
  --muted: #a8988f;
  --line: #3a2f2a;
  --accent: #f08a6c;
  --accent-text: #1c1715;
  --accent-soft: #4a2c23;
  --danger: #ff7b6b;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

.center { text-align: center; padding: 48px 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* шапка мастера */
.header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 20px; flex: none;
}
.header h1 { font-size: 20px; margin: 0; }
.header .sub { font-size: 14px; color: var(--muted); }
.header .grow { flex: 1; min-width: 0; }
.link-btn {
  background: none; border: 0; color: var(--accent); font: inherit; font-size: 14px;
  padding: 8px 0; cursor: pointer;
}

h2 { font-size: 17px; margin: 20px 0 10px; }

/* списки */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-align: left; color: inherit; font: inherit; cursor: pointer;
}
.item:active { transform: scale(0.99); }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .meta { font-size: 14px; color: var(--muted); }
.item .price { font-weight: 600; white-space: nowrap; text-align: right; }

/* выбранная услуга */
.summary {
  background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 4px;
}
.summary .title { font-weight: 600; }

/* дни */
.days {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -16px; padding-left: 16px;
  scrollbar-width: none;
}
.days::-webkit-scrollbar { display: none; }
.day {
  flex: none; width: 56px; padding: 8px 0; border-radius: 12px; text-align: center;
  background: var(--card); border: 1px solid var(--line); color: inherit; font: inherit; cursor: pointer;
}
.day .wd { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.day .mon { font-size: 11px; color: var(--accent); line-height: 1.1; }
.day.active .mon { color: inherit; }
.day .dn { font-size: 18px; font-weight: 600; }
.day[disabled] { opacity: 0.35; cursor: default; }
.day.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.day.active .wd { color: inherit; opacity: 0.85; }

/* слоты */
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 360px) { .slots { grid-template-columns: repeat(3, 1fr); } }
.slot {
  padding: 10px 0; border-radius: 10px; text-align: center;
  background: var(--card); border: 1px solid var(--line); color: inherit; font: inherit;
  font-weight: 600; cursor: pointer;
}
.slot.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* форма */
label { display: block; font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
input, textarea {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }

.btn {
  display: block; width: 100%; margin-top: 20px; padding: 15px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 600; cursor: pointer;
}
.btn[disabled] { opacity: 0.6; cursor: default; }
.btn.secondary { background: var(--card); color: var(--accent); border: 1px solid var(--line); }
.btn.small-btn { width: auto; display: inline-block; margin: 0; padding: 10px 14px; font-size: 14px; }
.btn.danger { color: var(--danger); }

.error {
  background: var(--accent-soft); color: var(--danger); border-radius: 12px; padding: 10px 12px;
  margin-top: 12px; font-size: 14px;
}
.done-icon {
  width: 64px; height: 64px; border-radius: 50%; margin: 24px auto 12px;
  background: var(--accent); color: var(--accent-text); display: grid; place-items: center;
  font-size: 32px; font-weight: 700;
}
.footer { margin-top: 28px; text-align: center; font-size: 12px; color: var(--muted); }
.footer a { color: inherit; }

/* ---------- кабинет мастера ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px;
}
.day-card.off { opacity: 0.75; }
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.day-name { font-weight: 600; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; margin: 0; color: var(--muted); font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .slider {
  width: 44px; height: 26px; border-radius: 13px; background: var(--line); position: relative; flex: none;
  transition: background 0.15s;
}
.switch .slider::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::after { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }
.intervals { margin-top: 10px; }
.interval { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.interval .time { flex: 1; min-width: 0; padding: 10px; text-align: center; }
.interval .dash { color: var(--muted); }
.icon-btn {
  width: 36px; height: 36px; flex: none; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.icon-btn.placeholder { border: 0; background: none; cursor: default; }
.day-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.field-error { color: var(--danger); font-size: 13px; margin: -2px 0 6px; }
.notice {
  background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px;
}
.save-bar {
  position: sticky; bottom: 0; padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 75%, transparent);
}
.save-bar .btn { margin-top: 8px; }

/* вкладки и записи */
.tabs { display: flex; gap: 4px; background: var(--line); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.tab { flex: 1; border: 0; background: none; padding: 9px; border-radius: 10px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.day .cnt { font-size: 12px; font-weight: 600; color: var(--accent); margin-top: 2px; }
.day .cnt.zero { color: var(--muted); font-weight: 400; }
.day.active .cnt { color: inherit; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-between h2 { margin: 16px 0 10px; }
.appt { display: flex; gap: 12px; align-items: flex-start; }
.appt .appt-time { font-weight: 700; white-space: nowrap; min-width: 92px; }
.appt .title { font-weight: 600; }
.appt .meta { font-size: 14px; color: var(--muted); }
.appt .meta a { color: var(--accent); text-decoration: none; }
.badge { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 600; vertical-align: middle; }
.danger-link { color: var(--danger); padding: 4px 0 0; }
.chips { display: flex; flex-direction: column; gap: 6px; }
.chip { display: flex; justify-content: space-between; gap: 8px; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: inherit; font: inherit; cursor: pointer; }
.chip.active { border-color: var(--accent); background: var(--accent-soft); }
.chip-sub { color: var(--muted); font-size: 13px; white-space: nowrap; }
.inline-label { align-items: center; margin-top: 10px; }
.inline-label .time { max-width: 140px; }
.hints { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; margin-top: 4px; overflow: hidden; }
.hint { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: var(--card); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.hint:last-child { border-bottom: 0; }

/* календарь особых дней */
.tabs .tab { padding: 9px 4px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; }
.cal-title { font-weight: 700; font-size: 17px; }
.cal-head .icon-btn[disabled] { opacity: 0.35; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.cal-wd { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-cell {
  position: relative; aspect-ratio: 1 / 1; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: inherit; font: inherit; cursor: pointer; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.cal-cell.empty { border: 0; background: none; cursor: default; }
.cal-cell .num { font-weight: 600; }
.cal-cell .tag { font-size: 10px; line-height: 1; color: var(--accent); }
.cal-cell .dot {
  position: absolute; top: 3px; right: 3px; min-width: 15px; height: 15px; border-radius: 8px; padding: 0 3px;
  background: var(--accent); color: var(--accent-text); font-size: 10px; line-height: 15px; font-weight: 700;
}
.cal-cell.k-weekly-off { background: var(--bg); color: var(--muted); }
.cal-cell.k-off { background: repeating-linear-gradient(45deg, var(--accent-soft), var(--accent-soft) 4px, transparent 4px, transparent 8px); color: var(--danger); border-color: var(--accent-soft); }
.cal-cell.k-hours { border: 2px solid var(--accent); }
.cal-cell.today .num { text-decoration: underline; text-underline-offset: 3px; }
.cal-cell.past { opacity: 0.3; cursor: default; }
.cal-cell.sel { outline: 3px solid var(--text); outline-offset: -3px; }
.cal-cell.range-start { outline-style: dashed; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); display: inline-block; }
.lg.k-off { background: repeating-linear-gradient(45deg, var(--accent-soft), var(--accent-soft) 3px, transparent 3px, transparent 6px); }
.lg.k-hours { border: 2px solid var(--accent); }
.lg.k-weekly-off { background: var(--bg); }
.lg.dotlg { border-radius: 7px; background: var(--accent); border: 0; }
.special { display: flex; align-items: center; gap: 12px; }
.special .title { font-weight: 600; }
.special .meta { font-size: 14px; color: var(--muted); }
.sel-bar { background: var(--bg); border-top: 1px solid var(--line); margin: 12px -16px 0; padding-left: 16px; padding-right: 16px; }
.sel-bar .row .btn { margin-top: 8px; }
.sel-bar .interval { margin-top: 8px; }
.special .grow { flex: 1; min-width: 0; }

/* настройки */
.tabs .tab { font-size: 14px; }
.set-title { font-weight: 600; margin: 14px 0 8px; }
.card > .set-title:first-child { margin-top: 2px; }
.set-hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn {
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  color: inherit; font: inherit; font-size: 14px; cursor: pointer;
}
.seg-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.link-box {
  padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px dashed var(--line);
  font-size: 14px; word-break: break-all; user-select: all; -webkit-user-select: all;
}
.card .btn.secondary { margin-top: 10px; }
.select {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit;
}
.row .btn.small-btn { flex: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); width: max-content; z-index: 10;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* услуги */
.svc { display: flex; align-items: center; gap: 10px; margin-bottom: 0; padding: 0 10px 0 0; }
.svc-main {
  flex: 1; min-width: 0; text-align: left; border: 0; background: none; color: inherit;
  font: inherit; padding: 12px 0 12px 14px; cursor: pointer;
}
.svc-main .title { font-weight: 600; }
.svc-main .meta { font-size: 14px; color: var(--muted); margin-top: 2px; }
.svc.hidden .svc-main { opacity: 0.55; }
.svc-move { display: flex; gap: 6px; flex: none; }
.svc-move .icon-btn { width: 32px; height: 32px; font-size: 16px; }
.svc-move .icon-btn[disabled] { opacity: 0.3; cursor: default; }
.badge.muted-badge { background: var(--line); color: var(--muted); }
.center-hint { text-align: center; margin-top: 10px; }
.list + .btn { margin-top: 12px; }
.btn.secondary.danger { margin-top: 10px; }
.tabs .tab { font-size: 13px; padding: 9px 2px; letter-spacing: -0.1px; }
.link-label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
.card .set-title + .link-label { margin-top: 0; }

/* веб-версия */
.back-link { border: 0; background: none; color: var(--accent); font: inherit; font-size: 15px; padding: 0 0 10px; cursor: pointer; }
.consent { margin-top: 10px; text-align: center; }
.login { text-align: center; padding: 40px 4px; }
.login .avatar { margin: 0 auto 12px; }
.login h1 { font-size: 22px; margin: 0 0 16px; }
.login .steps { text-align: left; margin: 12px auto 20px; padding-left: 22px; max-width: 420px; line-height: 1.5; }
.login a.btn { display: block; text-decoration: none; text-align: center; }
@media (min-width: 900px) {
  /* браузер на компьютере: шире колонка, крупнее поля */
  #app { max-width: 720px; padding-top: 32px; }
  .slots { grid-template-columns: repeat(6, 1fr); }
  .days { flex-wrap: wrap; overflow: visible; } /* мышью неудобно листать вбок */
}

/* админка */
body.admin #app { max-width: 1120px; }
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile-label { font-size: 13px; color: var(--muted); }
.tile-value { font-size: 28px; font-weight: 800; line-height: 1.2; margin: 2px 0; }
.tile-sub { font-size: 12px; color: var(--muted); }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.chart-card { padding-bottom: 8px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 120px; margin-top: 12px; }
.bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; cursor: default; }
.bar { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar.zero { background: var(--line); }
.bar-col:hover .bar, .bar-col:focus .bar { filter: brightness(0.85); }
.bar-col:hover::after, .bar-col:focus::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-size: 12px; padding: 3px 7px; border-radius: 6px; white-space: nowrap; z-index: 2;
}
.bars-axis { display: flex; justify-content: space-between; margin-top: 4px; }
.mini-table td { padding: 1px 12px 1px 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.toolbar .search { max-width: 280px; }
.mtable { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.mrow {
  display: grid; grid-template-columns: 2.4fr 1.2fr .9fr .7fr .7fr 1.3fr; gap: 10px; align-items: center;
  width: 100%; padding: 10px 14px; border: 0; border-top: 1px solid var(--line); background: none;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.mrow:hover, .mrow.open { background: var(--bg); }
.mhead { border-top: 0; cursor: default; font-size: 13px; color: var(--muted); }
.mhead:hover { background: none; }
.mrow .num { text-align: right; font-variant-numeric: tabular-nums; }
.mname { font-weight: 600; }
.note-dot { color: var(--accent); }
.st { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 8px; }
.st-ok { background: var(--accent-soft); color: var(--accent); }
.st-muted { background: var(--line); color: var(--muted); }
.st-warn { border: 1px dashed var(--muted); color: var(--muted); }
.st-bad { background: var(--danger); color: #fff; }
.detail { padding: 6px 14px 16px; border-top: 1px solid var(--line); background: var(--bg); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.detail .kv { font-size: 14px; margin: 2px 0; overflow-wrap: anywhere; }
.detail ul.plain { margin: 0; padding-left: 18px; font-size: 14px; }
.detail .sched { font: inherit; font-size: 14px; white-space: pre-wrap; margin: 0; }
.detail textarea { min-height: 60px; }
.detail .btn.small-btn { margin-top: 8px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 760px) {
  .mrow { grid-template-columns: 1fr auto; }
  .mrow > :nth-child(n+3) { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
}
.detail a { color: var(--accent); }
