/* ----------------------------------------------------------------------
   Owner Center mobile — "concierge" theme
   Warm paper & ink, terracotta accent, source-coded bookings.
   ---------------------------------------------------------------------- */

:root {
  --paper: #f4efe6;
  --paper-2: #efe8dc;
  --card: #fbf8f2;
  --ink: #211d18;
  --ink-soft: #6b6357;
  --ink-faint: #9a9081;
  --line: #e2d9c9;
  --line-strong: #d3c7b2;

  --accent: #bd5638;      /* terracotta */
  --accent-deep: #97442b;

  /* booking source colours */
  --src-airbnb: #e0593f;
  --src-booking: #2f5fa8;
  --src-direct: #3f8a6e;
  --src-block: #8d8474;

  --paid: #3f8a6e;
  --unpaid: #b07d2a;
  --overdue: #b3472f;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(33, 29, 24, 0.06), 0 8px 24px -12px rgba(33, 29, 24, 0.22);
  --shadow-lift: 0 2px 6px rgba(33, 29, 24, 0.08), 0 18px 40px -16px rgba(33, 29, 24, 0.30);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Hanken Grotesk', system-ui, sans-serif;

  --tabbar-h: 68px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  background-image:
    radial-gradient(120% 80% at 50% -20%, rgba(189, 86, 56, 0.07), transparent 60%);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: contain;
}

/* subtle paper grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

.hidden { display: none !important; }

/* ---------- Login ---------- */

#auth {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(130% 90% at 50% 0%, #f7f1e6, var(--paper));
}
#auth:empty { display: none; }

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: 36px 28px 30px;
  text-align: center;
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.brand-mark {
  width: 56px; height: 56px;
  margin: 0 auto 18px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-deep));
  color: #fbeee7;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  box-shadow: 0 10px 24px -10px rgba(151, 68, 43, 0.7);
}

.login-card h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 27px;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.login-card p { color: var(--ink-soft); font-size: 14px; margin-bottom: 24px; }

.field { text-align: left; margin-bottom: 14px; }
.field label {
  display: block; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-faint); margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(189, 86, 56, 0.14);
}

.btn-primary {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  font-size: 16px; font-weight: 600;
  color: #fbeee7;
  background: linear-gradient(145deg, var(--accent), var(--accent-deep));
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 20px -10px rgba(151, 68, 43, 0.8);
  transition: transform 0.12s, filter 0.15s;
}
.btn-primary:active { transform: translateY(1px) scale(0.99); }
.btn-primary:disabled { filter: grayscale(0.4) opacity(0.7); }

.login-error {
  color: var(--overdue); font-size: 13.5px; font-weight: 500;
  min-height: 18px; margin-top: 12px;
}
.auth-note {
  font-size: 12.5px; color: var(--ink-soft); line-height: 1.5;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 13px; margin-top: 16px; text-align: left;
}
.auth-note .lock { color: var(--accent); font-weight: 600; }
.auth-skip { margin-top: 16px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }

/* ---------- App shell ---------- */

#app { position: relative; z-index: 1; max-width: 540px; margin: 0 auto;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 18px 12px;
  background: linear-gradient(var(--paper) 72%, transparent);
  backdrop-filter: blur(2px);
}
.topbar .title { font-family: var(--font-display); font-weight: 600; font-size: 24px; letter-spacing: -0.01em; }
.topbar .title small { display: block; font-family: var(--font-body); font-weight: 500;
  font-size: 12px; color: var(--ink-faint); letter-spacing: 0.02em; margin-top: 1px; }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  transition: transform 0.12s, color 0.15s;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.spin svg { animation: spin 0.7s linear infinite; }

.view { padding: 4px 18px 0; animation: fade 0.3s ease both; }

/* ---------- Filter chips ---------- */

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; font-size: 13.5px; font-weight: 600;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: all 0.15s;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip[aria-pressed="true"] {
  color: var(--ink);
  border-color: var(--ink);
  background: var(--paper-2);
}
.chip[aria-pressed="false"] { opacity: 0.6; }

/* segmented control */
.segment {
  display: inline-flex; padding: 4px; gap: 2px;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 14px;
}
.segment button {
  padding: 7px 16px; font-size: 13.5px; font-weight: 600;
  color: var(--ink-soft); border-radius: 9px; transition: all 0.15s;
}
.segment button[aria-selected="true"] {
  color: var(--ink); background: var(--card); box-shadow: var(--shadow);
}

/* ---------- Agenda ---------- */

.month-head {
  font-family: var(--font-display);
  font-weight: 600; font-size: 15px; letter-spacing: 0.02em;
  color: var(--accent-deep);
  margin: 22px 2px 12px; text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
}
.month-head::after { content: ''; flex: 1; height: 1px; background: var(--line-strong); }

.bk {
  position: relative;
  display: grid; grid-template-columns: 54px 1fr auto; gap: 14px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px 13px 13px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.12s, box-shadow 0.2s;
}
.bk:active { transform: scale(0.992); }
.bk::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--src); }
.bk.is-block { background: repeating-linear-gradient(135deg, var(--card), var(--card) 9px, #f0ebe0 9px, #f0ebe0 18px); }

.bk-date { text-align: center; }
.bk-date .d { font-family: var(--font-display); font-weight: 600; font-size: 22px; line-height: 1; }
.bk-date .m { font-size: 11px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 3px; }
.bk-date .arrow { color: var(--ink-faint); font-size: 11px; margin: 3px 0; }

.bk-body { min-width: 0; }
.bk-body .name { font-weight: 600; font-size: 16px; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-body .meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prop-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-weight: 600; font-size: 11.5px; color: var(--ink-soft);
}
.prop-chip .mono { width: 17px; height: 17px; border-radius: 5px; display: grid; place-items: center;
  font-size: 10px; font-weight: 700; color: #fff; }

.bk-right { text-align: right; }
.src-tag {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--src); padding: 4px 8px; border-radius: 7px;
  background: color-mix(in srgb, var(--src) 12%, transparent);
}
.bk-right .nights { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }

/* ---------- Month grid ---------- */

.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-nav h2 { font-family: var(--font-display); font-weight: 600; font-size: 21px; }
.cal-nav .nav-btns { display: flex; gap: 6px; }

.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.weekdays span { text-align: center; font-size: 10.5px; font-weight: 700; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.03em; }

/* Timeline month view: week rows with a day-cell background and a lane overlay
   carrying continuous booking bars. */
.calendar {
  --lanes: 2;              /* set inline per render to the visible property count */
  --lane-h: 23px;         /* height of one property lane */
  --lane-gap: 4px;        /* gap between lanes */
  --num-h: 22px;          /* space reserved for the day number */
}

.week { position: relative; margin-bottom: 4px; }

.daybg { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.daycell {
  /* tall enough for the day number + N lanes */
  min-height: calc(var(--num-h) + var(--lanes, 2) * (var(--lane-h) + var(--lane-gap)) + 6px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 5px 4px 4px;
}
.daycell.empty { background: transparent; border-color: transparent; }
.daycell.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.daycell .num { font-weight: 600; font-size: 12px; color: var(--ink-soft); }
.daycell.today .num { color: var(--accent); }

/* Overlay sitting on top of the day cells, holding the lanes. */
.lanes {
  position: absolute; left: 0; right: 0;
  top: var(--num-h); bottom: 6px;
  pointer-events: none;
}
.lane { position: relative; height: var(--lane-h); margin-bottom: var(--lane-gap); }

.bar {
  position: absolute; top: 0; height: var(--lane-h);
  display: flex; align-items: center; gap: 5px;
  padding: 0 7px; border-radius: 7px;
  font-size: 11px; font-weight: 600; color: #fff;
  background: var(--src);
  box-shadow: 0 1px 2px rgba(33, 29, 24, 0.16);
  white-space: nowrap; overflow: hidden;
  pointer-events: auto; cursor: pointer;
  transition: transform 0.1s;
}
.bar:active { transform: scale(0.97); }
.bar .mono { flex-shrink: 0; font-size: 9px; font-weight: 800; opacity: 0.9;
  background: rgba(255, 255, 255, 0.25); border-radius: 4px; padding: 1px 4px; }
.bar .bl { overflow: hidden; text-overflow: ellipsis; }
/* Square the edges where a booking continues into the previous/next week. */
.bar.cont-left { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.bar.cont-right { border-top-right-radius: 0; border-bottom-right-radius: 0; }
/* Blocks: hatched so they read as "unavailable" rather than a guest. */
.bar.is-block {
  background-image: repeating-linear-gradient(135deg,
    rgba(255,255,255,0.18) 0 5px, transparent 5px 10px);
}

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 16px 2px 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }
.legend .dot { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- Invoices ---------- */

.inv {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 16px; margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.inv .period { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.inv .sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.inv .amt { text-align: right; font-weight: 700; font-size: 16px; }
.inv .amt small { display: block; font-weight: 500; font-size: 11px; color: var(--ink-faint); }
.status {
  justify-self: end; align-self: end;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 4px 9px; border-radius: 7px;
}
.status.paid { color: var(--paid); background: color-mix(in srgb, var(--paid) 13%, transparent); }
.status.unpaid { color: var(--unpaid); background: color-mix(in srgb, var(--unpaid) 15%, transparent); }
.status.overdue { color: var(--overdue); background: color-mix(in srgb, var(--overdue) 13%, transparent); }

/* ---------- Bottom tab bar ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--ink-faint); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.02em; transition: color 0.15s;
}
.tab svg { width: 22px; height: 22px; transition: transform 0.15s; }
.tab[aria-selected="true"] { color: var(--accent); }
.tab[aria-selected="true"] svg { transform: translateY(-1px); }
.tab.tab-cta { color: var(--accent); }
.tab.tab-cta .plus {
  width: 40px; height: 40px; border-radius: 13px; margin-top: -2px;
  display: grid; place-items: center; color: #fbeee7;
  background: linear-gradient(145deg, var(--accent), var(--accent-deep));
  box-shadow: 0 8px 18px -8px rgba(151, 68, 43, 0.8);
}
.tab.tab-cta .plus svg { width: 22px; height: 22px; }

/* ---------- Sheet / modal ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(33, 29, 24, 0.42);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.2s ease both;
}
.sheet {
  width: 100%; max-width: 540px;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--line);
  padding: 10px 20px calc(env(safe-area-inset-bottom, 0px) + 24px);
  box-shadow: 0 -10px 40px -12px rgba(33, 29, 24, 0.4);
  animation: sheet-up 0.32s cubic-bezier(0.2, 0.85, 0.2, 1) both;
  max-height: 88dvh; overflow-y: auto;
}
.sheet .grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 6px auto 16px; }
.sheet h3 { font-family: var(--font-display); font-weight: 600; font-size: 21px; margin-bottom: 2px; }
.sheet .sub { font-size: 13px; color: var(--ink-soft); margin-bottom: 18px; }

.seg-prop { display: flex; gap: 8px; margin-bottom: 16px; }
.seg-prop button {
  flex: 1; padding: 13px; border-radius: 12px; font-weight: 600; font-size: 14px;
  border: 1.5px solid var(--line-strong); color: var(--ink-soft);
  background: var(--paper); transition: all 0.15s; text-align: left;
  display: flex; align-items: center; gap: 9px;
}
.seg-prop button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--paper-2); }
.seg-prop .mono { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0; }

.sheet .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sheet label.fl { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--ink-faint); margin: 0 0 6px 2px; }
.sheet input[type="date"], .sheet input[type="text"] {
  width: 100%; padding: 12px 13px; font-size: 16px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: 11px;
}
.sheet input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(189,86,56,0.13); }
.sheet .full { margin-top: 14px; }

.sheet-err { color: var(--overdue); font-size: 13.5px; font-weight: 500; min-height: 18px; margin-top: 12px; }

.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet-actions .btn-primary { margin-top: 0; }
.btn-ghost {
  padding: 14px 18px; font-size: 15px; font-weight: 600; border-radius: var(--radius-sm);
  color: var(--ink-soft); background: var(--paper-2); border: 1px solid var(--line);
}
.btn-danger {
  padding: 14px 18px; font-size: 15px; font-weight: 600; border-radius: var(--radius-sm);
  color: #fff; background: var(--overdue);
}

/* detail rows in sheet */
.detail-row { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.detail-row:last-of-type { border-bottom: none; }
.detail-row .k { color: var(--ink-soft); }
.detail-row .v { font-weight: 600; text-align: right; }

.line-item { padding: 11px 0; border-bottom: 1px solid var(--line); }
.line-item:last-child { border-bottom: none; }
.line-item .li-desc { font-size: 14px; font-weight: 500; }
.line-item .li-meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; display: flex; justify-content: space-between; gap: 12px; }

/* ---------- States ---------- */

.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-faint); }
.empty-state .big { font-family: var(--font-display); font-size: 19px; color: var(--ink-soft); margin-bottom: 6px; }
.skeleton { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  height: 74px; margin-bottom: 10px; position: relative; overflow: hidden; }
.skeleton::after { content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  animation: shimmer 1.3s infinite; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px); transform: translateX(-50%);
  z-index: 60; background: var(--ink); color: var(--paper);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lift); animation: toast 0.3s ease both;
  max-width: 90%; text-align: center;
}
.toast.err { background: var(--overdue); }

.feedbox {
  background: var(--paper-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  padding: 14px; margin-top: 14px; font-size: 13px; color: var(--ink-soft); word-break: break-all;
}
.feedbox .lbl { font-weight: 700; color: var(--ink); text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; margin-bottom: 6px; }
.feedbox code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.feedbox button { margin-top: 8px; font-size: 12.5px; font-weight: 600; color: var(--accent); }

/* ---------- Animations ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.stagger > * { animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.stagger > *:nth-child(1) { animation-delay: 0.02s; }
.stagger > *:nth-child(2) { animation-delay: 0.06s; }
.stagger > *:nth-child(3) { animation-delay: 0.10s; }
.stagger > *:nth-child(4) { animation-delay: 0.14s; }
.stagger > *:nth-child(5) { animation-delay: 0.18s; }
.stagger > *:nth-child(6) { animation-delay: 0.22s; }
.stagger > *:nth-child(7) { animation-delay: 0.26s; }
.stagger > *:nth-child(8) { animation-delay: 0.30s; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; }
}
