/* ============================================================
   RESET & VARIABLES
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --p: #B8962E;
  --p-dark: #3D2B1F;
  --p-light: #FDF6E3;
  --p-grad: linear-gradient(135deg, #C9A84C 0%, #B8962E 100%);
  --red: #EF4444;
  --red-bg: #FEF2F2;
  --green: #10B981;
  --bg: #FAF7F2;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --text: #111827;
  --muted: #6B7280;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --r: 14px;
  --r-sm: 8px;
  --r-lg: 22px;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

#app {
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.scrollable {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ============================================================
   LOGIN
   ============================================================ */
.v-login {
  background: var(--p-grad);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  padding-top: max(2rem, env(safe-area-inset-top, 1rem));
}

.login-card {
  background: white;
  border-radius: var(--r-lg);
  padding: 2rem 1.75rem 1.75rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

.login-brand { text-align: center; margin-bottom: 2rem; }

.login-icon {
  width: 200px; height: auto;
  display: block; margin: 0 auto 0.75rem;
}

.login-brand h1 { display: none; }
.login-brand p  { font-size: 0.875rem; color: var(--muted); margin-top: 0.25rem; }

/* ============================================================
   SHARED INPUTS
   ============================================================ */
.field { margin-bottom: 1rem; }

.field label {
  display: block;
  font-size: 0.75rem; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 0.375rem;
}

.field input, .field select {
  width: 100%;
  padding: 0.8125rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-family: inherit; font-size: 1rem; color: var(--text);
  background: white; outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  -webkit-appearance: none; appearance: none;
}

.field input:focus, .field select:focus {
  border-color: var(--p);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  padding: 0.875rem 1.25rem;
  border: none; border-radius: var(--r-sm);
  font-family: inherit; font-size: 1rem; font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap; outline: none;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.55; pointer-events: none; }

.btn-primary  { background: var(--p-grad); color: white; box-shadow: 0 4px 14px rgba(185,150,46,0.4); }
.btn-outline  { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-danger   { background: var(--red); color: white; }
.btn-ghost    { background: transparent; color: var(--muted); }
.btn-w        { width: 100%; }

.btn-icon {
  width: 40px; height: 40px;
  border-radius: 12px; border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  font-size: 1.0625rem;
  background: rgba(255,255,255,0.18); color: white;
  flex-shrink: 0;
}
.btn-icon:active { transform: scale(0.9); }
.btn-icon.copy-btn { background: var(--p-light); color: var(--p); }
.btn-icon.del-btn  { background: var(--red-bg); color: var(--red); }
.btn-icon.back-btn { background: var(--border); color: var(--text); }

/* ============================================================
   APP HEADER
   ============================================================ */
.app-header {
  background: var(--p-grad);
  padding: 0.875rem 1rem;
  padding-top: max(0.875rem, env(safe-area-inset-top, 0.875rem));
  display: flex; align-items: center; gap: 0.625rem;
  flex-shrink: 0;
  box-shadow: 0 2px 16px rgba(109,40,217,0.25);
}

.header-text { flex: 1; min-width: 0; }
.header-title { font-size: 1.125rem; font-weight: 700; color: white; letter-spacing: -0.01em; }
.header-sub   { font-size: 0.75rem; color: rgba(255,255,255,0.7); margin-top: 0.1rem; }

.header-badge {
  background: rgba(255,255,255,0.22); color: white;
  font-size: 0.75rem; font-weight: 700;
  padding: 0.2rem 0.6rem; border-radius: 50px; flex-shrink: 0;
}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.625rem 1rem; flex-shrink: 0;
}

.search-wrap { position: relative; }

.search-wrap svg {
  position: absolute; left: 0.875rem; top: 50%;
  transform: translateY(-50%); color: var(--muted); pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.625rem 1rem 0.625rem 2.75rem;
  border: 1.5px solid var(--border); border-radius: 50px;
  font-family: inherit; font-size: 0.9375rem; color: var(--text);
  background: var(--bg); outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  -webkit-appearance: none;
}

.search-input:focus {
  border-color: var(--p); background: white;
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

/* ============================================================
   CUSTOMER LIST
   ============================================================ */
.list-content { padding: 0.75rem 1rem 6rem; }

.list-empty { text-align: center; padding: 4rem 1.5rem; color: var(--muted); }
.list-empty-icon { font-size: 3.5rem; display: block; margin-bottom: 0.75rem; opacity: 0.45; }
.list-empty h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 0.375rem; }
.list-empty p  { font-size: 0.875rem; line-height: 1.5; }

.section-header {
  font-size: 0.6875rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 0.625rem 0.25rem 0.375rem;
}

.customer-card {
  background: var(--surface);
  border-radius: var(--r);
  padding: 0.875rem;
  margin-bottom: 0.5rem;
  display: flex; align-items: center; gap: 0.875rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid rgba(229,231,235,0.8);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.customer-card:active { transform: scale(0.978); box-shadow: none; }

.c-avatar {
  width: 50px; height: 50px;
  border-radius: 15px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.125rem; font-weight: 700; color: white;
  flex-shrink: 0; overflow: hidden;
}
.c-avatar img { width: 100%; height: 100%; object-fit: cover; }

.c-info { flex: 1; min-width: 0; }
.c-name  { font-size: 0.9375rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.c-addr  { font-size: 0.8125rem; color: var(--muted); margin-top: 0.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-price { font-size: 0.9375rem; font-weight: 700; color: var(--p); flex-shrink: 0; }

/* ============================================================
   FAB
   ============================================================ */
.fab {
  position: fixed;
  bottom: max(1.5rem, calc(env(safe-area-inset-bottom) + 1rem));
  right: max(1.25rem, calc(50vw - 240px + 1.25rem));
  width: 58px; height: 58px;
  border-radius: 18px;
  background: var(--p-grad); color: white; border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(124,58,237,0.5), 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 100; -webkit-tap-highlight-color: transparent;
  font-size: 1.625rem; line-height: 1;
}
.fab:active { transform: scale(0.9); box-shadow: 0 2px 10px rgba(124,58,237,0.35); }

/* ============================================================
   FORM HEADER
   ============================================================ */
.form-header {
  background: white;
  padding: 0.875rem 1rem;
  padding-top: max(0.875rem, env(safe-area-inset-top, 0.875rem));
  display: flex; align-items: center; gap: 0.625rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.form-header-title { flex: 1; font-size: 1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.form-header-actions { display: flex; gap: 0.375rem; }

/* ============================================================
   PHOTO GALLERY STRIP
   ============================================================ */
.photo-section {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 1rem 0 1rem 1rem;
  flex-shrink: 0;
}

.photo-section-label {
  font-size: 0.6875rem; font-weight: 700;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
  padding-right: 1rem;
}

.photo-strip {
  display: flex;
  gap: 0.625rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  padding-right: 1rem;
  padding-bottom: 2px; /* prevent shadow clipping */
}
.photo-strip::-webkit-scrollbar { display: none; }

.photo-thumb {
  position: relative;
  width: 88px; height: 88px;
  flex-shrink: 0;
  border-radius: 14px;
  overflow: hidden;
  scroll-snap-align: start;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  border: 2px solid rgba(124,58,237,0.15);
  -webkit-tap-highlight-color: transparent;
}

.photo-thumb img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.2s;
}
.photo-thumb:active img { transform: scale(0.95); }

.photo-thumb-del {
  position: absolute; top: 5px; right: 5px;
  width: 22px; height: 22px;
  background: rgba(0,0,0,0.65);
  color: white; border: none; border-radius: 50%;
  font-size: 0.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 10;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}
.photo-thumb-del:active { background: var(--red); }

.photo-thumb-pending { opacity: 0.75; }
.photo-thumb-pending::after {
  content: 'NEU';
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(124,58,237,0.85);
  color: white; font-size: 0.5rem; font-weight: 700;
  text-align: center; padding: 2px 0;
  letter-spacing: 0.06em;
}

.photo-add {
  width: 88px; height: 88px;
  flex-shrink: 0;
  border-radius: 14px;
  border: 2px dashed var(--border);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer; color: var(--muted);
  gap: 0.25rem;
  scroll-snap-align: start;
  transition: border-color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.photo-add:active { background: var(--bg); border-color: var(--p); }
.photo-add svg { opacity: 0.5; }
.photo-add span { font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.6; }

/* ============================================================
   FORM SECTIONS
   ============================================================ */
.form-body { padding-bottom: 6rem; }

.form-section {
  background: white;
  margin-top: 0.625rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.form-section-label {
  font-size: 0.6875rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 0.875rem 1rem 0;
}

.form-rows { padding: 0.25rem 1rem 0.25rem; }

.frow {
  display: flex; align-items: flex-start; gap: 0.875rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
}
.frow:last-child { border-bottom: none; }

.preis-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.875rem; margin: 4px 0 8px;
}
.preis-table th, .preis-table td {
  padding: 6px 4px; text-align: center;
  border-bottom: 1px solid var(--border);
}
.preis-table th { padding-bottom: 8px; }
.pt-label-head { width: 30%; }
.pt-label {
  text-align: left; font-size: 0.8rem;
  font-weight: 500; color: var(--muted); width: 30%;
}
.pt-date {
  width: 100%; border: none; outline: none;
  font-family: inherit; font-size: 0.8rem;
  color: var(--text); text-align: center;
  background: transparent; border-bottom: 1.5px solid var(--border);
  padding: 2px 0;
}
.pt-date::placeholder { color: var(--muted); }
.pt-val {
  width: 100%; border: none; outline: none;
  font-family: inherit; font-size: 0.875rem;
  color: var(--text); text-align: center;
  background: transparent;
}
.pt-val::placeholder { color: var(--muted); }
.pt-cell { display: flex; align-items: center; justify-content: center; }
.pt-cell .pt-val { flex: 1; min-width: 0; }
.pt-eur { font-size: 0.75rem; color: var(--muted); flex-shrink: 0; padding-left: 2px; }

.frow-label {
  font-size: 0.8125rem; font-weight: 500; color: var(--muted);
  width: 100px; flex-shrink: 0; padding-top: 0.125rem;
}

.frow-input {
  flex: 1; border: none; outline: none;
  font-family: inherit; font-size: 1rem; color: var(--text);
  background: transparent; padding: 0; min-width: 0;
  -webkit-appearance: none; appearance: none;
}
.frow-input::placeholder { color: #C4A882; }
.termin-val {
  flex: 1; display: block; font-size: 0.92rem; color: var(--text);
  padding: 2px 0; line-height: 1.5; white-space: pre-line;
}
.termin-val .tappt-item {
  display: flex; align-items: baseline; gap: 6px;
  padding: 2px 0;
}
.termin-val .tappt-date {
  font-weight: 600; color: var(--p); min-width: 70px;
}
.termin-val .tappt-time {
  color: #888; font-size: 0.85rem; min-width: 38px;
}
.termin-val .tappt-title { color: var(--text); }
.frow-input[type="number"] { -moz-appearance: textfield; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.frow-ta { align-items: flex-start; padding: 10px 0; }
/* ============================================================
   CALENDAR
   ============================================================ */
/* ── Termine-View ────────────────────────────────────────── */
.termine-view {
  display: flex; flex-direction: column; height: 100%;
  background: var(--bg);
}
.termine-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 10px;
  background: linear-gradient(135deg, var(--p), var(--p-light));
  color: white; flex-shrink: 0;
}
.termine-topbar-title {
  flex: 1; font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em;
}
.termine-body {
  flex: 1; overflow-y: auto; padding: 12px 12px 80px;
}
.termine-group-label {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  padding: 14px 4px 6px;
}
.termine-date-label {
  font-size: 1rem; font-weight: 700; color: var(--p);
  padding: 9px 8px 6px 10px; margin: 4px 0 2px;
  border-left: 3px solid var(--p); background: rgba(184,150,46,0.07);
  border-radius: 0 var(--r) var(--r) 0;
}
.termine-date-label .termine-date-count {
  font-weight: 400; color: var(--muted); font-size: 0.8rem;
}
.termine-date-group {
  margin-bottom: 4px;
}
.termine-card {
  background: var(--surface); border-radius: var(--r);
  box-shadow: var(--shadow-sm); margin-bottom: 8px;
  display: flex; align-items: stretch; overflow: hidden;
  cursor: pointer; transition: box-shadow .15s;
}
.termine-card:active { box-shadow: 0 0 0 2px var(--p-light); }
.termine-card-bar {
  width: 4px; background: var(--p); flex-shrink: 0;
}
.termine-card-bar.past { background: #ccc; }
.termine-card-body {
  flex: 1; padding: 10px 12px;
}
.termine-card-date {
  font-size: 0.8rem; font-weight: 700; color: var(--p); margin-bottom: 2px;
}
.termine-card-date.past { color: #999; }
.termine-card-title { font-size: 0.85rem; font-weight: 400; color: var(--text); }
.termine-card-customer { font-size: 0.8rem; color: var(--muted); margin-top: 1px; }
.termine-card-time { font-size: 0.8rem; color: #888; margin-top: 1px; }
.termine-card-btns {
  display: flex; flex-direction: row; align-items: center;
  justify-content: center; flex-shrink: 0; padding: 0 4px; gap: 0;
}
.termine-card-edit {
  display: flex; align-items: center; justify-content: center;
  color: #ccc; font-size: 1.1rem;
  background: none; border: none; cursor: pointer; padding: 4px 8px;
}
.termine-card-edit:active { color: var(--p); }
.termine-card-del {
  display: flex; align-items: center; justify-content: center;
  color: #ccc; font-size: 1.1rem;
  background: none; border: none; cursor: pointer; padding: 4px 8px;
}
.termine-card-del:active { color: #ef4444; }
.termine-fab {
  position: fixed; bottom: 24px; right: 20px;
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--p-light), var(--p));
  color: white; font-size: 1.6rem; border: none;
  box-shadow: 0 4px 16px rgba(184,150,46,0.4);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
.termine-empty {
  text-align: center; color: var(--muted); padding: 40px 20px;
  font-size: 0.95rem;
}
.tform-row { margin-bottom: 6px; }
.tform-row label {
  font-size: 0.78rem; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; display: block;
  margin-bottom: 2px; cursor: pointer; }
.tform-row select, .tform-row input {
  width: 100%; border: none; border-bottom: 1.5px solid var(--border);
  padding: 12px 0; font-family: inherit; font-size: 1rem;
  color: var(--text); background: transparent; outline: none;
  -webkit-appearance: none; appearance: none;
  min-height: 44px; box-sizing: border-box; cursor: pointer;
  touch-action: manipulation; text-align: center;
}
.tform-row input:focus { border-bottom-color: var(--p); }
.tform-row select {
  background: white; padding: 12px 8px; border-radius: 8px;
  border: 1.5px solid var(--border); min-height: 44px;
}
.nt-search-wrap { position: relative; }
.nt-search-input {
  width: 100%; border: none; border-bottom: 1.5px solid var(--border);
  padding: 12px 32px 12px 0; font-family: inherit; font-size: 1rem;
  color: var(--text); background: transparent; outline: none;
  -webkit-appearance: none; appearance: none; box-sizing: border-box;
  min-height: 44px; touch-action: manipulation; text-align: center;
}
.nt-search-input::placeholder { color: #C4A882; }
.nt-search-clear {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #bbb; font-size: 1rem;
  cursor: pointer; padding: 0 2px; display: none;
}
.nt-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 999;
  background: white; border: 1.5px solid var(--border); border-top: none;
  border-radius: 0 0 8px 8px; max-height: 180px; overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.nt-dropdown-item {
  padding: 10px 12px; font-size: 0.9rem; cursor: pointer;
  color: var(--text); border-bottom: 1px solid var(--border);
}
.nt-dropdown-item:last-child { border-bottom: none; }
.nt-dropdown-item:active, .nt-dropdown-item.hovered { background: #FAF7F2; }
.nt-dropdown-empty { padding: 10px 12px; color: var(--muted); font-size: 0.85rem; }
.nt-selected-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: #FAF7F2; border: 1.5px solid var(--p-light);
  border-radius: 20px; padding: 4px 10px; font-size: 0.88rem;
  color: var(--text); margin-top: 4px;
}
.nt-selected-badge button {
  background: none; border: none; color: #bbb; cursor: pointer;
  font-size: 0.9rem; padding: 0; line-height: 1;
}

.cal-wrap {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.cal-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.cal-nav { background: none; border: none; font-size: 1.25rem; color: var(--p); padding: 4px 10px; cursor: pointer; }
.cal-grid { padding: 8px 8px 4px; }
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7,1fr);
  margin-bottom: 4px;
}
.cal-wd {
  text-align: center; font-size: 0.7rem; font-weight: 600;
  color: var(--muted); padding: 2px 0;
}
.cal-days { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; }
.cal-day {
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 2px 6px; border-radius: 10px; cursor: pointer;
  min-height: 44px; position: relative;
}
.cal-day:active { background: var(--p-light); }
.cal-day.other-month .cal-day-num { color: #D1D5DB; }
.cal-day.today .cal-day-num {
  background: var(--p); color: white;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.cal-day.selected { background: var(--p-light); }
.cal-day-num { font-size: 0.9rem; font-weight: 500; color: var(--text); line-height: 28px; min-width: 28px; text-align: center; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--p); margin-top: 2px; }
.cal-appts { border-top: 1px solid var(--border); }
.cal-appt-day-label {
  padding: 10px 16px 4px; font-size: 0.75rem; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em;
}
.cal-appt-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.cal-appt-item:last-child { border-bottom: none; }
.cal-appt-time {
  font-size: 0.75rem; color: var(--muted); min-width: 38px; text-align: right;
}
.cal-appt-body { flex: 1; }
.cal-appt-title { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.cal-appt-notes { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.cal-appt-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.cal-appt-edit { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 4px; }
.cal-appt-edit:active { color: var(--p); }
.cal-appt-del { background: none; border: none; color: #EF4444; font-size: 1.1rem; cursor: pointer; padding: 4px; }
.cal-add-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; color: var(--p); font-size: 0.9rem; font-weight: 500;
  cursor: pointer; border: none; background: none; width: 100%;
}
.cal-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 0.85rem; }

.frow-textarea {
  resize: none; line-height: 1.4;
  padding: 2px 0; min-height: 2.8rem;
  overflow: hidden;
}
.frow-input[type="number"]::-webkit-outer-spin-button,
.frow-input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

.frow-select {
  flex: 1; border: none; outline: none;
  font-family: inherit; font-size: 1rem; color: var(--text);
  background: transparent;
  -webkit-appearance: none; appearance: none;
  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='%23C4B5FD' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0 center;
  padding-right: 1.25rem;
}

/* ============================================================
   FORM FOOTER
   ============================================================ */
.form-footer {
  position: fixed; bottom: 0;
  left: max(0px, calc(50vw - 240px));
  width: 100%; max-width: 480px;
  padding: 0.875rem 1rem;
  padding-bottom: max(0.875rem, env(safe-area-inset-bottom, 0.875rem));
  background: white; border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06); z-index: 50;
}
.footer-btns { display: flex; gap: 0.75rem; }

/* ============================================================
   BOTTOM SHEET MODAL
   ============================================================ */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 500;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}

.bottom-sheet {
  background: white;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 1.5rem 1.25rem;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 1.5rem));
  width: 100%; max-width: 480px;
  overflow-y: auto;
  max-height: 90vh;
  -webkit-overflow-scrolling: touch;
}

.sheet-pill { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 1.25rem; }
.sheet-title { font-size: 1.0625rem; font-weight: 700; text-align: center; margin-bottom: 0.5rem; }
.sheet-msg   { font-size: 0.9375rem; color: var(--muted); text-align: center; line-height: 1.55; margin-bottom: 1.5rem; }
.sheet-btns  { display: flex; flex-direction: column; gap: 0.625rem; }

/* ============================================================
   LIGHTBOX
   ============================================================ */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.96);
  z-index: 2000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  touch-action: pan-y;
}

.lb-header {
  position: absolute; top: 0; left: 0; right: 0;
  padding: max(1rem, env(safe-area-inset-top, 1rem)) 1rem 1rem;
  display: flex; justify-content: space-between; align-items: center;
  z-index: 10;
}

.lb-counter {
  color: rgba(255,255,255,0.8);
  font-size: 0.875rem; font-weight: 600;
  background: rgba(255,255,255,0.1);
  padding: 0.25rem 0.75rem; border-radius: 50px;
}

.lb-close-btn {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.15); border: none; border-radius: 50%;
  color: white; font-size: 1.125rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.lb-close-btn:active { background: rgba(255,255,255,0.3); }

.lb-viewport { width: 100%; overflow: hidden; flex-shrink: 0; }

.lb-track {
  display: flex;
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.lb-slide {
  min-width: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 0 1rem;
  max-height: 72vh;
}

.lb-slide img {
  max-width: 100%; max-height: 72vh;
  object-fit: contain; border-radius: 10px;
  display: block;
  user-select: none; -webkit-user-drag: none;
}

.lb-dots {
  display: flex; gap: 6px; padding: 1.25rem 1rem 0.5rem;
  flex-wrap: wrap; justify-content: center; max-width: 300px;
}

.lb-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transition: background 0.2s, transform 0.2s;
  cursor: pointer;
}
.lb-dot.active { background: white; transform: scale(1.4); }

.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.12); border: none; border-radius: 50%;
  width: 46px; height: 46px; color: white; font-size: 1.375rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.lb-nav:active { background: rgba(255,255,255,0.25); }
.lb-nav.prev { left: 0.75rem; }
.lb-nav.next { right: 0.75rem; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 5.5rem; left: 50%; transform: translateX(-50%);
  width: calc(100% - 2rem); max-width: 440px;
  background: #1F2937; color: white;
  padding: 0.875rem 1rem; border-radius: var(--r);
  font-size: 0.9375rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 0.625rem;
  z-index: 1500;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast.success { border-left: 4px solid var(--green); }
.toast.error   { border-left: 4px solid var(--red); }
.toast.info    { border-left: 4px solid var(--p); }
.toast-icon    { font-size: 1.125rem; flex-shrink: 0; }

@keyframes toastIn {
  from { transform: translateX(-50%) translateY(24px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ============================================================
   LOADER
   ============================================================ */
.loader {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 3000;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.spinner {
  width: 44px; height: 44px;
  border: 3.5px solid var(--p-light); border-top-color: var(--p);
  border-radius: 50%; animation: spin 0.65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-banner {
  background: var(--red-bg); border: 1px solid #FECACA; color: var(--red);
  padding: 0.75rem 1rem; border-radius: var(--r-sm);
  font-size: 0.875rem; font-weight: 500; margin-bottom: 1rem;
}
