:root {
  --bg: #f3ece0;
  --card: #fffdf9;
  --ink: #2c2a22;
  --muted: #776e5f;
  --line: #e4dac8;
  --olive: #56663a;
  --olive-deep: #36411f;
  --olive-soft: #e5e8d6;
  --hold: #d4952e;
  --hold-soft: #fbeed5;
  --danger: #b3432f;
  --free: #e9e1d2;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(60, 45, 20, .05), 0 6px 20px -8px rgba(60, 45, 20, .16);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.6 'Tajawal', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--olive); }
h1, h2, h3 { margin: 0; line-height: 1.35; }
p { margin: 0; }
[hidden] { display: none !important; }
.ico { width: 1.25em; height: 1.25em; flex: none; }
:focus-visible { outline: 2px solid var(--hold); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; min-height: 44px; padding: 0 20px; border-radius: 12px; font-weight: 700; white-space: nowrap; transition: background-color .2s, transform .1s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; }
.btn--sm { min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn--primary { background: var(--olive); color: #fff; }
.btn--primary:hover { background: var(--olive-deep); }
.btn--ghost { background: #f1ebdf; }
.btn--ghost:hover { background: #e8e0d0; }
.btn--danger { background: #f7e1dc; color: var(--danger); }
.btn--danger:hover { background: #f0cfc7; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); }
.iconbtn:hover { background: var(--olive-soft); }

/* login */
.login { min-height: 100svh; display: grid; place-items: center; padding: 16px; }
.login__card { width: min(380px, 100%); background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 32px 24px; display: grid; gap: 12px; text-align: center; }
.login__mark { width: 56px; height: 56px; margin: 0 auto 4px; border-radius: 50%; background: var(--olive); color: #fff; display: grid; place-items: center; }
.login__mark .ico { width: 28px; height: 28px; }
.login__card h1 { font-size: 22px; }
.login__card p { color: var(--muted); }
.login__card input { height: 48px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 14px; background: #fff; text-align: center; font-size: 16px; }
.login__card input:focus { border-color: var(--olive); outline: none; }
.login__error { color: var(--danger) !important; min-height: 1.6em; font-weight: 700; }

/* app shell */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px; padding: 10px 16px; background: var(--olive-deep); color: #fff; }
.top__brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; margin-inline-end: auto; min-width: 0; }
.top__brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top__mark { width: 32px; height: 32px; border-radius: 50%; background: rgba(255, 255, 255, .14); display: grid; place-items: center; flex: none; }
.top__link { color: #fff; font-size: 14px; padding: 8px 10px; border-radius: 8px; text-decoration: none; opacity: .9; }
.top__link:hover { background: rgba(255, 255, 255, .12); }
.tabs { display: flex; gap: 4px; padding: 10px 12px 0; overflow-x: auto; max-width: 1200px; margin: 0 auto; scrollbar-width: none; }
.tab { flex: none; padding: 10px 12px; border-radius: 12px 12px 0 0; font-weight: 700; color: var(--muted); }
.tab.is-active { background: var(--card); color: var(--ink); box-shadow: 0 -2px 0 var(--olive) inset; }
.panel { max-width: 1200px; margin: 0 auto; padding: 12px 12px 48px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
@media (min-width: 600px) { .card { padding: 22px; } .panel { padding-inline: 20px; } .tabs { padding-inline: 20px; } }
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
@media (min-width: 900px) { .layout { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 18px; } .day { position: sticky; top: 72px; } }

/* calendar */
.cal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal__head h2 { font-size: 20px; }
.cal__weekdays, .cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal__weekdays span { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding-bottom: 4px; }
.cal__grid { transition: opacity .2s; min-height: 250px; }
.cal__grid.is-loading { opacity: .4; pointer-events: none; }
.cell { aspect-ratio: 1 / 1.1; border-radius: 10px; background: #f8f4ec; border: 1.5px solid transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
@media (min-width: 900px) { .cell { aspect-ratio: auto; height: 64px; } }
.cell:hover { border-color: var(--olive); }
.cell--blank { background: none; }
.cell--past { opacity: .5; }
.cell--today { border-color: var(--hold); }
.cell--holiday .cell__num { color: #b8653f; text-decoration: underline; text-underline-offset: 3px; }
.cell.is-selected { border-color: var(--olive); background: var(--olive-soft); box-shadow: 0 0 0 2px var(--olive) inset; }
.cell__num { font-weight: 800; font-size: 15px; line-height: 1; }
/* Same key as the public calendar: morning | evening on top, full day below spanning both. */
.cell__chips { display: grid; grid-template-columns: 14px 14px; gap: 2px; }
.cell__chips .chip { width: auto; height: 7px; }
.cell__chips .chip:nth-child(3) { grid-column: 1 / -1; }
@media (min-width: 900px) { .cell__chips { grid-template-columns: 20px 20px; } .cell__chips .chip { height: 8px; } }
.chip { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.chip--free { background: var(--free); box-shadow: 0 0 0 1px #d6ccb9 inset; }
.chip--confirmed { background: var(--olive); }
.chip--hold { background: var(--hold); }
.chip--blocked { background: repeating-linear-gradient(45deg, #cfc4b1 0 2px, #eee7da 2px 4px); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend__key { flex-basis: 100%; gap: 10px !important; }
.legend__key .cell__chips { grid-template-columns: 22px 22px; }
.legend__key .chip { height: 8px; }
.legend .legend__key-labels { display: grid; grid-template-columns: auto auto; gap: 0 10px; font-size: 12px; line-height: 1.5; }
.legend .legend__key-labels span { display: block; }
.legend .legend__key-labels span:last-child { grid-column: 1 / -1; }
.legend__holiday { font-style: normal; font-weight: 800; color: #b8653f; text-decoration: underline; }
.cal__stats { margin-top: 10px; font-weight: 700; color: var(--olive-deep); font-size: 14px; }

/* day panel */
.day { scroll-margin-top: 64px; }
.day__empty { color: var(--muted); text-align: center; padding: 24px 0; }
.day__head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.day__head h3 { font-size: 19px; }
.day__type { color: #b8653f; font-size: 13px; font-weight: 700; }
.day__switches { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.switch.switch--danger input:checked + .switch__track { background: var(--danger); }
.closed-box { border: 1.5px dashed var(--danger); background: #fcf1ee; border-radius: 14px; padding: 14px; display: grid; gap: 8px; }
.closed-box strong { color: var(--danger); }
.closed-box p { color: var(--muted); font-size: 14px; }
.cell--closed { background: repeating-linear-gradient(45deg, #f7e6e1 0 6px, #fbf3f0 6px 12px); }
.cell--closed .cell__num { color: var(--danger); text-decoration: line-through; }
.cell--closed .cell__chips { visibility: hidden; }
.hold-timer { font-size: 13px; color: #9a6614; font-weight: 700; margin-top: 6px; }
.slots { display: grid; gap: 10px; }
.slot { border: 1.5px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 10px; }
.slot--free { grid-template-columns: 1fr auto; align-items: center; }
.slot--confirmed { border-color: var(--olive); background: #f7f8f1; }
.slot--hold { border-color: var(--hold); background: #fffaf0; }
.slot--blocked { background: #f6f2ea; border-style: dashed; }
.slot__head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.slot__head strong { display: block; }
.slot__head small { display: block; color: var(--muted); font-size: 12.5px; }
.slot__head small.slot__price { color: var(--olive-deep); font-weight: 700; }
.slot__icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--olive-soft); color: var(--olive); flex: none; }
.slot__note { color: var(--muted); font-size: 13.5px; }
.badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 999px; }
.badge--confirmed { background: var(--olive); color: #fff; }
.badge--hold { background: var(--hold-soft); color: #9a6614; }
.booking dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; font-size: 14px; }
.booking dt { color: var(--muted); }
.booking dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.booking__actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; font-weight: 500; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track { width: 42px; height: 24px; border-radius: 999px; background: #d9cfbd; position: relative; flex: none; transition: background-color .2s; }
.switch__track::after { content: ''; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch input:checked + .switch__track { background: var(--olive); }
.switch input:checked + .switch__track::after { transform: translateX(-18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--hold); outline-offset: 2px; }

/* upcoming */
.list-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.list-head h2 { font-size: 19px; }
.filter { display: flex; background: var(--bg); padding: 3px; border-radius: 10px; }
.filter button { padding: 6px 14px; border-radius: 8px; font-size: 14px; font-weight: 700; color: var(--muted); }
.filter button.is-active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.up { border-top: 1px solid var(--line); padding: 12px 0; }
.up:first-child { border-top: 0; }
.up__date { font-weight: 800; margin-bottom: 6px; text-align: start; }
.up__date:hover { color: var(--olive); }
.up__date em { font-style: normal; background: var(--hold-soft); color: #9a6614; font-size: 12px; padding: 1px 8px; border-radius: 999px; margin-inline-start: 4px; }
.up__row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 4px 0; font-size: 14px; }
.up__name { font-weight: 500; }
.up__phone { color: var(--muted); text-decoration: none; }
.up__hold { font-size: 12px; font-weight: 800; color: #9a6614; }
.empty { color: var(--muted); text-align: center; padding: 28px 0; }

/* pricing */
.pricing { display: grid; gap: 14px; max-width: 760px; }
.pricing h2 { font-size: 18px; margin-top: 10px; }
.pricing h2:first-child { margin-top: 0; }
.pricing h2 small { color: var(--muted); font-weight: 500; font-size: 13px; }
.matrix { display: grid; gap: 8px; }
.matrix__row { display: grid; grid-template-columns: minmax(90px, 1.2fr) repeat(3, 1fr); gap: 6px; align-items: center; }
.matrix__row--head span { font-size: 13px; font-weight: 800; color: var(--muted); text-align: center; }
.matrix__label strong { display: block; font-size: 14px; }
.matrix__label small { color: var(--muted); font-size: 11.5px; }
.matrix input, .field input, .field textarea { width: 100%; min-width: 0; height: 44px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 10px; background: #fff; }
.matrix input { text-align: center; font-weight: 700; font-size: 14px; padding: 0 4px; }
.field textarea { height: auto; padding: 10px; resize: vertical; line-height: 1.6; }
.matrix input:focus, .field input:focus, .field textarea:focus { border-color: var(--olive); outline: none; }
.matrix input.is-bad { border-color: var(--danger); background: #fdf3f1; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--muted); }
.grid2 { display: grid; gap: 10px; }
@media (min-width: 520px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.hint { font-size: 13.5px; color: var(--olive-deep); background: var(--olive-soft); padding: 8px 12px; border-radius: 10px; }
.savebar { position: sticky; bottom: 0; padding: 12px 0 calc(4px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--card) 30%); }
.savebar .btn { width: 100%; }

/* dialog */
.dialog { width: min(460px, 100% - 24px); border: 0; border-radius: 20px; padding: 0; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .4); color: var(--ink); background: var(--card); }
.dialog::backdrop { background: rgba(30, 28, 20, .5); }
.dialog form { padding: 22px 18px 18px; display: grid; gap: 12px; }
.dialog h3 { font-size: 19px; }
.dialog__sub { color: var(--muted); margin-top: -8px; }
.dialog__error { color: var(--danger); font-weight: 700; min-height: 1em; font-size: 14px; }
.dialog__error:empty { display: none; }
.dialog__actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); padding: 3px; border-radius: 12px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 8px 6px; border-radius: 9px; font-size: 13.5px; font-weight: 700; color: var(--muted); }
.seg input:checked + span { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg input[value="hold"]:checked + span { color: #9a6614; }
.seg input:focus-visible + span { outline: 2px solid var(--hold); }

/* toast */
.toast { position: fixed; z-index: 100; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; translate: -50% 20px; max-width: calc(100% - 32px); background: var(--olive-deep); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 700; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .4); opacity: 0; pointer-events: none; transition: opacity .25s, translate .25s; }
.toast.is-on { opacity: 1; translate: -50% 0; }
.toast--bad { background: var(--danger); }
