/* SP Beauty & Spa - Design System v4 (owner-approved, static/flat) */
:root {
  /* Palette */
  --ivory: #F6F7EB;
  --card: #FFFFFF;
  --charcoal: #393E41;
  --blue: #3F88C5;
  --teal: #44BBA4;
  --vermilion: #E94F37;

  --text: #393E41;
  --text-2: #6b7075;
  --border: rgba(57, 62, 65, 0.10);

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(57, 62, 65, 0.08);
  --tap: 44px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --header-h: 56px;
  --tabbar-h: 64px;
  --sidenav-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--ivory);
  color: var(--text);
  font-family: "Noto Sans Lao", "Noto Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.75; /* Lao script needs taller line-height */
  -webkit-font-smoothing: antialiased;
}

.num { font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-weight: 700; line-height: 1.5; color: var(--charcoal); }
button { font-family: inherit; cursor: pointer; }

/* ---- Top utility header ---- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex; align-items: center; gap: 10px;
  padding-left: 16px; padding-right: 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
#topbar .brand { font-weight: 700; color: var(--charcoal); margin-right: auto; }

.tag {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  border: 1px solid transparent;
}
.tag.active { background: rgba(68,187,164,.15); color: var(--teal); border-color: rgba(68,187,164,.35); }
.tag.locked { background: rgba(233,79,55,.12); color: var(--vermilion); border-color: rgba(233,79,55,.35); }

.sync-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2);
}
.sync-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }
.sync-dot.offline::before { background: var(--text-2); }
.sync-dot.pending::before { background: var(--vermilion); }

.user-badge {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue); color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}

/* ---- Layout regions ---- */
#app {
  padding-top: calc(var(--header-h) + var(--safe-top));
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  min-height: 100%;
}
.screen { display: none; padding: 16px; max-width: 1100px; margin: 0 auto; }
.screen.is-active { display: block; }

/* ---- Cards ---- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px;
}
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat {
  border-radius: var(--radius); padding: 16px; color: #fff;
}
.stat .label { font-size: 13px; opacity: .9; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat.blue { background: var(--blue); }
.stat.teal { background: var(--teal); }
.stat.charcoal { background: var(--charcoal); }
.stat.vermilion { background: var(--vermilion); }

/* ---- Buttons ---- */
.btn {
  min-height: var(--tap); padding: 0 18px; border: none; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 15px; transition: transform .15s ease-out, opacity .15s ease-out;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--vermilion); color: #fff; }
.btn.blue { background: var(--blue); color: #fff; }
.btn.ghost { background: transparent; color: var(--charcoal); border: 1px solid var(--border); }
.btn.block { width: 100%; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; color: var(--text-2); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; min-height: var(--tap); padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--text); font-family: inherit; font-size: 16px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--blue); outline-offset: -1px; }

/* ---- Bottom tab bar (mobile/tablet) ---- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; background: var(--card); border-top: 1px solid var(--border);
}
#tabbar button {
  flex: 1; background: none; border: none; color: var(--text-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; min-height: var(--tap);
}
#tabbar button svg { width: 22px; height: 22px; }
#tabbar button.is-active { color: var(--vermilion); }

/* Desktop side nav (>=1024px) */
#sidenav { display: none; }
@media (min-width: 1024px) {
  #tabbar { display: none; }
  #sidenav {
    display: flex; flex-direction: column; gap: 4px;
    position: fixed; top: calc(var(--header-h) + var(--safe-top)); bottom: 0; left: 0;
    width: var(--sidenav-w); background: var(--card);
    border-right: 1px solid var(--border); padding: 12px;
  }
  #sidenav button {
    display: flex; align-items: center; gap: 12px; width: 100%;
    background: none; border: none; color: var(--text-2);
    padding: 10px 12px; border-radius: var(--radius-sm); font-size: 15px; text-align: left;
  }
  #sidenav button svg { width: 20px; height: 20px; }
  #sidenav button.is-active { background: rgba(63,136,197,.12); color: var(--blue); font-weight: 600; }
  #app { padding-left: var(--sidenav-w); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ---- Sheet-style modal ---- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(57,62,65,.45);
  display: none; align-items: flex-end; justify-content: center;
}
.sheet-backdrop.open { display: flex; }
.sheet {
  background: var(--card); width: 100%; max-width: 560px;
  border-radius: var(--radius) var(--radius) 0 0; padding: 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
  max-height: 90vh; overflow-y: auto;
}
@media (min-width: 1024px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: var(--radius); }
}

/* ---- Auth / PIN ---- */
#auth-screen {
  position: fixed; inset: 0; z-index: 80; background: var(--ivory);
  display: none; flex-direction: column; align-items: center; justify-content: center; padding: 24px;
}
#auth-screen.show { display: flex; }
#auth-screen .card { width: 100%; max-width: 380px; }
.pin-row { display: flex; gap: 10px; justify-content: center; margin: 12px 0; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); }
.pin-dot.filled { background: var(--charcoal); border-color: var(--charcoal); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button { min-height: 56px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--card); font-size: 22px; font-weight: 600; }

.muted { color: var(--text-2); font-size: 14px; }
.hidden { display: none !important; }

.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.screen-head h1 { margin: 0; }

.cat-title { font-size: 14px; font-weight: 700; color: var(--text-2); margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 8px;
}
.list-row .main { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; }
.list-row .sub { font-size: 13px; color: var(--text-2); }
.list-row .price { font-weight: 700; color: var(--charcoal); }
.list-row .row-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--card); display: grid; place-items: center; color: var(--text-2);
}
.icon-btn.danger { color: var(--vermilion); }

.pill { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.pill.vip { background: rgba(233,79,55,.12); color: var(--vermilion); }
.pill.regular { background: rgba(63,136,197,.12); color: var(--blue); }
.pill.first { background: rgba(68,187,164,.15); color: var(--teal); }
.pill.bundle { background: rgba(57,62,65,.10); color: var(--charcoal); }

.bundle-line { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.bundle-line select { flex: 1; }
.bundle-line input { width: 80px; }
.sheet h2 { margin-bottom: 14px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 8px; }
.sheet-actions .btn { flex: 1; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
