:root {
  --brand: #2e7d32;
  --brand-ink: #ffffff;
  --brand-soft: #e7f3e8;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e9e6;
  --bg: #f3f6f4;
  --card: #ffffff;
  --free: #e7f3e8;
  --free-line: #b9dcbc;
  --free-ink: #1b5e20;
  --busy: #f3f4f6;
  --busy-ink: #9ca3af;
  --wa: #1fa855;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #4caf50;
    --brand-ink: #06150a;
    --brand-soft: #1b3320;
    --ink: #e8ece9;
    --muted: #97a29b;
    --line: #26302a;
    --bg: #0e1310;
    --card: #161d19;
    --free: #173020;
    --free-line: #2c5a37;
    --free-ink: #a5d6a7;
    --busy: #1c2420;
    --busy-ink: #5c6a62;
    --wa: #25d366;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  min-height: 60px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
.logo { width: 36px; height: 36px; border-radius: 10px; flex: none; }
.top h1 { flex: 1; min-width: 0; font-size: 19px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  display: grid; place-items: center; width: 42px; height: 42px; margin-inline-start: -8px; flex: none;
  border: 0; border-radius: 12px; background: transparent;
}
.icon-btn:active { background: var(--busy); }
.install-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 6px 14px; min-height: 38px; border: 0; border-radius: 99px;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 15px;
}

main { max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- Home ---------- */
.hero { padding: 4px 2px 14px; }
.hero h2 { font-size: 22px; font-weight: 700; }
.hero p { color: var(--muted); font-size: 15px; }
.search-box { position: relative; }
.search-box svg { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search {
  width: 100%; padding: 13px 16px; padding-inline-start: 44px; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px; background: var(--card); box-shadow: var(--shadow);
}
.search:focus { outline: 2px solid var(--brand); outline-offset: 0; }
.venues { display: grid; gap: 10px; margin-top: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.venue {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; text-align: start;
}
.venue:active { transform: scale(.99); }
.venue:hover, .venue:focus-visible { border-color: var(--brand); }
.avatar {
  display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 14px;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 20px;
}
.venue-text { flex: 1; min-width: 0; }
.venue h2 { font-size: 17px; font-weight: 700; line-height: 1.4; }
.venue .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--muted); flex: none; }
.meta { color: var(--muted); font-size: 14px; }
.tip {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 12px 14px;
  font-size: 14px; color: var(--ink); background: var(--brand-soft); border-radius: 14px;
}
.tip button { margin-inline-start: auto; border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1; padding: 0 4px; }

/* ---------- Venue page ---------- */
.venue-head { padding: 12px; display: grid; gap: 10px; }
.head-row { display: flex; gap: 10px; align-items: flex-start; }
.head-text { flex: 1; min-width: 0; display: grid; gap: 2px; padding-inline-start: 2px; }
.wa-icon {
  display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 12px;
  background: var(--brand-soft); color: var(--wa); text-decoration: none;
}
.line { display: flex; gap: 6px; align-items: flex-start; font-size: 15px; font-weight: 600; }
.line svg { flex: none; margin-top: 3px; color: var(--brand); }
.notes { color: var(--muted); font-size: 14px; line-height: 1.5; }

.tabs {
  display: flex; gap: 4px; padding: 3px; overflow-x: auto; scrollbar-width: none;
  background: var(--bg); border-radius: 12px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto; padding: 4px 14px; min-height: 38px; border: 0; border-radius: 10px;
  background: transparent; font-weight: 700; color: var(--muted); white-space: nowrap;
}
.tab[aria-selected="true"] { background: var(--brand); color: var(--brand-ink); }

.pitch-info { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin: 0 2px; }
.price { font-size: 19px; font-weight: 700; color: var(--ink); }
.price small { font-size: 14px; font-weight: 400; color: var(--muted); }
.chip { display: inline-block; padding: 1px 10px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 700; }
.pitch-desc { color: var(--muted); font-size: 14px; }

.calendar-card { margin-top: 10px; padding: 12px; }
.weeknav { display: flex; align-items: center; gap: 6px; }
.weeknav .label { flex: 1; text-align: center; font-weight: 700; font-size: 15px; }
.weeknav .label small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; line-height: 1.3; }
.nav-btn {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
}
.nav-btn:disabled { opacity: .3; cursor: default; }

/* Day picker (phones): 7 equal columns, no sideways scrolling. */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 12px; }
.day {
  display: grid; justify-items: center; gap: 0; padding: 6px 0 7px; min-width: 0;
  border: 0; border-radius: 12px; background: transparent; line-height: 1.25;
}
.day small { font-size: 12px; color: var(--muted); white-space: nowrap; }
.day b { font-size: 18px; }
.day i { width: 6px; height: 6px; margin-top: 4px; border-radius: 50%; background: transparent; }
.day.has-free i { background: var(--brand); }
.day.closed b, .day.full b { color: var(--busy-ink); }
.day[aria-selected="true"] { background: var(--brand); color: var(--brand-ink); }
.day[aria-selected="true"] small, .day[aria-selected="true"] b { color: var(--brand-ink); }
.day[aria-selected="true"] i { background: var(--brand-ink); }

.day-sum { margin: 12px 2px 8px; font-size: 15px; }
.day-sum b { color: var(--brand); }
.slots { display: grid; gap: 8px; }
.slot {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  min-height: 52px; padding: 8px 14px; text-align: start;
  border: 1px solid transparent; border-radius: 14px;
}
.slot .time { font-size: 16px; font-weight: 700; }
.slot .state { font-size: 14px; font-weight: 700; white-space: nowrap; }
.slot.free { background: var(--free); border-color: var(--free-line); color: var(--free-ink); }
.slot.free:active { transform: scale(.99); }
.slot.free:hover, .slot.free:focus-visible { border-color: var(--free-ink); }
.slot.busy { background: var(--busy); color: var(--busy-ink); cursor: default; }
.slot.busy .time { font-weight: 600; }
.slot.busy .state { font-weight: 400; }

/* Week grid (wide screens) */
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 2px 8px; font-size: 13px; color: var(--muted); }
.legend span::before { content: ''; display: inline-block; width: 12px; height: 12px; margin-inline-end: 6px; border-radius: 4px; vertical-align: -1px; }
.legend .l-free::before { background: var(--free); border: 1px solid var(--free-line); }
.legend .l-busy::before { background: var(--busy); border: 1px solid var(--line); }
.grid-wrap { overflow-x: auto; }
table.week { width: 100%; border-collapse: separate; border-spacing: 4px; min-width: 720px; }
.week th { font-size: 14px; font-weight: 700; padding: 4px; }
.week th.today { color: var(--brand); }
.week th small { display: block; font-weight: 400; color: var(--muted); }
.week td.hour { width: 80px; font-size: 13px; color: var(--muted); text-align: center; white-space: nowrap; }
.cell { width: 100%; min-height: 40px; padding: 4px; border: 0; border-radius: 10px; font-size: 13px; font-weight: 700; }
.cell.free { background: var(--free); color: var(--free-ink); }
.cell.free:hover, .cell.free:focus-visible { outline: 2px solid var(--free-ink); }
.cell.busy { background: var(--busy); color: var(--busy-ink); cursor: default; font-weight: 400; }
.cell.off { background: transparent; color: var(--busy-ink); cursor: default; font-weight: 400; }

/* ---------- Booking sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); animation: fade .2s ease; }
.sheet-panel {
  position: relative; width: 100%; max-width: 480px; padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  background: var(--card); border-radius: 22px 22px 0 0; animation: up .22s ease;
}
.sheet-panel::before { content: ''; display: block; width: 40px; height: 4px; margin: 0 auto 12px; border-radius: 4px; background: var(--line); }
@media (min-width: 600px) { .sheet { align-items: center; } .sheet-panel { border-radius: 22px; } }
.sheet h3 { font-size: 19px; margin-bottom: 10px; }
.summary { margin: 0; display: grid; gap: 0; border: 1px solid var(--line); border-radius: 14px; }
.summary div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; }
.summary div + div { border-top: 1px solid var(--line); }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 700; text-align: end; }
.hint { margin: 12px 2px; color: var(--muted); font-size: 14px; }
.wa-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 12px 20px; min-height: 52px; border: 0; border-radius: 14px;
  background: var(--wa); color: #fff; font-weight: 700; font-size: 17px; text-decoration: none;
}
.ghost-btn { display: block; width: 100%; margin-top: 8px; min-height: 46px; border: 0; border-radius: 14px; background: transparent; color: var(--muted); font-weight: 600; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.empty, .error { padding: 28px 16px; text-align: center; color: var(--muted); }
.error button { margin-top: 12px; padding: 10px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.spinner { width: 30px; height: 30px; margin: 36px auto; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.wide-only { display: none; }
@media (min-width: 760px) { .wide-only { display: block; } .narrow-only { display: none; } }
