:root {
  --bg: #0b0b0d;
  --bg2: #111114;
  --card: #17171b;
  --card2: #1e1e24;
  --line: #2a2a32;
  --text: #f4f1ea;
  --muted: #8d8b96;
  --gold: #d9b26a;
  --gold2: #f1d38e;
  --gold-ink: #1a1304;
  --green: #4fc58a;
  --red: #ef6461;
  --blue: #6aa7ff;
  --radius: 18px;
  --tab-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: 'Heebo', system-ui, -apple-system, 'Segoe UI', sans-serif; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* Private account and cloud sync */
button:disabled { cursor: default; opacity: .5; }
.auth-screen { min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px; background: radial-gradient(ellipse at 50% 10%, #302516 0, transparent 65%); }
.auth-card { width: 100%; max-width: 390px; padding: 30px 24px 22px; background: var(--card); border: 1px solid #493922; border-radius: 24px; box-shadow: 0 24px 80px #0005; }
.auth-mark { width: 68px; height: 68px; display: grid; place-items: center; font-size: 38px; border: 1px solid #493922; border-radius: 20px; background: #241d14; margin: 0 auto 22px; }
.auth-eyebrow { color: var(--gold); font-size: 13px; margin: 0; text-align: center; }
.auth-card h1 { margin: 5px 0 8px; font-size: 32px; text-align: center; }
.auth-intro { text-align: center; color: #b8b5bd; font-size: 14px; margin: 0 0 26px; }
.auth-card form { display: grid; gap: 10px; }
.auth-card label { font-size: 14px; margin-top: 8px; }
.auth-card input { width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--bg2); color: var(--text); }
.auth-card input:focus { outline: 2px solid var(--gold); outline-offset: 2px; }
.auth-note { color: #aaa7b0; font-size: 13px; text-align: center; margin: 20px 0 0; }
.auth-credit { color: var(--muted); font-size: 11px; text-align: center; margin: 24px 0 0; }
.cloud-error { color: #ff9997; font-size: 13px; margin: 0; overflow-wrap: anywhere; }
.cloud-error:empty { display: none; }
.cloud-bar { max-width: 560px; margin: auto; padding: calc(var(--safe-t) + 4px) 16px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--green); border-bottom: 1px solid var(--line); font-size: 12px; }
.cloud-bar + .auth-screen.hidden + #app { padding-top: 12px; }
.cloud-bar[data-status="offline"], .cloud-bar[data-status="pending"], .cloud-bar[data-status="connecting"] { color: var(--gold); }
.cloud-bar[data-status="conflict"], .cloud-bar[data-status="error"] { color: #ff9997; }
.cloud-bar > span { flex: 1; }
.cloud-bar > div { display: flex; flex-shrink: 0; }
.cloud-link { min-height: 44px; padding: 4px 8px; color: #c0bdc5; font-size: 12px; }
.cloud-overlay { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; padding: 20px; background: #000b; backdrop-filter: blur(5px); }
.cloud-dialog { width: 100%; max-width: 480px; max-height: calc(100dvh - 40px); overflow-y: auto; border-radius: 22px; border: 1px solid #584426; padding: 22px; background: var(--card); }
.cloud-dialog h2 { margin: 0 0 14px; font-size: 22px; }
.cloud-dialog p { font-size: 14px; line-height: 1.7; color: #c0bdc5; }
.cloud-dialog .btn { margin-top: 10px; white-space: normal; height: auto; min-height: 48px; padding: 10px 14px; }
.cloud-choice { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 20px 0; min-width: 0; }
.cloud-choice legend { padding: 0 4px; color: var(--gold); font-size: 14px; }
.cloud-choice label { display: block; padding: 10px 0; font-size: 14px; overflow-wrap: anywhere; }
.cloud-choice input { accent-color: var(--gold); margin-inline-end: 8px; }
.cloud-choice span { color: #c0bdc5; }
.cloud-issues { font-size: 14px; line-height: 1.8; color: #ffbbb5; padding-inline-start: 20px; }
@media (max-width: 380px) { .cloud-overlay { padding: 12px; } .cloud-dialog { padding: 18px; } .auth-card { padding: 26px 20px 20px; } }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding: calc(var(--safe-t) + 14px) 16px calc(var(--tab-h) + var(--safe-b) + 28px); }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 18px; }
.top h1 { font-size: 26px; font-weight: 800; margin: 0; letter-spacing: -.3px; }
.top .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.gold { background: linear-gradient(135deg, var(--gold2), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.icon-btn { width: 42px; height: 42px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; font-size: 18px; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card, .card + .section, .section + .card { margin-top: 12px; }
.section { margin-top: 22px; }
.section h2 { font-size: 15px; color: var(--muted); font-weight: 500; margin: 0 4px 10px; display: flex; justify-content: space-between; align-items: center; }
.section h2 button { color: var(--gold); font-size: 14px; }

.next-card { background: linear-gradient(160deg, #2a2113 0%, #17171b 60%); border-color: #4a3b1f; position: relative; overflow: hidden; }
.next-card .lbl { color: var(--gold); font-size: 13px; font-weight: 500; letter-spacing: .3px; }
.next-card .big-time { font-size: 44px; font-weight: 800; line-height: 1; margin: 6px 0 4px; letter-spacing: -1px; }
.next-card .who { font-size: 19px; font-weight: 700; }
.next-card .what { color: var(--muted); font-size: 14px; margin-top: 2px; }
.next-card .actions { display: flex; gap: 8px; margin-top: 14px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 22px; font-weight: 800; }
.stat span { color: var(--muted); font-size: 12px; }

/* ---------- buttons ---------- */
.btn { white-space: nowrap; height: 46px; padding: 0 18px; border-radius: 14px; background: var(--card2); border: 1px solid var(--line); font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: linear-gradient(135deg, var(--gold2), var(--gold)); color: var(--gold-ink); border: 0; font-weight: 700; }
.btn.green { background: #14301f; border-color: #1f5236; color: var(--green); }
.btn.wa { background: #12301f; border-color: #1c5a37; color: #4fe08f; }
.btn.danger { color: var(--red); border-color: #4a2423; background: #231415; }
.btn.block { width: 100%; }
.btn.sm { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 11px; }
.btn.flex1 { flex: 1; }
.btn:active { transform: scale(.97); }
.row { display: flex; gap: 8px; }
.row.wrap { flex-wrap: wrap; }

/* ---------- list items ---------- */
.item { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; width: 100%; text-align: right; }
.item + .item { margin-top: 8px; }
.item .time { min-width: 52px; font-weight: 700; font-size: 17px; }
.item .time small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.item .meta { flex: 1; min-width: 0; }
.item .meta b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta span { color: var(--muted); font-size: 13px; }
.dot { width: 8px; align-self: stretch; border-radius: 6px; background: var(--gold); flex: none; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, #3a2f19, #1d1a12); border: 1px solid #4a3b1f; display: grid; place-items: center; font-weight: 700; color: var(--gold2); flex: none; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 99px; background: var(--card2); color: var(--muted); }
.badge.done { background: #14301f; color: var(--green); }
.badge.noshow { background: #3a1d1d; color: var(--red); }
.badge.cancelled { background: #2a2a32; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 9px 14px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); font-weight: 500; font-size: 15px; }
.chip.on { background: linear-gradient(135deg, var(--gold2), var(--gold)); color: var(--gold-ink); border: 0; font-weight: 700; }

/* ---------- calendar ---------- */
.week { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.week .days { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.wd { padding: 8px 0 7px; border-radius: 14px; text-align: center; background: var(--card); border: 1px solid transparent; position: relative; }
.wd small { display: block; color: var(--muted); font-size: 11px; }
.wd b { font-size: 17px; font-weight: 700; }
.wd.today b { color: var(--gold); }
.wd.sel { background: linear-gradient(160deg, var(--gold2), var(--gold)); color: var(--gold-ink); }
.wd.sel small, .wd.sel b { color: var(--gold-ink); }
.wd.has::after { content: ''; position: absolute; bottom: 3px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--gold); }
.wd.sel.has::after { background: var(--gold-ink); }
.wd.closed { opacity: .45; }
.week .nav { width: 30px; height: 52px; color: var(--muted); font-size: 20px; }

.day-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.day-head h2 { margin: 0; font-size: 18px; }
.day-head span { color: var(--muted); font-size: 13px; }

.tl { position: relative; margin-right: 0; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; touch-action: pan-y; }
.tl .hr { position: absolute; right: 0; left: 0; border-top: 1px solid #1e1e24; }
.tl .hr span { position: absolute; right: 10px; top: -9px; background: var(--bg2); padding: 0 4px; font-size: 11px; color: var(--muted); }
.tl .hr.half { border-top-style: dashed; border-color: #17171c; }
.tl .off { position: absolute; right: 0; left: 0; background: repeating-linear-gradient(135deg, #131316 0 8px, #0f0f12 8px 16px); }
.tl .ap { line-height: 1.25; position: absolute; right: 52px; left: 8px; border-radius: 12px; padding: 6px 10px; overflow: hidden; border: 1px solid rgba(255,255,255,.08); text-align: right; cursor: pointer; display: flex; flex-direction: column; justify-content: center; }
.tl .ap b { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.tl .ap span { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl .ap.done { opacity: .55; }
.tl .ap.noshow { opacity: .5; filter: grayscale(1); }
.tl .ap.blk { background: repeating-linear-gradient(135deg, #26262d 0 8px, #202026 8px 16px) !important; color: var(--muted); }
.tl .ap.blk b { color: var(--muted); }
.tl .now { position: absolute; right: 0; left: 0; height: 2px; background: var(--red); z-index: 3; pointer-events: none; }
.tl .now::before { content: ''; position: absolute; right: 44px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; bottom: 0; right: 0; left: 0; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: rgba(14,14,17,.92); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--line); display: flex; justify-content: center; z-index: 20; }
.tabbar .in { width: 100%; max-width: 560px; display: grid; grid-template-columns: 1fr 1fr 74px 1fr 1fr; align-items: center; }
.tab { height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; }
.tab svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--gold); }
.fab { width: 58px; height: 58px; border-radius: 20px; margin: -26px auto 0; background: linear-gradient(135deg, var(--gold2), var(--gold)); color: var(--gold-ink); display: grid; place-items: center; box-shadow: 0 10px 28px rgba(217,178,106,.35); }
.fab svg { width: 28px; height: 28px; stroke: currentColor; stroke-width: 2.6; fill: none; stroke-linecap: round; }
.fab:active { transform: scale(.94); }

/* ---------- sheet ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; animation: fade .18s ease; }
.sheet { position: fixed; bottom: 0; right: 0; left: 0; z-index: 41; max-width: 560px; margin: 0 auto; max-height: 92dvh; overflow-y: auto; background: var(--bg2); border: 1px solid var(--line); border-bottom: 0; border-radius: 26px 26px 0 0; padding: 10px 18px calc(24px + var(--safe-b)); animation: up .24s cubic-bezier(.2,.8,.2,1); }
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: #34343d; margin: 4px auto 14px; }
.sheet h3 { margin: 0 0 14px; font-size: 20px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- forms ---------- */
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; color: var(--muted); font-size: 13px; margin: 0 2px 6px; }
input, select, textarea { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; height: 48px; outline: none; color: var(--text); appearance: none; -webkit-appearance: none; }
textarea { height: 84px; padding: 12px 14px; resize: none; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: 18px 21px, 24px 21px; background-size: 6px 6px; background-repeat: no-repeat; padding-left: 40px; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
input[type=checkbox] { width: 24px; height: 24px; padding: 0; flex: none; border-radius: 8px; border: 1.5px solid #4a4a55; background: var(--card); position: relative; }
input[type=checkbox]:checked { background: linear-gradient(135deg, var(--gold2), var(--gold)); border-color: transparent; }
input[type=checkbox]:checked::after { content: ''; position: absolute; left: 7px; top: 3px; width: 6px; height: 12px; border: solid var(--gold-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
input[type=checkbox]:disabled { opacity: .4; }
.credit { text-align: center; color: var(--muted); font-size: 13px; margin: 28px 0 8px; }
.credit b { color: var(--gold); font-weight: 600; }
input[type=color] { padding: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.search { margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 12.5px; margin: -6px 2px 14px; }
.sw { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px; }
.dayrow { display: grid; grid-template-columns: 56px 1fr 1fr; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.dayrow:first-child { border-top: 0; }
.dayrow .nm { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dayrow input { height: 40px; padding: 0 8px; font-size: 14px; }
.dayrow .brk { grid-column: 1 / -1; display: grid; grid-template-columns: 56px 1fr 1fr; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }

/* ---------- misc ---------- */
.lock { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-items: center; text-align: center; padding: 24px; }
.lock .pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 14px; justify-content: center; margin-top: 26px; }
.lock .pad button { height: 72px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); font-size: 26px; font-weight: 500; }
.lock .dots { display: flex; gap: 14px; justify-content: center; margin: 20px 0 0; }
.lock .dots i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--gold); }
.lock .dots i.on { background: var(--gold); }
.lock.err .dots { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
#toast { position: fixed; bottom: calc(var(--tab-h) + var(--safe-b) + 20px); right: 50%; transform: translate(50%, 20px); background: #25252c; border: 1px solid var(--line); padding: 11px 18px; border-radius: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; font-weight: 500; }
#toast.on { opacity: 1; transform: translate(50%, 0); }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; color: var(--muted); font-size: 14px; }
.kv b { color: var(--text); font-weight: 600; }
.note { background: #1c1a12; border: 1px solid #3a3320; color: #e6d7ae; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-top: 10px; }
