/* KBS Membership — design tokens + utilities (Tailwind-flavored, hand-rolled) */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: local('Inter');
}

:root {
  --brand:        #C8392F;
  --brand-deep:   #9B2A22;
  --brand-soft:   #FBE9E7;
  --ink:          #0F172A;
  --ink-2:        #334155;
  --muted:        #64748B;
  --hint:         #94A3B8;
  --line:         #E2E8F0;
  --line-2:       #CBD5E1;
  --surface:      #FFFFFF;
  --canvas:       #F8FAFC;
  --canvas-2:     #F1F5F9;
  --success:      #16A34A;
  --warning:      #D97706;
  --danger:       #DC2626;
  --ring:         rgba(200, 57, 47, 0.32);
  --shadow-sm:    0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:       0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg:    0 16px 40px rgba(15, 23, 42, 0.10);
  --radius:       12px;
  --radius-sm:    8px;
  --radius-lg:    20px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink:        #E5E7EB;
    --ink-2:      #CBD5E1;
    --muted:      #94A3B8;
    --hint:       #64748B;
    --line:       #1E293B;
    --line-2:     #334155;
    --surface:    #0F172A;
    --canvas:     #0B1220;
    --canvas-2:   #111827;
    --brand-soft: rgba(200, 57, 47, 0.12);
    --shadow:     0 8px 32px rgba(0, 0, 0, 0.45);
    --shadow-lg:  0 24px 60px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--canvas);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img { max-width: 100%; display: block; }
a { color: var(--brand-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}
button { font: inherit; cursor: pointer; }

/* Layout */
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.container-sm { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 20px; }
@media (max-width: 480px) { .container-sm { padding: 0 14px; } }
.container-lg { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 20px; }

.stack > * + * { margin-top: var(--gap, 16px); }
.stack-sm { --gap: 8px; }
.stack-lg { --gap: 24px; }
.stack-xl { --gap: 40px; }

.row  { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
.grid-3 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
}
/* On phones, NEVER let a child force the grid to grow extra implicit columns
   — inline `style="grid-column: span 2"` is a desktop-only hint. */
@media (max-width: 719px) {
  .grid-2 > *, .grid-3 > * { grid-column: auto !important; }
}

/* Header / nav */
.app-header {
  background: #e81c1d;
  border-bottom: 1px solid rgba(0, 0, 0, 0.10);
  position: sticky; top: 0; z-index: 30;
  color: #fff;
}
.app-header .inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; max-width: 1280px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; color: #fff; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-logo {
  height: 44px;
  width: auto;
  display: block;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-name { font-size: 15px; line-height: 1.1; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub  { font-size: 11px; color: rgba(255, 255, 255, 0.78); letter-spacing: .06em; text-transform: uppercase; line-height: 1.1; }
@media (max-width: 480px) {
  .app-header .inner { padding: 10px 14px; }
  .brand-logo  { height: 36px; }
  .brand-text  { display: none; }     /* logo alone is enough on tiny screens */
}

/* Buttons sized for the red header background */
.btn-ghost-on-brand {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid transparent;
}
.btn-ghost-on-brand:hover { background: rgba(255, 255, 255, 0.22); }
.btn-outline-on-brand {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.55);
}
.btn-outline-on-brand:hover { background: rgba(255, 255, 255, 0.12); border-color: #fff; }

.app-footer { padding: 32px 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* Type */
.h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.005em; }
.lead { font-size: 17px; color: var(--ink-2); }
.muted { color: var(--muted); }
.tiny { font-size: 12px; color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; color: var(--brand); font-weight: 600; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mb-0 { margin-bottom: 0 !important; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px;
}
.card + .card { margin-top: 16px; }
.card-pad-lg { padding: 36px; }
.card-pad-sm { padding: 16px; }
@media (max-width: 600px) {
  .card { padding: 18px; border-radius: var(--radius); }
}
@media (max-width: 380px) {
  .card { padding: 14px; }
}

/* Hero */
.hero {
  background:
    radial-gradient(900px 400px at 20% -20%, rgba(200,57,47,0.10), transparent 60%),
    radial-gradient(700px 350px at 100% 0%, rgba(15, 23, 42, 0.06), transparent 60%),
    var(--canvas);
  padding: 56px 0 32px;
}
.hero-eyebrow { display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px; background: var(--brand-soft); color: var(--brand-deep); border-radius: 999px; font-size: 12px; font-weight: 600; }

/* Form fields */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink); display: flex; gap: 6px; align-items: center; line-height: 1.2; }
.field > label .req { color: var(--brand); }
.input, .select, .textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  padding: 11px 14px;
  font: inherit;
  font-size: 16px;            /* prevents iOS Safari from auto-zooming on focus */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-2); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
  outline: none;
}
.textarea { min-height: 96px; resize: vertical; }
.field-error { color: var(--danger); font-size: 12px; min-height: 1em; }
.input.is-error, .select.is-error, .textarea.is-error { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.16); }
.input::placeholder { color: var(--hint); }
.help-hint { color: var(--muted); font-size: 12px; }

.checkbox { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas-2); }
.checkbox input { margin-top: 3px; }
.checkbox span { font-size: 14px; color: var(--ink-2); }

/* Segmented */
.seg { display: inline-flex; padding: 4px; border: 1px solid var(--line-2); background: var(--canvas-2); border-radius: 12px; gap: 4px; }
.seg button {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-2);
  border-radius: 8px;
  transition: background .15s ease, color .15s ease;
}
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  background: var(--canvas-2);
  color: var(--ink);
  transition: transform .05s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:hover { background: var(--canvas); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, var(--brand) 0%, var(--brand-deep) 100%); color: #fff; box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.15); }
.btn-primary:hover { background: linear-gradient(180deg, var(--brand-deep) 0%, #7d2018 100%); }
.btn-ghost { background: transparent; }
.btn-outline { background: transparent; border-color: var(--line-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 15px; border-radius: 12px; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

/* Step indicator */
.steps { display: flex; gap: 8px; padding: 16px 0 8px; flex-wrap: wrap; }
.step-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--canvas-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.step-pill.is-active { background: var(--brand-soft); color: var(--brand-deep); border-color: var(--brand); }
.step-pill.is-done { background: var(--success); color: #fff; border-color: var(--success); }
.step-pill .dot { width: 18px; height: 18px; border-radius: 999px; background: var(--surface); display: inline-grid; place-items: center; font-size: 11px; color: var(--ink); }
.step-pill.is-done .dot { background: rgba(255,255,255,0.25); color: #fff; }

/* File drop */
.dropzone {
  display: grid; place-items: center; gap: 8px;
  padding: 22px;
  border: 1.5px dashed var(--line-2);
  background: var(--canvas-2);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--ink-2); }
.dropzone.has-file { border-style: solid; border-color: var(--success); background: rgba(22, 163, 74, 0.06); color: var(--ink); }
.dropzone input[type="file"] { display: none; }
.dropzone-thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; box-shadow: var(--shadow-sm); }

/* Signature */
.sig-pad {
  background: #fff;
  background-image:
    linear-gradient(0deg, transparent 49.5%, rgba(15, 23, 42, 0.08) 49.5%, rgba(15, 23, 42, 0.08) 50.5%, transparent 50.5%);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  width: 100%;
  height: 220px;
  touch-action: none;
  cursor: crosshair;
}

/* OTP modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(4px);
  z-index: 100; display: grid; place-items: center; padding: 16px;
}
.modal {
  width: 100%; max-width: 460px;
  background: var(--surface);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}
.otp-input {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 16px auto 4px;
  height: 64px;
  padding: 0 8px 0 calc(8px + 0.45em);    /* offset to centre the letter-spaced text */
  text-align: center;
  font: 700 30px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.45em;
  color: var(--ink);
  background: var(--canvas-2);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-sizing: border-box;
}
.otp-input::placeholder { color: var(--hint); font-weight: 400; letter-spacing: 0.45em; }
.otp-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
  outline: none;
  background: var(--surface);
}

/* Toast / banner */
.banner { padding: 12px 16px; border-radius: 12px; font-size: 14px; }
.banner-info  { background: rgba(15, 23, 42, 0.06); color: var(--ink-2); }
.banner-error { background: rgba(220, 38, 38, 0.10); color: var(--danger); border: 1px solid rgba(220, 38, 38, 0.20); }
.banner-success { background: rgba(22, 163, 74, 0.10); color: var(--success); border: 1px solid rgba(22, 163, 74, 0.20); }

/* Status pill */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-pending  { background: rgba(217, 119, 6, 0.12); color: #B45309; }
.pill-approved { background: rgba(22, 163, 74, 0.12); color: var(--success); }
.pill-rejected { background: rgba(220, 38, 38, 0.12); color: var(--danger); }

/* Admin table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
table.kbs { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.kbs th, table.kbs td { padding: 12px 16px; text-align: left; vertical-align: middle; }
table.kbs th { background: var(--canvas-2); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--line); }
table.kbs tbody tr + tr td { border-top: 1px solid var(--line); }
table.kbs tbody tr:hover { background: var(--canvas); }

/* Tabs */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--canvas-2); border-radius: 12px; border: 1px solid var(--line); }
.tabs a { padding: 8px 14px; font-weight: 600; font-size: 13px; border-radius: 8px; color: var(--muted); }
.tabs a.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* Summary list */
.summary { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .summary { grid-template-columns: 1fr 1fr; } }
.summary > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; background: var(--canvas-2); border-radius: 10px; }
.summary > div .k { color: var(--muted); font-size: 12px; }
.summary > div .v { color: var(--ink); font-weight: 500; }

/* Children rows */
.child-row { display: grid; gap: 10px; grid-template-columns: 1fr; align-items: end; padding: 12px; background: var(--canvas-2); border-radius: 12px; border: 1px solid var(--line); }
@media (min-width: 720px) { .child-row { grid-template-columns: 2fr 1.3fr 1fr auto; } }
.child-row > * { min-width: 0; }
.child-row .btn-remove { background: transparent; border: 1px solid var(--line-2); color: var(--danger); border-radius: 10px; padding: 8px 12px; font-weight: 600; width: 100%; }
@media (min-width: 720px) { .child-row .btn-remove { width: auto; } }

/* Photo modal */
.photo-modal img { max-height: 80vh; border-radius: 12px; }

/* Alpine.js — hide x-cloak elements until Alpine initializes */
[x-cloak] { display: none !important; }

/* Upload progress UI */
.dropzone.is-uploading { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.is-error     { border-color: var(--danger); background: rgba(220, 38, 38, 0.06); }

.spinner-dot {
  display: inline-block;
  width: 10px; height: 10px; border-radius: 999px;
  background: currentColor;
  animation: kbs-pulse 1.1s ease-in-out infinite;
  margin-right: 6px;
  vertical-align: middle;
}
@keyframes kbs-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.1);  }
}

.spinner-large {
  width: 56px; height: 56px;
  border: 4px solid rgba(15, 23, 42, 0.10);
  border-top-color: var(--brand);
  border-radius: 999px;
  margin: 0 auto;
  animation: kbs-spin 900ms linear infinite;
}
@keyframes kbs-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner-large { animation: none; } }

/* Full-screen "do not close this page" overlay */
.progress-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
}
.progress-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 36px 32px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  text-align: center;
}
.progress-card .h3 { color: var(--ink); }

/* Utility */
.hidden { display: none !important; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.w-full { width: 100%; }

/* Print */
@media print {
  .app-header, .app-footer, .no-print { display: none; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}
