/* Thrive Better Living back office. Calm, light, phone first. */
:root {
  --ink: #0b1430;
  --ink-2: #2b3553;
  --muted: #5b6684;
  --line: rgba(11, 20, 48, .1);
  --line-2: rgba(11, 20, 48, .06);
  --bg: #f5f6f8;
  --card: #fff;
  --blue: #2350f5;
  --blue-ink: #1d43d8;
  --blue-50: #eef2ff;
  --mint: #12a37f;
  --mint-ink: #0b7a5e;
  --mint-50: #e4f6ef;
  --red: #b42318;
  --red-50: #fdeceb;
  --amber: #9a5400;
  --amber-50: #fff2df;
  --grey-50: #eef0f4;
  --r-lg: 20px;
  --r: 14px;
  --r-sm: 10px;
  --shadow: 0 1px 2px rgba(11, 20, 48, .04), 0 10px 30px rgba(11, 20, 48, .05);
  --shadow-lg: 0 24px 60px rgba(11, 20, 48, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Arial, sans-serif;
  --gutter: 16px;
  --hour: 56px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.modal-open, html.modal-open body { overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: 17px; line-height: 1.3; letter-spacing: -.01em; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 3px solid rgba(35, 80, 245, .45); outline-offset: 2px; border-radius: 8px; }
h1:focus-visible, main:focus-visible { outline: none; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; }
.skip:focus { top: 12px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 650; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.wrap-any { overflow-wrap: anywhere; }

/* ---------- Icons ---------- */
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: middle; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 28px; height: 28px; }
[data-icon] { display: inline-flex; }

/* ---------- Boot and login ---------- */
.boot { min-height: 100vh; min-height: 100dvh; display: flex; gap: 12px; align-items: center; justify-content: center; color: var(--muted); }
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gutter); }
.login-card { width: min(400px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 32px 24px; box-shadow: var(--shadow); display: grid; gap: 16px; }
.login-card h1 { margin-top: 4px; }

.brand-mark { width: 36px; height: 36px; border-radius: 11px; background: linear-gradient(135deg, var(--blue), #4f74ff); color: #fff; display: grid; place-items: center; font-weight: 750; font-size: 17px; letter-spacing: -.02em; flex: none; }
.brand-mark-lg { width: 48px; height: 48px; border-radius: 14px; font-size: 22px; }

/* ---------- App shell ---------- */
.app { min-height: 100vh; min-height: 100dvh; }
.main { min-width: 0; }
.view { max-width: 1180px; margin: 0 auto; padding: 28px 32px 64px; }

.sidebar { display: none; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; }
.brand-name { font-weight: 650; font-size: 14.5px; line-height: 1.25; }
.brand-sub { color: var(--muted); font-size: 13px; }
.side-nav, .side-foot { display: grid; gap: 2px; }
.side-nav a, .side-foot a, .side-foot button {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px;
  color: var(--ink-2); font-weight: 550; text-decoration: none; background: none; border: 0; cursor: pointer; text-align: left; width: 100%;
}
.side-nav a:hover, .side-foot a:hover, .side-foot button:hover { background: rgba(11, 20, 48, .05); text-decoration: none; }
.side-nav a[aria-current="page"] { background: var(--card); color: var(--blue); box-shadow: 0 1px 2px rgba(11, 20, 48, .06), inset 0 0 0 1px var(--line-2); }
.side-label { margin: 18px 12px 6px; font-size: 12px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line);
  padding: 4px max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 54px; color: var(--muted); font-size: 11.5px; font-weight: 600; text-decoration: none; border-radius: 12px; }
.tabbar a .ic { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--blue); }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 252px minmax(0, 1fr); }
  .sidebar { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; padding: 22px 14px 18px; border-right: 1px solid var(--line); background: #eef0f4; }
  .tabbar { display: none; }
}
@media (max-width: 899.98px) {
  .view { padding: 20px max(var(--gutter), env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left)); }
  h1 { font-size: 26px; }
}

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head > div:first-child { min-width: 0; }
.page-sub { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
@media (max-width: 599.98px) {
  .page-actions { width: 100%; }
  .page-actions > .btn { flex: 1 1 auto; }
}
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin: -8px 0 6px -4px; padding: 0 6px; font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: 15px; line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 1px 2px rgba(35, 80, 245, .25); }
.btn-primary:hover:not(:disabled) { background: #1b43dc; }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: rgba(11, 20, 48, .22); }
.btn-quiet { background: transparent; color: var(--blue); padding: 0 12px; }
.btn-quiet:hover:not(:disabled) { background: var(--blue-50); }
.btn-mint { background: var(--mint); color: #fff; }
.btn-mint:hover:not(:disabled) { background: #0f8f6f; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #9a1d14; }
.btn-danger-ghost { background: var(--card); color: var(--red); border-color: rgba(180, 35, 24, .3); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--red-50); }
.btn-sm { padding: 0 14px; font-size: 14px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; border: 1px solid transparent;
  background: transparent; color: var(--ink-2); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: rgba(11, 20, 48, .05); text-decoration: none; }
.icon-btn.bordered { border-color: var(--line); background: var(--card); }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: spin .8s linear infinite; flex: none; opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards and layout ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .muted { font-size: 13.5px; }
.card + .card, .stack > * + * { margin-top: 16px; }
.dash-grid, .detail-grid { display: grid; gap: 16px; margin-top: 16px; }
.dash-grid > .card + .card, .detail-grid > .card + .card { margin-top: 0; }
@media (min-width: 1100px) {
  .dash-grid { grid-template-columns: 1.25fr 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .span-2 { grid-column: 1 / -1; }
}
@media (max-width: 599.98px) {
  .card { padding: 16px; border-radius: 18px; }
}

.loading { display: grid; gap: 12px; }
.sk { height: 14px; border-radius: 8px; background: linear-gradient(90deg, #eef0f4 0%, #f6f7f9 50%, #eef0f4 100%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
.sk:nth-child(3n+1) { width: 60%; }
.sk:nth-child(3n+2) { width: 90%; }
.sk:nth-child(3n) { width: 75%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); display: grid; justify-items: center; gap: 6px; }
.empty .ic { width: 32px; height: 32px; color: #9aa3ba; margin-bottom: 4px; }
.empty-title { color: var(--ink); font-weight: 650; }
.empty .btn { margin-top: 10px; }

.error-card { display: flex; gap: 14px; align-items: flex-start; border-color: rgba(180, 35, 24, .25); background: #fffafa; }
.error-card .ic { color: var(--red); margin-top: 2px; }
.error-card p + p { margin-top: 4px; }
.error-card .btn { margin-top: 12px; }

.note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r); background: var(--blue-50); color: var(--ink-2); font-size: 14px; }
.note .ic { color: var(--blue); margin-top: 1px; }
.note-warn { background: var(--amber-50); }
.note-warn .ic { color: var(--amber); }
.note-red { background: var(--red-50); }
.note-red .ic { color: var(--red); }
.note p + p { margin-top: 4px; }

/* ---------- Pills and badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-confirmed { background: #eaf0ff; color: var(--blue-ink); }
.st-completed { background: var(--mint-50); color: var(--mint-ink); }
.st-cancelled { background: var(--red-50); color: var(--red); }
.st-no_show { background: var(--amber-50); color: var(--amber); }
.st-held { background: var(--grey-50); color: #4a5470; }
.st-expired { background: #f3f4f7; color: var(--muted); box-shadow: inset 0 0 0 1px rgba(11, 20, 48, .12); }

.src { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px 0 8px; border-radius: 8px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.src .ic { width: 15px; height: 15px; }
.src-odoeric { background: var(--blue-50); color: var(--blue-ink); }
.src-odoeric-voice { background: #f1ecff; color: #5a32d6; }
.src-thrivebetterliving { background: #e3f5f2; color: #0b6f64; }
.src-latepoint { background: #fff1e5; color: #a8430a; }
.src-admin { background: #eceef3; color: var(--ink-2); }
.fill-odoeric { background: var(--blue); }
.fill-odoeric-voice { background: #7a55f0; }
.fill-thrivebetterliving { background: #14a090; }
.fill-latepoint { background: #e77a2e; }
.fill-admin { background: #5b6684; }

.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 650; background: var(--blue-50); color: var(--blue-ink); vertical-align: middle; }
.tag-warn { background: var(--amber-50); color: var(--amber); }
.tag-grey { background: var(--grey-50); color: var(--muted); }

/* ---------- Dashboard ---------- */
.setup { padding: 0; overflow: hidden; }
.setup-head { padding: 18px 20px 6px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.setup-list { padding: 6px 8px 10px; }
.setup-item { display: flex; gap: 14px; align-items: flex-start; padding: 12px; border-radius: 14px; }
.setup-item + .setup-item { border-top: 1px solid var(--line-2); border-radius: 0; }
.setup-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.setup-dot .ic { width: 16px; height: 16px; stroke-width: 2.2; }
.dot-ok { background: var(--mint-50); color: var(--mint-ink); }
.dot-warn { background: var(--amber-50); color: var(--amber); }
.dot-todo { background: var(--red-50); color: var(--red); }
.setup-body { flex: 1; min-width: 0; }
.setup-body p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.setup-body .btn { margin-top: 10px; }
.setup-done { display: flex; align-items: center; gap: 12px; padding: 14px 18px; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .stats { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.stat { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; color: var(--ink); box-shadow: var(--shadow); min-width: 0; }
a.stat:hover { text-decoration: none; border-color: rgba(35, 80, 245, .35); }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.visits > li + li { border-top: 1px solid var(--line-2); }
.visit { display: flex; align-items: center; gap: 8px; }
.visit-main { flex: 1; min-width: 0; display: flex; gap: 14px; align-items: center; padding: 12px 4px; color: var(--ink); min-height: 56px; }
.visit-main:hover { text-decoration: none; }
.visit-main:hover .strong { color: var(--blue); }
.visit-time { font-weight: 700; font-variant-numeric: tabular-nums; width: 56px; flex: none; line-height: 1.2; }
.visit-time small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.visit-body { min-width: 0; display: grid; gap: 2px; }
.visit-body > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bars { display: grid; gap: 14px; }
.bar-label { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.bar-num { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-num small { color: var(--muted); font-weight: 500; font-size: 12.5px; margin-left: 4px; }
.bar-track { height: 10px; border-radius: 999px; background: var(--grey-50); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; min-width: 2px; }

.rows > li + li { border-top: 1px solid var(--line-2); }
.row-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 4px; color: var(--ink); min-height: 56px; }
.row-item:hover { text-decoration: none; }
.row-item:hover .strong { color: var(--blue); }
.row-main { min-width: 0; display: grid; gap: 2px; }
.row-main > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; flex: none; max-width: 55%; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.hint { font-size: 13px; color: var(--muted); }
.field-error { font-size: 13px; color: var(--red); font-weight: 550; }
input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="password"], input[type="number"],
input[type="search"], input[type="date"], input[type="time"], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 1px solid rgba(11, 20, 48, .16);
  background: #fff; font-size: 16px; line-height: 1.35; -webkit-appearance: none; appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type="date"], input[type="time"] { min-width: 0; display: block; }
input::-webkit-date-and-time-value { text-align: left; }
textarea { min-height: 88px; resize: vertical; }
select {
  padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6684' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(35, 80, 245, .14); outline: none; }
.invalid input, .invalid select, .invalid textarea, input[aria-invalid="true"] { border-color: var(--red); }
.input-unit { position: relative; display: flex; align-items: center; }
.input-unit input { padding-right: 96px; }
.input-unit .unit { position: absolute; right: 14px; color: var(--muted); font-size: 14px; pointer-events: none; }
.input-money { position: relative; }
.input-money::before { content: "\00a3"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-money input { padding-left: 30px; }
.form-error { color: var(--red); font-weight: 600; font-size: 14px; background: var(--red-50); padding: 10px 14px; border-radius: 12px; }

.form-grid { display: grid; gap: 16px; }
.row-fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.form-section { display: grid; gap: 14px; }
.form-section + .form-section { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line-2); }
.form-section-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }

.check { display: flex; gap: 12px; align-items: flex-start; min-height: 44px; padding: 10px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--blue); }
.check span { padding-top: 1px; }
.check small { display: block; color: var(--muted); font-size: 13px; }

.radio-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; min-height: 48px; }
.radio-card + .radio-card { margin-top: 8px; }
.radio-card input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--blue); flex: none; }
.radio-card:has(input:checked) { border-color: var(--blue); background: #f7f9ff; }
.radio-card .grow { flex: 1; min-width: 0; display: grid; gap: 8px; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-weight: 600; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { width: 46px; height: 28px; border-radius: 999px; background: #d4d8e2; position: relative; transition: background-color .2s; flex: none; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(11, 20, 48, .25); transition: transform .2s; }
.switch input:checked + .switch-ui { background: var(--mint); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 3px solid rgba(35, 80, 245, .45); outline-offset: 2px; }

/* Segmented control */
.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--grey-50); padding: 3px; border-radius: 12px; gap: 3px; width: 100%; max-width: 360px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 12px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(11, 20, 48, .12); }
.seg input:focus-visible + span { outline: 3px solid rgba(35, 80, 245, .45); outline-offset: 1px; }

/* Slot chips */
.picker { display: grid; gap: 14px; }
.slot-days { display: grid; gap: 14px; max-height: 340px; overflow-y: auto; padding: 2px; overscroll-behavior: contain; }
.slot-day-label { font-weight: 650; font-size: 14px; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; min-width: 72px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; }
.chip:hover { border-color: var(--blue); }
.chip[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ---------- Filters, tables, cards ---------- */
.filters { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow); }
.filters .grow { grid-column: 1 / -1; }
.filters-end { display: flex; align-items: center; justify-content: space-between; gap: 8px; grid-column: 1 / -1; flex-wrap: wrap; }
@media (min-width: 1100px) {
  .filters { grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(130px, 1fr)) auto; }
  .filters .grow { grid-column: auto; }
  .filters-end { grid-column: auto; }
}
.search-field { position: relative; }
.search-field .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field input { padding-left: 42px; }
.result-count { margin: 14px 4px 10px; color: var(--muted); font-size: 14px; }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 650; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr[data-href] { cursor: pointer; }
.table tr[data-href]:hover td { background: #fafbfc; }
.table td a.strong { color: var(--ink); }
.table td.nowrap, .table th.nowrap { white-space: nowrap; }
.table .sub { display: block; color: var(--muted); font-size: 13px; }

.cards { display: grid; gap: 10px; }
.bk-card { display: grid; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; color: var(--ink); box-shadow: var(--shadow); min-width: 0; }
.bk-card:hover { text-decoration: none; border-color: rgba(35, 80, 245, .35); }
.bk-card-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.bk-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.bk-card .line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wide-only { display: none; }
@media (min-width: 1100px) {
  .wide-only { display: block; }
  .narrow-only { display: none !important; }
}

/* ---------- Booking detail ---------- */
.bk-head { display: grid; gap: 8px; margin-bottom: 18px; }
.bk-head-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.bk-when { font-size: 18px; font-weight: 600; }
.bk-when span { color: var(--muted); font-weight: 500; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
@media (max-width: 599.98px) {
  .actions .btn { flex: 1 1 calc(50% - 5px); }
}
.dl { display: grid; gap: 0; }
.dl > div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.dl > div:first-child { border-top: 0; padding-top: 0; }
.dl dt { color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 420px) {
  .dl > div { grid-template-columns: 1fr; gap: 2px; }
}
.contact-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.contact-row .btn { flex: 1 1 auto; }
.events > li { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 12px; padding: 8px 0; }
.events > li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #c7cdda; margin-top: 7px; }
.events .ev-when { color: var(--muted); font-size: 13px; }
.notes-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Diary ---------- */
.diary-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.diary-bar .switch { margin-left: 4px; }
.dg { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.dg-head, .dg-body { display: grid; grid-template-columns: 58px repeat(7, minmax(0, 1fr)); }
.dg-head { border-bottom: 1px solid var(--line); }
.dg-head > div { padding: 10px 8px; text-align: center; font-size: 13px; color: var(--muted); font-weight: 600; border-left: 1px solid var(--line-2); }
.dg-head > div:first-child { border-left: 0; }
.dg-head .dg-daynum { display: block; font-size: 20px; color: var(--ink); font-weight: 700; letter-spacing: -.02em; }
.dg-head .is-today { color: var(--blue); }
.dg-head .is-today .dg-daynum { color: var(--blue); }
.dg-times { position: relative; }
.dg-times span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dg-col { position: relative; border-left: 1px solid var(--line-2); background: #f6f7f9; }
.dg-col::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1; background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour) - 1px), var(--line-2) calc(var(--hour) - 1px), var(--line-2) var(--hour)); }
.dg-col.is-today { background: #f2f5ff; }
.dg-open { position: absolute; left: 0; right: 0; background: #fff; z-index: 0; }
.dg-col.is-today .dg-open { background: #fbfcff; }
.dg-off { position: absolute; left: 3px; right: 3px; z-index: 2; border-radius: 8px; padding: 4px 6px; font-size: 11.5px; color: #4a5470; overflow: hidden; background: repeating-linear-gradient(135deg, #eceef3 0, #eceef3 6px, #f6f7f9 6px, #f6f7f9 12px); border: 1px solid rgba(11, 20, 48, .08); }
.dg-ev { position: absolute; z-index: 3; border-radius: 9px; padding: 4px 7px; font-size: 12px; line-height: 1.3; overflow: hidden; color: var(--ink); background: #eaf0ff; border-left: 3px solid var(--blue); box-shadow: 0 1px 2px rgba(11, 20, 48, .08); }
.dg-ev:hover { text-decoration: none; filter: brightness(.97); z-index: 4; }
.dg-ev b { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-ev span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.dg-ev.st-completed { background: var(--mint-50); border-left-color: var(--mint); }
.dg-ev.st-cancelled { background: #fdf3f2; border-left-color: var(--red); opacity: .75; }
.dg-ev.st-cancelled b { text-decoration: line-through; }
.dg-ev.st-no_show { background: var(--amber-50); border-left-color: #d98a1c; }
.dg-ev.st-held { background: var(--grey-50); border-left-color: #8a93aa; }
.dg-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--red); z-index: 5; pointer-events: none; }
.dg-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

.agenda { display: grid; gap: 12px; }
.ag-day { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow); }
.ag-day.is-today { border-color: rgba(35, 80, 245, .4); }
.ag-day h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 16px; }
.ag-day .ag-hours { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ag-list { margin-top: 10px; }
.ag-list > li + li { border-top: 1px solid var(--line-2); }
.ag-item { display: flex; gap: 12px; padding: 10px 0; color: var(--ink); min-height: 52px; align-items: center; }
.ag-item:hover { text-decoration: none; }
.ag-item .visit-time { width: 52px; }
.ag-off { display: flex; gap: 10px; align-items: center; padding: 10px 0; color: #4a5470; font-size: 14px; }

/* ---------- Services, hours, settings ---------- */
.svc-list { display: grid; gap: 16px; }
.svc-card .card-head { margin-bottom: 16px; align-items: flex-start; }
.svc-title { display: grid; gap: 6px; min-width: 0; }
.svc-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.svc-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }

.hours-day { padding: 14px 0; border-top: 1px solid var(--line-2); display: grid; gap: 10px; }
.hours-day:first-child { border-top: 0; padding-top: 0; }
.hours-day-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hours-day-head .strong { font-size: 15.5px; }
.hours-ranges { display: grid; gap: 10px; }
.hours-range { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) 44px; gap: 8px; align-items: end; max-width: 520px; }
.hours-range .to { color: var(--muted); padding-bottom: 12px; font-size: 14px; }
.hours-ranges > .btn { justify-self: start; }

.off-list > li { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line-2); }
.off-list > li:first-child { border-top: 0; }
.off-list .row-main { flex: 1; }

.settings-group { display: grid; gap: 16px; }
.settings-group .card-head { margin-bottom: 4px; display: block; }
.settings-group .card-head p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.save-bar { position: sticky; bottom: 0; z-index: 20; display: flex; justify-content: flex-end; gap: 10px; padding: 14px 0 4px; margin-top: 16px; background: linear-gradient(to top, var(--bg) 70%, rgba(245, 246, 248, 0)); }
@media (max-width: 899.98px) {
  .save-bar { bottom: calc(62px + env(safe-area-inset-bottom)); }
  .save-bar .btn { flex: 1; }
}

.more-list { padding: 6px 8px; }
.more-list a, .more-list button { display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 0 10px; width: 100%; border: 0; background: none; color: var(--ink); font-weight: 600; text-decoration: none; cursor: pointer; border-radius: 12px; text-align: left; font-size: 15.5px; }
.more-list li + li { border-top: 1px solid var(--line-2); }
.more-list .ic:last-child { margin-left: auto; color: #9aa3ba; }
.more-list .danger { color: var(--red); }

.check-list > li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.check-list .ic { margin-top: 2px; }
.check-list .ok { color: var(--mint-ink); }
.check-list .bad { color: var(--red); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 1000; left: 50%; transform: translateX(-50%); bottom: 24px; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
@media (max-width: 899.98px) { .toasts { bottom: auto; top: calc(12px + env(safe-area-inset-top)); } }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 14px; background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); font-weight: 550; font-size: 14.5px; pointer-events: auto; animation: toast-in .25s ease-out; }
.toast .ic { color: #7ee2c3; margin-top: 1px; }
.toast-error { background: #7d1a12; }
.toast-error .ic { color: #ffd2cc; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Dialog ---------- */
.dialog {
  border: 0; padding: 0; color: var(--ink); background: var(--card);
  width: min(560px, calc(100vw - 32px)); max-width: calc(100vw - 32px);
  max-height: min(88vh, 900px); max-height: min(88dvh, 900px);
  border-radius: 22px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.dialog.dialog-wide { width: min(720px, calc(100vw - 32px)); }
.dialog[open] { display: flex; flex-direction: column; }
.dialog::backdrop { background: rgba(11, 20, 48, .38); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 10px 10px 20px; border-bottom: 1px solid var(--line-2); flex: none; }
.dlg-head h2 { font-size: 18px; }
.dlg-form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.dlg-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 20px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; display: grid; gap: 16px; align-content: start; }
.dlg-foot { flex: none; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line-2); background: #fff; }
@media (max-width: 639.98px) {
  .dialog, .dialog.dialog-wide {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 22px 22px 0 0;
    max-height: 94vh; max-height: 94dvh;
  }
  .dlg-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .dlg-foot .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
