/* BookFlow UI.
   Mobile-first: the customer is standing in a driveway on a phone, and the
   owner is checking the diary with dirty hands. Big targets, plain words,
   one decision per screen. */

:root {
  --bg:        #f6f7f9;
  --surface:   #ffffff;
  --surface-2: #eef1f5;
  --line:      #dde2e9;
  --ink:       #10161f;
  --ink-2:     #4d5865;
  --ink-3:     #7b8695;
  --brand:     #1d63d1;
  --brand-ink: #ffffff;
  --ok:        #0f7a4d;
  --ok-bg:     #e3f5ec;
  --warn:      #a35b00;
  --warn-bg:   #fdf0dd;
  --live:      #12a150;
  --danger:    #b3261e;
  --danger-bg: #fbe9e8;
  --radius:    14px;
  --shadow:    0 1px 2px rgba(16,22,31,.06), 0 6px 20px rgba(16,22,31,.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0e1219;
    --surface:   #161c26;
    --surface-2: #1e2634;
    --line:      #2b3546;
    --ink:       #eef2f7;
    --ink-2:     #aeb9c7;
    --ink-3:     #7d8899;
    --brand:     #5b9bf8;
    --brand-ink: #06182f;
    --ok:        #5ed6a0;
    --ok-bg:     #0f2f22;
    --warn:      #f0b45e;
    --warn-bg:   #33240d;
    --live:      #3ed07f;
    --danger:    #ff8a80;
    --danger-bg: #34120f;
    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 96px; }
.wide { max-width: 1080px; }

/* ---------------------------------------------------------------- header */

header.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}
header.top .inner { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
header.top.wide .inner { max-width: 1080px; }
header.top h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
header.top .sub { color: var(--ink-3); font-size: 13px; margin-top: 1px; }

.live-dot {
  margin-left: auto; display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--ink-3); white-space: nowrap;
}
.live-dot i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--live);
  box-shadow: 0 0 0 0 rgba(18,161,80,.55); animation: pulse 2.2s infinite;
}
.live-dot.off i { background: var(--ink-3); animation: none; box-shadow: none; }
@keyframes pulse {
  70%  { box-shadow: 0 0 0 7px rgba(18,161,80,0); }
  100% { box-shadow: 0 0 0 0 rgba(18,161,80,0); }
}

/* ---------------------------------------------------------------- steps */

.steps { display: flex; gap: 6px; margin: 18px 0 20px; }
.steps div {
  flex: 1; height: 4px; border-radius: 2px; background: var(--line);
  transition: background .25s;
}
.steps div.done { background: var(--brand); }
.step-label { color: var(--ink-3); font-size: 13px; margin-bottom: 6px; }

h2.section { font-size: 22px; margin: 4px 0 16px; letter-spacing: -.02em; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

button.pick {
  width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
  color: var(--ink); font: inherit; display: flex; gap: 14px; align-items: center;
  transition: border-color .15s, transform .06s, background .15s;
}
button.pick:hover { border-color: var(--brand); }
button.pick:active { transform: scale(.995); }
button.pick[aria-selected="true"] { border-color: var(--brand); background: var(--surface-2); }
button.pick .grow { flex: 1; min-width: 0; }
button.pick .name { font-weight: 600; }
button.pick .meta { color: var(--ink-3); font-size: 13.5px; margin-top: 3px; }
button.pick .price { font-weight: 700; font-size: 17px; white-space: nowrap; }
button.pick .chev { color: var(--ink-3); }

/* ---------------------------------------------------------------- days & slots */

.days { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: thin; }
.day {
  flex: 0 0 auto; width: 68px; padding: 10px 6px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  text-align: center; color: var(--ink); font: inherit;
}
.day .dw  { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.day .dn  { font-size: 20px; font-weight: 700; margin: 2px 0; }
.day .free{ font-size: 11px; color: var(--ok); font-weight: 600; }
.day[aria-selected="true"] { border-color: var(--brand); background: var(--surface-2); }
.day.empty { opacity: .45; cursor: not-allowed; }
.day.empty .free { color: var(--ink-3); font-weight: 400; }

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.slot {
  padding: 14px 6px; border-radius: 12px; cursor: pointer; font: inherit;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; text-align: center; transition: border-color .15s, background .15s;
}
.slot:hover { border-color: var(--brand); }
.slot .until { display: block; font-size: 11px; color: var(--ink-3); font-weight: 400; margin-top: 2px; }
.slot.taken { opacity: .35; pointer-events: none; text-decoration: line-through; }
.slot.fresh { animation: fadein .4s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(-3px); } }

/* ---------------------------------------------------------------- form */

label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: 13.5px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }
input, textarea, select {
  width: 100%; padding: 13px 14px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
textarea { min-height: 84px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 18px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 650; font-size: 16px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--danger-bg); color: var(--danger); border: 1px solid transparent; }
.btn.sm { width: auto; padding: 9px 14px; font-size: 14px; border-radius: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.link { background: none; border: 0; color: var(--brand); font: inherit; cursor: pointer; padding: 8px 0; }

/* ---------------------------------------------------------------- status */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; font-size: 13px; font-weight: 650;
  background: var(--surface-2); color: var(--ink-2);
}
.pill.confirmed   { background: var(--ok-bg);     color: var(--ok); }
.pill.in_progress { background: var(--warn-bg);   color: var(--warn); }
.pill.completed   { background: var(--surface-2); color: var(--ink-2); }
.pill.held        { background: var(--warn-bg);   color: var(--warn); }
.pill.cancelled,
.pill.no_show     { background: var(--danger-bg); color: var(--danger); }

/* The process, drawn. Both sides see this same ladder. */
.track { list-style: none; margin: 18px 0 0; padding: 0; }
.track li { display: flex; gap: 14px; padding-bottom: 20px; position: relative; }
.track li:last-child { padding-bottom: 0; }
.track li::before {
  content: ""; position: absolute; left: 11px; top: 26px; bottom: 0; width: 2px; background: var(--line);
}
.track li:last-child::before { display: none; }
.track .dot {
  flex: 0 0 24px; height: 24px; border-radius: 50%; background: var(--surface-2);
  border: 2px solid var(--line); display: grid; place-items: center;
  font-size: 12px; color: var(--ink-3); z-index: 1;
}
.track li.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.track li.current .dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.track .what { font-weight: 600; }
.track .when { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.track li.pending .what { color: var(--ink-3); font-weight: 500; }

/* ---------------------------------------------------------------- diary */

.diary { display: grid; gap: 10px; }
.job {
  display: grid; grid-template-columns: 78px 1fr auto; gap: 14px; align-items: start;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.job.confirmed   { border-left-color: var(--brand); }
.job.in_progress { border-left-color: var(--warn); background: var(--warn-bg); }
.job.completed   { border-left-color: var(--ok); opacity: .72; }
.job.held        { border-left-color: var(--ink-3); border-style: dashed; }
.job.no_show     { border-left-color: var(--danger); opacity: .7; }
.job .when { font-weight: 700; font-size: 15px; }
.job .when small { display: block; color: var(--ink-3); font-weight: 400; font-size: 12px; }
.job .who { color: var(--ink-2); font-size: 14px; margin-top: 3px; }
.job .title { font-weight: 600; }
.job.fresh { animation: land .5s ease; }
@keyframes land {
  0%   { background: var(--ok-bg); transform: translateY(-4px); }
  100% { transform: none; }
}

.gap {
  text-align: center; color: var(--ink-3); font-size: 13px;
  border: 1px dashed var(--line); border-radius: 10px; padding: 8px;
}

.stats { display: flex; gap: 10px; margin-bottom: 16px; }
.stat { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; }
.stat b { display: block; font-size: 24px; letter-spacing: -.02em; }
.stat span { color: var(--ink-3); font-size: 12.5px; }

.muted { color: var(--ink-3); }
.empty-state { text-align: center; color: var(--ink-3); padding: 40px 20px; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 550; z-index: 60; box-shadow: var(--shadow); max-width: 90vw;
}
.toast.err { background: var(--danger); color: #fff; }

.sticky-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.sticky-foot .inner { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.sticky-foot .summary { flex: 1; min-width: 0; font-size: 13.5px; }
.sticky-foot .summary b { display: block; font-size: 15px; }

.countdown { font-variant-numeric: tabular-nums; font-weight: 700; }
