@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-latin-var.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: 'Source Serif 4';
  src: url('../fonts/source-serif-4-latin-var.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light;

  --ink: #16332d;
  --muted: #63736e;
  --cream: #f7f3eb;
  --paper: #fff;
  --line: #dce0d9;
  --brand: #c7502e;
  --brand-strong: #ad4529;
  --forest: #173e35;
  --surface-soft: #f1efe7;
  --shadow: 0 18px 50px #17352d18;

  --font-sans: 'Inter', system-ui, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-lg: 1.25rem;

  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;

  --radius-sm: 0.4rem;
  --radius-md: 0.65rem;
  --radius-lg: 1rem;
  --radius-pill: 2rem;
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1 {
  margin: 0 0 var(--space-2);
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
p {
  margin: 0;
  text-wrap: pretty;
}
:focus-visible {
  outline: 3px solid #087e67;
  outline-offset: 2px;
}
.eyebrow {
  color: var(--brand-strong);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.impersonation-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: #ffd978;
  color: #281900;
  border-bottom: 1px solid #d5a938;
  font-size: var(--text-sm);
}
.pending-banner {
  background: #e3eee8;
  border-bottom-color: #9cc0af;
  color: #17352d;
}
.admin-demo-actions {
  display: flex;
  gap: var(--space-2);
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  height: 4rem;
  padding: 0 clamp(1rem, 4vw, 3rem);
  background: #fffc;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: inherit;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--text-lg);
  text-decoration: none;
}
.logo {
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}
.topbar nav {
  flex: 1;
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.topbar nav a {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  text-decoration: none;
}
.topbar nav a.active {
  background: #deebe3;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-4);
  border: 0;
  border-radius: var(--radius-md);
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.button:hover {
  background: var(--brand-strong);
}
.button-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.button-secondary:hover {
  background: var(--surface-soft);
}
.button-danger {
  background: transparent;
  color: var(--brand-strong);
  border: 1px solid var(--brand-strong);
}
.button-danger:hover {
  background: var(--brand-strong);
  color: #fff;
}
.button-small {
  min-height: 2.25rem;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}

.auth-page {
  min-height: calc(100vh - 4rem);
  display: grid;
  place-items: center;
  padding: var(--space-8) var(--space-4);
}
.auth-card {
  display: grid;
  gap: var(--space-2);
  width: min(100%, 26rem);
  padding: var(--space-8);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.auth-card h1 {
  margin-bottom: var(--space-2);
}
.auth-card label {
  font-size: var(--text-sm);
  font-weight: 700;
}
.auth-card input {
  min-height: 3rem;
  margin-bottom: var(--space-2);
  padding: var(--space-3);
  border: 1px solid #cbd2cb;
  border-radius: var(--radius-md);
  background: var(--paper);
  font: inherit;
  color: inherit;
}
.auth-card button {
  margin-top: var(--space-2);
  min-height: 3rem;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.auth-card button:hover {
  background: var(--brand-strong);
}
.form-status {
  min-height: 1.5rem;
  color: var(--brand-strong);
  font-size: var(--text-sm);
  font-weight: 700;
}

.planning-shell {
  padding: clamp(1rem, 3vw, 2.5rem);
}
.planning-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}
.view-switcher {
  display: flex;
  padding: 0.25rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}
.view-switcher a {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  color: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  text-decoration: none;
}
.view-switcher a[aria-current='true'] {
  background: var(--ink);
  color: #fff;
}
.planning-filters {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background: #ede9df;
  border-radius: var(--radius-md);
}
.field {
  display: grid;
  gap: 0.35rem;
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.field input {
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid #cbd2cb;
  border-radius: var(--radius-md);
  background: var(--paper);
  font: inherit;
  letter-spacing: normal;
  text-transform: none;
}
.planning-hint {
  margin-bottom: var(--space-4);
  color: var(--muted);
  font-size: var(--text-sm);
}
.privacy-note {
  margin-top: var(--space-6);
  color: var(--muted);
  font-size: var(--text-sm);
}

.calendar-card {
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

/* Each row is its own grid sharing one column template, so an event bar spans
   its nights with `grid-column` and sits on top of the day cells by taking the
   same `grid-row`. */
.rack {
  --rack-unit: 11rem;
  --rack-day: 3.5rem;
  min-width: max-content;
}
.rack-row {
  display: grid;
}
.rack-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.rack-head .rack-unit {
  z-index: 4;
  background: var(--forest);
  color: #fff;
}
.rack-unit {
  position: sticky;
  left: 0;
  z-index: 2;
  display: grid;
  align-content: center;
  gap: 0.15rem;
  padding: var(--space-3);
  background: var(--paper);
  border-right: 1px solid var(--line);
}
.rack-unit small {
  color: inherit;
  opacity: 0.75;
  font-size: var(--text-xs);
}
.rack-day {
  display: grid;
  align-content: center;
  justify-items: center;
  padding: var(--space-2);
  border-left: 1px solid #e5e7e2;
  font-size: var(--text-xs);
  text-align: center;
}
.rack-cell {
  grid-row: 1;
  min-height: 3.5rem;
  border-left: 1px solid #e5e7e2;
  border-bottom: 1px solid #e5e7e2;
}
.rack-event {
  grid-row: 1;
  z-index: 1;
  align-self: center;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.5rem;
  margin: 0 0.15rem;
  padding: 0 var(--space-2);
  background: #dcebe4;
  border: 1px solid #b6d3c6;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 700;
  overflow: hidden;
  cursor: grab;
  /* without this a finger drag scrolls the rack instead of moving the stay */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.rack-event-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rack-event-maintenance {
  background: #f9e5c8;
  border-color: #e2c48d;
}
.rack-event-block {
  background: #e9e5da;
  border-color: #cdc6b6;
}
.rack-event.is-paid .rack-event-label::before {
  content: '€ ';
  color: #2b6b56;
}
.rack-event.is-dragging {
  z-index: 5;
  box-shadow: var(--shadow);
  cursor: grabbing;
}
.rack-event.is-locked {
  cursor: not-allowed;
  opacity: 0.7;
}
.rack-event.is-clipped-start {
  border-left-style: dashed;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.rack-event.is-clipped-end {
  border-right-style: dashed;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.rack-handle {
  flex: 0 0 auto;
  width: 0.7rem;
  height: 1.6rem;
  border-radius: var(--radius-sm);
  background: #17352d26;
  cursor: ew-resize;
  touch-action: none;
}
.rack-handle-start {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.rack-handle-end {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.rack-event.is-locked .rack-handle {
  display: none;
}

.rack-event-ghost {
  background: #cfe3d8;
  border: 2px dashed #6f9c8a;
  color: var(--forest);
  display: grid;
  place-items: center;
  cursor: crosshair;
  pointer-events: none;
}
.rack-cell {
  cursor: crosshair;
  /* deliberately NO touch-action here: a finger drag on empty cells pans the
     rack; a tap creates a one-night occupation adjustable by the handles */
}

.create-dialog {
  width: min(calc(100vw - 2rem), 24rem);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  background: var(--paper);
  color: var(--ink);
}
.create-dialog::backdrop {
  background: #16332d59;
}
.create-dialog form {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6);
}
.create-dialog h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: var(--text-lg);
}
.create-summary {
  color: var(--muted);
  font-size: var(--text-sm);
}
.create-dialog select,
.create-dialog input {
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid #cbd2cb;
  border-radius: var(--radius-md);
  background: var(--paper);
  font: inherit;
  letter-spacing: normal;
  text-transform: none;
}
.create-dialog menu {
  display: flex;
  justify-content: end;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
}

.metric-row {
  display: flex;
  gap: var(--space-4);
}
.metric {
  display: grid;
  gap: 0.15rem;
  padding: var(--space-3) var(--space-4);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  text-align: right;
}
.metric b {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-variant-numeric: tabular-nums;
}
.metric small {
  color: var(--muted);
  font-size: var(--text-xs);
}
.panel-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: var(--text-lg);
}
.panel-title small {
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}
.stay-row,
.reservation-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.stay-row.is-done {
  opacity: 0.55;
}
.stay-row-copy {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}
.stay-row-copy small {
  color: var(--muted);
  font-size: var(--text-xs);
}
.reservation-list {
  display: grid;
}
.reservation-side {
  display: grid;
  gap: 0.2rem;
  justify-items: end;
  flex: 0 0 auto;
}
.badge {
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--surface-soft);
}
.badge-pending { background: #f8e7be; color: #795614; }
.badge-confirmed { background: #ddefe5; color: #25624f; }
.badge-in_house { background: #dcebe4; color: #17352d; }
.badge-completed { background: var(--surface-soft); color: var(--muted); }
.badge-cancelled { background: #fae1dc; color: #993b2c; }
.ok { color: #2b6b56; font-weight: 700; }
.warn { color: #ad4529; font-weight: 700; }
.audit-data {
  overflow-wrap: anywhere;
}

.password-reveal {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  background: #f8e7be;
  border: 1px solid #d5a938;
  border-radius: var(--radius-md);
  color: #573f0a;
}
.password-reveal code {
  justify-self: start;
  padding: var(--space-2) var(--space-3);
  background: var(--paper);
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  user-select: all;
}

.properties-shell {
  padding: clamp(1rem, 3vw, 2.5rem);
  display: grid;
  gap: var(--space-6);
  max-width: 70rem;
}
.property-card {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.property-card-new {
  background: var(--surface-soft);
  border-style: dashed;
}
.property-form,
.unit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-3);
}
.property-form {
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line);
}
.property-card-new .property-form {
  padding-bottom: 0;
  border-bottom: 0;
}
.photo-strip {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  overflow-x: auto;
  padding-bottom: var(--space-2);
  -webkit-overflow-scrolling: touch;
}
.photo-thumb {
  position: relative;
  flex: 0 0 auto;
  margin: 0;
}
.photo-thumb img {
  display: block;
  width: 9rem;
  height: 6.75rem;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}
.photo-thumb figcaption {
  position: absolute;
  left: 0.4rem;
  bottom: 0.4rem;
  padding: 0.1rem 0.5rem;
  background: var(--forest);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 700;
}
.photo-action {
  position: absolute;
  left: 0.4rem;
  bottom: 0.4rem;
  /* 44px de alvo de toque, visual mais pequeno */
  min-width: 2.75rem;
  min-height: 2rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: #fffd;
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
}
.photo-action-danger {
  left: auto;
  right: 0.4rem;
  top: 0.4rem;
  bottom: auto;
  min-width: 2rem;
  color: var(--brand-strong);
}
.photo-upload {
  flex: 0 0 auto;
}

.unit-list {
  display: grid;
  gap: var(--space-3);
}
.unit-row.is-archived {
  opacity: 0.6;
}
.price-periods {
  padding: var(--space-2) 0 var(--space-2) var(--space-4);
  border-left: 3px solid var(--line);
}
.price-periods summary {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 700;
}
.price-periods summary small {
  color: var(--muted);
  font-weight: 400;
}
.price-period-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
}
.unit-row-new {
  padding-top: var(--space-3);
  border-top: 1px dashed var(--line);
}
.field.grow {
  flex: 1 1 14rem;
}
.field.grow-full {
  flex: 1 1 100%;
}
.field.narrow input {
  width: 6.5rem;
}
.field select {
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid #cbd2cb;
  border-radius: var(--radius-md);
  background: var(--paper);
  font: inherit;
  letter-spacing: normal;
  text-transform: none;
}
.unit-meta {
  align-self: center;
  color: var(--muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}
.property-remove {
  justify-self: end;
}

@media (max-width: 720px) {
  .topbar {
    gap: var(--space-3);
  }
  .rack {
    --rack-unit: 8rem;
    --rack-day: 3rem;
  }
  .rack-event {
    /* 44px touch target */
    min-height: 2.75rem;
  }
  .rack-handle {
    width: 1rem;
    height: 2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
