:root {
  --terra: #B8552F; --terra-dark: #8E3E1F; --terra-light: #F4DCCF;
  --sand: #F7F1E8; --sand-2: #EFE5D6; --card: #FFFDF9;
  --ink: #2B211C; --muted: #7A6A5F; --line: #E2D5C3;
  --olive: #5E7445; --olive-light: #DDE6D0;
  --sea: #2F7F86; --sea-light: #D5ECEC;
  --gold: #F2C14E; --rust: #A6452A;
  --r-card: 14px; --r: 12px;
  --serif: "DM Serif Display", Georgia, serif;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tabs-h: 64px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--sand); color: var(--ink);
  font: 500 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--terra-dark); }
h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; }
h2 { font-size: 22px; } h3 { font-size: 18px; }

.wordmark { font-family: var(--serif); font-size: 24px; line-height: 1; color: var(--terra-dark); }
.wordmark.big { font-size: 44px; text-align: center; }
.smallcaps { font-size: 10.5px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.boot { min-height: 100vh; display: grid; place-items: center; }

/* ---------- login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(circle at 15% 10%, rgba(184,85,47,.18), transparent 45%),
    radial-gradient(circle at 90% 90%, rgba(47,127,134,.18), transparent 50%),
    var(--sand);
}
.login-card {
  width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px 24px 26px; box-shadow: 0 20px 50px -24px rgba(43,33,28,.35);
  display: grid; gap: 14px;
}
.login-card .smallcaps { text-align: center; margin: -6px 0 8px; }

/* ---------- form controls ---------- */
.field { display: grid; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 700; color: var(--muted); }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 11px 12px; font-size: 16px; outline: none; min-height: 44px;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { border-color: var(--terra); box-shadow: 0 0 0 3px var(--terra-light); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; min-height: 44px; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--olive); }
.form-error { color: var(--rust); font-weight: 700; font-size: 13.5px; min-height: 0; }
.form-error:empty { display: none; }
.form-ok { background: var(--olive-light); color: var(--olive); border-radius: 10px; padding: 10px 12px; font-weight: 700; }
.help { font-size: 12.5px; color: var(--muted); background: var(--sand); border-radius: 10px; padding: 10px 12px; }
.warn { font-size: 12.5px; color: var(--terra-dark); background: var(--terra-light); border-radius: 10px; padding: 10px 12px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--sand-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; border-radius: 8px; padding: 9px 6px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg button.on.olive { color: var(--olive); }
.seg button.on.terra { color: var(--terra-dark); }

.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: var(--r);
  padding: 11px 16px; font-weight: 800; min-height: 44px; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; white-space: nowrap;
}
.btn.primary { background: var(--terra); border-color: var(--terra); color: #fff; }
.btn.primary:active { background: var(--terra-dark); }
.btn.olive { background: var(--olive); border-color: var(--olive); color: #fff; }
.btn.danger { color: var(--rust); border-color: #E9C3B6; }
.btn.danger.solid { background: var(--rust); color: #fff; border-color: var(--rust); }
.btn.small { min-height: 36px; padding: 7px 12px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns > .grow { flex: 1; }

/* ---------- app shell ---------- */
.app { min-height: 100vh; padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px); }
.topbar {
  position: sticky; top: 0; z-index: 5; background: rgba(247,241,232,.94); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--line);
}
.topbar .wordmark { font-size: 26px; }
.account-pill {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 4px 12px 4px 4px; min-height: 40px; max-width: 55%;
}
.account-pill .who { display: grid; text-align: left; line-height: 1.15; min-width: 0; }
.account-pill .who b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-pill .who small { font-size: 11px; color: var(--muted); font-weight: 700; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--terra); color: #fff; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 12.5px; letter-spacing: .02em;
}
.avatar.grey { background: #B9ADA2; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }

.datebar {
  display: grid; grid-template-columns: 44px 1fr 44px auto auto; align-items: center; gap: 6px;
  padding: 10px 16px; max-width: 1100px; margin: 0 auto;
}
.datebar .nav { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); font-size: 22px; line-height: 1; }
.datebar .label { text-align: center; line-height: 1.2; }
.datebar .label b { font-family: var(--serif); font-weight: 400; font-size: 20px; display: block; }
.datebar .label small { color: var(--muted); font-weight: 700; font-size: 12px; }
.datebar .label small.today { color: var(--terra); }
.datepick { position: relative; width: 44px; height: 44px; }
.datepick span { position: absolute; inset: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--card); pointer-events: none; }
.datepick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; min-height: 0; padding: 0; cursor: pointer; }

.offline { margin: 0 16px 8px; background: #FBE7C6; color: #7A4B00; border-radius: 10px; padding: 9px 12px; font-weight: 700; font-size: 13px; }
.view { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  border: 0; background: none; height: var(--tabs-h); display: grid; place-items: center; align-content: center; gap: 3px;
  color: var(--muted); font-size: 11.5px; font-weight: 800;
}
.tabs button svg { width: 24px; height: 24px; }
.tabs button.on { color: var(--terra); }

/* ---------- cards / chips ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px; }
.card + .card { margin-top: 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px;
  font-weight: 800; font-size: 13.5px; display: flex; gap: 8px; align-items: center; min-height: 40px;
}
.chip small { font-weight: 700; color: var(--muted); }
.chip.on { background: var(--terra); border-color: var(--terra); color: #fff; }
.chip.on small { color: var(--terra-light); }
.pill { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 800; background: var(--sand-2); color: var(--muted); }
.pill.admin { background: var(--terra-light); color: var(--terra-dark); }
.pill.off { background: #EEE; color: #8a8a8a; }

.sector-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.sector-head p { margin: 3px 0 0; color: var(--muted); font-weight: 700; font-size: 13.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 5px; }
.legend .free { border: 1.5px dashed #C9B8A3; background: #fff; }
.legend .booked { background: var(--terra); }
.legend .arrived { background: var(--olive); }
.legend .paid { background: var(--gold); border-radius: 50%; }

/* ---------- map ---------- */
.strip {
  margin-top: 14px; border-radius: 10px 10px 4px 4px; text-align: center; font-size: 11px; font-weight: 800;
  letter-spacing: .3em; padding: 7px; color: var(--sea);
  background: repeating-linear-gradient(-45deg, var(--sea-light) 0 8px, #E6F4F4 8px 16px);
}
.strip.pool { color: #2B6F9A; background: repeating-linear-gradient(-45deg, #D6E9F5 0 8px, #E8F3FA 8px 16px); }
.grid-scroll { overflow-x: auto; margin: 10px -14px -4px; padding: 0 14px 6px; }
.grid { display: grid; gap: 6px; min-width: min-content; }
.spot {
  aspect-ratio: 1; border-radius: var(--r); border: 1.5px dashed #C9B8A3; background: #fff; position: relative;
  display: grid; align-content: center; justify-items: center; gap: 1px; padding: 3px; min-width: 46px; overflow: hidden;
  color: var(--muted);
}
.spot svg { width: 46%; max-width: 30px; height: auto; }
.spot b { font-size: 12px; line-height: 1; color: var(--ink); }
.spot em { font-style: normal; font-size: 10px; font-weight: 700; line-height: 1.1; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spot.booked { background: var(--terra); border: 1.5px solid var(--terra); color: #fff; }
.spot.arrived { background: var(--olive); border: 1.5px solid var(--olive); color: #fff; }
.spot.booked b, .spot.arrived b { color: #fff; }
.spot .paid { position: absolute; top: 3px; right: 3px; width: 15px; height: 15px; border-radius: 50%; background: var(--gold); color: #5A3E00; font-size: 9.5px; font-weight: 800; display: grid; place-items: center; }
.spot:active { transform: scale(.96); }
.gap { aspect-ratio: 1; min-width: 46px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-weight: 600; }

/* ---------- list ---------- */
.search { position: relative; margin-bottom: 12px; }
.search input { padding-left: 38px; background: var(--card); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.list { display: grid; gap: 8px; }
.res-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 12px; width: 100%;
}
.tag { min-width: 44px; height: 44px; border-radius: 10px; background: var(--terra); color: #fff; font-weight: 800; display: grid; place-items: center; padding: 0 6px; font-size: 14px; }
.tag.arrived { background: var(--olive); }
.tag.deleted { background: #B9ADA2; }
.res-row .main { min-width: 0; }
.res-row .main b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-row .main div { font-size: 12.5px; color: var(--muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.res-row .main .by { font-size: 11.5px; }
.res-row .price { text-align: right; font-weight: 800; white-space: nowrap; }
.res-row .price small { display: block; font-size: 11.5px; }
.ok { color: var(--olive); } .due { color: var(--rust); }
.list-date { font-family: var(--serif); font-size: 16px; margin: 10px 2px 0; color: var(--terra-dark); }

/* ---------- day ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 12px 14px; }
.kpi span { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi b { display: block; font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.15; color: var(--terra-dark); }
.kpi small { font-size: 12.5px; color: var(--muted); font-weight: 700; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.t td { padding: 9px 4px; border-bottom: 1px solid var(--sand-2); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t .num { text-align: right; white-space: nowrap; font-weight: 700; }
.bar { height: 8px; border-radius: 8px; background: var(--sand-2); overflow: hidden; min-width: 60px; }
.bar i { display: block; height: 100%; background: var(--terra); border-radius: 8px; }
.card h3 { margin-bottom: 8px; }

/* ---------- admin ---------- */
.subtabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.user-row, .sector-row, .act-row, .del-row {
  display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: 12px; width: 100%; text-align: left;
}
.user-row .main, .sector-row .main, .act-row .main, .del-row .main { flex: 1; min-width: 0; }
.user-row .main div, .sector-row .main div, .act-row .main div, .del-row .main div { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.act-row { align-items: flex-start; }
.act-row .time { font-size: 12px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.toolbar { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 180px; }
.updown { display: grid; gap: 4px; }
.updown button { width: 34px; height: 28px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; font-weight: 800; }
.export { display: grid; gap: 12px; max-width: 420px; }

/* ---------- sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(43,33,28,.42); z-index: 20; animation: fade .18s ease; }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 640px; max-height: 92vh;
  overflow-y: auto; overscroll-behavior: contain; background: var(--card); z-index: 21; border-radius: 20px 20px 0 0;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -12px 40px rgba(43,33,28,.25);
  animation: up .22s cubic-bezier(.2,.8,.2,1);
}
.sheet::before { content: ""; display: block; width: 40px; height: 4px; background: var(--line); border-radius: 4px; margin: 0 auto 12px; }
.sheet-head { margin-bottom: 14px; }
.sheet-head p { margin: 2px 0 0; color: var(--muted); font-weight: 700; font-size: 13.5px; }
.sheet form, .sheet .stack { display: grid; gap: 12px; }
@keyframes up { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes fade { from { opacity: 0; } }
.history { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.history h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.timeline { display: grid; gap: 10px; }
.tl { border-left: 3px solid var(--terra-light); padding-left: 10px; }
.tl b { font-size: 13.5px; }
.tl div { font-size: 12.5px; color: var(--muted); font-weight: 600; word-break: break-word; }
.tl.delete { border-color: #E9C3B6; } .tl.restore { border-color: var(--olive-light); }
.greybox { background: #F1ECE6; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }

/* sector editor */
.editor-grid { display: grid; gap: 4px; min-width: min-content; }
.editor-grid button {
  aspect-ratio: 1; min-width: 34px; border-radius: 8px; border: 1.5px solid var(--line); background: #fff; padding: 2px;
  display: grid; place-items: center; color: var(--terra-dark);
}
.editor-grid button svg { width: 70%; height: auto; }
.editor-grid button.x { background: var(--sand-2); border-style: dashed; color: transparent; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom));
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px;
  z-index: 30; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
@media (min-width: 700px) {
  .tabs { grid-auto-columns: minmax(0, 120px); justify-content: center; }
  .view { padding: 0 24px; }
  .datebar { padding: 12px 24px; }
}
