:root {
  --ink: #14211f;
  --muted: #55645f;
  --teal-900: #14453f;
  --teal-700: #1f6b5f;
  --teal-100: #dcebe7;
  --surface: #ffffff;
  --page: #eff3f1;
  --line: #cfd9d5;
  --pending-bg: #fdf0d2; --pending-fg: #6b4300;
  --ok-bg: #d9efe0;      --ok-fg: #12512d;
  --bad-bg: #f8dcd8;     --bad-fg: #7d1f15;
  --grey-bg: #e4e8e6;    --grey-fg: #3c4743;
  --focus: #0a58ca;
  --radius: 10px;
  --nav-h: 64px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Malayalam", sans-serif;
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8efec; --muted: #a5b4af; --teal-900: #0d2c28; --teal-700: #5cb8a7; --teal-100: #1b3a35;
    --surface: #17211f; --page: #0f1715; --line: #2c3b37;
    --pending-bg: #4a3710; --pending-fg: #fbd98a;
    --ok-bg: #173d27; --ok-fg: #a8e3bd;
    --bad-bg: #4a1f1a; --bad-fg: #f5b9b1;
    --grey-bg: #27312e; --grey-fg: #c3cfcb;
    --focus: #8ab4ff;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); min-height: 100vh; min-height: 100dvh; }
[hidden] { display: none !important; }

h1, h2, h3 { font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif; font-weight: 700; line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; margin-bottom: .75rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
a { color: var(--teal-700); }
.gap-top { margin-top: 1.25rem; }
.small { font-size: .88rem; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: .5rem; top: .5rem; }

/* ---------- shell and navigation ---------- */
.shell { display: block; }
main { padding: 1rem 1rem calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom, 0px)); max-width: 960px; margin: 0 auto; outline: none; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--teal-900);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav .brand, .nav .nav-out { display: none; }
.nav a {
  flex: 1; min-height: var(--nav-h); display: flex; align-items: center; justify-content: center; text-align: center;
  color: #e6f1ee; text-decoration: none; font-weight: 600; font-size: .92rem; padding: .25rem;
  border-top: 4px solid transparent;
}
.nav a[aria-current="page"] { border-top-color: #f2c14e; background: rgba(255,255,255,.1); color: #fff; }
.nav a:focus-visible, .nav button:focus-visible { outline-color: #fff; outline-offset: -4px; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
  .nav { position: sticky; top: 0; height: 100vh; flex-direction: column; padding: 1.25rem 0; align-self: start; }
  .nav .brand { display: block; color: #fff; font-family: Georgia, serif; font-size: 1.3rem; font-weight: 700; padding: 0 1.25rem 1.5rem; }
  .nav .brand span { display: block; font-family: system-ui, sans-serif; font-weight: 400; font-size: .82rem; color: #b9d3cd; margin-top: .15rem; }
  .nav a { flex: 0 0 auto; min-height: 48px; justify-content: flex-start; padding: 0 1.25rem; border-top: 0; border-left: 5px solid transparent; font-size: 1rem; }
  .nav a[aria-current="page"] { border-left-color: #f2c14e; }
  .nav .nav-out { display: block; margin: auto 1.25rem 0; }
  main { padding: 2rem 2rem 3rem; width: 100%; }
}
.nav .nav-out { background: transparent; color: #e6f1ee; border: 1px solid #5f8a82; border-radius: var(--radius); min-height: 44px; font: inherit; cursor: pointer; }

/* ---------- page header ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-head .sub { color: var(--muted); font-size: .92rem; }

/* ---------- buttons and forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 48px; padding: 0 1.1rem; border-radius: var(--radius);
  border: 1.5px solid var(--teal-700); background: var(--surface); color: var(--teal-700);
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--teal-700); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0b1a17; } }
.btn.danger { border-color: var(--bad-fg); color: var(--bad-fg); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.small { min-height: 44px; padding: 0 .9rem; font-size: .95rem; }

label { display: block; font-weight: 600; margin: 0 0 .25rem; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: .5rem .75rem; font: inherit; color: var(--ink);
  background: var(--surface); border: 1.5px solid #8ea39d; border-radius: var(--radius);
}
textarea { min-height: 84px; }
.field { margin-bottom: 1rem; }
.field-error { color: var(--bad-fg); background: var(--bad-bg); padding: .5rem .75rem; border-radius: 8px; margin: .5rem 0; font-size: .95rem; }
.hint { color: var(--muted); font-size: .9rem; margin-top: .3rem; }
.grid2 { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 600px) { .grid2 { grid-template-columns: 1fr 1fr; } }

/* ---------- panels, states ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.state { text-align: center; padding: 1.5rem 1rem; color: var(--muted); }
.state.error { color: var(--bad-fg); background: var(--bad-bg); border-radius: var(--radius); }
.state .btn { margin-top: .75rem; }
.banner { background: var(--pending-bg); color: var(--pending-fg); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; }
.banner.bad { background: var(--bad-bg); color: var(--bad-fg); }

/* ---------- dashboard tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1.25rem; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile {
  text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--teal-700);
  border-radius: var(--radius); padding: .8rem .9rem; min-height: 92px;
}
.tile .n { display: block; font-family: Georgia, serif; font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.tile .l { display: block; color: var(--muted); font-size: .92rem; margin-top: .15rem; }
.tile.pending { border-left-color: #d99a1c; }
.tile.wide { grid-column: 1 / -1; }
.tile .pair { display: flex; gap: 2.5rem; flex-wrap: wrap; margin-bottom: .35rem; }
.tile .pair .l { margin-top: 0; }
.tile.err .n { color: var(--bad-fg); font-size: 1.3rem; }

/* ---------- booking cards ---------- */
.list { display: grid; gap: .75rem; }
.booking { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.booking.is-pending { border-left: 6px solid #d99a1c; }
.booking-top { display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start; }
.guest { font-weight: 700; font-size: 1.08rem; overflow-wrap: anywhere; }
.facts { display: grid; gap: .15rem .75rem; margin: .5rem 0 0; grid-template-columns: 1fr; font-size: .97rem; }
@media (min-width: 600px) { .facts { grid-template-columns: 1fr 1fr; } }
.facts dt { display: inline; color: var(--muted); }
.facts dd { display: inline; margin: 0; }
.facts div { overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.actions .btn { flex: 1 1 8rem; }
@media (min-width: 600px) { .actions .btn { flex: 0 0 auto; min-width: 9rem; } }

.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.badge.pending { background: var(--pending-bg); color: var(--pending-fg); }
.badge.confirmed { background: var(--ok-bg); color: var(--ok-fg); }
.badge.rejected, .badge.cancelled { background: var(--bad-bg); color: var(--bad-fg); }
.badge.expired, .badge.unknown { background: var(--grey-bg); color: var(--grey-fg); }

.filters { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; margin-bottom: 1rem; }
.filters .wide { grid-column: 1 / -1; }
@media (min-width: 800px) { .filters { grid-template-columns: 2fr 1fr 1fr 1fr 1fr; } .filters .wide { grid-column: auto; } }
.chip { display: inline-flex; align-items: center; gap: .5rem; background: var(--teal-100); border-radius: 999px; padding: .2rem .4rem .2rem .8rem; font-size: .9rem; margin-bottom: .75rem; }
.chip button { min-height: 32px; min-width: 32px; border: 0; border-radius: 999px; background: transparent; font: inherit; cursor: pointer; color: inherit; }

/* ---------- calendar ---------- */
.seg { display: inline-flex; border: 1.5px solid var(--teal-700); border-radius: var(--radius); overflow: hidden; }
.seg button { min-height: 48px; padding: 0 1.1rem; border: 0; background: var(--surface); color: var(--teal-700); font: inherit; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--teal-700); color: #fff; }
@media (prefers-color-scheme: dark) { .seg button[aria-pressed="true"] { color: #0b1a17; } }
.cal-bar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.cal-month { display: flex; align-items: center; gap: .5rem; }
.cal-month strong { min-width: 9.5rem; text-align: center; font-family: Georgia, serif; font-size: 1.1rem; }
.cal-month .btn { min-width: 48px; padding: 0; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: .8rem; color: var(--muted); padding: .2rem 0; }
.day {
  min-height: 62px; padding: .25rem .2rem; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface);
  font: inherit; color: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .05rem;
}
.day .d { font-size: .8rem; color: var(--muted); }
.day .c { font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.day .t { font-size: .68rem; font-weight: 700; }
.day.open { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }
.day.few { background: var(--pending-bg); color: var(--pending-fg); border-color: transparent; }
.day.full { background: var(--bad-bg); color: var(--bad-fg); border-color: transparent; }
.day.nodata { background: var(--grey-bg); color: var(--grey-fg); border-color: transparent; }
.day.open .d, .day.few .d, .day.full .d, .day.nodata .d { color: inherit; }
.day.today { border: 3px solid var(--ink); }
.day[aria-pressed="true"] { outline: 3px solid var(--focus); outline-offset: 1px; }
.day.pad { visibility: hidden; border: 0; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; font-size: .88rem; margin: .75rem 0 1rem; }
.legend span::before { content: ""; display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.legend .open::before { background: var(--ok-bg); border: 1px solid var(--ok-fg); }
.legend .few::before { background: var(--pending-bg); border: 1px solid var(--pending-fg); }
.legend .full::before { background: var(--bad-bg); border: 1px solid var(--bad-fg); }
@media (max-width: 420px) { .day .t { display: none; } .day { min-height: 54px; } }

/* ---------- dialog, toast, login ---------- */
dialog { width: min(560px, calc(100vw - 1.5rem)); max-height: 90dvh; border: 0; border-radius: 14px; padding: 1.25rem; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(8, 20, 18, .55); }
dialog h2 { margin-bottom: .5rem; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; justify-content: flex-end; }
.dlg-actions .btn { flex: 1 1 8rem; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom, 0px)); z-index: 60; max-width: min(92vw, 520px); }
.toast p { margin: 0; padding: .75rem 1rem; border-radius: var(--radius); font-weight: 600; background: var(--teal-900); color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.toast p.bad { background: var(--bad-bg); color: var(--bad-fg); border: 1.5px solid var(--bad-fg); }
@media (min-width: 900px) { .toast { bottom: 1.5rem; left: calc(50% + 120px); } }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; background: var(--teal-900); }
.login-card { background: var(--surface); width: min(400px, 100%); border-radius: 14px; padding: 1.5rem; }
.login-card h1 { margin-bottom: .25rem; }
.login-card p.muted { margin: 0 0 1rem; }
.login-card .btn { margin-top: .75rem; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
