:root {
  --brand: #5b2a86;
  --brand-2: #7b46a8;
  --brand-soft: #efe7f7;
  --bar: #7b46a8;
  --bg: #f6f4f8;
  --surface: #ffffff;
  --ink: #1f1a24;
  --ink-2: #5c5566;
  --muted: #8b8494;
  --line: #e6e1ec;
  --good: #1f8a4c;
  --danger: #c0392b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: var(--brand); color: #fff;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: .3px; }
.sub { font-size: 13px; opacity: .85; }
.today-pill { background: rgba(255,255,255,.18); padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 14px; }

main { max-width: 560px; margin: 0 auto; padding: 12px; }
h2 { font-size: 18px; margin: 6px 4px 12px; }
h3 { font-size: 15px; margin: 0 0 10px; color: var(--ink-2); font-weight: 600; }
.view { display: none; }
.view.active { display: block; }

.card { background: var(--surface); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(30,10,50,.06); }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 10px 0 6px; }
label:first-child { margin-top: 0; }
label.inline { margin: 0; display: inline; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=search] {
  width: 100%; padding: 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus { outline: 2px solid var(--brand-2); border-color: transparent; }
.phone-row { display: flex; align-items: stretch; }
.prefix { padding: 12px 10px; background: var(--brand-soft); border: 1px solid var(--line); border-right: 0; border-radius: 10px 0 0 10px; color: var(--ink-2); }
.phone-row input { border-radius: 0 10px 10px 0; }
.hint { font-size: 13px; margin-top: 6px; color: var(--brand); min-height: 0; }
.hint:empty { display: none; }
.muted { color: var(--muted); font-size: 14px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.row-between label { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 12px; font-size: 14px; cursor: pointer; color: var(--ink); }
.chip small { color: var(--muted); margin-left: 4px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.on small { color: #e4d6f2; }

.selected-list { list-style: none; padding: 0; margin: 12px 0 0; }
.selected-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.selected-list li span { flex: 1; }
.selected-list input { width: 100px; padding: 8px; text-align: right; }
.x-btn { border: 0; background: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 4px; }
.empty-note { color: var(--muted); font-size: 13px; margin-top: 10px; }
.custom-box { display: flex; gap: 8px; margin-top: 10px; }
.custom-box input[type=text] { flex: 2; }
.custom-box input[type=number] { flex: 1; min-width: 70px; }
.hidden { display: none !important; }

.money-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }
.small-input { width: 110px !important; padding: 8px !important; text-align: right; }
.money-row.total { font-weight: 700; font-size: 20px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; }

.pay-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-modes button { padding: 14px 6px; font-size: 15px; border: 1px solid var(--line); background: #fff; border-radius: 12px; cursor: pointer; color: var(--ink); }
.pay-modes button.on { border: 2px solid var(--brand); background: var(--brand-soft); font-weight: 700; }

.btn { display: block; width: 100%; padding: 13px; font-size: 16px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; margin-top: 8px; color: var(--ink); }
.btn.primary { background: var(--brand); color: #fff; border: 0; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #f0c9c4; }
.btn.small { width: auto; padding: 10px 14px; margin: 0; }
.link { background: none; border: 0; color: var(--brand); font-weight: 600; cursor: pointer; font-size: 14px; }
.form-actions { display: flex; gap: 10px; }
.error { color: var(--danger); font-size: 14px; margin: 0 4px 6px; }
.error:empty { display: none; }

.day-nav { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.icon-btn { width: 44px; height: 44px; font-size: 24px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--ink); }
.day-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.day-summary .big { font-size: 20px; font-weight: 700; }
.day-summary .lbl { font-size: 12px; color: var(--muted); }
#searchBox { margin-bottom: 12px; }
.entry-list { list-style: none; padding: 0; margin: 0; }
.entry { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(30,10,50,.06); }
.entry .top { display: flex; justify-content: space-between; font-weight: 600; }
.entry .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.entry .svcs { font-size: 14px; color: var(--ink-2); margin-top: 6px; }
.entry .acts { display: flex; gap: 16px; margin-top: 8px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); margin-left: 6px; vertical-align: middle; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border-radius: 12px; padding: 4px; margin-bottom: 12px; border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 9px 4px; border-radius: 9px; font-size: 14px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--brand); color: #fff; font-weight: 600; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.tile { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 1px 2px rgba(30,10,50,.06); }
.tile .lbl { font-size: 12px; color: var(--muted); }
.tile .val { font-size: 22px; font-weight: 700; margin-top: 2px; }
.tile .note { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.progress { height: 6px; background: var(--line); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.progress > div { height: 100%; background: var(--good); border-radius: 3px; }

/* Bar chart – single series, one hue */
.chart { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding-top: 18px; border-bottom: 1px solid var(--line); position: relative; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; cursor: default; }
.chart .bar { width: 70%; max-width: 22px; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 0; }
.chart .col:hover .bar, .chart .col:focus .bar { background: var(--brand); }
.chart .col .tip { display: none; position: absolute; bottom: calc(100% + 4px); background: var(--ink); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 2; }
.chart .col:hover .tip, .chart .col:focus .tip { display: block; }
.chart .col.today .bar { background: var(--brand); }
.x-labels { display: flex; gap: 2px; margin-top: 4px; }
.x-labels span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); }

.hbar-row { margin-bottom: 10px; }
.hbar-row .row-between { font-size: 14px; margin-bottom: 4px; }
.hbar-row .row-between span:last-child { color: var(--ink-2); }
.hbar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.hbar > div { height: 100%; background: var(--bar); border-radius: 4px; }
.stat-line { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; border-bottom: 1px solid var(--line); }
.stat-line:last-child { border-bottom: 0; }

.svc-edit { list-style: none; padding: 0; margin: 0; }
.svc-edit li { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.svc-edit li input[type=text] { flex: 2; padding: 8px; }
.svc-edit li input[type=number] { flex: 1; padding: 8px; min-width: 70px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button { border: 0; background: none; padding: 8px 0 10px; font-size: 12px; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabbar button span { font-size: 20px; line-height: 1; }
.tabbar button.on { color: var(--brand); font-weight: 700; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; }
.toast.show { opacity: 1; }
code { background: var(--brand-soft); padding: 1px 5px; border-radius: 4px; }
.who { font-size: 12px; color: var(--brand); font-weight: 600; }
.btn:disabled { opacity: .6; cursor: wait; }
select { width: 100%; padding: 11px 12px; font-size: 15px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.filters { display: flex; gap: 8px; margin-bottom: 12px; }
.filters select { flex: 1; min-width: 0; }
.tabbar.cols-5 { grid-template-columns: repeat(5, 1fr); }
.tabbar.cols-4 { grid-template-columns: repeat(4, 1fr); }
.tabbar.cols-4, .tabbar.cols-5 { display: grid; }
.lead-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.lead-row:last-child { border-bottom: 0; }
.lead-row .row-between { font-size: 14px; }
.lead-row .sub2 { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.rank { display: inline-block; width: 22px; color: var(--muted); font-weight: 600; }
.team-list { list-style: none; padding: 0; margin: 0; }
.team-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.team-list li:last-child { border-bottom: 0; }
.team-list .nm { font-weight: 600; }
.team-list .em { font-size: 12px; color: var(--muted); }
.role-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); margin-left: 6px; }
.assign-box { display: grid; gap: 8px; margin-top: 8px; }
.assign-box .btn { margin: 0; }
