/* Shared design system: warm cream + coffee brown, used by customer, dashboard and admin pages. */

:root {
  --bg: #f6efe4;
  --bg-2: #ecdcc4;
  --surface: #ffffff;
  --surface-2: #fbf7f1;
  --frost: rgba(255, 255, 255, 0.72);
  --tint: rgba(74, 52, 38, 0.06);
  --tint-2: rgba(74, 52, 38, 0.11);
  --line: rgba(74, 52, 38, 0.12);
  --line-strong: rgba(74, 52, 38, 0.24);
  --text: #2e2219;
  --muted: #8b7a69;
  --faint: #b5a795;
  --coffee: #4a3426;
  --coffee-2: #6e4f39;
  --coffee-deep: #3a281c;
  --cream: #f3e6d1;
  --gold: #c79a6b;
  --kg-navy: #20225a;
  --ok: #3f8f5f;
  --warn: #c98327;
  --danger: #bf5340;
  --shadow: 0 14px 36px rgba(74, 52, 38, 0.13);
  --shadow-sm: 0 4px 14px rgba(74, 52, 38, 0.08);
  --blur: saturate(160%) blur(18px);
  --font-display: 'Josefin Sans', 'Segoe UI', sans-serif;
  --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
body.locked { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { display: block; max-width: 100%; }
h1, h2, h3, .display { font-family: var(--font-display); font-weight: 400; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- background ---------- */
.bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 600px at 100% 0%, rgba(199, 154, 107, 0.18), transparent 60%),
    radial-gradient(700px 500px at 0% 100%, rgba(199, 154, 107, 0.12), transparent 60%),
    var(--bg);
}
.blob { display: none; }

/* ---------- brand: KG logo + colour stripe ---------- */
.kg-logo { display: block; height: auto; }
.kg-stripe { display: block; height: 4px; background: url(/brand/kg-stripe.webp) center / 100% 100% no-repeat; }
.page-stripe { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 150; pointer-events: none; }
.brand-mark { display: inline-grid; place-items: center; color: var(--coffee); }
.brand-mark svg { width: 100%; height: 100%; }
.brand-name {
  font-family: var(--font-display); font-weight: 400; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--coffee);
}

/* ---------- surfaces ---------- */
.glass {
  background: var(--frost);
  border: 1px solid rgba(255, 255, 255, 0.8);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow-sm);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 50px; padding: 0 24px; border-radius: 999px;
  font-weight: 600; font-size: 15px; white-space: nowrap; letter-spacing: 0.01em;
  transition: transform 0.15s var(--ease), opacity 0.2s, background 0.2s, box-shadow 0.2s;
  user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--coffee); color: var(--cream); box-shadow: 0 8px 20px rgba(74, 52, 38, 0.28); }
.btn-ghost { background: var(--surface); border: 1px solid var(--line); color: var(--coffee); }
.btn-ok { background: var(--ok); color: #fff; box-shadow: 0 8px 20px rgba(63, 143, 95, 0.28); }
.btn-danger { background: rgba(191, 83, 64, 0.08); color: var(--danger); border: 1px solid rgba(191, 83, 64, 0.3); }
.btn-light { background: #fff; color: var(--coffee); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18); }
.btn-sm { height: 38px; padding: 0 16px; font-size: 14px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto;
  display: inline-grid; place-items: center; font-size: 17px; color: var(--coffee);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--ease), background 0.2s;
}
.icon-btn:active { transform: scale(0.92); }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(243, 230, 209, 0.35); border-top-color: var(--cream);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- form fields ---------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input {
  width: 100%; height: 50px; padding: 0 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
  outline: none; font-size: 16px; /* 16px stops iOS zooming on focus */
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--coffee-2); box-shadow: 0 0 0 4px rgba(110, 79, 57, 0.12); }
textarea.input { height: auto; min-height: 84px; padding: 13px 16px; resize: vertical; line-height: 1.45; }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234a3426' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 15px center;
}

/* pill choice (radio-like) */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-strong);
  font-weight: 600; font-size: 14px; color: var(--coffee);
  transition: background 0.25s var(--ease), color 0.25s, transform 0.2s var(--spring), border-color 0.25s;
}
.choice:active { transform: scale(0.94); }
.choice.on { background: var(--coffee); border-color: var(--coffee); color: var(--cream); }

/* stepper */
.stepper {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface);
}
.stepper button {
  width: 36px; height: 36px; border-radius: 50%; font-size: 19px; font-weight: 500; line-height: 1; color: var(--coffee);
  transition: transform 0.15s var(--spring), background 0.2s;
}
.stepper button:active { transform: scale(0.86); background: var(--tint); }
.stepper output { min-width: 30px; text-align: center; font-weight: 700; font-size: 16px; }
.stepper.sm button { width: 30px; height: 30px; font-size: 16px; }
.stepper.sm output { min-width: 24px; font-size: 14px; }

/* toggle switch */
.switch { position: relative; width: 48px; height: 28px; flex: 0 0 48px; }
.switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--tint-2); transition: background 0.25s; }
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(74, 52, 38, 0.25); transition: transform 0.3s var(--spring);
}
.switch input:checked + span { background: var(--coffee); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ---------- bottom sheet (centered modal on wide screens) ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(46, 34, 25, 0.38);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity 0.35s var(--ease);
}
.backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; flex-direction: column; max-height: 92vh; max-height: 92dvh; overflow: hidden;
  border-radius: 30px 30px 0 0; background: var(--surface-2);
  box-shadow: 0 -20px 50px rgba(46, 34, 25, 0.25);
  transform: translateY(105%); visibility: hidden;
  transition: transform 0.5s var(--ease), visibility 0s linear 0.5s;
  padding-bottom: var(--safe-b);
}
.sheet.open { transform: translateY(0); visibility: visible; transition: transform 0.5s var(--ease), visibility 0s; }
.sheet.dragging { transition: none; }
.sheet-head { flex: 0 0 auto; padding: 10px 20px 4px; touch-action: none; }
.grab { width: 44px; height: 5px; border-radius: 5px; background: var(--line-strong); margin: 0 auto 10px; }
.sheet-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-title h2 { margin: 0; font-size: 24px; color: var(--coffee); }
.sheet-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 12px 20px 20px; -webkit-overflow-scrolling: touch; }
.sheet-foot { flex: 0 0 auto; padding: 12px 20px 16px; border-top: 1px solid var(--line); background: var(--surface-2); }

@media (min-width: 760px) {
  .sheet {
    left: 50%; right: auto; top: 50%; bottom: auto; width: min(520px, 92vw); max-height: 88vh;
    border-radius: 28px; padding-bottom: 0;
    transform: translate(-50%, -46%) scale(0.96); opacity: 0;
    transition: transform 0.35s var(--ease), opacity 0.25s, visibility 0s linear 0.35s;
  }
  .sheet.open { transform: translate(-50%, -50%) scale(1); opacity: 1; transition: transform 0.35s var(--ease), opacity 0.25s, visibility 0s; }
  .sheet .grab { display: none; }
  .sheet-head { padding-top: 18px; }
}

/* stagger children in when a sheet opens */
.sheet.open .stagger > * { animation: rise 0.55s var(--ease) both; }
.sheet.open .stagger > *:nth-child(1) { animation-delay: 0.05s; }
.sheet.open .stagger > *:nth-child(2) { animation-delay: 0.1s; }
.sheet.open .stagger > *:nth-child(3) { animation-delay: 0.15s; }
.sheet.open .stagger > *:nth-child(4) { animation-delay: 0.2s; }
.sheet.open .stagger > *:nth-child(5) { animation-delay: 0.25s; }
.sheet.open .stagger > *:nth-child(n+6) { animation-delay: 0.3s; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(14px + var(--safe-t)); z-index: 100;
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px);
  padding: 12px 20px; border-radius: 999px; font-weight: 600; font-size: 14px;
  background: var(--coffee-deep); color: var(--cream);
  box-shadow: 0 12px 30px rgba(46, 34, 25, 0.3);
  transform: translate(-50%, calc(-100% - 30px)); transition: transform 0.45s var(--spring);
}
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- sign-in screens ---------- */
.center-screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(400px, 100%); border-radius: 32px; overflow: hidden; background: var(--surface-2);
  box-shadow: var(--shadow); animation: rise 0.6s var(--ease) both;
}
.login-hero {
  padding: 34px 24px 30px; text-align: center; border-radius: 0 0 32px 32px;
  background: linear-gradient(180deg, #fbf6ee 0%, var(--bg-2) 100%);
}
.login-hero .brand-mark { width: 44px; height: 44px; margin: 10px auto 0; }
.login-hero .brand-name { font-size: 22px; }
.login-hero .kg-stripe { width: 130px; margin: 14px auto 0; border-radius: 2px; }
.login-form { padding: 26px 26px 30px; }
.login-form h1 { margin: 0 0 4px; font-size: 26px; color: var(--coffee); }
.login-form p { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.pin-input { text-align: center; font-size: 24px; letter-spacing: 0.4em; font-weight: 700; height: 58px; margin-bottom: 16px; }
.shake { animation: shake 0.45s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
