:root {
  font-family: ui-rounded, "SF Pro Rounded", "SF Pro Display", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2a23;
  background: #f4f5f1;
  font-synthesis: none;
  --green: #24543a;
  --green-dark: #183d2a;
  --green-soft: #e1ede4;
  --cream: #fffdf7;
  --border: #d9ddd6;
  --muted: #68736b;
  --warning: #8b5e16;
  --danger: #8b3027;
  --shadow: 0 8px 24px rgba(30, 50, 36, 0.08);
  --bottom-nav-height: 64px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: #f4f5f1; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 18px 14px;
  color: white; background: linear-gradient(135deg, var(--green), var(--green-dark));
}
.eyebrow { margin: 0 0 2px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
h1 { margin: 0; font-size: 1.35rem; }
.app-shell { max-width: 760px; margin: 0 auto; padding: 18px 16px calc(var(--bottom-nav-height) + 20px + env(safe-area-inset-bottom)); }

.bottom-nav {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  min-height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
}
.nav-item { min-width: 0; min-height: 55px; border: 0; background: transparent; color: var(--muted); padding: 3px 1px; display: grid; gap: 1px; justify-items: center; align-content: center; }
.nav-item span { font-size: 1.25rem; filter: grayscale(1); }
.nav-item small { max-width: 100%; font-size: .66rem; line-height: 1; white-space: nowrap; }
.nav-item.active { color: var(--green); font-weight: 700; }
.nav-item.active span { filter: none; }
.nav-icon { position: relative; }
.nav-badge {
  position: absolute; top: -6px; right: -10px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border: 2px solid white; border-radius: 999px;
  color: white; background: var(--danger);
  font-size: .58rem; line-height: 13px; text-align: center;
}

.icon-button { width: 42px; height: 42px; border: 0; border-radius: 50%; background: rgba(255,255,255,.17); color: inherit; font-size: 1.55rem; display: grid; place-items: center; }
.status-message {
  position: fixed; z-index: 40; top: calc(76px + env(safe-area-inset-top)); left: 50%;
  max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 999px;
  color: white; background: var(--green-dark); box-shadow: var(--shadow);
  font-weight: 700; opacity: 0; pointer-events: none;
  transform: translate(-50%, -8px); transition: opacity .15s ease, transform .15s ease;
}
.status-message.visible { opacity: 1; transform: translate(-50%, 0); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.section-heading h2 { margin: 0; font-size: 1.3rem; }
.section-heading p { margin: 3px 0 0; color: var(--muted); }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 18px; }
.summary-card { background: var(--cream); border: 1px solid var(--border); border-radius: 15px; padding: 12px; box-shadow: var(--shadow); }
.summary-card strong { display: block; font-size: 1.35rem; color: var(--green-dark); }
.summary-card span { font-size: .78rem; color: var(--muted); }

.card-list { display: grid; gap: 11px; }
.card { background: white; border: 1px solid var(--border); border-radius: 17px; padding: 14px; box-shadow: var(--shadow); }
.card-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.card h3 { margin: 0 0 3px; font-size: 1.08rem; }
.card p { margin: 4px 0; }
.time-pill, .status-pill { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.time-pill { color: var(--green-dark); background: var(--green-soft); }
.status-pill.booked { color: var(--green-dark); background: var(--green-soft); }
.status-pill.due-soon { color: var(--warning); background: #fff0ce; }
.status-pill.overdue { color: var(--danger); background: #f9ded9; }
.status-pill.paused { color: #5d5d5d; background: #e7e7e7; }
.status-pill.no-pattern { color: #5d5d5d; background: #eceae4; }
.muted { color: var(--muted); font-size: .9rem; }
.note { padding: 9px 10px; border-radius: 10px; background: #f6f7f3; font-size: .9rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.list-heading { margin: 20px 2px 9px; font-size: 1rem; color: var(--green-dark); }
.list-heading:first-of-type { margin-top: 0; }
.visit-meta { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; margin-top: 10px; }
.button { border: 0; border-radius: 11px; padding: 10px 13px; font-weight: 700; }
.button:disabled { cursor: wait; opacity: .65; }
.button.primary { background: var(--green); color: white; }
.button.secondary { background: #edf0eb; color: var(--green-dark); }
.button.danger { background: #f7e5e2; color: var(--danger); }
.button.small { padding: 7px 10px; font-size: .84rem; }

.filter-row { display: flex; gap: 7px; overflow-x: auto; padding: 1px 0 12px; scrollbar-width: none; }
.filter-chip { flex: 0 0 auto; border: 1px solid var(--border); border-radius: 999px; background: white; padding: 8px 12px; color: var(--muted); }
.filter-chip.active { background: var(--green); border-color: var(--green); color: white; }

.empty { text-align: center; padding: 34px 22px; background: white; border: 1px dashed #cfd5cd; border-radius: 17px; color: var(--muted); }
.empty strong { display: block; color: var(--green-dark); margin-bottom: 6px; }

.dialog {
  width: min(620px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: hidden; border: 0; border-radius: 20px; padding: 0;
  box-shadow: 0 30px 80px rgba(0,0,0,.24);
}
.dialog::backdrop { background: rgba(18,35,25,.48); backdrop-filter: blur(3px); }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-header h2 { margin: 0; }
.dialog-header .icon-button { background: #edf0eb; color: var(--green-dark); }
.form-stack {
  display: grid; gap: 15px; padding: 20px;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.form-stack label, fieldset { display: grid; gap: 6px; font-size: .88rem; font-weight: 700; }
.form-stack input, .form-stack select, .form-stack textarea { width: 100%; border: 1px solid #cbd2ca; border-radius: 11px; background: white; padding: 11px; color: #1f2a23; }
.form-stack textarea { resize: vertical; }
.customer-picker { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.customer-picker .button { min-height: 44px; }
.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
fieldset { margin: 0; border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
legend { padding: 0 5px; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip { display: inline-flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 5px !important; padding: 7px 9px; border: 1px solid var(--border); border-radius: 999px; background: #fafbf8; font-weight: 500 !important; }
.check-chip input { width: auto !important; }
.check-row { display: grid !important; grid-template-columns: auto 1fr; align-items: center; }
.check-row input { width: auto !important; }
.dialog-actions {
  position: sticky; z-index: 2; bottom: -20px;
  display: flex; justify-content: flex-end; gap: 9px;
  margin: 4px -20px -20px; padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: white;
}
.dialog-actions .visit-delete { margin-right: auto; }

.customer-meta { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; margin-top: 10px; }
.meta-item { background: #f6f7f3; border-radius: 10px; padding: 8px; }
.meta-item small { display: block; color: var(--muted); }
.settings-section { margin-bottom: 18px; }
.settings-section h3 { margin-bottom: 8px; }
.settings-actions { display: grid; gap: 9px; }
.warning-box { background: #fff4dc; border: 1px solid #eed7a3; border-radius: 13px; padding: 12px; color: #69490f; }
.invoice-warning { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.invoice-warning .button { flex: 0 0 auto; }
.signed-out .app-shell { padding-bottom: 18px; }
.auth-shell { min-height: calc(100dvh - 36px); display: grid; place-items: center; }
.auth-card { width: min(100%, 420px); }
.auth-card.form-stack { max-height: none; overflow: visible; }
.auth-eyebrow { color: var(--green); opacity: 1; }

@media (max-width: 430px) {
  .nav-item span { font-size: 1.1rem; }
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .summary-card { padding: 10px 8px; }
  .summary-card strong { font-size: 1.15rem; }
  .form-grid.two { grid-template-columns: 1fr; }
  .form-stack input, .form-stack select, .form-stack textarea { font-size: 16px; }
  .customer-picker { grid-template-columns: 1fr; }
  .customer-picker .button { width: 100%; }
  .customer-meta { grid-template-columns: 1fr 1fr; }
  .invoice-warning { align-items: stretch; flex-direction: column; }
}
