:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #15202b;
  --muted: #64707f;
  --line: #e1e6ec;
  --field: #f8fafc;
  --brand: #0e7c6b;
  --brand-ink: #ffffff;
  --brand-soft: #e3f4f0;
  --gold: #e0a100;
  --danger: #c0352b;
  --good: #16803c;
  --warn: #b25e09;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1116; --card: #161c23; --ink: #e7ecf2; --muted: #95a1b1; --line: #27303b;
    --field: #10151b; --brand: #34c3a8; --brand-ink: #04211c; --brand-soft: #123a33;
    --gold: #f5c542; --danger: #f2786d; --good: #4ade80; --warn: #f0a24b;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
[hidden] { display: none !important; }

/* ---------- app bar ---------- */
.app-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: inherit; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
}
.brand-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync {
  margin-left: auto; flex: none; border: 1px solid var(--line); background: var(--field);
  color: var(--muted); font: inherit; font-size: 12px; border-radius: 99px; padding: 4px 10px;
  display: flex; align-items: center; gap: 6px; cursor: pointer; min-height: 30px;
}
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.sync.live::before { background: var(--good); }
.sync.busy::before { background: var(--gold); }

/* ---------- layout ---------- */
main { max-width: 980px; margin: 0 auto; padding: 16px; }
.page-head { margin: 4px 0 14px; }
.page-head h1 { font-size: 24px; letter-spacing: -.015em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.section-title { font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 20px 0 8px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.stack > * + * { margin-top: 12px; }

/* ---------- selectors ---------- */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 4px;
}
.seg button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600;
  min-height: 42px; border-radius: 9px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); outline: 1px solid var(--line); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 550; min-height: 40px; padding: 0 14px;
  border-radius: 99px; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.filters { display: grid; gap: 12px; margin-bottom: 14px; }
.persons-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.persons-row > span { color: var(--muted); font-size: 14px; font-weight: 550; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--card); overflow: hidden; }
.stepper button { width: 44px; height: 44px; border: 0; background: transparent; color: var(--ink); font-size: 20px; cursor: pointer; }
.stepper input { width: 56px; height: 44px; border: 0; border-inline: 1px solid var(--line); text-align: center; font: inherit; font-size: 17px; font-weight: 650; background: var(--field); color: var(--ink); border-radius: 0; padding: 0; min-height: 0; }
.tier-note { font-size: 13px; color: var(--muted); }
.tier-note b { color: var(--ink); }

/* ---------- package cards ---------- */
.pkg-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.pkg { display: flex; flex-direction: column; gap: 10px; }
.pkg-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stars { color: var(--gold); letter-spacing: 1px; font-size: 16px; }
.stars .off { color: var(--line); }
.badge { font-size: 11px; font-weight: 650; padding: 3px 8px; border-radius: 99px; background: var(--field); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); border-color: transparent; }
.badge.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); border-color: transparent; }
.pkg h3 { font-size: 16px; }
.price { display: flex; align-items: baseline; gap: 6px; }
.price b { font-size: 28px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.price small { color: var(--muted); }
.price.none b { font-size: 18px; color: var(--muted); font-weight: 600; }
.pkg .sub { color: var(--muted); font-size: 13px; margin-top: -6px; }
.pkg-actions { display: flex; gap: 8px; margin-top: auto; }
.pkg-actions .btn { flex: 1; }

/* price matrix */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.matrix { width: 100%; border-collapse: collapse; min-width: 420px; font-variant-numeric: tabular-nums; }
.matrix th, .matrix td { padding: 12px 10px; text-align: right; border-bottom: 1px solid var(--line); }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix thead th { font-size: 12px; color: var(--muted); font-weight: 650; background: var(--field); }
.matrix tr:last-child td { border-bottom: 0; }
.matrix td a { text-decoration: none; color: var(--ink); font-weight: 600; display: block; }
.matrix td.cur { background: var(--brand-soft); }
.matrix td.cur a { color: var(--brand); }
.matrix .na { color: var(--muted); font-weight: 400; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row .btn { flex: 1 1 140px; }
.link-btn { border: 0; background: none; color: var(--danger); font: inherit; font-size: 14px; cursor: pointer; padding: 6px; min-height: 36px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 340px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 550; }
input, select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--field); color: var(--ink);
  font: inherit; font-size: 16px; /* prevents iOS zoom */
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }

.line-item { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.line-item.three { grid-template-columns: 1fr 1fr 1fr auto; }
@media (max-width: 520px) {
  .line-item.three { grid-template-columns: 1fr 1fr auto; }
  .line-item.three .field:first-child { grid-column: 1 / -1; }
}

.totals { display: grid; gap: 6px; font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; gap: 12px; }
.totals .grand { font-size: 20px; font-weight: 750; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.totals .due { color: var(--danger); font-weight: 650; }
.totals .paid { color: var(--good); }

.sticky-actions {
  position: sticky; bottom: calc(68px + env(safe-area-inset-bottom, 0px)); z-index: 5;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; display: flex; gap: 8px; align-items: center; margin-top: 16px; box-shadow: 0 -4px 20px rgba(0,0,0,.06);
}
.sticky-actions .sum { flex: 1; min-width: 0; }
.sticky-actions .sum small { display: block; color: var(--muted); font-size: 12px; }
.sticky-actions .sum b { font-size: 18px; font-variant-numeric: tabular-nums; }

/* ---------- bookings list ---------- */
.list { display: grid; gap: 10px; }
.booking { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.booking .avatar {
  width: 42px; height: 42px; border-radius: 12px; flex: none; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 750;
}
.booking .meta { flex: 1; min-width: 0; }
.booking .meta b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.booking .meta small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.booking .amt { text-align: right; font-variant-numeric: tabular-nums; flex: none; }
.booking .amt b { display: block; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .btn { margin-top: 12px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- printable documents ---------- */
.paper {
  background: #fff; color: #111; border-radius: 6px; padding: 28px 24px; max-width: 760px; margin: 0 auto;
  box-shadow: var(--shadow); border: 1px solid #e5e7eb; font-size: 14px;
}
.paper header { display: flex; justify-content: space-between; gap: 16px; border-bottom: 3px solid #0e7c6b; padding-bottom: 14px; flex-wrap: wrap; }
.paper h1 { font-size: 22px; color: #0e7c6b; }
.paper h2 { font-size: 16px; margin: 20px 0 8px; }
.paper .muted { color: #555; }
.paper table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.paper th, .paper td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #e5e7eb; vertical-align: top; }
.paper td.r, .paper th.r { text-align: right; white-space: nowrap; }
.paper tfoot td { font-weight: 700; border-bottom: 0; }
.paper .two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 520px) {
  .paper { padding: 20px 14px; }
  .paper .two { grid-template-columns: 1fr; }
  .paper header > div:last-child { text-align: left !important; }
}
.paper ul { margin: 6px 0; padding-left: 18px; }
.paper .stamp { display: inline-block; border: 2px solid; border-radius: 6px; padding: 2px 10px; font-weight: 800; letter-spacing: .05em; }
.paper .stamp.due { color: #c0352b; } .paper .stamp.paid { color: #16803c; }
.doc-tools { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

/* ---------- editor ---------- */
.tabs {
  position: sticky; top: calc(55px + env(safe-area-inset-top, 0px)); z-index: 10;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  background: var(--bg); padding: 8px 0 10px; margin-bottom: 4px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none; border: 1px solid var(--line); background: var(--card); color: var(--muted);
  font: inherit; font-weight: 600; font-size: 14px; min-height: 40px; padding: 0 14px; border-radius: 99px; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.card h3 { font-size: 16px; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.card h3 small { font-weight: 500; }
.count { font-weight: 600; font-size: 12px; color: var(--muted); background: var(--field); border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; }
.muted { color: var(--muted); }

.rows { display: grid; gap: 10px; margin-bottom: 4px; }
.row { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; background: var(--field); }
.row-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; min-height: 28px; }
.row-head b { font-size: 12px; color: var(--muted); }
.row-sum { flex: 1; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { border: 0; background: none; color: var(--danger); font: inherit; font-size: 13px; cursor: pointer; padding: 4px 6px; min-height: 32px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid .wide { grid-column: 1 / -1; }
@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
  .grid .wide { grid-column: span 2; }
}
label.f { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
label.f span { font-size: 12px; color: var(--muted); font-weight: 550; }
.row input { background: var(--card); min-height: 42px; }
.hotel { border: 1px dashed var(--line); border-radius: 14px; padding: 12px; margin-bottom: 12px; }
.hotel h4 { margin: 0 0 8px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.hotel .rows { margin: 10px 0 8px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 10px; }
.stat { background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat small { display: block; color: var(--muted); font-size: 12px; }
.stat b { display: block; font-size: 20px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.stat .pos { color: var(--good); } .stat .neg { color: var(--danger); }
table.mini { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
table.mini th, table.mini td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--line); }
table.mini th:first-child, table.mini td:first-child { text-align: left; }
table.mini th { color: var(--muted); font-size: 12px; font-weight: 600; }
table.mini tr.tot td { font-weight: 700; border-bottom: 0; }
.totals .grand { font-size: 18px; font-weight: 750; border-top: 1px solid var(--line); padding-top: 8px; }

.inc { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; }
.inc span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.doc-btn { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; padding: 14px; }
.doc-btn span { font-size: 24px; }
.doc-btn small { color: var(--muted); }

/* documents */
.paper.wide { max-width: 980px; }
.paper h3 { font-size: 14px; margin: 14px 0 4px; color: #0e7c6b; }
.paper .doc-table { overflow-x: auto; }
.paper .doc-table table { min-width: 100%; }
.paper .doc-table th { font-size: 12px; color: #555; background: #f5f7f9; white-space: nowrap; }
.paper table.plain td { border: 0; padding: 3px 6px 3px 0; }
.paper table.plain td:first-child { color: #555; width: 40%; }
.paper table.totals-table { max-width: 420px; margin-left: auto; }
.paper table.totals-table td { padding: 6px; }
.paper table.totals-table tr.grand td { font-weight: 800; font-size: 15px; border-top: 2px solid #111; }

/* ---------- bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600;
}
.tabbar svg { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--brand); }
.tabbar a.fab span:first-child {
  width: 40px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand); color: var(--brand-ink);
}
@media (min-width: 900px) {
  .tabbar { left: 50%; transform: translateX(-50%); max-width: 520px; bottom: 16px; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding-bottom: 0; }
  body { padding-bottom: 100px; }
  .sticky-actions { bottom: 92px; }
}

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  z-index: 50; max-width: calc(100vw - 32px); text-align: center; box-shadow: var(--shadow);
}

/* ---------- login gate ---------- */
#lock {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: grid; place-items: center; padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top, 0px));
}
.lock-card {
  width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 22px;
  display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.lock-mark { width: 48px; height: 48px; border-radius: 14px; font-size: 18px; margin: 0 auto 4px; }
.lock-card h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.lock-card .tier-note { margin: 0; }
.lock-card input { text-align: center; min-height: 48px; }
.lock-card .btn { margin-top: 4px; }
.lock-err { margin: 0; color: var(--danger); font-size: 13px; font-weight: 600; }

/* ---------- print ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; padding: 0; }
  .app-bar, .tabbar, .doc-tools, #toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .paper { box-shadow: none; border: 0; padding: 0; max-width: none; }
}
