/* Fern & Fringe dashboard (KP Labs demo). System fonts only, no external requests. */
:root {
  --paper: #FAF8F5; --card: #fff; --line: #E7E2DA; --line-strong: #8A8278;
  --ink: #1E1C21; --ink-soft: #5D5862; --accent: #5B2A6E; --accent-soft: #F1E8F4; --now: #C2410C;
  --booked: #EEF2F7; --booked-bar: #4A6283; --arrived: #FDF2DC; --arrived-bar: #9A6200;
  --chair: #F1E8F4; --chair-bar: #5B2A6E; --done: #E8F3EC; --done-bar: #2F6B47;
  --noshow: #FBEAE8; --noshow-bar: #B42318;
  --err: #B42318; --row: 20px; --gutter: 56px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums; overflow-wrap: break-word;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
small { font-size: 12px; }
.ic { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: 0 0 0 2px #fff; }
.sub { color: var(--ink-soft); font-size: 13px; }
.soft { color: var(--ink-soft); }

.nojs { max-width: 560px; margin: 48px auto; padding: 0 20px; display: grid; gap: 12px; }
.nojs h1 { font-size: 22px; }

/* banner and top bar */
.banner { background: var(--ink); color: #F4F1EC; padding: 8px 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px; font-size: 13px; }
.banner[hidden] { display: none; }
.banner button { background: none; border: 0; color: inherit; text-decoration: underline; min-height: 32px; padding: 0 4px; }
.banner :focus-visible { outline-color: #fff; box-shadow: none; }
.top { display: flex; align-items: center; gap: 16px; padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 17px; color: var(--ink); }
.brand .ic { color: var(--accent); width: 20px; height: 20px; }
.daynav { display: flex; align-items: center; gap: 4px; margin-left: 12px; }
.daynav button { min-width: 36px; height: 36px; border: 1px solid var(--line-strong); background: var(--card); border-radius: 8px; font-size: 18px; line-height: 1; }
.daynav .today { padding: 0 12px; font-size: 14px; }
.daynav h1 { font-size: 20px; font-weight: 600; margin-left: 10px; }
.spacer { flex: 1; }
.chip { font-size: 12px; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: #fff; border: 0; border-radius: 999px; min-height: 40px; padding: 0 18px; font-weight: 600; }
.primary .ic { width: 16px; height: 16px; }
.primary:hover { background: #4a2159; }
.ghost { background: var(--card); border: 1px solid var(--line-strong); border-radius: 999px; min-height: 32px; padding: 0 12px; font-size: 13px; white-space: nowrap; }
.ghost:hover { background: var(--paper); }

/* layout (desktop first areas, then smaller screens override) */
.layout { display: grid; gap: 20px; padding: 20px 24px; grid-template-columns: minmax(0, 1fr) 320px; grid-template-rows: auto auto auto 1fr;
  grid-template-areas: "cal today" "cal week" "cal due" "cal ."; align-items: start; }
.p-today { grid-area: today; } .cal { grid-area: cal; } .p-week { grid-area: week; } .p-due { grid-area: due; }
.mob { display: none; }
.layout:not(.ready) { visibility: hidden; animation: reveal 0s 2s forwards; } /* hidden until JS fills the panels (no layout shift); fail-safe shows it after 2s */
@keyframes reveal { to { visibility: visible; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.panel h2 { font-size: 15px; font-weight: 600; }
.p-today, .p-week, .p-due { padding: 16px; }
.p-today h2 { margin-bottom: 12px; }
.p-week h2, .p-due h2 { margin-bottom: 2px; }
.p-week .sub, .p-due .sub { margin-bottom: 12px; }
@media (min-width: 900px) and (max-width: 1199px) {
  .layout { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: auto auto; grid-template-areas: "cal cal cal" "today week due"; }
}

/* today figures */
.figs { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.fig .l { font-size: 12px; color: var(--ink-soft); }
.fig .n { font-size: 28px; font-weight: 600; line-height: 1.2; }
.fig .n small { font-size: 15px; font-weight: 400; color: var(--ink-soft); }
.fig .c { font-size: 12px; color: var(--ink-soft); }
.track { height: 6px; background: var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.track i { display: block; height: 100%; background: var(--accent); }
.next { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; }

/* calendar */
.cal { overflow: hidden; }
.calscroll { overflow: auto; max-height: max(480px, calc(100vh - 230px)); }
#calin { min-width: 640px; }
.calhead, .calbody { display: grid; grid-template-columns: var(--gutter) minmax(0, 1fr); }
.calhead { position: sticky; top: 0; z-index: 3; background: var(--card); border-bottom: 1px solid var(--line); grid-template-columns: var(--gutter) repeat(4, minmax(0, 1fr)); }
.colhead { padding: 10px 12px; font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.colhead small { font-weight: 400; color: var(--ink-soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.times { position: relative; }
.times span { position: absolute; right: 8px; font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.cols { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(#F3EFE9 1px, transparent 1px);
  background-size: 100% calc(var(--row) * 4), 100% calc(var(--row) * 2); }
.cols > i { border-left: 1px solid var(--line); }
.blocks { position: absolute; inset: 0; }
.cols.live .blocks { cursor: cell; }
.appt { position: absolute; width: calc(25% - 8px); border: 0; border-radius: 6px; text-align: left; padding: 5px 8px 5px 12px; overflow: hidden; font-size: 13px; line-height: 1.3;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-content: start; column-gap: 6px; cursor: pointer; }
.appt::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.appt .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt .st { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.appt .st .ic { width: 13px; height: 13px; }
.appt .svc, .appt .tm { grid-column: 1 / -1; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt.sm { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; align-content: center; padding: 0 8px 0 12px; font-size: 12px; line-height: 1.2; }
.appt.sm .nm { grid-row: 1; grid-column: 1; }
.appt.sm .svc { grid-column: 2; grid-row: 1; }
.appt.sm .st { grid-row: 1; grid-column: 3; }
.appt:hover { filter: brightness(.97); }
.s-booked { background: var(--booked); } .s-booked::before { background: var(--booked-bar); }
.s-arrived { background: var(--arrived); } .s-arrived::before { background: var(--arrived-bar); }
.s-chair { background: var(--chair); } .s-chair::before { background: var(--chair-bar); }
.s-done { background: var(--done); } .s-done::before { background: var(--done-bar); }
.s-noshow { background: repeating-linear-gradient(135deg, var(--noshow) 0 8px, #F7DEDB 8px 10px); } .s-noshow::before { background: var(--noshow-bar); }
.s-noshow .nm { text-decoration: line-through; }
.now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--now); z-index: 2; pointer-events: none; }
.now span { position: absolute; right: 0; top: -11px; background: var(--now); color: #fff; font-size: 11px; line-height: 1.5; border-radius: 4px; padding: 0 5px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; border-left: 4px solid; display: inline-block; }
.legend .s-booked { border-color: var(--booked-bar); } .legend .s-arrived { border-color: var(--arrived-bar); }
.legend .s-chair { border-color: var(--chair-bar); } .legend .s-done { border-color: var(--done-bar); } .legend .s-noshow { border-color: var(--noshow-bar); }
.legend-note { margin-left: auto; }
.closed { padding: 40px 24px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.closed h3 { font-size: 20px; }
.closed p { max-width: 420px; color: var(--ink-soft); }
.empty { padding: 24px 0; color: var(--ink-soft); }

/* week bars */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; align-items: end; }
.wb { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; font-size: 11px; color: var(--ink-soft); min-width: 0; }
.wb .v { margin-bottom: 3px; white-space: nowrap; }
.wb i { display: block; width: 100%; background: #CFC6D8; border-radius: 4px 4px 0 0; }
.wb.fut i { background: repeating-linear-gradient(135deg, #E4DEEA 0 4px, #CFC6D8 4px 6px); }
.wb.shut i { background: var(--line); }
.wb.sel { color: var(--ink); font-weight: 600; }
.wb.sel i { background: var(--accent); }
.wb .dn { margin-top: 4px; }

/* due back */
.due li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.due li:first-child { border-top: 0; }
.due small { display: block; color: var(--ink-soft); }

/* dialogs */
dialog { border: 0; padding: 0; color: var(--ink); background: var(--card); }
dialog::backdrop { background: rgba(30, 28, 33, .4); }
.dbox { padding: 24px; display: grid; gap: 14px; align-content: start; position: relative; }
.drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(380px, 100vw); max-width: none; height: 100%; max-height: none; border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(30, 28, 33, .16); overflow: auto; }
.modal { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); border-radius: 12px; overflow: auto; box-shadow: 0 20px 50px rgba(30, 28, 33, .25); }
.drawer h2, .modal h2 { font-size: 22px; font-weight: 600; }
#dbody { min-height: 100%; }
.eyebrow { font-size: 12px; color: var(--ink-soft); margin-bottom: -10px; }
.close { position: absolute; right: 14px; top: 14px; width: 40px; height: 40px; border: 1px solid var(--line); background: var(--card); border-radius: 50%; display: grid; place-items: center; }
.close .ic { width: 16px; height: 16px; }
.steps { display: flex; gap: 4px; font-size: 12px; }
.steps li { flex: 1; text-align: center; padding: 6px 2px; border-radius: 999px; background: var(--paper); color: var(--ink-soft); border: 1px solid var(--line); }
.steps .on { background: var(--arrived); color: var(--ink); border-color: var(--arrived-bar); font-weight: 600; }
.steps .past { background: var(--done); color: var(--ink); border-color: transparent; }
dl { display: grid; grid-template-columns: 80px 1fr; gap: 8px 12px; font-size: 14px; }
dt { color: var(--ink-soft); }
.note { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .ghost, .actions .primary { min-height: 40px; }
.field { display: grid; gap: 4px; min-width: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { font-weight: 600; font-size: 13px; }
.opt { font-weight: 400; color: var(--ink-soft); }
input, select, textarea { width: 100%; min-height: 40px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 10px; background: #fff; }
textarea { resize: vertical; }
[aria-invalid="true"] { border-color: var(--err); border-width: 2px; }
.hint { font-size: 12px; color: var(--ink-soft); }
.err { font-size: 13px; color: var(--err); font-weight: 600; }
.err[hidden] { display: none; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 12px); z-index: 50; max-width: min(92vw, 420px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; visibility: hidden; }
.toast.show { opacity: 1; transform: translate(-50%, 0); visibility: visible; }
.fab { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .toast { transition: opacity .2s, transform .2s, visibility .2s; }
  .drawer[open] { animation: slide .22s ease-out; }
  .modal[open] { animation: pop .18s ease-out; }
  @keyframes slide { from { transform: translateX(24px); opacity: 0; } }
  @keyframes pop { from { transform: translateY(8px); opacity: 0; } }
}

/* mobile: agenda list, stylist tabs, bottom sheet */
@media (max-width: 899px) {
  .banner { padding: 8px 16px; }
  .top { padding: 12px 16px; gap: 8px; }
  .daynav { margin-left: 0; width: 100%; order: 3; }
  .daynav button { min-width: 44px; height: 44px; }
  .daynav h1 { font-size: 17px; margin-left: 8px; flex: 1; }
  .chip, .top .nb-open { display: none; }
  .banner button, .close, .closed .ghost { min-height: 44px; min-width: 44px; }
  .close { width: 44px; height: 44px; }
  .layout { display: flex; flex-direction: column; gap: 14px; padding: 12px 16px 84px; }
  .p-today { order: 1; } .mob { order: 2; display: block; } .p-due { order: 3; } .p-week { order: 4; }
  .cal { display: none; }
  .figs { gap: 12px; }
  .due li:nth-child(n+4) { display: none; }
  .due .ghost { min-height: 44px; }
  .tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px; margin-bottom: 10px; }
  .tabs button { min-height: 44px; padding: 0 16px; border: 1px solid var(--line-strong); background: var(--card); border-radius: 999px; white-space: nowrap; }
  .tabs button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
  .agenda li { margin-bottom: 8px; }
  .agenda .appt { position: relative; width: 100%; display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 2px 10px; padding: 10px 12px 10px 16px; min-height: 56px; font-size: 14px; }
  .agenda .tm { grid-column: 1; grid-row: 1 / span 2; font-weight: 600; font-size: 13px; color: var(--ink); }
  .agenda .nm { grid-column: 2; grid-row: 1; }
  .agenda .nm .by { font-weight: 400; color: var(--ink-soft); }
  .agenda .svc { grid-column: 2; grid-row: 2; }
  .agenda .st { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
  .nowrow { display: flex; align-items: center; gap: 8px; color: var(--now); font-weight: 600; font-size: 12px; margin: 4px 0 8px; }
  .nowrow::after { content: ""; flex: 1; border-top: 2px solid var(--now); }
  .fab { display: inline-flex; position: fixed; right: 16px; bottom: 16px; min-height: 52px; box-shadow: 0 6px 18px rgba(91, 42, 110, .35); z-index: 5; }
  .drawer { inset: auto 0 0 0; width: 100%; height: auto; max-height: 88vh; border-left: 0; border-radius: 12px 12px 0 0; box-shadow: 0 -12px 32px rgba(30, 28, 33, .2); }
  .drawer .ghost, .drawer .primary, .modal .ghost, .modal .primary { min-height: 44px; }
  .drawer[open] { animation-name: sheet; }
  @keyframes sheet { from { transform: translateY(24px); opacity: 0; } }
  .row2 { grid-template-columns: 1fr; }
  input, select, textarea { min-height: 44px; }
}
@media (max-width: 899px) and (prefers-reduced-motion: reduce) { .drawer[open] { animation: none; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
