:root {
  --bg:           #F5F2EE;
  --surface:      #FFFFFF;
  --cream:        #F0EBE1;
  --header-bg:    #1C1C1A;
  --primary:      #C4934A;
  --primary-hover:#A87838;
  --danger:       #c0392b;
  --danger-hover: #a93226;
  --text:         #1C1C1A;
  --text-muted:   #7a6e62;
  --border:       #E2DDD5;
  --radius:       10px;
  --shadow:       0 2px 12px rgba(28,28,26,0.08);
  --font-ui:      'Nunito Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Cormorant Garamond', Georgia, serif;
}

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

/* ── 1. Typography + ── 3. Background texture ────────────────────────────── */
body {
  font-family: var(--font-ui);
  background-color: var(--bg);
  /* Subtle warm gradient mesh — depth without distraction */
  background-image:
    radial-gradient(ellipse at 12% 35%, rgba(196,147,74,0.06) 0%, transparent 52%),
    radial-gradient(ellipse at 88% 75%, rgba(219,191,176,0.09) 0%, transparent 46%),
    radial-gradient(ellipse at 55% 10%, rgba(200,187,168,0.05) 0%, transparent 38%);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── 5. Gold border instead of heavy shadow ───────────────────── */
header {
  background: var(--header-bg);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(196,147,74,0.38);
}
.header-inner {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
/* ── 1. Logo uses Cormorant Garamond ─────────────────────────────────────── */
.logo { display: flex; align-items: baseline; gap: 8px; }
.logo-afg {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  font-style: italic;
  color: #fff;
  letter-spacing: 4px;
  line-height: 1;
}
.logo-studio {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 400;
  color: rgba(255,255,255,0.38);
  letter-spacing: 2.5px;
  text-transform: uppercase;
}
.header-controls { display: flex; align-items: center; gap: 10px; }

/* Logout button (desktop) */
.btn-logout {
  display: flex; align-items: center; gap: 5px;
  background: none;
  border: 1.5px solid rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.55);
  font-family: var(--font-ui);
  font-size: 13px; font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
  letter-spacing: 0.2px;
}
.btn-logout:hover { color: #ff8a80; border-color: #ff8a80; }
.master-filter {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  font-family: var(--font-ui);
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
}
.master-filter:hover  { border-color: rgba(255,255,255,0.35); }
.master-filter option { background: #2a2a28; color: #fff; }

/* Buttons */
.btn-primary {
  background: var(--primary); color: white; border: none;
  border-radius: 6px; padding: 8px 16px; font-size: 14px;
  font-family: var(--font-ui); font-weight: 600;
  cursor: pointer; transition: background .15s; white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px; padding: 8px 14px; font-size: 14px;
  font-family: var(--font-ui);
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-secondary:hover { background: rgba(255,255,255,0.18); color: #fff; }

.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 16px; font-size: 14px;
  font-family: var(--font-ui);
  cursor: pointer; transition: all .15s;
}
.btn-ghost:hover { background: var(--cream); color: var(--text); }
.btn-danger {
  background: var(--danger); color: white; border: none;
  border-radius: 6px; padding: 8px 16px; font-size: 14px;
  font-family: var(--font-ui); font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 5px 10px !important; font-size: 12px !important; }

/* Main */
main { max-width: 1400px; margin: 20px auto; padding: 0 16px 40px; }
#calendar {
  background-color: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  background-image: url("/static/logo-bird.svg");
  background-repeat: no-repeat;
  background-position: center 60%;
  background-size: 40% auto;
}
#calendar[data-view="timeGridWeek"] { background-position: center 72%; }
#calendar[data-view="timeGridDay"]  { max-width: 748px; margin-inline: auto; background-position: center 68%; }

/* Desktop only: time grid views get 10% wider container */
@media (min-width: 768px) {
  main:has(#calendar[data-view="timeGridWeek"]),
  main:has(#calendar[data-view="timeGridDay"]) {
    max-width: 1540px;
  }
}

/* FullCalendar overrides */
.fc { font-family: var(--font-ui); }
.fc-toolbar-title { font-size: 17px !important; font-weight: 600; }

.fc-button-group { display: inline-flex !important; gap: 4px !important; }
.fc-button {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  border-radius: 6px !important;
  font-size: 13px !important;
  font-family: var(--font-ui) !important;
  font-weight: 500 !important;
}
.fc-button:hover        { background: var(--primary-hover) !important; border-color: var(--primary-hover) !important; }
.fc-button-active       { background: var(--primary-hover) !important; border-color: var(--primary-hover) !important; }
.fc-button:focus        { box-shadow: 0 0 0 0.1rem rgba(90,55,20,0.45) !important; outline: none !important; }
.fc-toolbar-chunk       { display: flex !important; align-items: center !important; gap: 6px !important; }

/* ── 4. Hour vs half-hour slot differentiation ───────────────────────────── */
.fc-timegrid-slot       { height: 24px !important; }
.fc-timegrid-slot-minor { border-top-style: dashed !important; border-top-color: rgba(226,221,213,0.5) !important; }

/* ── 2. Event cards — colored fill, slightly softened ────────────────────── */
.fc-timegrid-event {
  border-width: 0 0 0 3px !important;
  border-radius: 0 5px 5px 0 !important;
  padding: 0 !important;
  box-shadow: 0 1px 5px rgba(28,28,26,0.18), 0 0 0 0.5px rgba(28,28,26,0.08) !important;
  transition: box-shadow .15s, transform .12s !important;
  opacity: 0.88 !important;
}
.fc-timegrid-event:hover {
  opacity: 1 !important;
  box-shadow: 0 3px 10px rgba(28,28,26,0.13) !important;
  transform: translateY(-1px);
}
.fc-timegrid-event.fc-event-dragging {
  opacity: 1 !important;
  cursor: grabbing !important;
  box-shadow: 0 8px 24px rgba(28,28,26,0.18) !important;
  transform: translateY(-2px) scale(1.015);
}

/* Month view events keep compact style */
.fc-daygrid-event {
  border-width: 0 0 0 3px !important;
  border-radius: 0 3px 3px 0 !important;
  font-size: 11px !important;
  opacity: 0.88 !important;
}
.fc-event               { cursor: grab; }
.fc-event-frozen        { opacity: 0.55; cursor: default; }
.fc-event-frozen:hover  { opacity: 0.6; }
.fc-col-header-cell     { background: var(--bg); }
:root { --fc-today-bg-color: rgba(196,147,74,0.07); }

/* ── 3. Master name row — bigger, warmer ─────────────────────────────────── */
.master-day-label {
  font-size: 13px; font-weight: 600; padding: 2px 4px 6px; text-align: center;
  min-height: 22px; line-height: 1.4;
}
.master-day-label:empty { min-height: 22px; }

.master-month-label {
  font-size: 10px; font-weight: 500; padding: 0 4px 2px;
  line-height: 1.4; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}

/* Modal */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-overlay { position: absolute; inset: 0; background: rgba(28,28,26,0.52); backdrop-filter: blur(3px); }
.modal-content {
  position: relative; z-index: 1;
  background: linear-gradient(160deg, #ffffff 0%, var(--cream) 100%);
  border-radius: var(--radius);
  padding: 28px; width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 24px 64px rgba(28,28,26,0.2), 0 0 0 1px rgba(226,221,213,0.6);
}
.modal-wide { max-width: min(95vw, 1200px); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.appt-frozen-notice {
  margin-top: 12px; padding: 10px 14px;
  background: rgba(196,147,74,0.08); border: 1px solid rgba(196,147,74,0.25);
  border-radius: 8px; font-size: 13px; color: var(--text-muted); text-align: center;
}

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; letter-spacing: 0.3px; text-transform: uppercase; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; color: var(--text);
  font-family: var(--font-ui);
  background: rgba(255,255,255,0.8); outline: none; transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(196,147,74,0.12);
  background-color: #fff;
}
/* Custom select arrow — positions chevron like the date field's icon */
.form-group select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a6e62' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
.form-group textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Master + warning + session: 2-col on desktop, ordered stack on mobile */
.master-session-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas: "master session" "warning warning";
  column-gap: 12px;
  margin-bottom: 14px;
}
.fg-master  { grid-area: master; }
.fg-session { grid-area: session; }
.fg-warning { grid-area: warning; }

/* Client search */
.client-search-wrap { position: relative; }
.dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-top: none; border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 12px rgba(28,28,26,0.1); z-index: 10;
  max-height: 200px; overflow-y: auto;
}
.dropdown.hidden { display: none; }
.dropdown-item { padding: 9px 12px; font-size: 14px; cursor: pointer; transition: background .1s; }
.dropdown-item:hover { background: var(--bg); }
.dropdown-new { color: var(--primary); font-weight: 600; border-top: 1px solid var(--border); }
.client-badge {
  display: flex; align-items: center; gap: 8px;
  background: var(--cream); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 12px; font-size: 14px; margin-top: 6px; color: var(--primary);
}
.client-badge.hidden { display: none; }
.client-badge-remove { margin-left: auto; cursor: pointer; color: var(--text-muted); font-size: 18px; line-height: 1; }

/* New client block */
.new-client-block { background: var(--cream); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.new-client-block.hidden { display: none; }
.new-client-title { font-size: 13px; font-weight: 600; color: var(--primary); margin-bottom: 10px; }

/* Error */
.form-error { background: #fdf2f2; border: 1px solid #f5c6c6; color: var(--danger); border-radius: 6px; padding: 10px 12px; font-size: 13px; margin-top: 8px; }
.form-error.hidden { display: none; }

/* Appointment details */
.appt-detail-row { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.appt-detail-row:last-child { border-bottom: none; }
.appt-detail-row span   { color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.appt-detail-row strong { text-align: right; }

/* Master shift mismatch warning */
.master-shift-warning {
  background: #fff8e6; border: 1px solid #e8c86a; color: #7a5f1a;
  border-radius: 6px; padding: 9px 12px; font-size: 13px;
}
.master-shift-warning.hidden { display: none; }

/* Social warning */
.social-warning {
  background: #fefbe8; border: 1px solid #e8d88a; color: #7a5f1a;
  border-radius: 6px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px;
}
.social-warning.hidden { display: none; }

/* Visit count */
.visit-count {
  background: #f4fbf6; border: 1px solid #a8d5b5; color: #2d6a4f;
  border-radius: 6px; padding: 8px 12px; font-size: 13px; margin-bottom: 14px;
}
.visit-count.hidden { display: none; }

/* ── Schedule modal ──────────────────────────────────────────────────────── */
.schedule-nav {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.schedule-week-label { font-weight: 600; font-size: 15px; }

.schedule-table-wrap { overflow-x: auto; margin-bottom: 4px; }
.schedule-table { width: 100%; border-collapse: collapse; }
.schedule-table th {
  background: var(--bg); padding: 8px 6px; font-size: 11px;
  font-weight: 700; text-align: center; border-bottom: 2px solid var(--border);
  color: var(--text-muted); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.5px;
}
.schedule-master-header { text-align: left; padding-left: 12px; min-width: 90px; }
.schedule-table td { padding: 5px 4px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.schedule-master-cell { font-weight: 600; font-size: 13px; padding-left: 12px; white-space: nowrap; }
.schedule-day-cell { text-align: center; min-width: 120px; }

.shift-pill {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid; border-radius: 5px;
  padding: 4px 8px; font-size: 12px;
  background: var(--cream); white-space: nowrap;
}
.shift-delete-btn { background: none; border: none; font-size: 15px; color: var(--text-muted); cursor: pointer; padding: 0 2px; line-height: 1; }
.shift-delete-btn:hover { color: var(--danger); }
.shift-add-btn {
  background: none; border: 1.5px dashed var(--border);
  border-radius: 5px; padding: 4px 14px; font-size: 18px; line-height: 1;
  color: var(--border); cursor: pointer; transition: all .15s;
}
.shift-add-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--cream); }

.shift-popup {
  position: fixed; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
  box-shadow: 0 8px 32px rgba(28,28,26,0.16);
  z-index: 400; width: 230px;
}
.shift-popup.hidden { display: none; }
.shift-popup-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.shift-popup-row { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.shift-time-sel {
  flex: 1; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 5px; font-size: 13px; color: var(--text); background: var(--surface);
  font-family: var(--font-ui);
}
.shift-popup-actions { display: flex; gap: 8px; }

/* Responsive — desktop small */
@media (max-width: 600px) {
  .modal-content { padding: 16px; margin: 8px; max-height: 95vh; }
}

/* ════════════════════════════════════════════════════════════
   MOBILE  ≤ 767px  —  адаптивная версия
════════════════════════════════════════════════════════════ */

/* Show/hide helpers — no !important so @media can override by source order */
.mobile-only      { display: none; }
.mobile-only-flex { display: none; }
.mobile-screen    { display: none; }
.m-shift-overlay  { display: none; }
.m-shift-content  { display: none; }
/* Mobile header logo suffix */
.m-cal-suffix     { display: none; }
/* Force-hide via class (JS toggle, safe with !important) */
.mobile-hidden    { display: none !important; }

/* Slide-up animation for bottom sheets */
@keyframes mSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@media (max-width: 767px) {
  .mobile-only      { display: block; }          /* no !important — JS inline style can override */
  .mobile-only-flex { display: flex; }           /* same */
  .desktop-only     { display: none !important; }

  /* Mobile screen: shown when .hidden is removed */
  .mobile-screen              { display: block !important; }
  .mobile-screen.hidden       { display: none !important; }
  .m-shift-overlay            { display: block !important; }
  .m-shift-overlay.hidden     { display: none !important; }
  .m-shift-content            { display: block !important; }
  .m-shift-content.hidden     { display: none !important; }

  /* Hide FullCalendar toolbar on mobile (CSS fallback in case JS check fails) */
  .fc-toolbar                 { display: none !important; }
  .fc-col-header-cell-cushion { pointer-events: none; }

  /* ── Prevent horizontal overflow (only on specific containers, not html/body — iOS Safari fix) */

  /* ── Header ─────────────────────────────────────────────── */
  header { height: 48px; padding: 0 12px; }
  .header-inner { justify-content: center !important; }
  .logo-afg    { font-size: 18px; letter-spacing: 2px; }
  .logo-studio { display: none !important; }
  .m-cal-suffix {
    display: inline !important;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 400;
    color: rgba(255,255,255,0.42);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-left: 8px;
    vertical-align: middle;
  }
  .header-controls { display: none !important; }
  #scheduleBtn, #syncSheetsBtn, #newApptBtn { display: none !important; }
  .master-filter { display: none !important; }

  /* ── Mobile Date Nav ─────────────────────────────────────── */
  .mobile-date-nav {
    background: var(--header-bg);
    border-bottom: 1px solid rgba(196,147,74,0.38);
    position: sticky;
    top: 48px;
    z-index: 99;
    padding: 10px 14px 12px;
  }
  .mdn-toprow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
  }
  .mdn-title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    text-transform: capitalize;
  }
  .mdn-arrow {
    width: 30px; height: 30px;
    background: rgba(255,255,255,0.1);
    border: none; border-radius: 8px;
    color: rgba(255,255,255,0.8);
    font-size: 20px; line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .mdn-week { display: flex; gap: 2px; }
  .mdn-day {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mdn-day-name {
    font-size: 8px; font-weight: 700;
    color: rgba(255,255,255,0.4);
    letter-spacing: 0.5px; text-transform: uppercase;
  }
  .mdn-day-num {
    width: 27px; height: 27px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 500;
    color: rgba(255,255,255,0.55);
  }
  .mdn-day-num.today   { color: var(--primary); font-weight: 700; }
  .mdn-day.active .mdn-day-num {
    background: var(--primary); color: #fff; font-weight: 700;
  }
  .mdn-day.active .mdn-day-name { color: rgba(255,255,255,0.75); }

  /* ── Main & Calendar ─────────────────────────────────────── */
  main {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 0 calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    position: relative;
  }
  #calendar {
    border-radius: 0 !important;
    padding: 4px !important;
    box-shadow: none !important;
    background-image: none !important;
    max-width: 100% !important;
    margin-inline: 0 !important;
  }
  .fc-timegrid-slot     { height: 35px !important; }
  .fc-timegrid-axis     { width: 44px !important; font-size: 10px !important; }
  .fc-col-header-cell-cushion { font-size: 13px !important; padding: 6px 4px !important; }
  .fc-timegrid-event    { border-radius: 0 6px 6px 0 !important; }
  .master-day-label     { font-size: 11px !important; }

  /* Day view (mobile): hide day-name row, show only master — bigger, compact header */
  .fc-timeGridDay-view .fc-col-header-cell-cushion { display: none !important; }
  .fc-timeGridDay-view .master-day-label {
    font-size: 15px !important;
    font-weight: 700 !important;
    padding: 7px 4px !important;
    min-height: 0 !important;
  }
  /* Time slots 10% narrower in day view */
  .fc-timeGridDay-view .fc-timegrid-slot { height: 31px !important; }

  /* Mobile logout in "Ещё" screen */
  .m-logout-btn {
    width: 100%; padding: 13px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: var(--font-ui); font-size: 15px; font-weight: 600;
    color: #c0392b;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* ── Modal → Bottom Sheet ────────────────────────────────── */
  .modal { align-items: flex-end !important; }
  .modal-overlay { backdrop-filter: none !important; }
  .modal-content {
    width: 100vw !important;
    max-width: 100vw !important;
    left: 0 !important; right: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 88dvh !important;
    margin: 0 !important;
    padding: 0 16px calc(24px + env(safe-area-inset-bottom, 0px)) !important;
    animation: mSlideUp 0.28s cubic-bezier(0.4,0,0.2,1) !important;
    overflow-x: hidden !important;
  }
  /* Prevent form fields from overflowing; font-size 16px prevents iOS auto-zoom */
  .modal-content input,
  .modal-content select,
  .modal-content textarea { max-width: 100% !important; width: 100% !important; font-size: 16px !important; }
  /* drag handle on all bottom-sheet modals */
  .modal-content::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 12px auto 0;
  }
  .modal-header  { padding-top: 12px; margin-bottom: 14px !important; }
  .modal-wide    { max-width: 100% !important; }
  .modal-actions { gap: 8px !important; flex-direction: column !important; }
  .modal-actions .btn-primary,
  .modal-actions .btn-danger,
  .modal-actions .btn-ghost { width: 100% !important; text-align: center; }
  .form-row { grid-template-columns: 1fr !important; gap: 8px !important; }
  .schedule-table-wrap { overflow-x: auto; }

  /* ── Mobile Screen Overlays ──────────────────────────────── */
  .mobile-screen {
    position: fixed;
    top: 48px;   /* = header height */
    left: 0; right: 0;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    z-index: 90;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .mscreen-inner { padding: 16px 14px 24px; }
  .mscreen-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
  .mscreen-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
  .mscreen-weeknav {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
  }
  .mscreen-week-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }

  /* Master cards */
  .m-master-card {
    background: var(--surface);
    border-radius: 12px;
    overflow: visible;
    margin-bottom: 12px;
    box-shadow: 0 1px 5px rgba(28,28,26,0.08);
  }
  .m-master-card-hdr {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    overflow: hidden;
  }
  .m-master-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
  }
  .m-master-name  { font-size: 14px; font-weight: 700; color: var(--text); }
  .m-master-hours { font-size: 11px; color: var(--text-muted); }
  .m-add-shift-btn {
    margin-left: auto;
    display: flex; align-items: center; gap: 4px;
    background: var(--cream);
    border: 1.5px solid var(--primary);
    border-radius: 18px;
    padding: 5px 10px;
    font-size: 11px; font-weight: 700; color: var(--primary);
    cursor: pointer;
    touch-action: manipulation;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
  }
  .m-master-week-grid {
    display: flex;
    padding: 10px 12px 12px; gap: 4px;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
    background: var(--surface);
  }
  .m-week-day-cell {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    position: relative;
  }
  .m-wday-lbl {
    font-size: 7px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.3px;
  }
  .m-wday-blk {
    width: 100%; min-height: 34px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 600;
    position: relative;
    cursor: pointer;
  }
  .m-wday-work { color: #fff; }
  .m-wday-off  { background: var(--bg); color: var(--text-muted); font-size: 14px; }
  .m-today     { box-shadow: 0 0 0 2px var(--primary); border-radius: 6px; }
  .m-del-shift {
    position: absolute; top: -6px; right: -6px;
    width: 17px; height: 17px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 50%;
    font-size: 12px; line-height: 1;
    color: var(--danger);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; padding: 0;
    touch-action: manipulation;
    z-index: 5;
  }
  .m-wday-time { font-size: 8px; color: var(--text-muted); text-align: center; }

  /* More screen */
  .m-more-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 5px rgba(28,28,26,0.07);
  }
  .m-more-card-head {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 8px;
  }
  .m-more-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .m-more-card-title { font-size: 15px; font-weight: 700; color: var(--text); }
  .m-more-card-desc  { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-bottom: 10px; }
  .m-sync-status {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px; color: var(--text-muted);
    margin-bottom: 10px;
  }
  .m-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #4caf80; flex-shrink: 0; }
  .m-sync-btn { width: 100% !important; padding: 12px 16px !important; font-size: 14px !important; }

  /* ── Shift Bottom Sheet ───────────────────────────────────── */
  .m-shift-overlay {
    position: fixed; inset: 0;
    background: rgba(28,28,26,0.45);
    z-index: 490;
  }
  .m-shift-content {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    z-index: 500;
    padding: 0 18px calc(28px + env(safe-area-inset-bottom, 0px));
    animation: mSlideUp 0.28s cubic-bezier(0.4,0,0.2,1);
  }
  .m-shift-drag { display: flex; justify-content: center; padding: 10px 0 4px; }
  .m-shift-drag-bar { width: 36px; height: 4px; background: var(--border); border-radius: 2px; }
  .m-shift-hdr {
    display: flex; align-items: center; justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
  }
  .m-shift-title { font-size: 17px; font-weight: 700; color: var(--text); }
  .m-shift-close {
    width: 28px; height: 28px;
    background: var(--cream); border-radius: 50%; border: none;
    font-size: 20px; color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; line-height: 1;
    touch-action: manipulation;
  }
  .m-shift-master-badge {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--cream);
    border-radius: 20px; padding: 5px 12px;
    font-size: 13px; font-weight: 700;
    margin-bottom: 14px;
  }
  .m-shift-master-dot { width: 9px; height: 9px; border-radius: 50%; }
  .m-flabel {
    display: block;
    font-size: 9px; font-weight: 700; letter-spacing: 1.5px;
    text-transform: uppercase; color: var(--text-muted);
    margin-bottom: 5px;
  }
  .m-input, .m-select {
    width: 100%;
    padding: 11px 12px;
    border: 1.5px solid var(--border);
    border-radius: 9px;
    font-size: 14px;
    font-family: var(--font-ui);
    color: var(--text);
    background: var(--bg);
    outline: none;
    margin-bottom: 12px;
    -webkit-appearance: none;
  }
  .m-input:focus, .m-select:focus { border-color: var(--primary); }
  .m-shift-times  { display: flex; gap: 8px; align-items: flex-start; justify-content: center; }
  .m-shift-times > div:not(.m-shift-sep) { flex: 0 0 auto; width: 120px; }
  .m-shift-sep { color: var(--text-muted); font-size: 20px; padding-top: 24px; }
  .m-shift-save-btn {
    width: 100%; padding: 14px;
    background: var(--primary); color: #fff;
    border: none; border-radius: 12px;
    font-size: 15px; font-weight: 700;
    font-family: var(--font-ui);
    cursor: pointer;
    margin-top: 6px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* ── Bottom Navigation ───────────────────────────────────── */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    align-items: center;
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 12px rgba(28,28,26,0.07);
    overflow: visible;
  }
  .mbn-tab {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
    gap: 3px;
    background: none; border: none;
    padding: 10px 0 4px;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .mbn-tab.active::before {
    content: '';
    position: absolute;
    top: 0; left: 50%; transform: translateX(-50%);
    width: 24px; height: 2px;
    background: var(--primary); border-radius: 2px;
  }
  .mbn-tab svg { stroke: var(--text-muted); transition: stroke 0.15s; }
  .mbn-tab.active svg { stroke: var(--primary); }
  .mbn-tab-label {
    font-size: 8px; font-weight: 700;
    letter-spacing: 0.8px; text-transform: uppercase;
    color: var(--text-muted); transition: color 0.15s;
  }
  .mbn-tab.active .mbn-tab-label { color: var(--primary); }
  .mbn-fab-wrap {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  }
  .mbn-fab {
    width: 52px; height: 52px;
    background: var(--primary);
    border-radius: 50%;
    border: 3px solid var(--surface);
    box-shadow: 0 4px 14px rgba(196,147,74,0.45);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    position: relative; top: -18px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .mbn-fab-label {
    font-size: 8px; font-weight: 700;
    letter-spacing: 0.8px; text-transform: uppercase;
    color: var(--primary);
    position: relative; top: -16px;
  }

  /* Master-session area: stack with warning between master and session type */
  .master-session-area {
    grid-template-columns: 1fr !important;
    grid-template-areas: "master" "warning" "session" !important;
    gap: 8px !important;
    margin-bottom: 8px;
  }
  .fg-master, .fg-session { margin-bottom: 0 !important; }

  /* Date input: strip native iOS chrome so it renders like other form fields */
  .form-group input[type="date"] {
    -webkit-appearance: none !important;
    appearance: none !important;
    text-align: left !important;
    min-width: 0 !important;
    width: 100% !important;
    display: block !important;
    box-sizing: border-box !important;
  }
  .form-group input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
    min-height: 1.5em;
    display: block;
  }
}

/* ════════════════════════════════════════════════════════════
   LOGIN SCREEN
════════════════════════════════════════════════════════════ */

#loginScreen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(28,28,26,0.54);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
#loginScreen.hidden { display: none; }

/* Mobile top (dark) — hidden on desktop */
.ls-top { display: none; }

/* ── Card ── */
.ls-card {
  background: linear-gradient(155deg, #ffffff 0%, var(--cream) 100%);
  border-radius: 18px;
  padding: 36px 32px 32px;
  width: 400px;
  box-shadow:
    0 0 0 1px rgba(226,221,213,0.8),
    0 20px 60px rgba(28,28,26,0.26),
    0 4px 16px rgba(28,28,26,0.1);
}

/* ── Logo inside card (desktop) ── */
.ls-logo-inner {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: 22px;
}
.ls-logo-icon {
  width: 52px; height: 52px;
  background: var(--header-bg);
  border: 1.5px solid rgba(196,147,74,0.35);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
  overflow: hidden;
}
.ls-afg {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 600; font-style: italic;
  color: var(--text); letter-spacing: 5px; line-height: 1;
}
.ls-afg-sub {
  font-size: 8px; font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 3px; text-transform: uppercase; margin-top: 4px;
}
.ls-sep { width: 28px; height: 1px; background: var(--border); margin: 16px auto 18px; }

/* Drag handle — hidden on desktop */
.ls-drag-wrap { display: none; }
.ls-drag-bar  { width: 34px; height: 4px; background: var(--border); border-radius: 2px; }

/* ── Headings ── */
.ls-title-desk   { font-size: 14px; font-weight: 600; color: var(--text); text-align: center; margin-bottom: 20px; }
.ls-title-mob    { display: none; }
.ls-subtitle-mob { display: none; }

/* ── Error ── */
.ls-error {
  display: flex; align-items: center; gap: 7px;
  background: #fdf2f2; border: 1px solid #f5c6c6; color: #c0392b;
  border-radius: 8px; padding: 9px 13px; font-size: 13px;
  margin-bottom: 14px;
}
.ls-error.hidden { display: none; }
.ls-error svg    { flex-shrink: 0; }

/* ── Form fields ── */
.ls-fg { margin-bottom: 14px; }
.ls-fg label {
  display: block; font-size: 9px; font-weight: 700;
  color: var(--text-muted); letter-spacing: 1.2px;
  text-transform: uppercase; margin-bottom: 6px;
}
.ls-fg input {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; color: var(--text); font-family: var(--font-ui);
  background: rgba(255,255,255,0.8); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.ls-fg input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(196,147,74,0.11);
  background: #fff;
}
.ls-fg input::placeholder { color: rgba(122,110,98,0.45); }
.ls-fg input.ls-err-field { border-color: #f5c6c6 !important; background: #fffafa !important; }

/* Password with eye toggle */
.ls-input-row { position: relative; }
.ls-input-row input { padding-right: 42px; }
.ls-eye {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); cursor: pointer; display: flex; line-height: 0;
  user-select: none;
}
.ls-eye:hover { color: var(--text); }

/* Remember me */
.ls-remember {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 18px; cursor: pointer;
}
.ls-remember input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }
.ls-remember span  { font-size: 13px; color: var(--text-muted); }

/* Submit button */
.btn-ls-login {
  width: 100%; padding: 12px;
  background: var(--primary); color: #fff; border: none;
  border-radius: 9px; font-size: 14px; font-family: var(--font-ui);
  font-weight: 700; cursor: pointer; letter-spacing: 0.3px;
  transition: background .15s, transform .1s;
}
.btn-ls-login:hover    { background: var(--primary-hover); transform: translateY(-1px); }
.btn-ls-login:disabled { opacity: 0.7; cursor: default; transform: none; }

/* Footer */
.ls-footer { text-align: center; margin-top: 16px; font-size: 11px; color: var(--text-muted); }

/* Shake animation on error */
@keyframes lsShake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-7px); }
  40%      { transform: translateX(7px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
.ls-shake { animation: lsShake 0.35s ease; }

/* ── Mobile overrides (≤ 767px) ─────────────────────────────────────────── */
@media (max-width: 767px) {
  #loginScreen {
    flex-direction: column;
    align-items: stretch;
    background: var(--header-bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* Dark top section with logo */
  .ls-top {
    display: flex; flex-direction: column; align-items: center;
    padding: 36px 20px 40px;
    flex-shrink: 0;
  }
  .ls-top .ls-logo-icon {
    background: rgba(196,147,74,0.14);
    border: 1.5px solid rgba(196,147,74,0.4);
    margin-bottom: 12px;
  }
  .ls-top .ls-afg     { color: #fff; font-size: 22px; }
  .ls-top .ls-afg-sub { color: rgba(255,255,255,0.32); }

  /* Card becomes the white rounded form section */
  .ls-card {
    flex: 1;
    width: 100% !important;
    border-radius: 28px 28px 0 0 !important;
    padding: 0 !important;
    margin-top: -24px;
    box-shadow: none !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative; z-index: 2;
    display: flex; flex-direction: column;
  }

  .ls-drag-wrap {
    display: flex; justify-content: center;
    padding: 12px 0 0; flex-shrink: 0;
  }

  /* Hide desktop-specific elements */
  .ls-logo-inner   { display: none !important; }
  .ls-sep          { display: none !important; }
  .ls-title-desk   { display: none !important; }

  /* Show mobile-specific elements */
  .ls-title-mob    { display: block; font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
  .ls-subtitle-mob { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 22px; }

  /* Form body padding */
  .ls-card-body {
    padding: 18px 20px calc(40px + env(safe-area-inset-bottom, 0px));
    flex: 1;
  }

  /* Larger inputs: font-size 16px prevents iOS zoom */
  .ls-fg input {
    font-size: 16px !important;
    padding: 13px 14px !important;
    border-radius: 11px !important;
    -webkit-appearance: none !important;
  }
  .ls-input-row input { padding-right: 50px !important; }
  .ls-eye { right: 15px; }

  .ls-remember input { width: 18px !important; height: 18px !important; }
  .ls-remember span  { font-size: 14px; }

  .btn-ls-login {
    padding: 15px !important;
    font-size: 16px !important;
    border-radius: 13px !important;
    box-shadow: 0 4px 14px rgba(196,147,74,0.32);
    margin-bottom: 8px;
    -webkit-appearance: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative; z-index: 1;
  }

  .ls-error { border-radius: 10px; font-size: 14px; }
}
