/* ---------- Design tokens ---------- */
:root {
  --bg: #f1f1ee;
  --surface: #ffffff;
  --border: #e3e2dd;
  --text: #1a1a1a;
  --text-muted: #6b6b68;
  --accent: #a83a2e;
  --accent-contrast: #ffffff;
  --success: #3f7d4e;
  --success-bg: #e9f3ea;
  --pending: #9a6b0c;
  --pending-bg: #faf1dd;
  --danger: #8b3a3a;
  --danger-bg: #f6e9e8;
  --radius: 10px;
  --nav-height: 62px;
  --header-height: 56px;
  --font-ui: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

#app-root {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: 16px; /* prevents iOS auto-zoom on focus */
}

a { color: var(--accent); }

.hidden { display: none !important; }

/* ---------- Header ---------- */
.app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}

.app-header h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
}

.app-header .header-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-data);
}

.header-logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.header-back-btn {
  background: none;
  border: none;
  padding: 4px 4px 4px 0;
  font-size: 24px;
  line-height: 1;
  color: var(--text);
}

/* ---------- Main content area ---------- */
.view {
  flex: 1;
  padding: 16px 16px calc(var(--nav-height) + 24px) 16px;
  overflow-y: auto;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: sticky;
  bottom: 0;
  display: flex;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 5;
}

.nav-btn {
  flex: 1;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-muted);
}

.nav-btn .nav-icon { font-size: 19px; line-height: 1; }
.nav-btn .nav-icon svg { display: block; width: 20px; height: 20px; }

.nav-btn.active { color: var(--accent); font-weight: 600; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.section-title {
  font-size: 13px;
  color: var(--text-muted);
  margin: 20px 0 8px 2px;
}

.section-title:first-child { margin-top: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 600;
  width: 100%;
  text-decoration: none;
}

.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { width: auto; padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.45; }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.field textarea { resize: vertical; min-height: 60px; }

.error-text { color: var(--danger); font-size: 13px; margin-top: 6px; }
.hint-text { color: var(--text-muted); font-size: 12px; margin-top: 6px; }

/* ---------- Badges / status ---------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-data);
}

.badge-confirmed { background: var(--success-bg); color: var(--success); }
.badge-pending { background: var(--pending-bg); color: var(--pending); }
.badge-rejected, .badge-cancelled { background: var(--danger-bg); color: var(--danger); }
.badge-unavailable { background: var(--border); color: var(--text-muted); }

.money { font-family: var(--font-data); font-weight: 600; }

/* ---------- Calendar ---------- */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.calendar-nav .month-label { font-size: 16px; font-weight: 600; }
.calendar-nav button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 16px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-weekday {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding-bottom: 4px;
}

.calendar-day {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 13px;
  position: relative;
}

.calendar-day.outside-month { opacity: 0.35; }
.calendar-day.today { border-color: var(--accent); border-width: 2px; }

.calendar-day .dots { display: flex; gap: 2px; }
.dot { width: 5px; height: 5px; border-radius: 50%; }
.dot-own { background: var(--accent); }
.dot-other { background: var(--text-muted); }

/* ---------- Equipment list ---------- */
.equip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.equip-row:last-child { border-bottom: none; }

.equip-name { font-weight: 600; font-size: 15px; }
.equip-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.equip-thumb {
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--border);
  flex-shrink: 0;
}

.equip-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

/* ---------- Item picker (booking flow) ---------- */
.pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.pick-row:last-child { border-bottom: none; }
.pick-row.disabled { opacity: 0.4; }

.pick-info { flex: 1; }

.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-control button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 15px;
}

.qty-control .qty-value { min-width: 16px; text-align: center; font-family: var(--font-data); }

/* ---------- Breakdown table ---------- */
.breakdown-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.breakdown-total {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 700;
  padding-top: 10px;
}

/* ---------- Login screen ---------- */
.login-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
}

.login-wrap .brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-wrap .brand .brand-mark {
  display: block;
  width: 88px;
  height: 88px;
  margin: 0 auto 12px auto;
}

.login-wrap .brand h1 { font-size: 19px; margin: 0 0 4px 0; }
.login-wrap .brand p { font-size: 13px; color: var(--text-muted); margin: 0; }

/* ---------- Splash (shown while the session is checked on load) ---------- */
.splash-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.splash-logo {
  width: 72px;
  height: 72px;
  opacity: 0.9;
}

/* ---------- Empty states ---------- */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px;
  font-size: 14px;
}

/* ---------- Modal / sheet ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 18px) 16px;
  max-height: 80vh;
  overflow-y: auto;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto 14px auto;
}

.sheet-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + 16px);
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 30;
  max-width: 90%;
  text-align: center;
}

/* ---------- Tabs within a view (Admin) ---------- */
.subtabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.subtab {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.subtab.active { background: var(--text); color: #fff; border-color: var(--text); }
