/* Rayani FitTrack — one stylesheet, no framework. Mobile-first. */

:root {
  --plum: #4b0824;
  --plum-700: #3a0619;
  --plum-50: #f6ecf0;
  --gold: #b8893b;
  --ink: #2b1d24;
  --muted: #7a6670;
  --line: #eadfd9;
  --bg: #f8f3f0;
  --card: #ffffff;
  --ok: #1e7a4c;
  --warn: #b26b00;
  --bad: #b3261e;
  --wa: #1f9d55;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(43, 29, 36, .05), 0 6px 20px rgba(43, 29, 36, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
body.no-scroll { overflow: hidden; }
a { color: var(--plum); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-family: var(--serif); font-weight: 500; font-size: 1.7rem; }
h1 small { font-family: var(--font); font-size: .95rem; color: var(--muted); margin-left: .4rem; }
h2 { font-size: 1.05rem; font-weight: 650; display: flex; align-items: center; gap: .55rem; margin-bottom: .9rem; }
h2 small { font-weight: 400; color: var(--muted); font-size: .85rem; }
code { background: var(--plum-50); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.ok { color: var(--ok); font-weight: 600; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .7rem max(16px, env(safe-area-inset-left));
  background: var(--plum); color: #fff;
}
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; }
.brand-logo { height: 30px; width: auto; margin-right: .1rem; }
.brand-mark { font-family: var(--serif); font-size: 1.35rem; letter-spacing: .02em; }
.brand-sub { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: #e8c88f; }
.nav { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.nav > a:not(.btn) { color: #f3e6ec; text-decoration: none; padding: .35rem .6rem; border-radius: 8px; font-size: .92rem; }
.nav > a:not(.btn):hover, .nav > a.on { background: rgba(255, 255, 255, .12); color: #fff; }
.nav .btn-primary { background: var(--gold); border-color: var(--gold); margin-left: .3rem; }

@media (max-width: 640px) {
  .topbar { position: static; padding-top: .55rem; padding-bottom: .55rem; }
  .nav > a:not(.btn) { padding: .3rem .45rem; font-size: .88rem; }
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 18px 16px 110px; }

/* ---------- cards & layout ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.narrow { max-width: 440px; margin: 7vh auto; }
.card.narrow h1 { margin-bottom: .4rem; }
.stack { display: grid; gap: 14px; margin-top: 1rem; }
.grid { display: grid; gap: 14px; }
@media (min-width: 640px) {
  .g2 { grid-template-columns: repeat(2, 1fr); }
  .g3 { grid-template-columns: repeat(3, 1fr); }
  .g4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) { .g4 { grid-template-columns: repeat(4, 1fr); } }

.page-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin: 4px 0 16px; }
.page-title p { margin: .25rem 0 0; }
.back { display: inline-block; font-size: .85rem; text-decoration: none; color: var(--muted); margin-bottom: .2rem; }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--plum-50); color: var(--plum); font-size: .78rem; font-weight: 700; flex: none; }

/* ---------- forms ---------- */
.field { display: grid; gap: 5px; }
.field > span, .mfield > span { font-size: .8rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #dccdc6; border-radius: 10px;
  padding: .62rem .75rem; min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--plum); box-shadow: 0 0 0 3px rgba(90, 30, 60, .12); }
input[type=checkbox] { width: auto; min-height: 0; }
input[type=range] { padding: 0; border: 0; min-height: 0; accent-color: var(--plum); }
.has-error input { border-color: var(--bad); }
.err { color: var(--bad); font-size: .8rem; font-style: normal; }

.mgroup { border: 0; margin: 0 0 14px; padding: 0; }
.mgroup legend { font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; padding: 0; }
.mgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .mgrid { grid-template-columns: repeat(4, 1fr); } }
.mfield { display: grid; gap: 4px; }
.mfield > span { font-weight: 500; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mfield input { text-align: center; font-weight: 600; padding: .5rem; }
.mfield input:not(:placeholder-shown) { background: #fffdfb; }

.hint { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--plum-50); font-size: .9rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.hint[hidden] { display: none; }

/* sticky save bar */
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; justify-content: flex-end; align-items: center; gap: 1rem;
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.savebar-msg { font-size: .85rem; color: var(--muted); }
body.is-dirty .savebar-msg { color: var(--warn); font-weight: 600; }
body:not(.is-dirty) .order-form[data-existing] .savebar-msg { visibility: hidden; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .55rem 1rem; border-radius: 10px;
  border: 1px solid #d8c7c0; background: #fff; color: var(--ink);
  font: 600 .92rem/1.2 var(--font); text-decoration: none; cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:hover { background: #fbf6f4; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--plum); border-color: var(--plum); color: #fff; }
.btn-primary:hover { background: var(--plum-700); }
.btn-ghost { background: transparent; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { background: #18834a; }
.btn-sm { min-height: 34px; padding: .35rem .75rem; font-size: .85rem; }
.btn-block { width: 100%; }

/* ---------- alerts & toast ---------- */
.flash, .alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: .92rem; }
.flash { background: #e7f4ec; color: #14532d; border: 1px solid #c6e6d2; }
.alert { background: #fdecea; color: #7f1d1d; border: 1px solid #f5c6c2; }
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px);
  max-width: min(92vw, 520px); padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: .9rem; white-space: pre-line;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--bad); }

/* ---------- order list ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 1.5rem; font-family: var(--serif); font-weight: 500; }
.stat span { font-size: .8rem; color: var(--muted); }
.stat-late b { color: var(--bad); }
.stat-soon b { color: var(--warn); }
.stat-ready b { color: var(--ok); }

.toolbar { display: grid; gap: 10px; margin-bottom: 14px; }
@media (min-width: 760px) { .toolbar { grid-template-columns: 1fr auto; align-items: center; } }
.tabs { display: flex; gap: 4px; background: #efe5e0; padding: 4px; border-radius: 12px; overflow-x: auto; }
.tab { padding: .45rem .8rem; border-radius: 9px; text-decoration: none; color: var(--muted); font-size: .88rem; font-weight: 600; white-space: nowrap; }
.tab.on { background: #fff; color: var(--plum); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

.order-list { display: grid; gap: 8px; }
.order-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s;
}
.order-row:hover { border-color: #cdb5bf; box-shadow: var(--shadow); }
.or-main { display: grid; gap: 2px; min-width: 0; }
.or-main .muted { font-size: .85rem; }
.or-side { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.chip { display: inline-block; font-size: .75rem; font-weight: 700; padding: .2rem .55rem; border-radius: 999px; background: #efe7e3; color: var(--muted); }
.st-new { background: #e8eefb; color: #1d4ea8; }
.st-in_progress { background: #fdf1dc; color: #8a5300; }
.st-trial { background: #f1e8fb; color: #6a2fb0; }
.st-alteration { background: #fde8e6; color: #a1281e; }
.st-ready { background: #e2f4ea; color: #146c3f; }
.st-delivered { background: #eceff1; color: #4b5563; }
.st-cancelled { background: #f1f1f1; color: #9ca3af; text-decoration: line-through; }
.due { font-size: .82rem; font-weight: 600; color: var(--muted); }
.due-late { color: var(--bad); }
.due-soon { color: var(--warn); }
.empty { text-align: center; padding: 36px 18px; }

/* ---------- uploads & galleries ---------- */
.uploader {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 2px dashed #e1d2cb; border-radius: 12px; padding: 12px; margin-bottom: 12px;
  transition: background .15s, border-color .15s;
}
.uploader.drag { background: var(--plum-50); border-color: var(--plum); }
.drop-hint, .upload-status { font-size: .85rem; color: var(--muted); }
.upload-status { font-weight: 600; color: var(--plum); }
@media (pointer: fine) { .cam-only { display: none; } }
@media (pointer: coarse) { .drop-hint { display: none; } }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.gallery:empty { display: none; }
.thumb { position: relative; margin: 0; border-radius: 10px; overflow: hidden; background: #f2ebe7; border: 1px solid var(--line); }
.thumb a { display: block; aspect-ratio: 1; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb figcaption { font-size: .75rem; padding: 5px 7px; color: var(--muted); background: #fff; border-top: 1px solid var(--line); }
.thumb-del {
  position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: rgba(43, 29, 36, .72); color: #fff; font-size: 1.15rem; line-height: 1; cursor: pointer;
}
.thumb-del:hover { background: var(--bad); }
.gallery[data-kind=sketch] .thumb img, .thumb img[alt="Design sketches"] { object-fit: contain; background: #fff; }
.thumb.is-busy { opacity: .4; pointer-events: none; }
.thumb.is-new { animation: pop .3s ease-out; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }

/* ---------- sketch pad ---------- */
.sketchpad { display: grid; gap: 10px; margin-bottom: 12px; }
.sk-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sk-group { display: flex; align-items: center; gap: 4px; font-size: .85rem; color: var(--muted); }
.sk-group select { min-height: 36px; padding: .3rem .5rem; max-width: 210px; }
.sk-size input { width: 90px; }
.sk-btn {
  min-height: 36px; padding: .3rem .65rem; border-radius: 8px; border: 1px solid #dccdc6;
  background: #fff; font: 600 .85rem var(--font); color: var(--ink); cursor: pointer;
}
.sk-btn.on { background: var(--plum); border-color: var(--plum); color: #fff; }
.sk-btn:disabled { opacity: .4; cursor: default; }
.sk-color { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; background: var(--c); box-shadow: 0 0 0 1px #d6c6bf; cursor: pointer; padding: 0; }
.sk-color.on { box-shadow: 0 0 0 2px var(--plum); }
.sk-check { gap: 6px; }
.sk-full-btn { margin-left: auto; }

.sk-stage { display: flex; justify-content: center; }
.sk-paper {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .02);
}
.sk-paper canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.sk-ink-canvas { cursor: crosshair; }
.erasing .sk-ink-canvas { cursor: cell; }
.sk-save { display: flex; gap: 10px; flex-wrap: wrap; }
.sk-save input { flex: 1 1 220px; }

.sketchpad.sk-fullscreen {
  position: fixed; inset: 0; z-index: 200; margin: 0;
  background: var(--bg); padding: 10px max(10px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom));
  grid-template-rows: auto 1fr auto;
}
.sk-fullscreen .sk-stage { min-height: 0; align-items: center; }
.sk-fullscreen .sk-paper { width: auto; height: 100%; max-width: 100%; }

/* ---------- sharing ---------- */
.share-row { display: flex; flex-wrap: wrap; gap: 10px; }
.preview { margin-top: 14px; }
.preview summary { cursor: pointer; color: var(--muted); font-size: .88rem; }
.preview pre { white-space: pre-wrap; font: .88rem/1.55 var(--font); background: #f1f8f3; border: 1px solid #d5eadc; border-radius: 10px; padding: 12px; margin: 8px 0 0; }

/* ---------- team ---------- */
.user-list { display: grid; }
.user-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }

/* ---------- client-facing page ---------- */
.public .wrap { max-width: 760px; padding-bottom: 40px; }
.public-hero h1 { font-size: 2rem; margin: .2rem 0 .3rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.facts div { background: var(--plum-50); border-radius: 10px; padding: 10px 12px; }
.facts span { display: block; font-size: .78rem; color: var(--muted); }
.facts b { font-size: 1.02rem; }
.notes { margin: 0; line-height: 1.65; }
.mhead { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); margin: 14px 0 6px; }
.mlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 18px; margin: 0; }
.mlist div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.mlist dt { color: var(--muted); }
.mlist dd { margin: 0; font-weight: 700; }
.contact { text-align: center; }
.contact .btn { margin: 4px; }

.login-page .wrap { padding-bottom: 40px; }

@media print {
  .topbar, .savebar, .uploader, .sketchpad, .share, .thumb-del, .toast { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ---------- install app ---------- */
.btn-install { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .35); color: #fff; }
.btn-install:hover { background: rgba(255, 255, 255, .22); }
.btn-install[hidden] { display: none; }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 300; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(43, 29, 36, .45); padding: 16px;
}
.sheet-backdrop[hidden] { display: none; }
@media (min-width: 640px) { .sheet-backdrop { align-items: center; } }
.sheet {
  width: 100%; max-width: 420px; background: #fff; border-radius: 18px; padding: 22px 20px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25); text-align: center; animation: pop .2s ease-out;
}
.sheet h2 { justify-content: center; margin: 10px 0 4px; font-size: 1.2rem; }
.sheet-icon { border-radius: 14px; }
.install-steps { text-align: left; margin: 16px 0 18px; padding-left: 1.3rem; line-height: 1.6; }
.install-steps li { margin-bottom: 8px; }
.share-ico {
  display: inline-block; width: 15px; height: 18px; vertical-align: -3px;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 24' fill='none' stroke='%231d6fe0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 15V2M5 7l5-5 5 5'/%3E%3Cpath d='M6 10H3v12h14V10h-3'/%3E%3C/svg%3E");
}

/* installed app: respect phone notches and status bar */
@media (display-mode: standalone) {
  .topbar { padding-top: calc(.7rem + env(safe-area-inset-top)); }
}
