:root {
  color-scheme: light;
  --ink: #18221d;
  --muted: #68736d;
  --line: #dfe7e2;
  --paper: #f4f7f3;
  --card: #ffffff;
  --forest: #1f5b43;
  --forest-dark: #174432;
  --mint: #dceee3;
  --amber: #f3b74b;
  --amber-bg: #fff4d9;
  --blue: #3878b8;
  --blue-bg: #eaf3fb;
  --shadow: 0 14px 40px rgba(30, 68, 50, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100dvh; overflow-x: hidden; background: var(--paper); color: var(--ink); -webkit-text-size-adjust: 100%; }
button, input { touch-action: manipulation; }
button, a { font: inherit; }
button { cursor: pointer; }
.shell { width: min(1540px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 64px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.eyebrow { margin: 0 0 7px; color: var(--forest); font-size: 11px; font-weight: 800; letter-spacing: .15em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(36px, 4vw, 58px); font-weight: 500; letter-spacing: -.04em; }
.subtitle { margin-bottom: 0; color: var(--muted); font-size: 15px; }
.week-controls { display: flex; align-items: center; gap: 8px; padding: 6px; background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.icon-button, .today-button { border: 0; border-radius: 9px; background: transparent; color: var(--ink); height: 38px; }
.icon-button { width: 40px; font-size: 20px; }
.today-button { padding: 0 18px; font-size: 13px; font-weight: 700; }
.icon-button:hover, .today-button:hover { background: var(--paper); }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 24px; }
.summary article { min-height: 105px; padding: 22px 25px; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; }
.summary article:last-child { border-right: 0; }
.summary span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.summary strong { font-family: Georgia, serif; font-size: 36px; font-weight: 500; }
.summary .danger { color: #a35d10; }
.summary .success { color: var(--forest); }
.calendar-section { padding: 25px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.72); box-shadow: var(--shadow); }
.calendar-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 22px; }
.calendar-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 27px; font-weight: 500; }
.legend { display: flex; flex-wrap: wrap; gap: 18px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-pending { background: var(--amber); }
.dot-sent { background: var(--forest); }
.dot-confirmed { background: var(--blue); }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(170px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.day { min-width: 170px; border: 1px solid var(--line); border-radius: 14px; background: #f8faf8; overflow: hidden; }
.day.today { border-color: #91b6a2; box-shadow: inset 0 0 0 1px #91b6a2; }
.day-header { padding: 14px 15px 12px; border-bottom: 1px solid var(--line); background: white; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.day-date { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.day-count { color: var(--muted); font-size: 10px; font-weight: 750; white-space: nowrap; }
.day-name { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.day-number { font-family: Georgia, serif; font-size: 25px; }
.day.today .day-number { color: var(--forest); }
.day-content { min-height: 340px; padding: 9px; display: flex; flex-direction: column; gap: 8px; }
.empty { margin: auto; color: #9ca6a0; font-size: 12px; }
.arrival-card { width: 100%; min-width: 0; border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: 10px; padding: 11px; background: white; color: inherit; text-align: left; box-shadow: 0 5px 15px rgba(31,91,67,.05); transition: transform .15s ease, box-shadow .15s ease; }
.arrival-card:hover { transform: translateY(-1px); box-shadow: 0 9px 18px rgba(31,91,67,.1); }
.arrival-card.sent { border-left-color: var(--forest); }
.arrival-card.confirmed { border-left-color: var(--blue); }
.card-property { display: block; margin-bottom: 5px; font-size: 12px; line-height: 1.3; font-weight: 800; }
.card-rental { display: block; color: var(--muted); font-size: 10px; line-height: 1.35; margin-bottom: 7px; }
.card-time { display: block; margin-bottom: 8px; padding: 5px 7px; border-radius: 6px; background: #eef4ea; color: var(--forest); font-size: 10px; font-weight: 800; line-height: 1.25; }
.card-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.card-status { display: inline-flex; margin-top: 9px; padding: 4px 7px; border-radius: 99px; background: var(--amber-bg); color: #8b530f; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.sent .card-status { background: var(--mint); color: var(--forest-dark); }
.confirmed .card-status { background: var(--blue-bg); color: #255b8c; }
.unmapped { border-left-color: #9aa19d; }
.unmapped .card-status { background: #eef0ef; color: #626965; }
.loading { padding: 70px 20px; text-align: center; color: var(--muted); }
.error-panel { padding: 15px 18px; margin-bottom: 18px; border: 1px solid #efb6b0; border-radius: 10px; background: #fff0ee; color: #8e3027; }
dialog { width: min(520px, calc(100% - 30px)); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 30px 90px rgba(16, 40, 28, .28); }
dialog::backdrop { background: rgba(18, 32, 25, .48); backdrop-filter: blur(4px); }
.dialog-card { position: relative; padding: 30px; }
.dialog-card h2 { margin-bottom: 8px; font-family: Georgia, serif; font-size: 30px; font-weight: 500; }
.dialog-close { position: absolute; right: 18px; top: 17px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--paper); font-size: 22px; }
.dialog-context { color: var(--muted); font-size: 13px; }
.dialog-note { padding: 14px; border-radius: 10px; background: var(--paper); color: var(--muted); font-size: 12px; line-height: 1.5; }
.capacity-warning { margin: 14px 0; padding: 12px 14px; border: 1px solid #efb6b0; border-radius: 10px; background: #fff0ee; color: #8e3027; font-size: 12px; font-weight: 700; }
.message-insights { margin: 14px 0; padding: 13px 14px; border-radius: 10px; background: var(--blue-bg); color: #255b8c; font-size: 12px; }
.message-insights blockquote { margin: 8px 0 0; padding-left: 10px; border-left: 2px solid #8cb6dc; font-style: italic; line-height: 1.45; }
.quantity-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 18px 0; padding: 15px; border: 1px solid var(--line); border-radius: 12px; }
.quantity-grid legend { padding: 0 7px; color: var(--forest); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.quantity-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.quantity-grid input { width: 100%; height: 39px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); font-weight: 800; }
.quantity-grid input[readonly] { background: var(--paper); color: var(--muted); }
.dialog-actions { display: grid; gap: 9px; margin-top: 20px; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 44px; padding: 0 16px; border: 0; border-radius: 10px; text-decoration: none; font-size: 13px; font-weight: 800; }
.button-primary { background: var(--forest); color: white; }
.button-primary:hover { background: var(--forest-dark); }
.button-success { background: var(--mint); color: var(--forest-dark); }
.button-secondary { background: var(--blue-bg); color: #255b8c; }

@media (max-width: 850px) {
  .shell { width: min(100% - 22px, 1540px); padding-top: 24px; }
  .topbar, .calendar-heading { align-items: flex-start; flex-direction: column; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .summary article:nth-child(2) { border-right: 0; }
  .summary article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .calendar-section { padding: 15px; }
}

@media (max-width: 1180px) {
  .calendar { grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .day { min-width: 0; }
  .day-content { min-height: 160px; }
}

@media (max-width: 680px) {
  :root { --shadow: 0 8px 24px rgba(30, 68, 50, 0.07); }
  .shell {
    width: 100%;
    padding: max(18px, env(safe-area-inset-top)) 12px calc(28px + env(safe-area-inset-bottom));
  }
  .topbar { gap: 18px; margin-bottom: 18px; }
  .topbar > div:first-child { width: 100%; }
  h1 { margin-bottom: 5px; font-size: clamp(34px, 11vw, 46px); line-height: 1; }
  .subtitle { max-width: 34rem; font-size: 13px; line-height: 1.45; }
  .week-controls {
    position: sticky;
    top: max(8px, env(safe-area-inset-top));
    z-index: 20;
    width: 100%;
    justify-content: space-between;
    padding: 5px;
    border-radius: 13px;
  }
  .icon-button, .today-button { min-height: 46px; }
  .icon-button { width: 52px; }
  .today-button { flex: 1; }

  .summary { margin-bottom: 14px; border-radius: 14px; }
  .summary article { min-height: 82px; padding: 14px 16px; }
  .summary span { font-size: 10px; }
  .summary strong { font-size: 29px; line-height: 1; }

  .calendar-section { padding: 12px; border-radius: 14px; }
  .calendar-heading { gap: 12px; margin-bottom: 14px; }
  .calendar-heading h2 { font-size: 21px; line-height: 1.2; }
  .calendar-heading .eyebrow { margin-bottom: 4px; }
  .legend { width: 100%; gap: 8px 14px; font-size: 10px; }

  .calendar { display: flex; flex-direction: column; gap: 10px; padding: 0; }
  .day { width: 100%; min-width: 0; border-radius: 12px; }
  .day-header { padding: 11px 13px; }
  .day-date { justify-content: flex-start; }
  .day-name { min-width: 34px; font-size: 11px; }
  .day-number { font-size: 22px; }
  .day-count { font-size: 10px; }
  .day-content { min-height: 0; padding: 8px; gap: 8px; }
  .empty { width: 100%; margin: 0; padding: 10px 4px; text-align: center; }

  .arrival-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 5px 10px;
    min-height: 48px;
    padding: 12px;
    border-left-width: 5px;
  }
  .arrival-card:active { transform: scale(.995); }
  .card-property { grid-column: 1; margin: 0; font-size: 14px; line-height: 1.25; }
  .card-rental { grid-column: 1 / -1; margin: 0 0 2px; font-size: 11px; line-height: 1.35; }
  .card-time { grid-column: 1 / -1; margin: 2px 0; padding: 7px 9px; font-size: 11px; line-height: 1.35; }
  .card-meta { grid-column: 1 / -1; gap: 12px; font-size: 11px; }
  .card-meta span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .card-meta span:last-child { flex: 0 0 auto; }
  .card-status { grid-column: 2; grid-row: 1; align-self: center; margin: 0; padding: 5px 8px; font-size: 8px; }

  .loading { padding: 48px 16px; }
  .error-panel { margin-bottom: 12px; font-size: 13px; }

  dialog {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
    overflow: hidden;
  }
  dialog::backdrop { backdrop-filter: blur(2px); }
  .dialog-card {
    max-height: 92dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px 16px calc(18px + env(safe-area-inset-bottom));
  }
  .dialog-card h2 { padding-right: 40px; font-size: 27px; line-height: 1.1; }
  .dialog-close { position: sticky; z-index: 2; float: right; right: 0; top: 0; width: 44px; height: 44px; margin: -10px -4px -34px 0; }
  .dialog-context { font-size: 12px; line-height: 1.5; }
  .message-insights { max-height: 190px; overflow-y: auto; }
  .quantity-grid { gap: 10px; margin: 14px 0; padding: 12px; }
  .quantity-grid input { height: 46px; font-size: 16px; }
  .dialog-note { font-size: 11px; }
  .dialog-actions { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); z-index: 2; margin: 16px -16px calc(-18px - env(safe-area-inset-bottom)); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(8px); }
  .button { min-height: 48px; }
}

@media (max-width: 390px) {
  .shell { padding-left: 8px; padding-right: 8px; }
  .summary article { padding: 13px 12px; }
  .calendar-section { padding: 8px; }
  .legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quantity-grid { grid-template-columns: 1fr 1fr; }
}

@media (hover: none) {
  .arrival-card:hover { transform: none; box-shadow: 0 5px 15px rgba(31,91,67,.05); }
  .icon-button:hover, .today-button:hover { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
