:root {
  --ink: #141414; --ink-2: #4a4a48; --muted: #7a7974; --line: #e3e1da; --bg: #f6f5f1; --card: #fff;
  --brand: #f5d300; --brand-ink: #141414; --red: #d93a2b; --red-bg: #fdecea;
  --green: #1d7a46; --green-bg: #e6f4ec; --blue: #1f5fbf; --blue-bg: #e8f0fc;
  --amber: #a15c00; --amber-bg: #fff3dc; --grey-bg: #eeede8;
  --r: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.4; }
a { color: var(--blue); text-decoration: none; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; color: var(--ink-2); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: 1rem; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* header */
#top { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 10; }
#top:empty { display: none; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem; max-width: 1280px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; font-weight: 700; white-space: nowrap; }
.brand img { width: 30px; height: 30px; }
.brand span { color: var(--brand); }
nav.main { display: flex; gap: .25rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
nav.main a { color: #d6d6d2; padding: .45rem .7rem; border-radius: 8px; white-space: nowrap; font-size: .93rem; }
nav.main a:hover { background: #2a2a28; color: #fff; }
nav.main a.on { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.who { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: #bdbdb8; white-space: nowrap; }
.who a, .who button { color: #fff; }
.who button { background: none; border: 1px solid #444; border-radius: 6px; padding: .25rem .5rem; cursor: pointer; font: inherit; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: .4rem .75rem; }
  .topbar .who { margin-left: auto; }
  nav.main { order: 3; flex-basis: 100%; }
}
main { max-width: 1280px; margin: 0 auto; padding: 1rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* cards & grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.cols-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .grid2, .grid3, .cols-main { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: .75rem .9rem; }
.stat .k { font-size: .8rem; color: var(--muted); }
.stat .v { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .15rem; }
.stat.warn .v { color: var(--red); }

/* room board */
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.room { display: block; background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--green); border-radius: var(--r);
  padding: .7rem .8rem; color: var(--ink); min-height: 118px; cursor: pointer; position: relative; box-shadow: var(--shadow); }
.room:hover { outline: 2px solid var(--brand); }
.room .n { font-size: 1.4rem; font-weight: 800; }
.room .t { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.room .g { font-weight: 600; margin-top: .35rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room .m { font-size: .82rem; color: var(--ink-2); }
.room.st-vacant { border-left-color: var(--green); }
.room.st-vacant .g { color: var(--green); }
.room.st-occupied { border-left-color: var(--blue); background: #fbfcff; }
.room.st-due { border-left-color: #e69500; background: #fffaf0; }
.room.st-overdue { border-left-color: var(--red); background: #fff8f7; }
.room.st-ooo { border-left-color: #999; background: var(--grey-bg); }
.room .clean { margin-top: .4rem; }

.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--ink-2); margin-bottom: .75rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }

/* badges */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.b-green { background: var(--green-bg); color: var(--green); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-grey { background: var(--grey-bg); color: var(--ink-2); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafaf7; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fffbe0; }
tr.void td { color: var(--muted); text-decoration: line-through; }
tr.void td.reason { text-decoration: none; }
tfoot td { font-weight: 700; border-bottom: none; }
.totals td { border: none; padding: .3rem .55rem; }
.totals tr.big td { font-size: 1.15rem; font-weight: 800; border-top: 2px solid var(--ink); padding-top: .5rem; }

/* forms */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: .2rem; }
input, select, textarea { width: 100%; font: inherit; padding: .5rem .6rem; border: 1px solid #cfcdc5; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--ink); }
input[type=checkbox] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: .7rem; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; }
.row > .field { margin-bottom: .7rem; }
.hint { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.hint.bad { color: var(--red); font-weight: 600; }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: .75rem 1rem .25rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .3rem; }
.inline { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline > * { flex: 1 1 120px; }
.inline > button { flex: 0 0 auto; }

/* buttons */
button, .btn { font: inherit; font-weight: 600; border-radius: 8px; padding: .5rem .9rem; border: 1px solid #cfcdc5;
  background: #fff; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
button:hover, .btn:hover { background: #f3f2ec; }
.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.primary:hover { background: #333; }
.accent { background: var(--brand); color: var(--brand-ink); border-color: #d9ba00; }
.accent:hover { background: #ffe033; }
.danger { color: var(--red); border-color: #f0b8b1; }
.danger:hover { background: var(--red-bg); }
.green { background: var(--green); color: #fff; border-color: var(--green); }
.green:hover { background: #17633a; }
.link { background: none; border: none; padding: 0; color: var(--blue); font-weight: 500; }
.link:hover { background: none; text-decoration: underline; }
.sm { padding: .25rem .55rem; font-size: .82rem; }
button:disabled { opacity: .5; cursor: not-allowed; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .9rem; color: var(--ink-2); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a.on { border-color: var(--ink); color: var(--ink); }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .85rem; }
dl.kv dd { margin: 0; font-weight: 500; }

.suggest { border: 1px solid var(--line); border-radius: 8px; margin-top: .25rem; background: #fff; max-height: 240px; overflow: auto; }
.suggest div { padding: .5rem .6rem; cursor: pointer; border-bottom: 1px solid var(--line); }
.suggest div:hover { background: #fffbe0; }

.note { background: var(--amber-bg); color: #5c3b00; border-radius: 8px; padding: .6rem .8rem; font-size: .88rem; margin-bottom: 1rem; }

#toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; }
#toast div { background: var(--ink); color: #fff; padding: .65rem 1rem; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.2); max-width: 90vw; }
#toast div.err { background: var(--red); }

dialog { border: none; border-radius: 12px; padding: 0; width: min(640px, 94vw); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .dh { padding: 1rem 1rem 0; }
dialog form { padding: 1rem; }
dialog .df { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }

/* login */
.login { max-width: 380px; margin: 8vh auto; }
.login .logo { text-align: center; margin-bottom: 1rem; }
.login .logo img { width: 84px; }
.login h1 { text-align: center; }

/* bars in monthly */
.bar { height: 8px; background: var(--brand); border-radius: 4px; min-width: 2px; }

/* print: bill */
.bill-paper { background: #fff; max-width: 780px; margin: 0 auto; padding: 28px 32px; border: 1px solid var(--line); color: #10204a; }
.bill-paper .bh { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid #10204a; padding-bottom: 10px; }
.bill-paper .bn { font-size: 26px; font-weight: 900; letter-spacing: .5px; line-height: 1; }
.bill-paper .bn small { display: block; font-size: 15px; letter-spacing: 3px; font-weight: 700; margin-top: 4px; }
.bill-paper .tag { font-size: 11px; font-style: italic; }
.bill-paper .contact { text-align: right; font-size: 12px; }
.bill-paper .title { text-align: center; margin: 12px 0; }
.bill-paper .title span { border: 2px solid #10204a; padding: 3px 14px; border-radius: 6px; font-weight: 800; letter-spacing: 1px; }
.bill-paper .meta { display: grid; grid-template-columns: 1fr auto; gap: 1rem; font-size: 13px; margin-bottom: 10px; }
.bill-paper .meta b { display: inline-block; min-width: 70px; }
.bill-paper table { border: 1.5px solid #10204a; }
.bill-paper th { background: none; color: #10204a; border-bottom: 1.5px solid #10204a; border-right: 1px solid #10204a; }
.bill-paper td { border-right: 1px solid #10204a; border-bottom: 1px dotted #9aa3bd; font-size: 13px; }
.bill-paper .tot td { border-top: 1.5px solid #10204a; border-bottom: none; font-weight: 800; }
.bill-paper .words { margin: 12px 0; font-size: 13px; border-bottom: 1px solid #10204a; padding-bottom: 4px; }
.bill-paper .sig { display: flex; justify-content: space-between; margin-top: 46px; font-size: 13px; }
.bill-paper .sig div { border-top: 1px solid #10204a; padding-top: 4px; min-width: 200px; text-align: center; }
.bill-paper .thanks { text-align: center; font-style: italic; margin-top: 14px; font-size: 13px; }

@media print {
  @page { margin: 10mm; }
  body { background: #fff; }
  #top, .no-print, #toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: none; padding: 0; }
  .bill-paper { border: none; padding: 0; }
  a { color: inherit; }
  th { background: none; }
}

/* booking calendar */
.cal-wrap { overflow-x: auto; padding: 0; }
table.cal { border-collapse: separate; border-spacing: 0; table-layout: fixed; min-width: 100%; }
.cal th, .cal td { border-bottom: 1px solid var(--line); border-right: 1px solid #efeee9; padding: 0; height: 46px; }
.cal thead th { text-align: center; font-size: .7rem; padding: .35rem 0; min-width: 52px; background: #fafaf7; }
.cal thead th b { display: block; font-size: 1rem; color: var(--ink); }
.cal thead th span { display: block; font-size: .65rem; }
.cal th.cal-room { position: sticky; left: 0; z-index: 2; background: #fff; text-align: left; padding: 0 .7rem; min-width: 74px; font-size: 1rem; color: var(--ink); text-transform: none; letter-spacing: 0; }
.cal th.cal-room span { display: block; font-size: .68rem; color: var(--muted); font-weight: 500; }
.cal thead th.cal-room { z-index: 3; background: #fafaf7; }
.cal .cal-we { background: #f3f2ec; }
.cal .cal-today { background: #fffbe0 !important; box-shadow: inset 2px 0 0 var(--brand), inset -2px 0 0 var(--brand); }
.cal td.cal-free { cursor: pointer; }
.cal td.cal-free:hover { background: #e9f7ee; box-shadow: inset 0 0 0 2px var(--green); }
.cal td.cal-b { padding: 4px 2px; cursor: pointer; }
.cal td.cal-b div { height: 100%; border-radius: 7px; padding: .25rem .5rem; font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; }
.cal td.cal-res div { background: #fde9b5; color: #6b4500; border: 1px solid #f2b630; }
.cal td.cal-in div { background: var(--blue); color: #fff; }
.cal td.cal-out div { background: #e4e3de; color: #6a6964; }
.cal td.cal-b:hover div { outline: 2px solid var(--ink); }

/* roles & permissions */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .5rem 1.25rem; margin-bottom: .75rem; }
.perm-h { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: .4rem 0 .25rem; }
label.perm { display: flex; gap: .45rem; align-items: flex-start; font-weight: 500; color: var(--ink); font-size: .88rem; padding: .15rem 0; cursor: pointer; }
label.perm input { margin-top: .15rem; }
label.perm.perm-no { color: var(--muted); cursor: not-allowed; }
.actions select { width: auto; }
