:root {
  --bg: #f5f2ec;
  --card: #fffdf9;
  --ink: #1f2a26;
  --ink-2: #55605b;
  --muted: #8a918d;
  --line: #e6e0d5;
  --brand: #2f6f5e;
  --brand-2: #e3efe9;
  --chart: #2a78d6;
  --chart-soft: #dbe8f8;
  --danger: #b4412f;
  --ok: #1f7a3a;
  --warn: #9a5b00;
  --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
h2 { font-size: 16px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
main { max-width: 760px; margin: 0 auto; padding: 12px; }

/* header + tabs */
.top { position: sticky; top: 0; z-index: 10; background: var(--brand); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.brand { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; align-items: center; padding: 10px 14px 6px; }
.logo { font-size: 26px; }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 12px; opacity: .8; }
.tabs { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tab {
  background: none; border: 0; color: #fff; opacity: .75; padding: 9px 2px 11px; font: inherit; font-size: 13px;
  border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.tab[aria-selected="true"] { opacity: 1; font-weight: 700; border-bottom-color: #f3d27a; }

.view { display: none; }
.view.on { display: block; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.hint { color: var(--ink-2); font-size: 13px; margin: -4px 0 10px; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; font-weight: 400; }
.empty { color: var(--muted); text-align: center; padding: 14px 0; margin: 0; grid-column: 1 / -1; }
.step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; margin-top: 10px; }

/* forms */
label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-top: 4px;
}
label.inline input, .controls input { width: auto; margin: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; margin: 0 0 10px; line-height: 1.5; }

.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 9px 14px; cursor: pointer; min-height: 40px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.danger { background: #fff; color: var(--danger); border-color: #e7b9b1; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; margin-top: 6px; }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn.icon { min-width: 40px; padding: 6px 8px; }
.btn.icon.small { min-width: 32px; }

/* services */
.svc-list { display: grid; gap: 8px; }
.svc {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "r n p" "r m p";
  column-gap: 10px; align-items: center; margin: 0; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 12px; cursor: pointer; color: var(--ink); background: #fff;
}
.svc input { grid-area: r; width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }
.svc-name { grid-area: n; font-weight: 600; }
.svc-meta { grid-area: m; font-size: 12px; color: var(--ink-2); }
.svc-price { grid-area: p; font-weight: 700; color: var(--brand); }
.svc.sel { border-color: var(--brand); background: var(--brand-2); }

/* chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll-x { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chip {
  font: inherit; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px;
  cursor: pointer; color: var(--ink); min-height: 38px;
}
.chip.day { border-radius: 12px; display: grid; text-align: center; padding: 6px 10px; min-width: 62px; flex: 0 0 auto; }
.chip.day small { font-size: 11px; color: var(--ink-2); }
.chip.sel { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip.sel small { color: #e8f2ee; }

/* slots */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; }
.slot {
  font: inherit; font-weight: 600; padding: 9px 0; border-radius: 10px; border: 1px solid #b9d5c9; background: #fff;
  color: var(--brand); cursor: pointer; display: grid; line-height: 1.1;
}
.slot small { font-size: 10px; font-weight: 500; }
.slot.sel { background: var(--brand); color: #fff; }
.slot.full, .slot.past {
  cursor: not-allowed; color: #a8a8a3; border-color: var(--line);
  background: repeating-linear-gradient(135deg, #f1efea 0 6px, #e8e5de 6px 7px);
}
.slot.past { text-decoration: line-through; }
.summary { background: var(--brand-2); border-radius: 10px; padding: 10px 12px; margin: 4px 0 8px; font-size: 14px; }

/* import */
.im-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; background: #fff; }
.im-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.raw { font-size: 13px; color: var(--ink-2); font-style: italic; word-break: break-word; }
.im-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.im-grid label { margin-bottom: 6px; font-size: 12px; }
.im-grid input, .im-grid select { padding: 7px 8px; font-size: 15px; margin-top: 2px; }
.status { font-size: 13px; font-weight: 600; padding: 4px 8px; border-radius: 8px; display: inline-block; }
.status.ok { color: var(--ok); background: #e5f3e8; }
.status.bad { color: var(--warn); background: #fdf0d9; }

/* owner */
.controls input[type=date] { padding: 7px 8px; font-size: 15px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; border: 0; background: #fff; padding: 8px 12px; cursor: pointer; color: var(--ink); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.sel { background: var(--brand); color: #fff; font-weight: 600; }
#ow-range-label { margin: 8px 0 0; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi-k { font-size: 12px; color: var(--ink-2); }
.kpi-v { font-size: 22px; font-weight: 750; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.kpi-s { font-size: 11px; color: var(--muted); min-height: 1em; }

.schedule { margin-top: 8px; }
.appt { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.appt-time { display: grid; text-align: center; font-variant-numeric: tabular-nums; }
.appt-time small { color: var(--muted); font-size: 11px; }
.appt-name { font-weight: 600; }
.appt-sub { font-size: 12.5px; color: var(--ink-2); }
.appt-act { display: flex; gap: 4px; }
.appt.cancelled .appt-name, .appt.cancelled .appt-sub, .appt.cancelled .appt-time { opacity: .5; text-decoration: line-through; }
.appt.live { background: linear-gradient(90deg, var(--brand-2), transparent); border-radius: 8px; }
.tag { font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: #eeebe4; color: var(--ink-2); vertical-align: 1px; }
.tag.new { background: #fbe9c6; color: #7a4a00; }
.tag.done { background: #e5f3e8; color: var(--ok); }
.tag.off { background: #f6e1dd; color: var(--danger); }
.tag.live { background: var(--brand); color: #fff; }

.grid2 { display: grid; gap: 0 12px; }
.bars { display: grid; gap: 10px; }
.bar-label { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 3px; }
.bar-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-val small { font-weight: 400; color: var(--ink-2); }
.bar-track { height: 10px; }
.bar { height: 100%; background: var(--chart); border-radius: 0 4px 4px 0; }
.bar-row:hover .bar { filter: brightness(1.1); }

.peak-text { font-size: 14px; margin-bottom: 10px; }
.cols { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; height: 150px; align-items: end; }
.col { display: grid; grid-template-rows: auto 1fr auto; height: 100%; text-align: center; }
.col-bar { align-self: end; background: var(--chart-soft); border-radius: 4px 4px 0 0; min-height: 0; }
.col.peak .col-bar { background: var(--chart); }
.col:hover .col-bar { filter: brightness(.95); }
.col-v { font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.col-l { font-size: 10.5px; color: var(--muted); padding-top: 3px; border-top: 1px solid var(--line); }

/* report */
#rp-text { margin-top: 10px; font-size: 14px; background: #fbfaf7; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px);
  background: #1f2a26; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100% - 24px); z-index: 20; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 640px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .svc-list { grid-template-columns: 1fr 1fr; }
  .im-grid { grid-template-columns: 2fr 1.4fr 1.4fr 1fr 2fr 1.2fr; }
  .tab { font-size: 14px; }
}
@media (max-width: 380px) {
  .tab { font-size: 12px; }
  .controls .row { flex-wrap: wrap; }
}
