:root {
    --bg: #e6e0d4;
    --paper: #f7f4ee;
    --ink: #221e19;
    --muted: #6b645b;
    --line: #ddd4c6;
    --line-strong: #cfc4b4;
    --green: #1e3d2f;
    --green-soft: #e7f0ea;
    --warn: #8a4b12;
    --danger: #8c3a2f;
    --shadow: 0 12px 40px rgba(34, 30, 25, 0.16);
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  html { -webkit-text-size-adjust: 100%; }
  body {
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.4;
  }
  button, input, select, textarea { font: inherit; color: inherit; }
  a { color: var(--green); }
  [hidden] { display: none !important; }
  #app.desktop-app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
  .preview-banner {
    background: var(--green);
    color: #f3f7f4;
    font-size: 13px;
    text-align: center;
    padding: 6px 12px;
  }
  .top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 10px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
  }
  .brand-kicker {
    margin: 0;
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .brand-title {
    margin: 0;
    font-family: Georgia, "Iowan Old Style", Palatino, serif;
    font-size: 26px;
    font-weight: 500;
    letter-spacing: -0.03em;
    line-height: 1;
  }
  .top nav { display: none; gap: 16px; align-items: center; flex-wrap: wrap; }
  .top nav a { color: var(--muted); text-decoration: none; font-size: 15px; padding: 8px 0; }
  .top nav a[aria-current="page"] { color: var(--green); font-weight: 650; }
  .split { min-height: 0; }
  .list-pane, .detail-pane { background: var(--paper); }
  .page { background: var(--paper); min-height: 60vh; }
  .narrow { max-width: 760px; margin: 0 auto; }
  .toolbar, .block, .event-head { padding: 14px 16px; }
  .toolbar { display: grid; gap: 10px; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .search { width: 100%; }
  label.lbl { display: block; font-size: 13px; color: #4e483f; margin-bottom: 6px; }
  input, select, textarea {
    width: 100%;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 11px 12px;
    font-size: 16px;
  }
  textarea { min-height: 120px; resize: vertical; }
  input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: 1px; }
  .summary-line {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
    color: var(--muted);
    font-size: 14px;
  }
  .summary-line a, .text-btn {
    color: var(--green);
    background: none;
    border: 0;
    padding: 8px 0;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
  }
  .row {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    text-align: left;
    cursor: pointer;
    align-items: center;
  }
  .row[aria-current="true"] { background: #efe8da; }
  .date-mon, .date-dow {
    display: block;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .date-num {
    display: block;
    font-family: Georgia, "Iowan Old Style", Palatino, serif;
    font-size: 28px;
    line-height: 1;
    letter-spacing: -0.03em;
  }
  .row-title { display: block; font-weight: 650; letter-spacing: -0.011em; }
  .row-sub { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
  .row-status { font-size: 12px; font-weight: 700; text-align: right; }
  [data-status="Inquiry"] { color: #6b645b; }
  [data-status="Hold"] { color: #8a5a12; }
  [data-status="Contract Sent"], [data-status="Contract Signed"] { color: #1f5f78; }
  [data-status="Deposit Paid"], [data-status="Paid"] { color: #1e3d2f; }
  [data-status="Final Count"] { color: #3d4f78; }
  [data-status="Invoiced"] { color: #5c3d78; }
  .earlier {
    padding: 16px 16px 6px;
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .event-head h1 {
    margin: 4px 0 0;
    font-family: Georgia, "Iowan Old Style", Palatino, serif;
    font-size: 32px;
    font-weight: 500;
    letter-spacing: -0.03em;
    line-height: 1.05;
  }
  .meta { color: var(--muted); margin: 6px 0 0; }
  .status-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 0 16px 12px;
    max-width: 100%;
  }
  .status-chip {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: #fff;
    cursor: pointer;
  }
  .status-chip[aria-pressed="true"] { background: var(--green); color: #f3f7f4; border-color: var(--green); }
  .price { padding: 4px 16px 8px; }
  .price-amt {
    margin: 0;
    font-family: Georgia, "Iowan Old Style", Palatino, serif;
    font-size: 48px;
    letter-spacing: -0.04em;
    line-height: 1;
  }
  .price-unit { font-family: "Segoe UI", system-ui, sans-serif; font-size: 16px; letter-spacing: 0; color: var(--muted); }
  .price-note, .price-math { margin: 6px 0 0; color: var(--muted); }
  .warn { color: var(--warn); }
  h2.sec {
    margin: 0 0 10px;
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
  }
  .fields { display: grid; gap: 12px; }
  .check { display: flex; gap: 10px; align-items: flex-start; }
  .check input { width: auto; margin-top: 3px; }
  .help { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
  .btn-row, .link-row { display: flex; flex-wrap: wrap; gap: 8px; }
  .btn, .btn.secondary, .btn.ghost, .btn.danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
    font-weight: 650;
  }
  .btn { background: var(--green); color: #f3f7f4; }
  .btn.secondary { background: transparent; color: var(--green); border-color: var(--green); }
  .btn.ghost { background: #fff; color: var(--ink); border-color: var(--line-strong); }
  .btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
  .btn:disabled { opacity: 0.5; cursor: default; }
  .btn.wide { width: 100%; }
  .note, .history-item {
    padding: 12px 0;
    border-top: 1px solid var(--line);
  }
  .note p, .history-item p { margin: 0; white-space: pre-wrap; }
  .note-meta, .history-item .note-meta { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
  .cat {
    display: inline-block;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 1px 8px;
    margin-right: 6px;
    font-size: 12px;
  }
  .empty { color: var(--muted); margin: 0; }
  .dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: rgba(247, 244, 238, 0.96);
    border-top: 1px solid var(--line);
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  }
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    background: var(--paper);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    position: relative;
    text-align: center;
    text-decoration: none;
    color: var(--muted);
    font-size: 11px;
    padding: 14px 2px 10px;
    min-height: 48px;
    overflow: hidden;
    white-space: nowrap;
  }
  .tab-badge {
    display: inline-block;
    min-width: 16px;
    height: 16px;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 999px;
    background: #c47b2b;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    vertical-align: 1px;
  }
  .tabbar .tab-badge {
    position: absolute;
    top: 4px;
    right: 2px;
    margin-left: 0;
  }
  @media (max-width: 359px) {
    .tabbar a { font-size: 10px; padding: 12px 0 10px; }
  }
  .cal-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
  .cal-nav h1 { margin: 0; font-family: Georgia, "Iowan Old Style", Palatino, serif; font-size: 26px; font-weight: 500; letter-spacing: -0.03em; }
  .cal-nav button { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; font-size: 22px; }
  .seg { display: flex; gap: 4px; background: #fff; border: 1px solid var(--line-strong); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
  .seg button { flex: 1; min-height: 40px; border: 0; border-radius: 8px; background: transparent; }
  .seg button[aria-pressed="true"] { background: var(--green); color: #f3f7f4; }
  .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
  .cal-dow { text-align: center; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding-bottom: 4px; }
  .cal-day { position: relative; min-height: 64px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px; overflow: hidden; }
  .cal-day.out { opacity: 0.45; }
  .cal-day.today { box-shadow: inset 0 0 0 2px var(--green); }
  .cal-day.selected { background: #efe8da; }
  .cal-num { font-family: Georgia, "Iowan Old Style", Palatino, serif; font-size: 14px; }
  .cal-hit { position: absolute; inset: 0; background: transparent; border: 0; color: transparent; }
  .cal-dots { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 6px; }
  .cal-dots i, .agenda i { width: 8px; height: 8px; border-radius: 99px; display: inline-block; background: #6b645b; }
  .cal-dots i[data-status="Hold"], .agenda i[data-status="Hold"] { background: #c4842a; }
  .cal-dots i[data-status="Contract Sent"], .cal-dots i[data-status="Contract Signed"], .agenda i[data-status="Contract Sent"], .agenda i[data-status="Contract Signed"] { background: #2c6e8a; }
  .cal-dots i[data-status="Deposit Paid"], .cal-dots i[data-status="Paid"], .agenda i[data-status="Deposit Paid"], .agenda i[data-status="Paid"] { background: #1e3d2f; }
  .cal-dots i[data-status="Final Count"], .agenda i[data-status="Final Count"] { background: #3d4f78; }
  .cal-dots i[data-status="Invoiced"], .agenda i[data-status="Invoiced"] { background: #6b4c7a; }
  .cal-desk { display: none; }
  .cal-chip { display: block; margin-top: 4px; padding: 3px 6px; border-radius: 6px; text-decoration: none; font-size: 12px; line-height: 1.25; overflow: hidden; background: #ece8e1; color: #221e19; white-space: normal; }
  .cal-chip[data-status="Hold"] { background: #f6e7c8; color: #6d4710; }
  .cal-chip[data-status="Contract Sent"], .cal-chip[data-status="Contract Signed"] { background: #d9ebf3; color: #1f5f78; }
  .cal-chip[data-status="Deposit Paid"], .cal-chip[data-status="Paid"] { background: #dceadf; color: #1e3d2f; }
  .cal-chip[data-status="Final Count"] { background: #e1e7f4; color: #3d4f78; }
  .cal-chip[data-status="Invoiced"] { background: #efe3f3; color: #5c3d78; }
  .cal-more { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
  .day-agenda, .week-day { margin-top: 16px; }
  .week-day h2, .day-agenda h2 { margin: 0 0 8px; font-size: 16px; }
  .agenda { display: grid; grid-template-columns: 12px 1fr; gap: 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
  .agenda strong { display: block; }
  .menu-choice { align-items: flex-start; }
  .menu-choice .help { display: block; }
  .menu-line { margin: 10px 0; padding-top: 8px; border-top: 1px solid var(--line); }
  .stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
  .stat-num { display: block; font-family: Georgia, "Iowan Old Style", Palatino, serif; font-size: 28px; line-height: 1; }
  .stat-label { display: block; font-weight: 650; margin-top: 4px; }
  .stat-note { display: block; color: var(--muted); font-size: 13px; }
  .banner { background: #f8ead0; border: 1px solid #e2c48a; border-radius: 10px; padding: 12px; margin: 8px 0 12px; }
  .banner p { margin: 0 0 8px; }
  .banner p:last-child { margin-bottom: 0; }
  .flag { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: #f6e7c8; color: #6d4710; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; vertical-align: 2px; }
  .pay-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 16px 0; }
  .pay-chip { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; border-radius: 999px; padding: 4px 8px; background: #efe8dc; color: #3c342c; }
  .pay-chip[data-pay="Deposit due"], .pay-chip[data-pay="Unpaid"] { background: #f6e0d2; color: #6d2e12; }
  .pay-chip[data-pay="Deposit paid"], .pay-chip[data-pay="Paid in full"], .pay-chip[data-pay="No deposit needed"] { background: #e3efe6; color: #1e3d2f; }
  .rebook { margin: 8px 16px 4px; }
  .attn { border-left: 3px solid #c47b2b; }
  .day-sheet h1 { font-family: Georgia, "Iowan Old Style", Palatino, serif; font-weight: 500; font-size: 34px; margin: 0 0 8px; }
  .day-sheet h2 { font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
  @media print {
    .preview-banner, .top, .tabbar, .dock, .backbar, .no-print { display: none !important; }
    body, #app, .page, .day-sheet { background: #fff !important; }
    .day-sheet { padding: 0; }
    a { color: #000; text-decoration: none; }
  }
  .tabbar a[aria-current="page"] { color: var(--green); font-weight: 700; }
  .with-tabs { padding-bottom: 84px; }
  .with-dock { padding-bottom: 92px; }
  .overlay {
    position: fixed;
    inset: 0;
    background: rgba(34, 30, 25, 0.45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 20;
  }
  .sheet {
    background: var(--paper);
    width: 100%;
    max-height: 92vh;
    overflow: auto;
    border-radius: 16px 16px 0 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  }
  .sheet h2 {
    margin: 0 0 8px;
    font-family: Georgia, "Iowan Old Style", Palatino, serif;
    font-size: 28px;
    font-weight: 500;
  }
  .sheet textarea { min-height: 140px; }
  .copy-block { min-height: 280px; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 14px; }
  #toast {
    position: fixed;
    left: 50%;
    top: 12px;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--paper);
    padding: 10px 14px;
    border-radius: 999px;
    z-index: 15;
    max-width: calc(100% - 32px);
  }
  .back, .backbar button {
    color: var(--green);
    text-decoration: none;
    font-weight: 750;
  }
  .backbar {
    position: sticky;
    top: 0;
    z-index: 12;
    display: flex;
    align-items: center;
    min-height: 52px;
    padding: 4px 8px;
    background: rgba(247, 244, 238, 0.96);
    border-bottom: 1px solid var(--line);
  }
  .backbar button {
    min-height: 44px;
    border: 0;
    background: transparent;
    font-size: 18px;
    padding: 0 10px;
  }
  .rate-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
  }
  .rate-row span { flex: 1; min-width: 0; }
  .rate-row input { width: 88px; flex: 0 0 88px; }
  .holiday-list { margin: 0; padding-left: 18px; color: var(--muted); }
  details { margin-top: 8px; }
  summary { cursor: pointer; font-weight: 650; padding: 8px 0; }
  @media (min-width: 720px) {
    .fields.two { grid-template-columns: 1fr 1fr; }
    .span-2 { grid-column: 1 / -1; }
    .overlay { align-items: center; padding: 24px; }
    .sheet { max-width: 560px; border-radius: 16px; }
  }
  @media (max-width: 959px) {
    .dock { bottom: calc(56px + env(safe-area-inset-bottom)); }
    .with-dock { padding-bottom: 156px; }
  }
  @media (min-width: 960px) {
    .top nav { display: flex; }
    .tabbar { display: none; }
    .with-tabs { padding-bottom: 24px; }
    .split { flex: 1; display: grid; grid-template-columns: 400px minmax(0, 1fr); }
    .list-pane, .detail-pane { overflow: auto; }
    #app.desktop-app .dock { left: 400px; }
    .cal-hit, .cal-dots { display: none; }
    .cal-desk { display: block; }
    .cal-day { min-height: 108px; }
    .cal-page { max-width: 980px; }
    .page.narrow, .detail-pane .narrow { max-width: 760px; }
  }
