:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #14213d;
  --muted: #64748b;
  --line: #dbe3ef;
  --primary: #2454d6;
  --primary-dark: #173a9b;
  --success: #147d4f;
  --warning: #9a6700;
  --danger: #b42318;
  --chip: #edf2ff;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

html,
body,
#app {
  min-width: 0;
  width: 100%;
}

/* Scrolling stays fully functional (wheel, trackpad, keyboard) — this only hides
   the visible scrollbar track/thumb, on every page. */
html {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* legacy Edge/IE */
}

html::-webkit-scrollbar {
  display: none; /* Chrome, Safari, modern Edge */
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  padding: 10px 14px;
  touch-action: manipulation;
  transition: transform 0.08s ease, filter 0.08s ease;
}

button:active:not(:disabled) {
  filter: brightness(0.96);
  transform: translateY(1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

button.primary {
  background: var(--primary);
  color: white;
}

button.primary:hover {
  background: var(--primary-dark);
}

button.secondary {
  background: #e7edf7;
  color: var(--text);
}

button.danger {
  background: #fee2e2;
  color: #b42318;
}

button.danger:hover {
  background: #fecaca;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 18px 28px;
  position: sticky;
  top: 0;
  /* Above Door cards overlay (.card-lock-layer) so embed UI never covers the header */
  z-index: 60;
}

.brand {
  align-items: center;
  display: flex;
  gap: 14px;
}

.app-logo {
  display: block;
  object-fit: contain;
}

.topbar-logo {
  border-radius: 12px;
  height: 64px;
  width: 64px;
}

.login-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.login-logo {
  max-width: 430px;
  width: min(86vw, 430px);
}

.brand h1 {
  font-size: 22px;
  margin: 0;
}

.brand span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 2px;
}

.sidebar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-flow: row wrap;
  gap: 4px;
  padding: 10px 28px;
  position: static;
  z-index: 55;
}

.tab-button {
  background: transparent;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  cursor: pointer;
  display: block;
  font: inherit;
  font-weight: 600;
  padding: 11px 12px;
  text-align: left;
  white-space: nowrap;
  width: auto;
}

.tab-button:hover {
  background: #f8fafc;
  color: var(--primary);
}

.tab-button.active {
  background: var(--chip);
  color: var(--primary);
}

/* Door cards: same tab-button look; only collapse behavior differs.
   In the horizontal top bar, the expanded items drop down below the toggle
   instead of pushing the bar taller. */
.sidebar-door-group {
  position: relative;
}

.sidebar-door-toggle {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.sidebar-door-chevron {
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  flex: 0 0 auto;
  height: 8px;
  margin-inline-end: 4px;
  opacity: 0.65;
  transform: rotate(45deg);
  transition: transform 0.16s ease;
  width: 8px;
}

.sidebar-door-group.is-open .sidebar-door-chevron {
  transform: rotate(-135deg);
  translate: 0 2px;
}

.sidebar-door-items {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
  display: none;
  flex-flow: column nowrap;
  gap: 4px;
  min-width: 180px;
  padding: 6px;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 56;
}

.sidebar-door-items.is-open {
  display: flex;
}

.ttlock-section {
  display: grid;
  align-content: start;
  gap: 14px;
}

.ttlock-section > .section-header {
  margin-bottom: 0;
}


.ttlock-system-wrap {
  display: grid;
  gap: 24px;
}

.ttlock-users {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  padding-top: 18px;
}

.ttlock-user-create {
  display: grid;
  gap: 12px;
}

.ttlock-field--wide {
  grid-column: 1 / -1;
}

.ttlock-section--system {
  gap: 20px;
  max-width: none;
  padding: 24px;
  width: 100%;
}

.ttlock-section--system .section-header h2 {
  font-size: 1.25rem;
  line-height: 1.25;
}

.ttlock-module-title {
  font-size: 1rem;
  margin: 0 0 8px;
}

.ttlock-block {
  display: grid;
  gap: 14px;
}

.ttlock-reception {
  display: grid;
  gap: 16px;
}

.ttlock-action-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ttlock-action-form {
  display: grid;
  gap: 14px;
  max-width: 520px;
}

.ttlock-action-fields {
  display: grid;
  gap: 12px;
}

.ttlock-system-form {
  align-content: start;
  display: grid;
  gap: 20px;
  margin: 0;
  width: 100%;
}

.ttlock-system-grid {
  align-items: start;
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr 1fr;
  width: 100%;
}

.ttlock-field {
  color: var(--text);
  display: grid;
  gap: 6px;
  margin: 0;
  min-width: 0;
  width: 100%;
}

.ttlock-field-label {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.ttlock-system-form .ttlock-field input[type="text"],
.ttlock-system-form .ttlock-field input[type="password"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-sizing: border-box;
  display: block;
  font-size: 14px;
  height: 42px;
  line-height: 1.2;
  margin: 0;
  max-height: 42px;
  max-width: none;
  min-height: 42px;
  min-width: 0;
  padding: 0 12px;
  width: 100%;
}

.ttlock-check {
  align-items: center;
  color: var(--text);
  display: flex;
  font-size: 13px;
  font-weight: 500;
  gap: 8px;
  line-height: 1.35;
  margin: 0;
  width: 100%;
}

.ttlock-check input[type="checkbox"] {
  flex: 0 0 auto;
  height: 16px;
  margin: 0;
  width: 16px;
}

.ttlock-system-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
  margin: 0;
  width: 100%;
}

.ttlock-system-actions .primary {
  font-size: 13px;
  padding: 9px 16px;
}

.ttlock-passcodes {
  margin-top: 1.25rem;
  display: grid;
  gap: 0.75rem;
}

.ttlock-passcodes-load {
  display: grid;
  gap: 0.75rem;
}

.ttlock-passcodes code {
  font-size: 0.95em;
  letter-spacing: 0.04em;
}

.ttlock-log {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding-top: 14px;
}

.ttlock-section .notice {
  background: #eef6ff;
  border: 1px solid #c9ddf5;
  border-radius: 10px;
  color: #1f4f7a;
  padding: 10px 12px;
}

@media (max-width: 640px) {
  .ttlock-system-grid {
    grid-template-columns: 1fr;
  }
}

.main {
  display: grid;
  gap: 20px;
  min-width: 0;
  padding: 20px;
  width: 100%;
}

.login-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  margin: 0 auto;
  max-width: 460px;
  width: 100%;
}

.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  min-width: 0;
  padding: 20px;
  width: 100%;
}

.section-header {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2,
.card h3 {
  margin: 0;
}

.section-header p,
.muted {
  color: var(--muted);
  margin: 4px 0 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.residence-select-wrap {
  display: block;
}

.residence-select {
  appearance: none;
  background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%231a2332' d='M1 1l5 5 5-5'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  border: 1px solid #c9d2de;
  border-radius: 10px;
  color: #122033;
  font-family: inherit;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
  max-width: 100%;
  padding: 8px 36px 8px 12px;
}

.residence-select-wrap--topbar {
  display: block;
  margin-top: 6px;
}

.residence-select--compact {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 28px 4px 8px;
  border-radius: 8px;
}

.tenant-admin-list,
.tenant-access-list {
  display: grid;
  gap: 12px;
}

.tenant-admin-form {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.tenant-admin-form:first-child {
  border-top: 0;
  padding-top: 0;
}

.tenant-access-row {
  align-items: end;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(160px, 1fr) minmax(170px, 0.8fr) minmax(260px, 2fr) auto;
  padding-top: 12px;
}

.tenant-access-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.tenant-property-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.super-admin-hero {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.super-admin-hero h2 {
  margin: 2px 0 4px;
}

.super-admin-hero p {
  margin: 0;
}

.super-company-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
}

.super-company-card {
  margin: 0;
}

.super-property-list {
  display: grid;
  gap: 10px;
}

.super-property-card {
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px;
}

.super-property-card.is-active {
  background: var(--chip);
  border-color: var(--primary);
}

.super-property-main {
  flex: 1;
  min-width: 0;
}

.super-property-title {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.feature-entitlement-form {
  margin: 12px 0;
}

.feature-entitlement-form summary {
  cursor: pointer;
  font-weight: 800;
}

.feature-entitlement-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 10px 0;
}

.feature-entitlement-option {
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 2px 8px;
  grid-template-columns: auto minmax(0, 1fr);
  padding: 8px 10px;
}

.feature-entitlement-option input {
  grid-row: 1 / span 2;
}

.feature-entitlement-option small {
  color: var(--muted);
}

.feature-entitlement-option.is-inherited {
  opacity: 0.7;
}

@media (max-width: 980px) {
  .tenant-access-row {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .super-admin-hero,
  .super-property-card {
    align-items: stretch;
    flex-direction: column;
  }
}

.police-fiche-toolbar {
  align-items: flex-end;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 12px;
}

.police-fiche-toolbar .police-fiche-date-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.police-fiche-empty-hint {
  margin-top: 8px;
}

.stats-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card,
.card {
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.stat-value {
  display: block;
  font-size: 32px;
  font-weight: 800;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-sublabel {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.grid-two {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
}

.stack-one {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid .full {
  grid-column: 1 / -1;
}

.batch-ari-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 12px;
}

.channel-batch-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px 0 0;
}

.channel-batch-help {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 16px;
  padding: 12px 16px;
}

.channel-batch-help ol {
  margin: 8px 0 8px 20px;
  padding: 0;
}

.batch-table-wrap {
  overflow-x: auto;
}

.batch-ari-header,
.batch-ari-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 28px minmax(140px, 1.6fr) 118px 118px 72px 56px 56px 64px 64px 64px;
  min-width: 900px;
}

.batch-avail-header,
.batch-avail-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 28px minmax(160px, 2fr) 140px 140px;
  min-width: 520px;
}

.batch-ari-header,
.batch-avail-header {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  padding: 0 4px;
  text-transform: uppercase;
}

.batch-ari-row,
.batch-avail-row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  padding: 8px;
}

.batch-row-num {
  align-items: center;
  background: var(--surface, #eef2ff);
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  font-weight: 700;
  height: 38px;
  justify-content: center;
}

.batch-cell-input {
  font-size: 13px;
  min-height: 38px;
  padding: 8px 10px;
}

@media (max-width: 960px) {
  .batch-ari-header span:nth-child(n + 6),
  .batch-ari-row > :nth-child(n + 6) {
    display: none;
  }

  .batch-ari-header,
  .batch-ari-row {
    grid-template-columns: 28px minmax(120px, 1.4fr) 110px 110px 72px;
    min-width: 0;
  }
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 6px;
}

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

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--primary);
  border-radius: 4px;
  padding: 0;
  width: auto;
}

/* Only the input chrome is themeable — the native calendar popup itself is
   drawn by the OS/browser and can't be restyled with CSS in any browser.
   Styled at rest (not just on hover/focus) so it reads as on-brand at a glance. */
input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
  background: #f5f8ff;
  border-color: rgba(36, 84, 214, 0.35);
  color: var(--primary-dark);
  cursor: pointer;
  font-weight: 700;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input[type="date"]:hover {
  background: white;
  border-color: var(--primary);
}

input[type="date"]:focus {
  background: white;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 84, 214, 0.15);
  outline: none;
}

/* Tints the native picker icon (default black) to match --primary; Chromium/Safari only. */
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: invert(53%) sepia(44%) saturate(737%) hue-rotate(189deg) brightness(69%) contrast(175%);
}

.autocomplete-field {
  position: relative;
}

.guest-suggestions,
.room-suggestions,
.staff-suggestions {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
  display: grid;
  gap: 4px;
  max-height: 190px;
  overflow-y: auto;
  padding: 6px;
  position: absolute;
  top: 74px;
  width: 100%;
  z-index: 12;
}

.guest-suggestion,
.room-suggestion,
.staff-suggestion {
  background: transparent;
  border-radius: 8px;
  color: var(--text);
  display: grid;
  font-weight: 500;
  padding: 8px 10px;
  text-align: left;
}

.guest-suggestion:hover,
.room-suggestion:hover,
.staff-suggestion:hover {
  background: var(--chip);
}

.guest-suggestion span,
.room-suggestion span,
.staff-suggestion span,
.field-help {
  color: var(--muted);
  font-size: 12px;
}

.selected-rooms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selected-room-chip {
  align-items: center;
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  display: inline-flex;
  gap: 8px;
  padding: 6px 8px 6px 10px;
}

.selected-room-chip button {
  border-radius: 999px;
  padding: 3px 8px;
}

.permissions-picker {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

.permissions-group {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.permissions-group-head {
  display: grid;
  gap: 2px;
}

.permissions-group-title {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
  text-transform: uppercase;
}

.permissions-group-hint {
  font-size: 12px;
  margin: 0;
}

.permissions-grid {
  align-items: stretch;
  display: grid;
  gap: 4px 10px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.permissions-grid--compact {
  gap: 2px 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.permission-chip {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  column-gap: 8px;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 0;
  padding: 5px 6px;
}

.permission-chip:hover {
  background: rgba(37, 99, 235, 0.06);
}

.permission-chip input[type="checkbox"] {
  flex-shrink: 0;
  grid-column: 1;
  grid-row: 1;
  height: 15px;
  margin: 0;
  max-height: 15px;
  max-width: 15px;
  width: 15px;
}

.permission-chip__title {
  font-size: 13px;
  font-weight: 500;
  grid-column: 2;
  grid-row: 1;
  line-height: 1.3;
  min-width: 0;
}

.permission-chip__slug {
  display: none;
}

.guest-suggestion[hidden],
.room-suggestion[hidden],
.staff-suggestion[hidden] {
  display: none;
}

.guest-suggestions[hidden],
.room-suggestions[hidden],
.staff-suggestions[hidden] {
  display: none;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 10px;
  grid-column: 1 / -1;
}

.history-filters {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(150px, 1fr));
  margin-bottom: 16px;
}

.history-filters.guest-search-only {
  grid-template-columns: minmax(0, 1fr);
  max-width: 560px;
}

.guest-filter-count {
  margin: -4px 0 10px;
}

.table-wrap {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.table-pagination {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-top: 12px;
}

.table-pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

table {
  border-collapse: collapse;
  min-width: 100%;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.compact-label {
  min-width: 150px;
}

.daily-sheet-wrap {
  border: 1px solid var(--line);
  border-radius: 14px;
}

.daily-sheet-table th,
.daily-sheet-table td {
  text-align: center;
}

.daily-sheet-table th:first-child,
.daily-sheet-table td:first-child {
  text-align: left;
}

.daily-planning-note-input {
  min-width: 160px;
  width: 100%;
}

.daily-sheet-status {
  border-radius: 8px;
  font-weight: 800;
}

.daily-sheet-status.status-av {
  background: #dcfce7;
  color: #166534;
}

.daily-sheet-status.status-na {
  background: #fee2e2;
  color: #991b1b;
}

.daily-sheet-status.status-nc {
  background: #fef3c7;
  color: #92400e;
}

.pill {
  background: var(--chip);
  border-radius: 999px;
  color: var(--primary);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 9px;
  text-transform: capitalize;
}

.pill.success {
  background: #e7f7ef;
  color: var(--success);
}

.pill.warning {
  background: #fff4d6;
  color: var(--warning);
}

.pill.danger {
  background: #fee4e2;
  color: var(--danger);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dashboard-controls {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.dashboard-controls label {
  display: grid;
  font-size: 12px;
  gap: 4px;
}

.dashboard-controls input,
.dashboard-controls select {
  min-width: 130px;
}

.finance-tables {
  margin-top: 16px;
}

.calendar {
  display: grid;
  gap: 8px;
}

.calendar-controls {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.calendar-controls label {
  display: grid;
  font-size: 12px;
  gap: 4px;
}

.calendar-controls input {
  min-width: 150px;
}

.calendar-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: 112px repeat(10, minmax(90px, 1fr));
}

.calendar-cell {
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 100px;
  min-width: 0;
  padding: 8px;
}

.calendar-cell.clickable {
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.calendar-cell.clickable:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 18px rgba(36, 84, 214, 0.12);
  transform: translateY(-1px);
}

.calendar-cell.selected {
  background: #edf2ff;
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.calendar-cell.header {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  min-height: auto;
  position: sticky;
  text-transform: uppercase;
  /* Sticks right below the topbar (which is itself sticky at top:0) instead of
     under it — --topbar-h is measured and set by app.js on every render, since
     the topbar's real height can vary (translations, logo, wrapping). */
  top: var(--topbar-h, 0px);
  z-index: 3;
}

/* Fills the full width of the header row, including the gaps between cells that
   grid-gap leaves as transparent — without this, room rows are visible sliding
   through those gaps as the sticky header stays put while the calendar scrolls. */
.calendar-header-bg {
  background: var(--panel);
  position: sticky;
  top: var(--topbar-h, 0px);
  z-index: 2;
}

.room-calendar-header {
  align-content: start;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.room-calendar-header > strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.room-calendar-type {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  min-width: 0;
  overflow-wrap: anywhere;
}

.calendar-type-header {
  align-content: center;
  background: #eef2f8;
  border-color: #d5dde8;
  min-height: 48px;
  padding: 6px 8px;
}

.calendar-type-header.is-collapsed {
  background: #e8eef8;
}

.calendar-type-band {
  align-items: center;
  background: #eef2f8;
  border-color: #d5dde8;
  display: flex;
  justify-content: center;
  min-height: 48px;
  pointer-events: none;
}

.calendar-type-band.is-collapsed {
  background: #e8eef8;
}

.calendar-type-day-available {
  color: var(--success, #157a4b);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.calendar-type-toggle {
  align-items: flex-start;
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 2px 8px;
  grid-template-columns: auto 1fr;
  padding: 0;
  text-align: start;
  width: 100%;
}

.calendar-type-chevron {
  font-size: 14px;
  font-weight: 800;
  grid-row: 1 / span 2;
  line-height: 1.2;
  margin-top: 1px;
}

.calendar-type-name {
  font-size: 13px;
  font-weight: 800;
  min-width: 0;
  overflow-wrap: anywhere;
}

.calendar-type-meta,
.calendar-type-available {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  grid-column: 2;
}

.calendar-type-available {
  color: var(--success, #157a4b);
}

.calendar-housekeeping {
  align-items: stretch;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  min-width: 0;
  width: 100%;
}

.housekeeping-badge {
  background: #fff4d6;
  border-radius: 999px;
  box-sizing: border-box;
  color: var(--warning);
  display: block;
  font-size: 11px;
  font-weight: 800;
  justify-content: center;
  max-width: 100%;
  padding: 4px 8px;
  text-align: center;
  overflow-wrap: anywhere;
  white-space: normal;
}

.calendar-housekeeping-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  width: 100%;
}

.mini-action {
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  box-sizing: border-box;
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  max-width: 100%;
  min-width: 0;
  padding: 6px 8px;
  overflow-wrap: anywhere;
  white-space: normal;
  width: 100%;
}

.mini-action:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.mini-action.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.mini-action.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.housekeeping-cell-hint {
  color: var(--warning);
  font-weight: 800;
  padding-right: 6px;
}

.calendar-mode-toggle {
  background: #eef2f7;
  border-radius: 999px;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
}

.calendar-mode-btn {
  background: transparent;
  border: none;
  border-radius: 999px;
  color: #64748b;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.calendar-mode-btn.is-active {
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  color: var(--text, #0f172a);
}

.calendar-mode-btn:hover:not(.is-active) {
  color: #334155;
}

.room-block {
  align-items: flex-start;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left-width: 3px;
  border-radius: 10px;
  color: #334155;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  font-size: 11px;
  font-weight: 700;
  gap: 2px;
  line-height: 1.25;
  min-height: 100%;
  padding: 8px 8px 8px 10px;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
  width: 100%;
}

.room-block:hover {
  background: #fff;
}

.room-block-dot {
  border-radius: 999px;
  display: inline-block;
  height: 6px;
  margin-bottom: 2px;
  width: 6px;
}

.room-block-label {
  font-size: 11px;
  letter-spacing: 0.01em;
}

.room-block-note {
  color: #64748b;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
}

.room-block-maintenance {
  border-left-color: #ea580c;
}

.room-block-maintenance .room-block-dot {
  background: #ea580c;
}

.room-block-dirty {
  border-left-color: #ca8a04;
}

.room-block-dirty .room-block-dot {
  background: #ca8a04;
}

.room-block-out_of_service {
  border-left-color: #64748b;
}

.room-block-out_of_service .room-block-dot {
  background: #64748b;
}

.room-block-other {
  border-left-color: #475569;
}

.room-block-other .room-block-dot {
  background: #475569;
}

.calendar-cell-blocked {
  background: #fcfdff;
  padding: 4px;
}

.room-block-modal {
  max-width: 520px;
}

.room-block-form .room-block-dates {
  display: grid;
  gap: 12px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.reason-chips-label {
  color: #64748b;
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}

.reason-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reason-chip {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  font-size: 12px;
  font-weight: 600;
  gap: 6px;
  padding: 7px 12px;
  transition: all 0.15s ease;
}

.reason-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.reason-chip:has(input:checked) {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.reason-chip-maintenance:has(input:checked) {
  background: #fff7ed;
  border-color: #fdba74;
  color: #c2410c;
}

.reason-chip-dirty:has(input:checked) {
  background: #fefce8;
  border-color: #fde047;
  color: #a16207;
}

.reason-chip-out_of_service:has(input:checked) {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #334155;
}

.reason-chip-other:has(input:checked) {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}

.danger-text {
  color: #b91c1c;
}

.channel-radio-field {
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  margin: 0;
  padding: 12px 14px;
}

.channel-radio-field legend {
  font-size: 12px;
  font-weight: 700;
  padding: 0 4px;
}

.channel-radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.channel-radio-option {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  font-size: 13px;
  font-weight: 600;
  gap: 8px;
  padding: 8px 14px;
  transition: all 0.15s ease;
}

.channel-radio-option:has(input:checked) {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.channel-radio-option input {
  accent-color: var(--primary, #2563eb);
}

.booking-bar,
.room-block-bar {
  align-self: stretch;
  justify-self: stretch;
  min-height: 100px;
  z-index: 1;
}

.room-block-bar {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.room-block-lock {
  color: #475569;
  fill: currentColor;
  height: 20px;
  width: 20px;
}

.booking {
  background: var(--primary);
  border-radius: 8px;
  color: white;
  display: block;
  font-size: 12px;
  font-weight: 800;
  padding: 6px;
  text-align: left;
  width: 100%;
}

.booking-bar-source {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.92;
}

.booking:hover {
  background: var(--primary-dark);
}

.booking-status-pending {
  background: var(--warning);
}

.booking-status-pending:hover {
  background: #7a5200;
}

.booking-status-confirmed {
  background: var(--primary);
}

.booking-status-confirmed:hover {
  background: var(--primary-dark);
}

.booking-status-checked_in {
  background: var(--success);
}

.booking-status-checked_in:hover {
  background: #0e5c3a;
}

.booking-status-checked_out {
  background: var(--muted);
}

.booking-status-checked_out:hover {
  background: #4b5a70;
}

.booking.overbooked {
  background: #b91c1c;
  box-shadow: inset 0 0 0 2px #7f1d1d;
}

.booking.overbooked:hover {
  background: #991b1b;
}

.calendar-legend {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
  bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  max-width: min(90vw, 640px);
  padding: 10px 16px;
  position: fixed;
  right: 20px;
  z-index: 50;
}

.calendar-legend-item {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 600;
  gap: 6px;
}

.calendar-legend-swatch {
  border-radius: 4px;
  display: inline-block;
  height: 12px;
  width: 12px;
}

.calendar-legend-swatch.booking-status-pending {
  background: var(--warning);
}

.calendar-legend-swatch.booking-status-confirmed {
  background: var(--primary);
}

.calendar-legend-swatch.booking-status-checked_in {
  background: var(--success);
}

.calendar-legend-swatch.booking-status-checked_out {
  background: var(--muted);
}

.calendar-legend-swatch.overbooked {
  background: #b91c1c;
}

.overbook-badge,
.overbook-badge-inline {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 4px;
  color: #b91c1c;
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  margin-left: 6px;
  padding: 1px 6px;
  vertical-align: middle;
}

.overbook-badge-inline {
  margin-left: 0;
  margin-top: 2px;
}

.overbooking-alert-banner {
  background: #fef2f2;
  border-color: #b91c1c;
  margin-bottom: 1rem;
}

.overbooking-alert-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.overbooking-alert-item {
  margin-top: 6px;
}

.overbooking-alert-item small {
  color: #7f1d1d;
  display: block;
  margin-top: 3px;
}

.overbooking-conflicts {
  border-top: 1px solid #fecaca;
  color: #7f1d1d;
  font-size: 12px;
  margin-top: 8px;
  padding-top: 8px;
}

.overbooking-conflicts ul {
  margin: 4px 0 0 18px;
  padding: 0;
}

.overbooking-conflicts li {
  margin-top: 3px;
}

tr.row-overbooked {
  background: #fff1f2;
}

tr.row-overbooked td:first-child {
  border-left: 3px solid #b91c1c;
}

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

.detail-item {
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 4px;
  padding: 12px;
}

.detail-item.full {
  grid-column: 1 / -1;
}

.detail-item span {
  color: var(--muted);
  font-size: 12px;
}

.detail-item strong {
  font-size: 14px;
  font-weight: 800;
}

.price-estimate {
  background: #edf2ff;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  padding: 12px;
}

.price-estimate span {
  color: var(--muted);
}

.price-estimate strong {
  color: var(--primary);
}

.price-estimate div {
  display: grid;
  gap: 2px;
  text-align: right;
}

.price-estimate small {
  color: var(--muted);
  display: block;
}

.money-with-fx {
  align-items: center;
  display: inline-flex;
  gap: 0.35rem;
}

.money-fx-hint {
  color: var(--muted);
  cursor: help;
  display: inline-flex;
  position: relative;
}

.money-fx-hint__icon {
  display: block;
  opacity: 0.75;
}

.money-fx-hint__tooltip {
  background: #111827;
  border-radius: 8px;
  bottom: calc(100% + 8px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  left: 50%;
  line-height: 1.35;
  opacity: 0;
  padding: 8px 10px;
  pointer-events: none;
  position: absolute;
  transform: translateX(-50%);
  visibility: hidden;
  white-space: nowrap;
  z-index: 30;
}

.money-fx-hint__tooltip::after {
  border: 6px solid transparent;
  border-top-color: #111827;
  content: "";
  left: 50%;
  position: absolute;
  top: 100%;
  transform: translateX(-50%);
}

.money-fx-hint:hover .money-fx-hint__tooltip,
.money-fx-hint:focus .money-fx-hint__tooltip,
.money-fx-hint:focus-visible .money-fx-hint__tooltip {
  opacity: 1;
  visibility: visible;
}

.auto-room-hint {
  background: #f8fafc;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  padding: 12px;
}

.billing-panel {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
}

.billing-panel h3 {
  margin: 0;
}

.billing-stats .stat-value {
  font-size: 20px;
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-grid > * {
  min-width: 0;
}

.cell-hint {
  color: var(--muted);
  display: inline-block;
  font-size: 12px;
  padding-top: 10px;
}

.cell-hint.strong {
  color: var(--primary);
  font-weight: 800;
}

.empty-state {
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.alert {
  background: #fee4e2;
  border: 1px solid #fecdca;
  border-radius: 12px;
  color: var(--danger);
  margin-bottom: 12px;
  padding: 12px;
}

.alert-success {
  background: #e6f4ec;
  border-color: #b8e0c8;
  color: var(--success);
}

.link-button {
  background: none;
  border: 0;
  border-radius: 0;
  color: var(--primary);
  font-weight: 600;
  padding: 0;
  text-decoration: underline;
}

.link-button:hover {
  color: var(--primary-dark);
}

/* Lock page scroll while any modal is open (prevents white page corners leaking under the overlay). */
body:has(.modal-backdrop) {
  overflow: hidden;
}

.modal-backdrop {
  align-items: flex-start;
  background: rgba(15, 23, 42, 0.42);
  display: flex;
  inset: 0;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 16px;
  position: fixed;
  -webkit-overflow-scrolling: touch;
  /* Above PMS topbar (60) / sidebar (55) so modal header is never covered */
  z-index: 100;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.14);
  display: flex;
  flex-direction: column;
  isolation: isolate;
  margin: auto;
  max-height: min(860px, calc(100dvh - 56px));
  max-width: 760px;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  width: min(760px, 100%);
}

.modal.modal--auth {
  max-width: min(720px, 100%);
  width: min(720px, 100%);
}

.modal > .section-header,
.modal > .modal-auth-header {
  align-items: flex-start;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  gap: 12px;
  margin: 0;
  padding: 18px 20px 14px;
  z-index: 3;
}

.modal > .section-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.modal > .section-header p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin: 4px 0 0;
  max-width: 48ch;
}

.modal > .alert {
  flex: 0 0 auto;
  margin: 12px 20px 0;
}

/* Scrollable body: form then billing — natural height, no flex-shrink overlap. */
.modal-body {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal-body > .alert {
  margin: 12px 20px 0;
}

/* Direct form child (auth, finance, …): form scrolls inside the modal. */
.modal > form.form-grid,
.modal > .form-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 20px 10px;
  -webkit-overflow-scrolling: touch;
}

/* Form / details inside .modal-body: full natural height, stacked above Billing. */
.modal-body > form.form-grid,
.modal-body > .form-grid,
.modal-body > form.details-grid,
.modal-body > .details-grid {
  display: grid;
  flex: none;
  height: auto;
  margin: 0;
  max-height: none;
  min-height: 0;
  overflow: visible;
  padding: 16px 20px 10px;
  position: relative;
  width: 100%;
  z-index: 1;
}

.modal > form.form-grid--auth,
.modal-body > form.form-grid--auth {
  gap: 12px;
}

.modal > form.form-grid .form-actions {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), var(--panel) 40%);
  border-top: 1px solid var(--line);
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin: 12px -20px 0;
  padding: 14px 20px 16px;
  position: sticky;
  z-index: 2;
}

/* Reservation: actions stay in document flow so they never cover Billing. */
.modal-body form[data-form] .form-actions {
  background: var(--panel);
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin: 12px -20px 0;
  padding: 14px 20px 16px;
  position: static;
}

.modal-body > .billing-panel {
  background: var(--panel);
  border-top: 1px solid var(--line);
  display: grid;
  flex: none;
  gap: 16px;
  height: auto;
  margin: 0;
  padding: 16px 20px 20px;
  position: relative;
  width: 100%;
  z-index: 0;
}

.modal.modal--guest {
  max-width: min(640px, 100%);
}

.modal.modal--reservation {
  max-width: min(780px, 100%);
}

.modal.modal--exchange {
  max-width: min(520px, 100%);
}

.daily-tasks-toolbar {
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
}

.daily-tasks-date-field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  min-width: 160px;
}

.daily-tasks-list {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.daily-task-item {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 12px;
}

.daily-task-item.is-done {
  opacity: 0.72;
}

.daily-task-item.is-done .daily-task-title {
  text-decoration: line-through;
}

.daily-task-check {
  align-items: center;
  cursor: pointer;
  display: flex;
  flex: 1;
  gap: 10px;
  margin: 0;
}

.daily-task-time {
  background: #e2e8f0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
}

.daily-task-title {
  font-weight: 600;
}

.daily-task-bell.has-due {
  background: #fff7ed;
  color: #c2410c;
}

.daily-task-notif-banner {
  margin-bottom: 12px;
}

.daily-task-notif-list {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.daily-task-notif-list li {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.exchange-calc-strip-wrap {
  margin: 0;
}

.exchange-calc {
  background: #f8fafc;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  display: grid;
  gap: 10px;
  padding: 12px 14px;
}

.exchange-calc--strip {
  margin-top: 2px;
}

.exchange-calc__header {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: space-between;
}

.exchange-calc__hint,
.exchange-calc__updated {
  font-size: 12px;
  margin: 0;
}

.exchange-calc__row {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.8fr);
}

.exchange-calc__row--reverse {
  align-items: center;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.8fr);
}

.exchange-calc__result {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.exchange-calc__mad {
  font-size: 1.15rem;
  font-weight: 700;
}

.exchange-calc__rate {
  font-size: 12px;
}

.exchange-calc__error {
  color: #b91c1c;
  font-size: 13px;
  font-weight: 600;
  width: 100%;
}

.exchange-calc__reverse-out {
  font-weight: 600;
  padding-bottom: 8px;
}

.exchange-calc__actions {
  margin: 0;
}

@media (max-width: 640px) {
  .exchange-calc__row,
  .exchange-calc__row--reverse {
    grid-template-columns: 1fr;
  }
}

.guest-empty-hint {
  margin-top: 12px;
  text-align: center;
}

.guests-page .section-header .guests-page-actions {
  flex-shrink: 0;
}

.modal form[data-form] .form-actions {
  z-index: 2;
}

form[data-form] button[type="submit"] {
  position: relative;
  touch-action: manipulation;
  z-index: 1;
}

@media (max-width: 980px) {
  .history-filters.guest-search-only {
    grid-template-columns: minmax(0, 1fr);
    max-width: none;
    width: 100%;
  }

  .grid-two {
    grid-template-columns: 1fr;
  }

  .main {
    gap: 14px;
    min-width: 0;
    padding: 14px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
    overflow-x: hidden;
  }

  button {
    padding: 10px 12px;
  }

  .app-shell {
    min-width: 0;
    width: 100%;
  }

  .topbar {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
    padding: 14px;
    position: static;
    width: 100%;
  }

  .topbar,
  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .brand h1 {
    font-size: 18px;
  }

  .topbar .form-actions,
  .section-header .form-actions {
    display: grid;
    flex-wrap: wrap;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .topbar .form-actions button,
  .section-header .form-actions button,
  .form-actions button {
    flex: 1 1 auto;
  }

  form[data-form] .form-actions button[type="submit"] {
    min-height: 48px;
  }

  .main {
    gap: 12px;
    padding: 10px;
    width: 100%;
  }

  .sidebar {
    border-radius: 16px;
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 100%;
    overflow: visible;
    padding: 8px;
    position: static;
    width: 100%;
  }

  .tab-button {
    min-width: 0;
    overflow-wrap: anywhere;
    text-align: center;
    white-space: normal;
    width: 100%;
  }

  .main {
    min-width: 0;
    width: 100%;
  }

  .section {
    border-radius: 16px;
    padding: 14px;
  }

  .stats-grid,
  .form-grid,
  .history-filters,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .stat-value {
    font-size: 26px;
  }

  .form-actions,
  .row-actions,
  .dashboard-controls,
  .calendar-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .history-filters.guest-search-only {
    grid-template-columns: minmax(0, 1fr);
    max-width: none;
    width: 100%;
  }

  .history-filters.guest-search-only label,
  .history-filters.guest-search-only input[type="search"] {
    min-width: 0;
  }

  .history-filters.guest-search-only input[type="search"] {
    min-height: 44px;
  }

  .dashboard-controls input,
  .dashboard-controls select,
  .calendar-controls input {
    min-width: 0;
  }

  .table-wrap {
    margin-inline: 0;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    padding-inline: 0;
    width: 100%;
  }

  .calendar {
    margin-inline: -14px;
    overflow-x: auto;
    padding-inline: 14px;
  }

  .table-wrap > table {
    width: max-content;
  }

  th,
  td {
    padding: 10px 8px;
  }

  .calendar-grid {
    grid-template-columns: 120px repeat(10, minmax(96px, 1fr));
    min-width: 1144px;
  }

  .calendar-cell {
    min-height: 96px;
    padding: 8px;
  }

  .housekeeping-badge {
    max-width: 100%;
  }

  .price-estimate {
    align-items: flex-start;
    display: grid;
    gap: 8px;
  }

  .price-estimate div {
    text-align: left;
  }

  .permissions-grid,
  .permissions-grid--compact {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    align-items: stretch;
    background: rgba(15, 23, 42, 0.5);
    overflow: hidden;
    padding: 0;
  }

  .modal {
    border-radius: 0;
    margin: 0;
    max-height: 100dvh;
    max-width: none;
    min-height: 100dvh;
    width: 100%;
  }

  .modal.modal--auth,
  .modal.modal--reservation {
    max-width: none;
    width: 100%;
  }

  .modal-body {
    flex: 1 1 auto;
  }

  .modal form[data-form] .form-actions {
    flex-direction: column;
    justify-content: stretch;
    margin-left: -20px;
    margin-right: -20px;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
  }

  .modal .form-actions button {
    min-height: 48px;
    width: 100%;
  }
}

@media (max-width: 420px) {
  .main {
    padding: 8px;
  }

  .topbar .form-actions,
  .section-header .form-actions {
    grid-template-columns: 1fr;
  }

  .section {
    padding: 12px;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    gap: 10px;
  }

  .stat-card,
  .card {
    padding: 12px;
  }

  .selected-room-chip {
    font-size: 12px;
  }

  .permission-chip__title {
    font-size: 12px;
  }

  .permission-chip__slug {
    font-size: 10px;
  }
}

.finance-payroll-hint {
  margin: 0 0 14px;
  font-size: 13px;
}

.finance-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  justify-content: flex-end;
}

.checkbox-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.checkbox-field input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.badge-monthly {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: #eef6fd;
  color: #1a4f7a;
  border: 1px solid #3b82c4;
  font-size: 11px;
  font-weight: 600;
}

.finance-stats-groups {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.finance-ota-breakdown {
  margin-top: 32px;
}

.finance-stats-group-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.finance-stats-group-desc {
  margin: 4px 0 12px;
  font-size: 13px;
}

.finance-stats-group-result .stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card-highlight {
  border-color: #3b82c4;
  background: linear-gradient(180deg, #f5faff 0%, #eef6fd 100%);
}

.stat-card-highlight .stat-value {
  color: #1a4f7a;
}

/* Business budget */
.business-budget-toolbar {
  flex-wrap: wrap;
}

.business-budget-view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.business-budget-hint {
  margin: 0 0 12px;
  font-size: 13px;
}

.budget-grid-wrap {
  overflow-x: auto;
}

.budget-grid {
  min-width: 960px;
  font-size: 12px;
}

.budget-grid th,
.budget-grid td {
  padding: 6px 8px;
  text-align: right;
  white-space: nowrap;
}

.budget-grid th:first-child,
.budget-grid td.budget-line-label {
  text-align: left;
  min-width: 180px;
}

.budget-section-row th {
  background: #e7edf7;
  color: var(--primary);
  font-weight: 800;
  text-align: left;
}

.budget-subtotal-row td {
  background: #edf2ff;
  font-weight: 700;
}

.budget-total-row td {
  background: #dbe3ef;
  font-weight: 800;
}

.budget-pnl-profit-row td {
  background: #e8f5e9;
  font-weight: 800;
}

.budget-pnl-pos {
  color: #1b7a3d;
  font-weight: 800;
}

.budget-pnl-neg {
  color: #b42318;
  font-weight: 800;
}

.budget-pnl-simple {
  display: grid;
  gap: 14px;
}

.budget-pnl-formula {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.budget-pnl-year-box {
  padding: 16px 18px;
}

.budget-pnl-year-title {
  font-weight: 700;
  margin-bottom: 12px;
}

.budget-pnl-equation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.budget-pnl-income-split {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.budget-pnl-income-total {
  font-weight: 800;
  background: #f7f9fc;
}

.budget-pnl-month-table-wide {
  min-width: 760px;
}

@media (max-width: 900px) {
  .budget-pnl-income-split {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

.budget-pnl-eq-block {
  display: grid;
  gap: 4px;
  min-width: 120px;
}

.budget-pnl-eq-label {
  font-size: 0.85rem;
  color: #5b6472;
}

.budget-pnl-eq-block strong {
  font-size: 1.15rem;
}

.budget-pnl-eq-op {
  font-size: 1.4rem;
  font-weight: 700;
  color: #5b6472;
}

.budget-pnl-eq-result {
  padding: 8px 12px;
  border-radius: 8px;
  background: #e8f5e9;
}

.budget-pnl-source {
  margin: 12px 0 0;
  font-size: 0.9rem;
}

.budget-pnl-month-table {
  width: 100%;
  border-collapse: collapse;
}

.budget-pnl-month-table th,
.budget-pnl-month-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e5e9f0;
  text-align: right;
}

.budget-pnl-month-table th:first-child,
.budget-pnl-month-table td:first-child {
  text-align: left;
}

html[dir="rtl"] .budget-pnl-month-table th,
html[dir="rtl"] .budget-pnl-month-table td {
  text-align: left;
}

html[dir="rtl"] .budget-pnl-month-table th:first-child,
html[dir="rtl"] .budget-pnl-month-table td:first-child {
  text-align: right;
}

.budget-pnl-month {
  font-weight: 700;
}

.budget-pnl-current-month td {
  background: #f3f7ff;
}

.budget-pnl-year-total-row td {
  background: #e8f5e9;
  font-weight: 800;
  border-bottom: none;
}

.budget-pnl-summary {
  margin: 0 0 14px;
}

.budget-cumulative-row td {
  background: #c7d4eb;
}

.budget-year-col {
  font-weight: 700;
}

.budget-cell-input {
  width: 88px;
  padding: 4px 6px;
  font-size: 12px;
  text-align: right;
}

.budget-actual-cell {
  position: relative;
  vertical-align: middle;
}

.budget-badge {
  display: block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 2px;
}

.budget-badge-auto {
  color: var(--muted);
}

.budget-badge-manual {
  color: var(--primary);
}

.budget-reset-btn {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  margin-top: 2px;
}

.budget-variance-pos {
  color: var(--danger);
  font-weight: 600;
}

.budget-variance-neg {
  color: var(--success);
  font-weight: 600;
}

.budget-variance-on-budget,
.budget-variance-on-budget-cell {
  color: var(--success);
  font-weight: 600;
}

.budget-variance-on-budget {
  display: inline-block;
  min-width: 2.5em;
  text-align: right;
}

.budget-readonly {
  color: var(--text);
}

.business-budget-analysis-stats .stat-value.budget-variance-pos,
.business-budget-analysis-stats .stat-value.budget-variance-neg {
  font-size: 28px;
}

.budget-analysis {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.budget-analysis-summary.panel {
  background: #fce8e8;
  border-radius: 16px;
  padding: 16px 18px;
}

.budget-analysis-table {
  width: 100%;
  font-size: 13px;
}

.budget-analysis-table th,
.budget-analysis-table td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid rgba(30, 64, 175, 0.12);
}

.budget-analysis-table th:first-child,
.budget-analysis-table td:first-child {
  text-align: left;
  font-weight: 700;
  color: var(--primary);
}

.budget-analysis-table thead th {
  background: rgba(255, 255, 255, 0.45);
  color: var(--primary);
  font-weight: 800;
}

.budget-analysis-total-row td {
  background: rgba(255, 255, 255, 0.55);
  font-weight: 800;
  color: var(--primary);
  border-bottom: 0;
}

.budget-analysis-charts {
  align-items: stretch;
}

.budget-analysis-chart-panel {
  min-height: 320px;
}

.budget-bar-chart {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}

.budget-bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 34%) 1fr;
  gap: 12px;
  align-items: center;
}

.budget-bar-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.3;
}

.budget-bar-tracks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.budget-bar-track {
  height: 14px;
  background: #e8eef8;
  border-radius: 4px;
  overflow: hidden;
}

.budget-bar-fill {
  height: 100%;
  border-radius: 4px;
  min-width: 2px;
  transition: width 0.2s ease;
}

.budget-bar-fill-planned {
  background: #93c5fd;
}

.budget-bar-fill-actual {
  background: #1d4ed8;
}

.budget-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

.budget-legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -2px;
}

.budget-legend-swatch-planned {
  background: #93c5fd;
}

.budget-legend-swatch-planned-dark {
  background: #1d4ed8;
}

.budget-legend-swatch-actual {
  background: #60a5fa;
}

.budget-legend-swatch-variance {
  background: #dc2626;
}

.budget-line-chart-wrap {
  overflow-x: auto;
  margin-top: 8px;
}

.budget-line-chart {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
}

.budget-chart-grid {
  stroke: rgba(30, 64, 175, 0.12);
  stroke-width: 1;
}

.budget-chart-axis {
  fill: var(--muted);
  font-size: 9px;
}

.budget-line-planned {
  stroke: #1d4ed8;
  stroke-width: 2.5;
}

.budget-line-actual {
  stroke: #60a5fa;
  stroke-width: 2.5;
}

.budget-line-variance {
  stroke: #dc2626;
  stroke-width: 2;
  stroke-dasharray: 4 3;
}

.budget-dot-planned {
  fill: #1d4ed8;
}

.budget-dot-actual {
  fill: #60a5fa;
}

.budget-dot-variance {
  fill: #dc2626;
}

@media (max-width: 900px) {
  .budget-bar-row {
    grid-template-columns: 1fr;
  }
}

.guest-link-panel {
  margin-bottom: 16px;
}

.guest-link-select-field,
.guest-link-url-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.guest-link-result {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.guest-link-url-field input {
  font-family: monospace;
  font-size: 12px;
}

.guest-link-qr {
  display: flex;
}

.guest-link-qr img {
  border: 1px solid var(--line, #d6dbe8);
  border-radius: 8px;
  padding: 6px;
  background: #fff;
}

a.button-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.guest-submission-card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #fafbff;
}

.guest-submission-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.guest-submission-meta {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

.guest-submission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px 16px;
  margin-bottom: 12px;
}

.guest-submission-detail {
  display: flex;
  flex-direction: column;
  font-size: 13px;
}

.guest-submission-detail span {
  color: #6b7280;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: #fff4e0;
  color: #92600a;
  border: 1px solid #e6b860;
  font-size: 11px;
  font-weight: 600;
}

.badge-status-ok {
  background: #e6f6ec;
  color: #1a7f4b;
  border-color: #5cbd87;
}

.badge-status-muted {
  background: #eef0f4;
  color: #6b7280;
  border-color: #c9cfda;
}

.payment-status-box {
  grid-column: 1 / -1;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line, #d6dbe8);
}

.payment-status-paid {
  background: #eef8f0;
  border-color: #b8dfc4;
}

.payment-status-due {
  background: #fff8ee;
  border-color: #ecd9b8;
}

.payment-status-detail {
  margin: 8px 0 0;
  font-size: 13px;
}

.payment-status-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 10px;
  font-size: 14px;
}

.room-calendar-order-panel {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line, #d6dbe8);
  border-radius: 10px;
  background: #f8fafc;
}

.room-calendar-order-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.room-order-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.room-order-item {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line, #d6dbe8);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: auto 32px 1fr auto;
  padding: 8px 10px;
}

.room-order-item-draggable {
  cursor: grab;
}

.room-order-item-draggable:active {
  cursor: grabbing;
}

.room-order-item-dragging {
  opacity: 0.55;
}

.room-order-item-drop-target {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.room-order-grip {
  color: #94a3b8;
  cursor: grab;
  font-size: 14px;
  letter-spacing: -2px;
  line-height: 1;
  padding: 4px 2px;
  user-select: none;
}

.room-order-position {
  align-items: center;
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  min-width: 56px;
}

.room-order-position select {
  min-width: 56px;
  padding: 4px 6px;
}

.room-order-rank {
  align-items: center;
  background: #eef2ff;
  border-radius: 999px;
  color: #3730a3;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.room-order-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.room-order-actions {
  display: inline-flex;
  gap: 4px;
}

.lang-switcher {
  display: inline-flex;
  gap: 2px;
  border: 1px solid var(--line, #d6dbe8);
  border-radius: 999px;
  padding: 2px;
  background: #f4f6fb;
}

.lang-btn {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #5b6273;
  cursor: pointer;
}

.lang-btn.active {
  background: #1f2a5c;
  color: #fff;
}

.refund-block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line, #d6dbe8);
}

.refund-title {
  margin: 0 0 4px;
  font-size: 15px;
}

.refund-block .muted {
  margin: 0 0 10px;
  font-size: 13px;
}

.card-lock-section {
  background: transparent;
  border: 0;
  display: grid;
  min-height: calc(100vh - 140px);
  padding: 0;
}

.card-lock-frame-slot {
  min-height: calc(100vh - 140px);
  width: 100%;
}

/* Persistent Door cards host — never moved in the DOM (moving iframes reloads them). */
.card-lock-layer {
  background: var(--bg);
  box-sizing: border-box;
  display: none;
  flex-direction: column;
  overflow: hidden;
  position: fixed;
  /* Below PMS topbar/sidebar so Encoder statusbar cannot cover the header */
  z-index: 5;
}

.card-lock-layer.is-open {
  display: flex;
}

.card-lock-layer-hint {
  background: var(--bg);
  flex: 0 0 auto;
  margin: 0;
  padding: 0 0 12px;
}

.card-lock-layer .card-lock-frame {
  background: transparent;
  border: 0;
  border-radius: 0;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  width: 100%;
}

@media (max-width: 900px) {
  .card-lock-frame-slot {
    min-height: 75vh;
  }
}