:root {
  --bg: #070604;
  --bg-soft: #0c0a06;
  --panel: #100d08;
  --panel-2: #171209;
  --panel-3: #20180c;
  --gold: #d79a31;
  --gold-light: #f3c865;
  --gold-dark: #865613;
  --text: #f8f4eb;
  --muted: rgba(248, 244, 235, .62);
  --muted-2: rgba(248, 244, 235, .4);
  --line: rgba(215, 154, 49, .28);
  --line-soft: rgba(215, 154, 49, .14);
  --green: #51c88c;
  --green-soft: rgba(81, 200, 140, .14);
  --blue: #6d9eff;
  --red: #dd6f5a;
  --red-soft: rgba(221, 111, 90, .12);
  --shadow: 0 28px 90px rgba(0, 0, 0, .52);
  --radius: 18px;
  --sidebar: 230px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 86% 0%, rgba(207, 143, 35, .15), transparent 32%),
    linear-gradient(145deg, #050403 0%, #0b0905 55%, #050403 100%);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .035);
  color: var(--text);
  padding: 12px 13px;
  outline: none;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(243, 200, 101, .72);
  background: rgba(255, 255, 255, .055);
  box-shadow: 0 0 0 3px rgba(215, 154, 49, .1);
}
textarea { resize: vertical; }
select option { background: #17120a; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 650; }

.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line-soft);
  background: rgba(5, 4, 3, .93);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.brand-mark {
  width: 43px;
  height: 43px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #171006;
  background: linear-gradient(135deg, var(--gold), var(--gold-light) 56%, var(--gold-dark));
  font: 800 17px Georgia, serif;
  box-shadow: 0 14px 36px rgba(215, 154, 49, .2);
}
.brand-mark.large { width: 58px; height: 58px; border-radius: 17px; font-size: 22px; }
.brand-title { font-weight: 800; font-size: 15px; }
.brand-subtitle { color: var(--muted-2); font-size: 10px; text-transform: uppercase; letter-spacing: .16em; margin-top: 3px; }
.nav { display: grid; gap: 7px; }
.nav-item {
  width: 100%;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font-weight: 700;
}
.nav-item span { color: rgba(215, 154, 49, .55); font-size: 11px; }
.nav-item:hover { background: rgba(255, 255, 255, .035); color: var(--text); }
.nav-item.active { border-color: var(--line); background: linear-gradient(90deg, rgba(215,154,49,.16), rgba(215,154,49,.04)); color: var(--text); }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line-soft); padding-top: 18px; display: grid; gap: 12px; }
.sync-mini { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 11px; line-height: 1.35; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(81,200,140,.08); flex: 0 0 auto; }
.sync-dot.loading { background: var(--gold); animation: pulse 1s infinite; }
.sync-dot.error { background: var(--red); }
@keyframes pulse { 50% { opacity: .35; } }
.text-btn { width: fit-content; border: 0; padding: 0; background: none; color: var(--muted); cursor: pointer; }
.text-btn:hover { color: var(--text); }

.workspace { min-width: 0; padding: 28px clamp(18px, 2.4vw, 38px) 64px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; margin-bottom: 24px; }
.eyebrow { color: var(--gold-light); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; margin-bottom: 7px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(30px, 4vw, 54px); letter-spacing: -.045em; line-height: .98; }
h2 { margin-bottom: 7px; font-size: clamp(22px, 2vw, 30px); letter-spacing: -.025em; }
h3 { margin-bottom: 4px; }
p { color: var(--muted); line-height: 1.55; }
.topbar-actions, .section-actions, .modal-actions, .month-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn, .icon-btn, .filter-chip, .month-label {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
  color: var(--text);
  padding: 11px 15px;
  font-weight: 750;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
  white-space: nowrap;
}
.btn:hover, .icon-btn:hover, .filter-chip:hover, .month-label:hover { transform: translateY(-1px); border-color: rgba(243,200,101,.58); }
.btn.primary { background: linear-gradient(135deg, #d99c34, #f3c865); color: #171006; border-color: transparent; }
.btn.secondary { background: rgba(255,255,255,.03); }
.btn.danger { color: #f09a89; border-color: rgba(221,111,90,.38); background: var(--red-soft); }
.btn.compact { padding: 8px 11px; font-size: 12px; }
.btn.full { width: 100%; justify-content: center; }
.icon-btn { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; font-size: 23px; }
.month-label { min-width: 155px; background: transparent; cursor: default; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card { border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, rgba(20,17,11,.9), rgba(8,7,5,.94)); padding: 17px 18px; min-height: 92px; display: grid; align-content: space-between; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { color: var(--gold-light); font-size: 28px; line-height: 1; }

.view { display: none; }
.view.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; margin: 30px 0 16px; }
.section-head p { margin-bottom: 0; font-size: 14px; }
.panel-toolbar, .sales-toolbar { border: 1px solid var(--line-soft); border-radius: 16px; background: rgba(12,10,6,.72); padding: 12px; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip { padding: 9px 13px; color: var(--muted); font-size: 12px; }
.filter-chip.active { background: linear-gradient(135deg, var(--gold), var(--gold-light)); color: #171006; border-color: transparent; }
.search-field { min-width: min(280px, 100%); }
.search-field input { padding: 10px 12px; }

.booking-workspace { display: grid; grid-template-columns: 290px minmax(0,1fr); gap: 14px; align-items: stretch; }
.property-selector, .calendar-card, .agenda-card, .lead-table, .requests-grid { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(17,14,9,.96), rgba(8,7,5,.96)); }
.property-selector { padding: 13px; max-height: 670px; overflow: hidden; display: flex; flex-direction: column; }
.selector-head { margin-bottom: 10px; }
.mobile-villa-select { display: none; }
.property-list { overflow-y: auto; display: grid; gap: 7px; padding-right: 3px; }
.property-option { border: 1px solid transparent; border-radius: 13px; padding: 10px; display: grid; grid-template-columns: 48px minmax(0,1fr); gap: 10px; background: transparent; cursor: pointer; text-align: left; }
.property-option:hover { background: rgba(255,255,255,.035); }
.property-option.active { border-color: var(--line); background: rgba(215,154,49,.09); }
.property-thumb { width: 48px; height: 48px; border-radius: 10px; background-size: cover; background-position: center; }
.property-option strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; margin-bottom: 4px; }
.property-option small { color: var(--muted); }
.calendar-card { padding: 15px; min-width: 0; }
.calendar-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 16px; }
.selected-property { min-width: 0; }
.selected-property strong { display: block; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-property span { color: var(--muted); font-size: 12px; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); }
.calendar-weekdays { color: var(--muted-2); text-align: center; font-size: 11px; font-weight: 800; text-transform: uppercase; padding-bottom: 7px; }
.calendar-grid { border-top: 1px solid var(--line-soft); border-left: 1px solid var(--line-soft); }
.calendar-day {
  min-height: 88px;
  border: 0;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255,255,255,.012);
  color: var(--text);
  padding: 8px;
  text-align: left;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.calendar-day:hover { background: rgba(215,154,49,.06); }
.calendar-day.outside { color: rgba(248,244,235,.24); background: rgba(0,0,0,.18); }
.calendar-day.today::after { content: ''; position: absolute; inset: 4px; border: 1px solid rgba(243,200,101,.65); border-radius: 9px; pointer-events: none; }
.day-number { font-size: 11px; font-weight: 800; position: relative; z-index: 2; }
.day-events { display: grid; gap: 4px; margin-top: 8px; position: relative; z-index: 2; }
.day-event { border-radius: 7px; padding: 5px 6px; font-size: 10px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-event.confirmed { background: rgba(81,200,140,.22); color: #9cf0c4; }
.day-event.hold { background: rgba(243,200,101,.18); color: var(--gold-light); }
.day-event.completed, .day-event.cancelled { background: rgba(255,255,255,.06); color: var(--muted); }
.calendar-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; color: var(--muted); font-size: 11px; }
.calendar-legend span { display: flex; align-items: center; gap: 6px; }
.legend { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.legend.confirmed { background: var(--green); }
.legend.hold { background: var(--gold-light); }
.legend.today { border: 1px solid var(--gold-light); }
.agenda-card { padding: 16px; margin-top: 14px; }
.agenda-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.agenda-head h3 { margin: 0; }
.agenda-head span { color: var(--muted); font-size: 12px; }
.agenda-list { display: grid; gap: 8px; }
.agenda-item { border: 1px solid var(--line-soft); border-radius: 13px; padding: 12px; display: grid; grid-template-columns: minmax(150px, .7fr) minmax(160px, .9fr) minmax(140px, 1fr) auto; gap: 14px; align-items: center; background: rgba(255,255,255,.018); cursor: pointer; }
.agenda-item:hover { border-color: var(--line); }
.agenda-item strong { display: block; margin-bottom: 3px; }
.agenda-item small { color: var(--muted); }
.status-pill { display: inline-flex; width: fit-content; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 850; }
.status-pill.confirmed { color: #8be8b8; background: var(--green-soft); }
.status-pill.hold { color: var(--gold-light); background: rgba(215,154,49,.12); }
.status-pill.cancelled, .status-pill.lost { color: #f09a89; background: var(--red-soft); }
.status-pill.new { color: #9cbaff; background: rgba(109,158,255,.12); }

.villa-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); gap: 14px; }
.villa-card { min-width: 0; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: linear-gradient(160deg, rgba(18,15,10,.98), rgba(6,5,4,.98)); display: flex; flex-direction: column; }
.villa-card.is-hidden { opacity: .62; }
.villa-image { height: 190px; background-size: cover; background-position: center; position: relative; }
.badge { position: absolute; top: 12px; border-radius: 999px; padding: 7px 10px; font-size: 10px; font-weight: 850; backdrop-filter: blur(8px); }
.badge.left { left: 12px; }
.badge.right { right: 12px; }
.badge.available { background: rgba(81,200,140,.9); color: #07180f; }
.badge.booked { background: rgba(243,200,101,.9); color: #1a1205; }
.badge.hidden { background: rgba(120,120,120,.88); }
.badge.type { background: rgba(20,17,10,.78); color: var(--gold-light); border: 1px solid var(--line); }
.villa-body { padding: 14px; display: flex; flex-direction: column; flex: 1; min-width: 0; }
.villa-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.villa-title { font-weight: 850; font-size: 18px; line-height: 1.15; min-width: 0; }
.price { color: var(--gold-light); font-weight: 850; white-space: nowrap; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.meta span { border: 1px solid var(--line-soft); border-radius: 999px; padding: 6px 8px; color: var(--muted); font-size: 10px; }
.address { color: var(--muted); font-size: 12px; line-height: 1.45; min-height: 36px; }
.card-actions { display: grid; grid-template-columns: 1fr; margin-top: auto; padding-top: 14px; }
.card-actions .btn { width: 100%; min-width: 0; }

.lead-table { overflow: hidden; }
.lead-row { display: grid; grid-template-columns: 1.2fr 1fr .8fr .8fr auto; gap: 16px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.lead-row:last-child { border-bottom: 0; }
.lead-row:hover { background: rgba(215,154,49,.04); }
.lead-row strong { display: block; margin-bottom: 4px; }
.lead-row small { color: var(--muted); }
.requests-grid { padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; }
.request-card { border: 1px solid var(--line-soft); border-radius: 14px; padding: 14px; background: rgba(255,255,255,.018); display: grid; gap: 12px; }
.request-card-head { display: flex; justify-content: space-between; gap: 10px; }
.request-card p { margin: 0; font-size: 13px; }
.request-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.request-actions .btn { padding: 8px 10px; font-size: 11px; }
.empty-state { grid-column: 1 / -1; padding: 30px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); text-align: center; }

.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 22px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.72); backdrop-filter: blur(11px); }
.modal-card { position: relative; z-index: 1; width: min(720px, 100%); max-height: calc(100vh - 44px); overflow: auto; border: 1px solid var(--line); border-radius: 22px; background: linear-gradient(150deg, #171108, #080704 70%); box-shadow: var(--shadow); padding: 22px; }
.booking-editor-card { width: min(760px, 100%); }
.villa-editor-card { width: min(1220px, 100%); padding: 0; }
.lead-editor-card { width: min(680px, 100%); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.modal-header h2 { margin-bottom: 0; }
.modal-close { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.03); cursor: pointer; font-size: 22px; }
.modal form { display: grid; gap: 14px; }
.field-grid { display: grid; gap: 12px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.field-grid.four { grid-template-columns: repeat(4, minmax(0,1fr)); }
.modal-actions { justify-content: space-between; margin-top: 6px; }
.sticky-modal-head { position: sticky; top: 0; z-index: 4; padding: 20px 22px 14px; margin: 0; background: rgba(15,11,7,.96); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line-soft); }
.villa-editor-card form { padding: 18px 22px 0; }
.villa-editor-layout { display: grid; grid-template-columns: 320px minmax(0,1fr); gap: 20px; }
.media-editor { min-width: 0; }
.main-image-preview { aspect-ratio: 4/3; border-radius: 16px; background-size: cover; background-position: center; border: 1px solid var(--line); margin-bottom: 10px; }
.upload-btn { border: 1px dashed var(--line); border-radius: 12px; padding: 13px; display: block; text-align: center; cursor: pointer; margin-bottom: 10px; }
.upload-btn input { display: none; }
.gallery-preview { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 7px; margin-top: 10px; }
.gallery-thumb { aspect-ratio: 1; border-radius: 9px; background-size: cover; background-position: center; border: 1px solid var(--line-soft); }
.villa-fields { display: grid; gap: 13px; min-width: 0; }
.sticky-modal-actions { position: sticky; bottom: 0; z-index: 4; margin: 18px -22px 0; padding: 14px 22px; background: rgba(11,8,5,.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line-soft); }
.sticky-modal-actions > div { display: flex; gap: 8px; }

.toast { position: fixed; z-index: 300; right: 22px; bottom: 22px; max-width: min(440px, calc(100vw - 44px)); padding: 13px 16px; border: 1px solid var(--line); border-radius: 13px; background: #171108; color: var(--text); box-shadow: var(--shadow); transform: translateY(24px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: rgba(221,111,90,.5); color: #ffc1b5; }
.login-overlay { position: fixed; inset: 0; z-index: 250; display: grid; place-items: center; padding: 22px; background: radial-gradient(circle at 50% 25%, rgba(215,154,49,.1), transparent 30%), #050403; }
.login-overlay.hidden { display: none; }
.login-card { width: min(470px, 100%); border: 1px solid var(--line); border-radius: 24px; padding: 34px; background: linear-gradient(150deg, #171108, #080704); box-shadow: var(--shadow); display: grid; gap: 20px; }
.login-card h2 { margin: 0; font-size: 34px; }
.mobile-menu, .sidebar-shade { display: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(215,154,49,.28); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1180px) {
  :root { --sidebar: 200px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .booking-workspace { grid-template-columns: 240px minmax(0,1fr); }
  .calendar-day { min-height: 76px; }
  .agenda-item { grid-template-columns: 1fr 1fr auto; }
  .agenda-item > :nth-child(3) { grid-column: 1 / 3; }
  .villa-editor-layout { grid-template-columns: 270px minmax(0,1fr); }
  .field-grid.four { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-105%); width: 270px; transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-shade { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.58); }
  .sidebar-shade.open { display: block; }
  .mobile-menu { display: grid; place-items: center; position: fixed; z-index: 35; left: 14px; top: 14px; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; background: rgba(10,8,5,.9); color: var(--text); }
  .workspace { padding-top: 76px; }
  .topbar { align-items: flex-end; }
  .booking-workspace { grid-template-columns: 1fr; }
  .property-selector { max-height: none; }
  .property-list { display: none; }
  .mobile-villa-select { display: block; }
  .selector-head .search-field { display: none; }
  .villa-editor-layout { grid-template-columns: 1fr; }
  .media-editor { max-width: 460px; }
  .lead-row { grid-template-columns: 1fr 1fr auto; }
  .lead-row > :nth-child(3), .lead-row > :nth-child(4) { grid-row: 2; }
}

@media (max-width: 680px) {
  .workspace { padding-left: 12px; padding-right: 12px; padding-bottom: 40px; }
  .topbar { display: grid; gap: 16px; }
  .topbar-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .topbar-actions .btn { min-width: 0; white-space: normal; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .stat-card { min-height: 80px; padding: 14px; }
  .section-head { align-items: stretch; display: grid; }
  .section-head .btn { width: 100%; }
  .panel-toolbar, .sales-toolbar { display: grid; }
  .search-field { min-width: 0; }
  .calendar-card { padding: 10px; }
  .calendar-toolbar { display: grid; }
  .month-controls { justify-content: space-between; }
  .month-label { flex: 1; min-width: 0; }
  .calendar-day { min-height: 63px; padding: 5px; }
  .day-events { margin-top: 5px; }
  .day-event { padding: 3px 4px; font-size: 8px; }
  .calendar-legend { gap: 10px; }
  .agenda-item { grid-template-columns: 1fr; gap: 8px; }
  .agenda-item > :nth-child(3) { grid-column: auto; }
  .villa-list { grid-template-columns: 1fr; }
  .villa-image { height: 210px; }
  .lead-row { grid-template-columns: 1fr auto; gap: 8px; }
  .lead-row > * { grid-column: 1; grid-row: auto; }
  .lead-row > :last-child { grid-column: 2; grid-row: 1; }
  .requests-grid { grid-template-columns: 1fr; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-card { width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; padding: 18px 14px; }
  .villa-editor-card { padding: 0; }
  .sticky-modal-head { padding: 17px 14px 12px; }
  .villa-editor-card form { padding: 14px 14px 0; }
  .sticky-modal-actions { margin-left: -14px; margin-right: -14px; padding: 12px 14px; display: grid; }
  .sticky-modal-actions > div { order: 2; }
  .sticky-modal-actions .btn { width: 100%; }
  .field-grid.two, .field-grid.three, .field-grid.four { grid-template-columns: 1fr; }
  .modal-actions { display: grid; }
  .modal-actions .btn { width: 100%; }
  .gallery-preview { grid-template-columns: repeat(5, minmax(0,1fr)); }
  .login-card { padding: 26px 20px; }
  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

@media (max-width: 390px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar-actions { grid-template-columns: 1fr; }
  .calendar-day { min-height: 56px; }
  .gallery-preview { grid-template-columns: repeat(4, minmax(0,1fr)); }
}

/* CRM v11 refinements */
.mobile-calendar-switch, .mobile-calendar-agenda { display: none; }
.day-event.segment-middle { border-radius: 0; margin-left: -8px; margin-right: -8px; padding-left: 8px; }
.day-event.segment-start { margin-left: 0; border-radius: 7px 0 0 7px; }
.day-event.segment-end { margin-right: 0; border-radius: 0 7px 7px 0; }
.day-event.segment-start.segment-end { border-radius: 7px; }

.sales-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 12px;
  align-items: start;
  overflow-x: auto;
  padding: 2px 0 10px;
}
.sales-column {
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(150deg, rgba(17,14,9,.96), rgba(8,7,5,.96));
  overflow: hidden;
}
.sales-column > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  font-weight: 800;
}
.sales-column > header strong {
  min-width: 25px;
  height: 25px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--gold-light);
  background: rgba(215,154,49,.11);
}
.sales-column-body { display: grid; gap: 8px; padding: 9px; min-height: 140px; }
.sales-card {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 11px;
  background: rgba(255,255,255,.022);
  cursor: pointer;
  min-width: 0;
}
.sales-card:hover { border-color: rgba(243,200,101,.5); background: rgba(215,154,49,.045); }
.sales-card-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.sales-card-top strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sales-card-top span, .sales-card small { color: var(--muted); font-size: 10px; }
.sales-card p { margin: 9px 0; font-size: 12px; color: var(--text); }
.sales-card-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 9px; }
.sales-card-meta span { border: 1px solid var(--line-soft); border-radius: 999px; padding: 5px 7px; color: var(--muted); font-size: 9px; }
.sales-empty { padding: 24px 8px; color: var(--muted-2); text-align: center; font-size: 11px; }

.mobile-booking-card {
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255,255,255,.02);
  display: grid;
  grid-template-columns: minmax(110px,.8fr) minmax(0,1fr) auto;
  gap: 12px;
  align-items: center;
  text-align: left;
  cursor: pointer;
}
.mobile-booking-card > span > strong, .mobile-booking-card > span > small { display: block; }
.mobile-booking-card small { color: var(--muted); margin-top: 4px; }
.mobile-booking-dates { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.mobile-booking-dates i { width: 18px; height: 1px; background: var(--gold); }

.villa-card, .villa-body, .villa-title-row, .topbar, .section-head, .panel-toolbar { min-width: 0; }
.villa-title, .address { overflow-wrap: anywhere; }
.price { max-width: 48%; overflow: hidden; text-overflow: ellipsis; }
.card-actions .btn { overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1280px) {
  .villa-list { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
  .sales-board { grid-template-columns: repeat(5, minmax(210px, 1fr)); }
}

@media (max-width: 900px) {
  .sales-board { grid-template-columns: repeat(5, minmax(250px, 78vw)); scroll-snap-type: x mandatory; }
  .sales-column { scroll-snap-align: start; }
}

@media (max-width: 680px) {
  .mobile-calendar-switch { display: flex; gap: 6px; width: 100%; }
  .mobile-calendar-switch .filter-chip { flex: 1; }
  .mobile-calendar-agenda { display: none; gap: 8px; }
  .calendar-card.mobile-list-mode .calendar-weekdays,
  .calendar-card.mobile-list-mode .calendar-grid,
  .calendar-card.mobile-list-mode .calendar-legend,
  .calendar-card.mobile-list-mode .month-controls { display: none; }
  .calendar-card.mobile-list-mode .mobile-calendar-agenda { display: grid; }
  .agenda-card { display: none; }
  .calendar-toolbar { margin-bottom: 10px; }
  .calendar-day { min-width: 43px; }
  .calendar-grid, .calendar-weekdays { min-width: 315px; }
  .calendar-card:not(.mobile-list-mode) { overflow-x: auto; }
  .mobile-booking-card { grid-template-columns: 1fr auto; }
  .mobile-booking-dates { grid-column: 1 / -1; }
  .villa-list { grid-template-columns: minmax(0,1fr); }
  .villa-image { height: clamp(180px, 52vw, 240px); }
  .villa-title-row { gap: 8px; }
  .price { max-width: 44%; font-size: 14px; }
  .sales-board { margin-left: -2px; margin-right: -2px; }
}

@media (max-width: 390px) {
  .mobile-booking-card { grid-template-columns: 1fr; }
  .mobile-booking-card .status-pill { grid-column: 1; }
}

.sales-card.dragging { opacity: .42; transform: scale(.98); }
.sales-column-body.drag-over { background: rgba(215,154,49,.08); box-shadow: inset 0 0 0 1px rgba(243,200,101,.4); }
.sales-owner { display: block; margin-top: 7px; color: var(--gold-light) !important; }
@media (pointer: coarse) { .sales-card { -webkit-user-drag: none; } }

/* CRM v12: inbox badges, background sync and compact workflow */
.nav-item .nav-label { flex: 1; color: inherit; font-size: inherit; }
.nav-alert {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: #d84b3e;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  box-shadow: 0 0 0 4px rgba(216,75,62,.1);
}
.nav-alert[hidden] { display: none; }

.request-inbox, .general-messages-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(17,14,9,.96), rgba(8,7,5,.96));
  padding: 14px;
  margin-bottom: 14px;
}
.request-inbox-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.request-inbox-head h3 { margin: 0 0 3px; font-size: 17px; }
.request-inbox-head p { margin: 0; font-size: 12px; }
.inbox-count {
  min-width: 32px;
  height: 32px;
  padding: 0 9px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #d84b3e;
  color: #fff;
  font-weight: 850;
  font-size: 12px;
}
.inbox-count.neutral { background: rgba(215,154,49,.13); color: var(--gold-light); }
.request-inbox-list, .general-request-list { display: grid; gap: 8px; }
.inbox-request-card {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0,1.1fr) minmax(150px,.7fr) auto;
  gap: 14px;
  align-items: center;
  background: rgba(255,255,255,.018);
}
.inbox-request-card.is-new {
  border-color: rgba(216,75,62,.5);
  background: linear-gradient(90deg, rgba(216,75,62,.09), rgba(255,255,255,.018));
}
.inbox-request-main, .inbox-request-meta { min-width: 0; }
.inbox-request-main strong, .inbox-request-main small, .inbox-request-meta strong, .inbox-request-meta small { display: block; }
.inbox-request-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-request-card small { color: var(--muted); margin-top: 4px; font-size: 11px; }
.inbox-request-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.inbox-request-actions .btn { padding: 9px 11px; font-size: 11px; }
.new-marker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ff9588;
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 5px;
}
.new-marker::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #d84b3e; }

.general-messages-card { margin-top: 18px; }
.general-message-card {
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(160px,.55fr) minmax(0,1fr) auto;
  gap: 12px;
  align-items: center;
  background: rgba(255,255,255,.016);
}
.general-message-card.is-new { border-color: rgba(216,75,62,.42); }
.general-message-card p { margin: 0; color: var(--text); font-size: 12px; overflow-wrap: anywhere; }

.lead-context {
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  padding: 12px;
  background: rgba(215,154,49,.06);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.lead-context strong { color: var(--text); }
.modal-action-group { display: flex; gap: 8px; flex-wrap: wrap; }

.sync-mini[data-state="pending"] .sync-dot { background: var(--gold); animation: pulse 1s infinite; }
.sync-mini[data-state="failed"] .sync-dot { background: var(--red); }

@media (max-width: 1050px) {
  .inbox-request-card { grid-template-columns: minmax(0,1fr) auto; }
  .inbox-request-meta { grid-column: 1; }
  .inbox-request-actions { grid-column: 2; grid-row: 1 / 3; }
}

@media (max-width: 680px) {
  .request-inbox, .general-messages-card { padding: 11px; }
  .inbox-request-card, .general-message-card { grid-template-columns: 1fr; gap: 10px; }
  .inbox-request-meta, .inbox-request-actions { grid-column: 1; grid-row: auto; }
  .inbox-request-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .inbox-request-actions .btn { width: 100%; white-space: normal; }
  .general-message-card .btn { width: 100%; }
  .modal-action-group { display: grid; width: 100%; }
}

@media (max-width: 390px) {
  .inbox-request-actions { grid-template-columns: 1fr; }
}

/* v13: currency management */
.pricing-editor {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: linear-gradient(145deg, rgba(215,154,49,.065), rgba(255,255,255,.012));
  display: grid;
  gap: 14px;
}
.pricing-editor-head, .current-rates-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.pricing-editor-head strong, .current-rates-head strong { display: block; font-size: 14px; }
.pricing-editor-head small, .current-rates-head small { display: block; color: var(--muted); margin-top: 3px; font-size: 11px; line-height: 1.4; }
.switch-row { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; color: var(--text); font-size: 12px; font-weight: 750; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-control { width: 42px; height: 24px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.06); position: relative; flex: 0 0 auto; transition: .2s ease; }
.switch-control::after { content: ''; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); position: absolute; top: 3px; left: 3px; transition: .2s ease; }
.switch-row input:checked + .switch-control { background: linear-gradient(135deg, var(--gold), var(--gold-light)); border-color: transparent; }
.switch-row input:checked + .switch-control::after { left: 21px; background: #161006; }
.switch-row.large { align-items: flex-start; width: 100%; }
.switch-row.large > span:last-child { display: grid; gap: 3px; }
.switch-row.large strong { font-size: 14px; }
.switch-row.large small { color: var(--muted); font-weight: 500; line-height: 1.45; }
.price-preview-grid, .current-rates-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.price-preview-grid > div, .current-rates-grid > div { border: 1px solid var(--line-soft); border-radius: 12px; padding: 10px 12px; background: rgba(0,0,0,.22); min-width: 0; }
.price-preview-grid span, .current-rates-grid span { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .06em; }
.price-preview-grid strong, .current-rates-grid strong { display: block; margin-top: 4px; color: var(--gold-light); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.currency-settings-card { width: min(650px, calc(100vw - 32px)); }
.currency-mode-card, .current-rates-card { border: 1px solid var(--line); border-radius: 15px; padding: 14px; background: rgba(255,255,255,.018); }
.current-rates-card { display: grid; gap: 14px; }
.rate-note { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.currency-update-warning { color: #ff9d91; }

@media (max-width: 760px) {
  .pricing-editor-head, .current-rates-head { align-items: flex-start; flex-direction: column; }
  .price-preview-grid, .current-rates-grid { grid-template-columns: 1fr; }
  .topbar-actions { flex-wrap: wrap; }
  #currencySettingsBtn { order: 3; width: 100%; }
}


/* v14: mixed currency rules and rounding */
.currency-rules-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.currency-rule-card {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 12px;
  background: rgba(0,0,0,.2);
  display: grid;
  gap: 10px;
  min-width: 0;
}
.currency-rule-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.currency-rule-head strong {
  color: var(--gold-light);
  font-size: 14px;
}
.currency-rule-head select {
  width: auto;
  min-width: 112px;
  height: 36px;
  padding: 0 30px 0 10px;
}
.currency-rule-head select:disabled {
  opacity: 1;
  color: var(--gold-light);
  cursor: default;
}
.currency-rule-auto,
.currency-rule-manual {
  min-width: 0;
}
.currency-rule-result {
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
  min-width: 0;
}
.currency-rule-result span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.currency-rule-result strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rounding-settings-card {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 14px;
  background: rgba(255,255,255,.018);
  display: grid;
  gap: 14px;
}
.rounding-settings-card > div:first-child strong {
  display: block;
  font-size: 14px;
}
.rounding-settings-card > div:first-child small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .currency-rules-grid { grid-template-columns: 1fr; }
  .currency-rule-head select { min-width: 132px; }
}

@media (max-width: 560px) {
  .currency-rule-head { align-items: stretch; flex-direction: column; }
  .currency-rule-head select { width: 100%; }
}


/* v20: visual gallery editor */
.main-image-preview { position: relative; overflow: hidden; min-height: 220px; background-color: #0e0b07; }
.main-image-badge { position: absolute; left: 10px; top: 10px; padding: 5px 8px; border-radius: 999px; background: rgba(7,6,4,.82); border: 1px solid var(--line-soft); color: var(--gold-light); font-size: 10px; font-weight: 800; }
.gallery-toolbar { display: flex; align-items: center; gap: 10px; }
.gallery-upload-btn { flex: 1; margin: 0; }
.gallery-counter { flex: 0 0 auto; color: var(--muted); font-size: 12px; font-weight: 800; }
.gallery-help { margin: 8px 0 10px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.gallery-editor { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.gallery-editor-item { position: relative; border: 1px solid var(--line-soft); border-radius: 12px; overflow: hidden; background: #0c0906; min-width: 0; }
.gallery-editor-thumb { aspect-ratio: 4 / 3; background-size: cover; background-position: center; position: relative; }
.gallery-editor-thumb-image { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; display:block; background:#080604; }
.gallery-editor-main { position: absolute; left: 7px; top: 7px; padding: 4px 7px; border-radius: 999px; background: rgba(7,6,4,.86); color: var(--gold-light); font-size: 9px; font-weight: 900; }
.gallery-editor-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px; }
.gallery-editor-actions button { min-width: 0; height: 30px; border-radius: 8px; border: 1px solid var(--line-soft); background: rgba(255,255,255,.035); color: var(--text); cursor: pointer; font-size: 12px; }
.gallery-editor-actions button:hover { background: rgba(255,255,255,.08); }
.gallery-editor-actions button.is-main { color: var(--gold-light); }
.gallery-editor-actions button.danger { color: #ff9d91; }
.gallery-alt-input { border: 0 !important; border-top: 1px solid var(--line-soft) !important; border-radius: 0 !important; background: rgba(255,255,255,.02) !important; font-size: 10px !important; min-height: 34px !important; padding: 7px 8px !important; }
.field-hint { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.35; }
@media (max-width: 980px) { .gallery-editor { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 620px) { .gallery-editor { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* PWA / iPhone standalone mode */
.pwa-install-hint {
  position: fixed;
  z-index: 10000;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  width: min(520px, calc(100vw - 28px));
  transform: translate(-50%, -12px);
  opacity: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #100d08;
  box-shadow: 0 20px 70px rgba(0, 0, 0, .58);
  transition: opacity .18s ease, transform .18s ease;
}
.pwa-install-hint[hidden] { display: none; }
.pwa-install-hint.visible { opacity: 1; transform: translate(-50%, 0); }
.pwa-install-hint strong { display: block; font-size: 13px; }
.pwa-install-hint span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.pwa-install-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #171006;
  background: linear-gradient(135deg, var(--gold), var(--gold-light) 56%, var(--gold-dark));
  font: 800 16px Georgia, serif;
}
.pwa-install-hint button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
}
.pwa-install-hint button:hover { color: var(--text); background: rgba(255, 255, 255, .08); }

@supports (padding: env(safe-area-inset-top)) {
  .pwa-standalone body {
    min-height: 100dvh;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .pwa-standalone .sidebar {
    padding-top: calc(24px + env(safe-area-inset-top));
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
  .pwa-standalone .workspace {
    padding-top: env(safe-area-inset-top);
  }
  .pwa-standalone .modal-card {
    margin-bottom: env(safe-area-inset-bottom);
  }
}

@media (max-width: 680px) {
  .pwa-install-hint {
    top: max(10px, env(safe-area-inset-top));
    width: calc(100vw - 20px);
  }
}

/* CRM v23: iPhone PWA safe-area fix */
@media (max-width: 900px) {
  .pwa-standalone .mobile-menu {
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: calc(env(safe-area-inset-left, 0px) + 14px);
    z-index: 90;
    width: 44px;
    height: 44px;
    background: #0c0a06;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .38);
  }

  .pwa-standalone .workspace {
    padding-top: calc(env(safe-area-inset-top, 0px) + 78px);
  }

  .pwa-standalone .sidebar {
    height: 100dvh;
    padding-top: calc(env(safe-area-inset-top, 0px) + 24px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  }

  .pwa-standalone .sidebar-shade {
    inset:
      env(safe-area-inset-top, 0px)
      env(safe-area-inset-right, 0px)
      env(safe-area-inset-bottom, 0px)
      env(safe-area-inset-left, 0px);
  }
}

@media (max-width: 680px) {
  .pwa-standalone .workspace {
    padding-top: calc(env(safe-area-inset-top, 0px) + 74px);
  }

  .pwa-standalone .topbar {
    margin-bottom: 20px;
  }
}

/* CRM v25: dashboard, analytics and compact mobile calendar */
.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0 16px;
}
.dashboard-kpi,
.dashboard-card {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(18,15,10,.96), rgba(7,6,4,.98));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.018);
}
.dashboard-kpi {
  min-height: 112px;
  padding: 16px;
  border-radius: 16px;
  display: grid;
  align-content: space-between;
  gap: 8px;
}
.dashboard-kpi span,
.dashboard-kpi small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.dashboard-kpi strong { color: var(--gold-light); font-size: clamp(26px, 3vw, 38px); line-height: 1; }
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.dashboard-grid-top { grid-template-columns: minmax(0, 1.45fr) minmax(300px, .55fr); }
.dashboard-card { border-radius: 18px; padding: 16px; min-width: 0; margin-bottom: 14px; }
.dashboard-grid .dashboard-card { margin-bottom: 0; }
.dashboard-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}
.dashboard-card-head h3 { margin: 0 0 4px; font-size: 18px; }
.dashboard-card-head p { margin: 0; font-size: 11px; color: var(--muted); }
.dashboard-card-head > strong { color: var(--gold-light); white-space: nowrap; }

.occupancy-chart {
  height: 190px;
  display: grid;
  grid-template-columns: repeat(30, minmax(3px, 1fr));
  align-items: end;
  gap: 3px;
  padding: 10px 0 0;
}
.occupancy-bar-wrap { height: 100%; display: grid; grid-template-rows: 1fr 16px; align-items: end; min-width: 0; }
.occupancy-bar {
  width: 100%;
  min-height: 4px;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold-dark));
  opacity: .92;
}
.occupancy-bar-wrap span { text-align: center; color: var(--muted-2); font-size: 8px; }

.integration-state {
  display: inline-flex;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}
.integration-state.success { color: #8be8b8; background: var(--green-soft); }
.integration-state.error { color: #ffc1b5; background: var(--red-soft); }
.integration-state.neutral { color: var(--muted); background: rgba(255,255,255,.06); }
.integration-details { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.integration-details > div { border: 1px solid var(--line-soft); border-radius: 12px; padding: 10px; }
.integration-details span,
.integration-details small,
.integration-details p { color: var(--muted); font-size: 10px; }
.integration-details strong { display: block; margin-top: 4px; color: var(--text); font-size: 20px; }
.integration-details small,
.integration-details p { grid-column: 1 / -1; }
.integration-error { color: #ffc1b5 !important; }

.overview-calendar-head { align-items: center; }
.overview-weekdays,
.overview-calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.overview-weekdays { padding-bottom: 7px; color: var(--muted-2); text-align: center; font-size: 10px; font-weight: 850; }
.overview-calendar-grid { border-left: 1px solid var(--line-soft); border-top: 1px solid var(--line-soft); }
.overview-day {
  min-height: 105px;
  padding: 7px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255,255,255,.012);
  overflow: hidden;
}
.overview-day.outside { opacity: .34; background: rgba(0,0,0,.18); }
.overview-day.today { box-shadow: inset 0 0 0 1px var(--gold-light); }
.overview-day header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 10px; }
.overview-day header b { min-width: 20px; height: 20px; display: grid; place-items: center; border-radius: 999px; color: #171006; background: var(--gold-light); font-size: 9px; }
.overview-day > div { display: grid; gap: 4px; }
.overview-event {
  width: 100%;
  padding: 4px 5px;
  border: 0;
  border-radius: 6px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 8px;
  font-weight: 800;
  cursor: pointer;
}
.overview-event.confirmed { color: #9cf0c4; background: rgba(81,200,140,.18); }
.overview-event.hold { color: var(--gold-light); background: rgba(243,200,101,.15); }
.overview-day small { color: var(--muted); font-size: 8px; }

.ranking-list,
.upcoming-list { display: grid; gap: 7px; }
.ranking-row,
.upcoming-row {
  width: 100%;
  display: grid;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: rgba(255,255,255,.015);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.ranking-row { grid-template-columns: 24px 44px minmax(0, 1fr) 36px; padding: 8px; }
.ranking-row:hover,
.upcoming-row:hover { border-color: var(--line); background: rgba(215,154,49,.04); }
.ranking-index { color: var(--muted-2); text-align: center; font-weight: 850; }
.ranking-image { width: 44px; height: 44px; border-radius: 10px; background-size: cover; background-position: center; }
.ranking-main { min-width: 0; }
.ranking-main strong,
.ranking-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-main small { color: var(--muted); margin-top: 3px; font-size: 9px; }
.ranking-main i { display: block; height: 4px; margin-top: 7px; border-radius: 99px; background: rgba(255,255,255,.05); overflow: hidden; }
.ranking-main i b { display: block; height: 100%; border-radius: inherit; background: var(--gold); }
.ranking-value { color: var(--gold-light); font-size: 20px; font-weight: 850; text-align: center; }

.upcoming-row { grid-template-columns: 48px minmax(0, 1fr) auto; padding: 9px; }
.upcoming-date { width: 48px; min-height: 48px; display: grid; place-items: center; align-content: center; border-radius: 11px; background: rgba(215,154,49,.1); }
.upcoming-date strong { color: var(--gold-light); font-size: 20px; }
.upcoming-date small { color: var(--muted); font-size: 9px; }
.upcoming-row > span:nth-child(2) { min-width: 0; }
.upcoming-row > span:nth-child(2) strong,
.upcoming-row > span:nth-child(2) small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upcoming-row > span:nth-child(2) small { color: var(--muted); margin-top: 4px; font-size: 9px; }

.revenue-table { display: grid; border: 1px solid var(--line-soft); border-radius: 13px; overflow: hidden; }
.revenue-row { display: grid; grid-template-columns: minmax(150px, 1.4fr) repeat(3, minmax(90px, 1fr)); border-bottom: 1px solid var(--line-soft); }
.revenue-row:last-child { border-bottom: 0; }
.revenue-row > * { padding: 10px 12px; border-right: 1px solid var(--line-soft); }
.revenue-row > *:last-child { border-right: 0; }
.revenue-row span { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.revenue-head { background: rgba(255,255,255,.025); }
.revenue-head span { color: var(--text); font-weight: 800; }

@media (max-width: 1280px) {
  .dashboard-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .dashboard-grid,
  .dashboard-grid-top { grid-template-columns: 1fr; }
  .overview-day { min-height: 88px; }
}
@media (max-width: 680px) {
  .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .dashboard-kpi { min-height: 96px; padding: 13px; }
  .dashboard-card { padding: 12px; }
  .dashboard-card-head,
  .overview-calendar-head { display: grid; }
  .occupancy-chart { height: 145px; gap: 2px; }
  .integration-details { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .overview-calendar-card { overflow: hidden; }
  .overview-weekdays,
  .overview-calendar-grid { width: 100%; min-width: 0; }
  .overview-day { min-width: 0; min-height: 65px; padding: 4px; }
  .overview-event { height: 5px; padding: 0; font-size: 0; }
  .overview-day header { margin-bottom: 4px; }
  .overview-day header b { min-width: 16px; height: 16px; font-size: 7px; }
  .overview-day small { display: none; }

  .calendar-card:not(.mobile-list-mode) { overflow: visible; }
  .calendar-grid,
  .calendar-weekdays { min-width: 0; width: 100%; }
  .calendar-day { min-width: 0; min-height: 52px; padding: 4px; }
  .day-number { font-size: 10px; }
  .day-events { display: flex; gap: 2px; margin-top: 6px; align-items: center; }
  .day-event {
    width: 8px;
    height: 5px;
    flex: 0 0 8px;
    padding: 0;
    margin: 0 !important;
    border-radius: 999px !important;
    font-size: 0;
  }
  .calendar-day.today::after { inset: 2px; border-radius: 6px; }
  .revenue-table { overflow-x: auto; }
  .revenue-row { min-width: 520px; }
  .upcoming-row { grid-template-columns: 44px minmax(0, 1fr); }
  .upcoming-row .status-pill { grid-column: 2; justify-self: start; }
}
@media (max-width: 390px) {
  .dashboard-kpis { grid-template-columns: 1fr; }
}



/* CRM v26: push notifications */
.push-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.push-details > div {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 10px;
}
.push-details span,
.push-details p,
.push-details small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}
.push-details strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 20px;
}
.push-details p,
.push-details small {
  grid-column: 1 / -1;
  margin: 0;
}
.notification-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.notification-actions .btn {
  flex: 1 1 190px;
}
@media (max-width: 680px) {
  .push-details {
    grid-template-columns: 1fr 1fr;
  }
  .notification-actions {
    display: grid;
  }
}

/* CRM v27: reliable dashboard layout */
body[data-view="home"] .stats-grid {
  display: none;
}

.dashboard-load-error {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 105, 90, .45);
  border-radius: 14px;
  background: rgba(255, 83, 66, .10);
  color: #ffc2ba;
  font-size: 12px;
  line-height: 1.45;
}

#view-home {
  width: 100%;
  min-width: 0;
}

#view-home .dashboard-kpis,
#view-home .dashboard-grid,
#view-home .dashboard-card {
  box-sizing: border-box;
}

@media (max-width: 680px) {
  body[data-view="home"] .workspace {
    padding-left: 14px;
    padding-right: 14px;
  }

  body[data-view="home"] .topbar {
    gap: 14px;
    margin-bottom: 18px;
  }

  body[data-view="home"] .topbar h1 {
    font-size: clamp(36px, 11vw, 52px);
    line-height: .98;
  }

  body[data-view="home"] .topbar-actions {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  body[data-view="home"] .topbar-actions .btn {
    min-height: 48px;
    padding: 10px;
    font-size: 12px;
    line-height: 1.15;
  }

  body[data-view="home"] #forceSyncBtn {
    grid-column: 1 / -1;
  }

  .dashboard-kpis {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin: 0 0 12px !important;
  }

  .dashboard-kpi {
    display: flex !important;
    min-width: 0;
    min-height: 112px !important;
    padding: 13px !important;
    border: 1px solid var(--line) !important;
    border-radius: 16px !important;
    background:
      radial-gradient(circle at 100% 0%, rgba(215,154,49,.10), transparent 46%),
      linear-gradient(145deg, rgba(19,16,10,.98), rgba(7,6,4,.99)) !important;
    flex-direction: column;
    justify-content: space-between;
    gap: 7px;
    overflow: hidden;
  }

  .dashboard-kpi span {
    display: block;
    min-height: 30px;
    color: var(--muted) !important;
    font-size: 10px !important;
    font-weight: 750;
    line-height: 1.35 !important;
  }

  .dashboard-kpi strong {
    display: block;
    color: var(--gold-light) !important;
    font-size: 30px !important;
    line-height: 1 !important;
    overflow-wrap: anywhere;
  }

  .dashboard-kpi small {
    display: block;
    color: var(--muted-2) !important;
    font-size: 8px !important;
    line-height: 1.35 !important;
  }

  .dashboard-grid,
  .dashboard-grid-top {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
    margin: 0 0 10px !important;
  }

  .dashboard-card {
    display: block !important;
    width: 100%;
    min-width: 0;
    margin: 0 0 10px !important;
    padding: 13px !important;
    border: 1px solid var(--line) !important;
    border-radius: 17px !important;
    background:
      radial-gradient(circle at 100% 0%, rgba(215,154,49,.07), transparent 42%),
      linear-gradient(145deg, rgba(18,15,10,.98), rgba(7,6,4,.99)) !important;
    overflow: hidden;
  }

  .dashboard-grid .dashboard-card {
    margin-bottom: 0 !important;
  }

  .dashboard-card-head,
  .overview-calendar-head {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 10px !important;
    margin: 0 0 12px !important;
  }

  .dashboard-card-head > div {
    min-width: 0;
  }

  .dashboard-card-head h3 {
    margin: 0 0 4px !important;
    font-size: 20px !important;
    line-height: 1.12 !important;
  }

  .dashboard-card-head p {
    margin: 0 !important;
    color: var(--muted) !important;
    font-size: 10px !important;
    line-height: 1.45 !important;
  }

  .dashboard-card-head > strong {
    flex: 0 0 auto;
    font-size: 13px;
  }

  .occupancy-chart {
    display: grid !important;
    height: 150px !important;
    grid-template-columns: repeat(30, minmax(2px, 1fr)) !important;
    align-items: end !important;
    gap: 2px !important;
    padding-top: 8px !important;
  }

  .occupancy-bar-wrap {
    display: grid !important;
    height: 100%;
    grid-template-rows: 1fr 14px;
    align-items: end;
    min-width: 0;
  }

  .notification-card {
    min-height: 0;
  }

  .push-details {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px !important;
    margin: 0 0 12px !important;
  }

  .push-details > div {
    min-width: 0;
    padding: 10px !important;
    border-radius: 12px !important;
  }

  .push-details strong {
    font-size: 22px !important;
  }

  .push-details p,
  .push-details small {
    margin: 0 !important;
    font-size: 9px !important;
    line-height: 1.45 !important;
  }

  .notification-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 7px !important;
  }

  .notification-actions .btn {
    width: 100%;
    min-height: 46px;
    font-size: 12px;
  }

  .overview-calendar-card {
    padding-bottom: 12px !important;
  }

  .overview-calendar-head {
    display: grid !important;
  }

  .overview-calendar-head .month-controls {
    display: grid !important;
    width: 100%;
    grid-template-columns: 44px minmax(0, 1fr) 44px auto;
    gap: 6px;
  }

  .overview-calendar-head .month-label {
    width: 100%;
    min-width: 0;
    padding: 0 6px;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .overview-calendar-head .btn.compact {
    min-width: 74px;
    padding: 0 8px;
    font-size: 10px;
  }

  .overview-weekdays,
  .overview-calendar-grid {
    display: grid !important;
    width: 100% !important;
    min-width: 0 !important;
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
  }

  .overview-weekdays span {
    min-width: 0;
    font-size: 8px;
    text-align: center;
  }

  .overview-day {
    display: block !important;
    min-width: 0 !important;
    min-height: 58px !important;
    padding: 4px !important;
    overflow: hidden;
  }

  .overview-day header {
    margin: 0 0 4px !important;
    font-size: 8px !important;
  }

  .overview-day header b {
    min-width: 14px !important;
    width: 14px;
    height: 14px !important;
    font-size: 7px !important;
  }

  .overview-event {
    display: block;
    width: 100%;
    height: 5px !important;
    padding: 0 !important;
    border-radius: 99px !important;
    font-size: 0 !important;
  }

  .ranking-list,
  .upcoming-list {
    display: grid !important;
    gap: 7px !important;
  }

  .ranking-row {
    grid-template-columns: 22px 42px minmax(0, 1fr) 30px !important;
    gap: 8px !important;
    padding: 8px !important;
  }

  .ranking-image {
    width: 42px !important;
    height: 42px !important;
  }

  .ranking-main strong {
    font-size: 11px;
  }

  .upcoming-row {
    grid-template-columns: 42px minmax(0, 1fr) !important;
    gap: 8px !important;
    padding: 8px !important;
  }

  .upcoming-date {
    width: 42px !important;
    min-height: 42px !important;
  }

  .upcoming-row .status-pill {
    grid-column: 2;
    justify-self: start;
  }

  .revenue-table {
    width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .revenue-row {
    min-width: 500px;
  }
}

@media (max-width: 370px) {
  .dashboard-kpis {
    grid-template-columns: 1fr !important;
  }

  .overview-calendar-head .month-controls {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
  }

  .overview-calendar-head .btn.compact {
    grid-column: 1 / -1;
  }
}

/* CRM v28: iOS login focus and viewport fix */
html {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.login-overlay {
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior: none;
}

.login-card {
  min-width: 0;
  max-width: min(470px, calc(100vw - 28px));
}

#adminPassword {
  min-width: 0;
  max-width: 100%;
  font-size: 16px !important;
  line-height: 1.25;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}

@supports (-webkit-touch-callout: none) {
  @media (max-width: 900px) {
    input,
    select,
    textarea {
      font-size: 16px;
    }

    .login-card label {
      min-width: 0;
    }

    .login-card input {
      width: 100%;
      min-width: 0;
      max-width: 100%;
      font-size: 16px !important;
    }
  }
}

/* CRM v29: calendar booking ranges */
.day-events {
  gap: 5px;
  margin-top: 9px;
}

.day-event {
  position: relative;
  display: flex;
  align-items: center;
  height: 17px;
  min-width: 0;
  padding: 0 7px;
  border: 1px solid rgba(255, 255, 255, .075);
  border-radius: 5px;
  background: rgba(255, 255, 255, .045);
  color: rgba(248, 244, 235, .88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
  font-size: 9px;
  font-weight: 760;
  line-height: 1;
  overflow: hidden;
  white-space: nowrap;
}

.day-event span,
.overview-event span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-event.confirmed {
  border-color: rgba(81, 200, 140, .20);
  background:
    linear-gradient(90deg, rgba(81, 200, 140, .075), rgba(255, 255, 255, .035));
  color: #dceee4;
}

.day-event.hold {
  border-color: rgba(243, 200, 101, .23);
  background:
    linear-gradient(90deg, rgba(243, 200, 101, .09), rgba(255, 255, 255, .035));
  color: #f4e5bd;
}

.day-event.completed,
.day-event.cancelled {
  border-color: rgba(255, 255, 255, .065);
  background: rgba(255, 255, 255, .025);
  color: var(--muted);
}

.day-event.has-label::before,
.overview-event.has-label::before {
  content: "";
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  margin-right: 5px;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .025);
}

.day-event.confirmed.has-label::before,
.overview-event.confirmed.has-label::before {
  background: #55c98d;
}

.day-event.hold.has-label::before,
.overview-event.hold.has-label::before {
  background: var(--gold-light);
}

.day-event.segment-middle {
  margin-left: -9px;
  margin-right: -9px;
  padding-left: 9px;
  padding-right: 9px;
  border-left-color: transparent;
  border-right-color: transparent;
  border-radius: 0;
}

.day-event.segment-start {
  margin-left: 0;
  border-radius: 5px 0 0 5px;
}

.day-event.segment-end {
  margin-right: 0;
  border-radius: 0 5px 5px 0;
}

.day-event.segment-start.segment-end {
  border-radius: 5px;
}

.day-event.actual-start {
  box-shadow:
    inset 2px 0 0 rgba(255, 255, 255, .16),
    inset 0 1px 0 rgba(255, 255, 255, .025);
}

.day-event.actual-end {
  box-shadow:
    inset -2px 0 0 rgba(255, 255, 255, .12),
    inset 0 1px 0 rgba(255, 255, 255, .025);
}

.day-event.actual-start.actual-end {
  box-shadow:
    inset 2px 0 0 rgba(255, 255, 255, .16),
    inset -2px 0 0 rgba(255, 255, 255, .12),
    inset 0 1px 0 rgba(255, 255, 255, .025);
}

.calendar-legend .legend {
  position: relative;
  width: 13px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
}

.calendar-legend .legend.confirmed::after,
.calendar-legend .legend.hold::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  transform: translateY(-50%);
}

.calendar-legend .legend.confirmed::after {
  background: #55c98d;
}

.calendar-legend .legend.hold::after {
  background: var(--gold-light);
}

.overview-day > div {
  display: grid;
  gap: 4px;
}

.overview-event {
  position: relative;
  display: flex;
  align-items: center;
  width: auto;
  height: 16px;
  min-width: 0;
  margin-left: 0;
  margin-right: 0;
  padding: 0 5px;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 4px;
  background: rgba(255, 255, 255, .04);
  color: rgba(248, 244, 235, .84);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .018);
  font-size: 7.5px;
  font-weight: 760;
  line-height: 1;
}

.overview-event.confirmed {
  border-color: rgba(81, 200, 140, .18);
  background:
    linear-gradient(90deg, rgba(81, 200, 140, .07), rgba(255, 255, 255, .028));
  color: #dceee4;
}

.overview-event.hold {
  border-color: rgba(243, 200, 101, .20);
  background:
    linear-gradient(90deg, rgba(243, 200, 101, .08), rgba(255, 255, 255, .028));
  color: #f4e5bd;
}

.overview-event.segment-middle {
  margin-left: -8px;
  margin-right: -8px;
  padding-left: 8px;
  padding-right: 8px;
  border-left-color: transparent;
  border-right-color: transparent;
  border-radius: 0;
}

.overview-event.segment-start {
  border-radius: 4px 0 0 4px;
}

.overview-event.segment-end {
  border-radius: 0 4px 4px 0;
}

.overview-event.segment-start.segment-end {
  border-radius: 4px;
}

.overview-event.actual-start {
  box-shadow:
    inset 2px 0 0 rgba(255, 255, 255, .14),
    inset 0 1px 0 rgba(255, 255, 255, .018);
}

.overview-event.actual-end {
  box-shadow:
    inset -2px 0 0 rgba(255, 255, 255, .10),
    inset 0 1px 0 rgba(255, 255, 255, .018);
}

@media (max-width: 680px) {
  .day-event {
    height: 7px;
    padding: 0;
    border-radius: 999px;
    font-size: 0;
  }

  .day-event.has-label::before {
    display: none;
  }

  .day-event.segment-middle {
    margin-left: -5px;
    margin-right: -5px;
    padding: 0;
  }

  .day-event.segment-start {
    border-radius: 999px 0 0 999px;
  }

  .day-event.segment-end {
    border-radius: 0 999px 999px 0;
  }

  .day-event.segment-start.segment-end {
    border-radius: 999px;
  }

  .overview-event {
    height: 6px !important;
    padding: 0 !important;
    border-radius: 999px !important;
    font-size: 0 !important;
  }

  .overview-event.has-label::before {
    display: none;
  }

  .overview-event.segment-middle {
    margin-left: -4px;
    margin-right: -4px;
    padding: 0;
  }
}

/* CRM v30: unique booking colors, full-width segments and overflow stacks */
.calendar-day {
  min-height: 108px;
}

.day-events,
.overview-events {
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(243, 200, 101, .35) transparent;
  overscroll-behavior: contain;
}

.day-events {
  display: grid;
  gap: 4px;
  max-height: 70px;
  margin-left: 0;
  margin-right: 0;
  padding-right: 2px;
  overflow-x: hidden;
  overflow-y: auto;
}

.day-events::-webkit-scrollbar,
.overview-events::-webkit-scrollbar {
  width: 4px;
}

.day-events::-webkit-scrollbar-thumb,
.overview-events::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(243, 200, 101, .28);
}

.day-event,
.overview-event {
  --booking-accent: #55C98D;
  --booking-bg: rgba(85, 201, 141, .115);
  --booking-border: rgba(85, 201, 141, .34);
  --booking-text: #DDF3E7;
  border-color: var(--booking-border) !important;
  background: linear-gradient(90deg, var(--booking-bg), rgba(255,255,255,.025)) !important;
  color: var(--booking-text) !important;
}

.day-event.hold,
.overview-event.hold {
  border-style: dashed;
  opacity: .84;
}

.day-event.confirmed,
.overview-event.confirmed {
  border-style: solid;
  opacity: 1;
}

.day-event.has-label::before,
.overview-event.has-label::before {
  background: var(--booking-accent) !important;
}

/* Start segments touch the right border, middle segments touch both borders. */
.day-event.segment-start:not(.segment-end) {
  margin-right: -10px;
  border-right-color: transparent !important;
}

.day-event.segment-middle:not(.segment-end) {
  margin-left: -10px;
  margin-right: -10px;
}

.day-event.segment-end:not(.segment-start) {
  margin-left: -10px;
}

.overview-event.segment-start:not(.segment-end) {
  margin-right: -9px;
  border-right-color: transparent !important;
}

.overview-event.segment-middle:not(.segment-end) {
  margin-left: -9px;
  margin-right: -9px;
}

.overview-event.segment-end:not(.segment-start) {
  margin-left: -9px;
}

/* The checkout date is visible as a half-day terminal cap. It is not counted
   as an occupied night by the operational booking logic. */
.day-event.checkout-day,
.overview-event.checkout-day {
  position: relative;
  justify-self: start;
  width: calc(50% + 10px);
  margin-right: auto !important;
  border-right-color: var(--booking-border) !important;
  border-radius: 0 999px 999px 0 !important;
  opacity: .72;
}

.overview-event.checkout-day {
  width: calc(50% + 9px);
}

.day-event.checkout-day::after,
.overview-event.checkout-day::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 4px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--booking-accent);
  transform: translateY(-50%);
}

.day-event.actual-start.checkout-day,
.overview-event.actual-start.checkout-day {
  width: calc(100% - 2px);
  margin-left: 0 !important;
  border-radius: 999px !important;
}

.overview-day {
  min-height: 125px;
}

.overview-events {
  display: grid !important;
  gap: 4px;
  max-height: 84px;
  padding-right: 2px;
  overflow-x: hidden;
  overflow-y: auto;
}

.calendar-legend .legend.booking-color {
  background: linear-gradient(90deg, #55C98D, #68A8FF, #A98AFF, #F09A63);
  border: 0;
}

.calendar-legend .legend.confirmed {
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.26);
}

.calendar-legend .legend.hold {
  background: rgba(255,255,255,.035);
  border: 1px dashed rgba(255,255,255,.34);
}

.calendar-legend .legend.checkout {
  width: 13px;
  border-radius: 999px 0 0 999px;
  background: linear-gradient(90deg, rgba(104,168,255,.18) 0 55%, transparent 55%);
  border: 1px solid rgba(104,168,255,.30);
  border-right-color: transparent;
}

@media (max-width: 680px) {
  .calendar-day {
    min-height: 62px;
  }

  .day-events {
    max-height: 28px;
    gap: 2px;
    padding-right: 1px;
  }

  .overview-day {
    min-height: 68px !important;
  }

  .overview-events {
    max-height: 32px;
    gap: 2px;
    padding-right: 1px;
  }

  .day-event.segment-start:not(.segment-end) {
    margin-right: -6px;
  }

  .day-event.segment-middle:not(.segment-end) {
    margin-left: -6px;
    margin-right: -6px;
  }

  .day-event.segment-end:not(.segment-start) {
    margin-left: -6px;
  }

  .overview-event.segment-start:not(.segment-end) {
    margin-right: -5px;
  }

  .overview-event.segment-middle:not(.segment-end) {
    margin-left: -5px;
    margin-right: -5px;
  }

  .overview-event.segment-end:not(.segment-start) {
    margin-left: -5px;
  }

  .day-event.checkout-day {
    width: calc(50% + 6px);
  }

  .overview-event.checkout-day {
    width: calc(50% + 5px);
  }
}

/* CRM v31: continuous booking ranges */
.calendar-grid,
.overview-calendar-grid {
  grid-auto-rows: minmax(108px, auto);
}

.calendar-day,
.overview-day {
  padding: 0 !important;
  overflow: hidden;
}

.day-number {
  display: block;
  padding: 8px 8px 0;
}

.overview-day header {
  padding: 7px 7px 0;
  margin-bottom: 7px !important;
}

.day-events,
.overview-events {
  display: grid !important;
  width: 100%;
  max-height: none !important;
  margin: 8px 0 0 !important;
  padding: 0 !important;
  gap: 4px !important;
  overflow: visible !important;
  scrollbar-width: none;
}

.day-events::-webkit-scrollbar,
.overview-events::-webkit-scrollbar {
  display: none;
}

.day-event,
.overview-event {
  --booking-fill: rgba(69, 185, 124, .30);
  --booking-accent: #45B97C;
  --booking-border: rgba(69, 185, 124, .68);
  --booking-text: #E8FFF1;

  position: relative;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 21px;
  margin: 0 !important;
  padding: 0 7px;
  border: 1px solid var(--booking-border) !important;
  border-radius: 0;
  background: var(--booking-fill) !important;
  color: var(--booking-text) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .045),
    inset 0 -1px 0 rgba(0, 0, 0, .12);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  white-space: nowrap;
}

.day-event.hold,
.overview-event.hold {
  border-style: dashed !important;
}

.day-event.confirmed,
.overview-event.confirmed {
  border-style: solid !important;
}

.day-event.segment-middle,
.overview-event.segment-middle {
  border-left-color: transparent !important;
  border-right-color: transparent !important;
}

.day-event.segment-start,
.overview-event.segment-start {
  border-left-color: var(--booking-border) !important;
}

.day-event.segment-end,
.overview-event.segment-end {
  border-right-color: var(--booking-border) !important;
}

.day-event.actual-start,
.overview-event.actual-start {
  width: calc(100% - 8px);
  margin-left: 8px !important;
  border-radius: 8px 0 0 8px;
}

.overview-event.actual-start {
  width: calc(100% - 7px);
  margin-left: 7px !important;
}

.day-event.week-start,
.overview-event.week-start {
  border-radius: 4px 0 0 4px;
}

.day-event.week-end,
.overview-event.week-end {
  border-radius: 0 4px 4px 0;
}

.day-event.checkout-day,
.overview-event.checkout-day {
  width: 62%;
  margin-left: 0 !important;
  margin-right: auto !important;
  border-left-color: transparent !important;
  border-right-color: var(--booking-border) !important;
  border-radius: 0 999px 999px 0 !important;
  opacity: 1;
}

.day-event.actual-start.checkout-day {
  width: calc(100% - 16px);
  margin-left: 8px !important;
  border-left-color: var(--booking-border) !important;
  border-radius: 999px !important;
}

.overview-event.actual-start.checkout-day {
  width: calc(100% - 14px);
  margin-left: 7px !important;
  border-left-color: var(--booking-border) !important;
  border-radius: 999px !important;
}

.booking-label {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.booking-edge-icon {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px;
  background: rgba(5, 5, 4, .66);
  color: var(--booking-text);
}

.booking-edge-icon.checkin {
  margin-right: 5px;
}

.booking-edge-icon.checkout {
  margin-left: auto;
}

.booking-edge-icon svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.day-event.actual-start::before,
.overview-event.actual-start::before,
.day-event.checkout-day::after,
.overview-event.checkout-day::after {
  content: none !important;
}

.overview-event {
  height: 19px;
  font-size: 8px;
  cursor: pointer;
}

.calendar-day,
.overview-day {
  min-height: 108px;
}

.calendar-grid,
.overview-calendar-grid {
  align-items: stretch;
}

.calendar-day,
.overview-day {
  height: auto;
}

/* Each week grows when several bookings overlap. No entries are clipped and
   no independent cell scrolling can desynchronize adjacent range segments. */
.day-events,
.overview-events {
  min-height: 0;
}

@media (max-width: 680px) {
  .calendar-grid,
  .overview-calendar-grid {
    grid-auto-rows: minmax(68px, auto);
  }

  .day-number {
    padding: 4px 4px 0;
  }

  .overview-day header {
    padding: 4px 4px 0;
    margin-bottom: 4px !important;
  }

  .day-events,
  .overview-events {
    margin-top: 5px !important;
    gap: 2px !important;
  }

  .day-event,
  .overview-event {
    height: 8px !important;
    padding: 0 !important;
    border-radius: 0;
    font-size: 0 !important;
  }

  .day-event.actual-start {
    width: calc(100% - 4px);
    margin-left: 4px !important;
    border-radius: 999px 0 0 999px;
  }

  .overview-event.actual-start {
    width: calc(100% - 4px);
    margin-left: 4px !important;
    border-radius: 999px 0 0 999px;
  }

  .day-event.checkout-day,
  .overview-event.checkout-day {
    width: 65%;
    border-radius: 0 999px 999px 0 !important;
  }

  .day-event.actual-start.checkout-day,
  .overview-event.actual-start.checkout-day {
    width: calc(100% - 8px);
    margin-left: 4px !important;
    border-radius: 999px !important;
  }

  .booking-edge-icon,
  .booking-label {
    display: none;
  }
}



/* CRM v32: solid booking colors */
.day-event,
.overview-event {
  background: var(--booking-fill) !important;
}

.booking-edge-icon {
  border-color: color-mix(in srgb, var(--booking-accent) 55%, white 20%);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, .18),
    0 0 0 1px rgba(0, 0, 0, .15);
}

.day-event.actual-start,
.overview-event.actual-start,
.day-event.checkout-day,
.overview-event.checkout-day {
  background: var(--booking-fill) !important;
}


/* CRM v33: fixed desktop navigation and tabbed villa editor */
@media (min-width: 981px) {
  .app-shell { display: block; min-height: 100vh; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); height: 100dvh; box-sizing: border-box; }
  .workspace { margin-left: var(--sidebar); }
}
.field-grid > label { align-self: start; align-content: start; }
.compact-fields > label { gap: 6px; }
.compact-fields input, .compact-fields select { min-height: 46px; }
.villa-editor-card { width: min(1180px, 100%); }
.villa-editor-card form { padding-top: 0; }
.villa-editor-tabs { position: sticky; top: 85px; z-index: 5; display: flex; gap: 6px; padding: 10px 22px; margin: 0 -22px 16px; overflow-x: auto; background: rgba(12,9,6,.97); border-bottom: 1px solid var(--line-soft); scrollbar-width: none; }
.villa-editor-tabs::-webkit-scrollbar { display:none; }
.villa-editor-tab { flex: 0 0 auto; min-height: 38px; padding: 0 14px; border: 1px solid var(--line-soft); border-radius: 11px; background: rgba(255,255,255,.025); color: var(--muted); font-weight: 800; cursor: pointer; }
.villa-editor-tab.active { color: #171006; border-color: var(--gold-light); background: linear-gradient(135deg,var(--gold),var(--gold-light)); }
.villa-editor-tab span { opacity:.72; margin-left:5px; }
.villa-tab-panel { display:none; min-height: 420px; }
.villa-tab-panel.active { display:block; }
.villa-section-grid { display:grid; gap: 12px; }
.editor-section { display:grid; gap:12px; padding:16px; border:1px solid var(--line-soft); border-radius:16px; background:rgba(255,255,255,.018); }
.editor-section-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.editor-section-head strong { display:block; font-size:14px; color:var(--text); }
.editor-section-head small { display:block; margin-top:3px; color:var(--muted); font-size:10px; line-height:1.4; }
.video-audit-row,.photo-source-inline-actions { display:flex; align-items:center; justify-content:space-between; gap:10px; color:var(--muted); font-size:10px; }
.video-audit-row .ok { color:#8be8b8; }.video-audit-row .error { color:#ffb0a6; }
.photo-editor-section { padding:0; border:0; background:transparent; }
.photo-section-head { padding:0 0 4px; }
.photo-source-toolbar { display:flex; flex-wrap:wrap; gap:8px; }
.photo-source-toolbar > * { flex:1 1 190px; }
.gallery-source-note { display:flex; align-items:flex-start; gap:8px; padding:10px 12px; border:1px solid var(--line-soft); border-radius:12px; background:rgba(255,255,255,.02); color:var(--muted); font-size:10px; line-height:1.45; }
.gallery-source-note strong { flex:0 0 auto; color:var(--gold-light); }
.photo-source-status-text { color:var(--muted); font-size:10px; line-height:1.4; }
.wide-main-image { min-height:300px; aspect-ratio:16/8.5; }
.unlimited-gallery { grid-template-columns:repeat(4,minmax(0,1fr)); }
.gallery-editor-item { cursor:grab; }
.gallery-editor-item.dragging { opacity:.45; transform:scale(.98); }
.gallery-editor-item.drag-over { outline:2px solid var(--gold-light); outline-offset:2px; }
.gallery-editor-order { position:absolute; right:7px; top:7px; min-width:24px; height:24px; display:grid; place-items:center; border-radius:999px; background:rgba(5,4,3,.82); color:var(--text); font-size:9px; font-weight:900; }
.gallery-editor-actions { grid-template-columns:repeat(2,1fr); }
.gallery-counter { color:var(--gold-light); font-size:12px; font-weight:850; }
.pricing-editor { gap:12px; }
.currency-rule-card { align-content:start; gap:9px; }
.currency-rule-auto,.currency-rule-manual { align-content:start; }
#villaPriceRangeField[hidden] { display:none !important; }
@media (max-width:980px) { .villa-editor-tabs { top:76px; } .unlimited-gallery{grid-template-columns:repeat(3,minmax(0,1fr));} .workspace{margin-left:0;} }
@media (max-width:620px) { .villa-editor-tabs{top:70px;margin-left:-14px;margin-right:-14px;padding-left:14px;padding-right:14px;} .unlimited-gallery{grid-template-columns:repeat(2,minmax(0,1fr));}.wide-main-image{min-height:190px;}.photo-source-toolbar{display:grid;}.video-audit-row,.photo-source-inline-actions{align-items:flex-start;flex-direction:column;} }

/* CRM v37: Drive gallery preview fix */
.currency-rule-card.is-base {
  border-color: rgba(243, 198, 93, .48);
  background: rgba(243, 198, 93, .035);
}
.currency-rule-card.is-base .currency-rule-head strong {
  color: var(--gold-light);
}
.currency-rule-head select {
  cursor: pointer;
}
.currency-rule-head select option:disabled {
  color: #6f675b;
}


/* v39: detailed photo ordering controls */
.gallery-editor-item.is-main-photo { border-color: rgba(246, 190, 72, .58); box-shadow: inset 0 0 0 1px rgba(246,190,72,.12); }
.gallery-editor-meta { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:8px 8px 0; border-top:1px solid var(--line-soft); }
.gallery-position-control { display:flex !important; flex-direction:row !important; align-items:center !important; gap:6px; min-width:0; color:var(--muted); font-size:10px; font-weight:800; }
.gallery-position-control input { width:62px !important; min-width:62px !important; height:30px !important; min-height:30px !important; padding:4px 7px !important; text-align:center; border-radius:8px !important; font-size:12px !important; color:var(--text) !important; background:rgba(255,255,255,.035) !important; }
.gallery-drag-hint { flex:0 0 auto; color:var(--muted); font-size:10px; font-weight:800; white-space:nowrap; cursor:grab; }
.gallery-editor-actions { grid-template-columns:repeat(3,minmax(0,1fr)) !important; gap:5px; padding:8px; }
.gallery-editor-actions button { height:32px; font-size:10px; line-height:1.1; padding:0 5px; }
.gallery-editor-actions button:disabled { opacity:.32; cursor:not-allowed; }
.gallery-editor-actions button.is-main { background:rgba(246,190,72,.12); border-color:rgba(246,190,72,.36); color:var(--gold-light); }
.gallery-alt-input { display:none !important; }
.gallery-editor-main { background:rgba(7,6,4,.9); border:1px solid rgba(246,190,72,.36); }
@media (max-width: 760px) {
  .gallery-editor-meta { align-items:flex-start; flex-direction:column; gap:5px; }
  .gallery-drag-hint { display:none; }
  .gallery-editor-actions { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
  .gallery-position-control { width:100%; justify-content:space-between; }
}
