/* =====================================================================
   STYLES — grouped by section
   1. Theme variables        5. Tables & pills
   2. Base & buttons         6. Billing / finance widgets
   3. Header / sidebar       7. Dashboard widgets
   4. Panels & forms         8. Responsive & print
   ===================================================================== */

/* ---------- 1. THEME VARIABLES ---------- */
:root{
  --navy:#0b2a35;   --blue:#0e7c8c;  --bg:#eef2f5;
  --text:#16262e;   --muted:#5d707a; --line:#dde5ea;
  --white:#fff;     --green:#16804a; --red:#c62828;
  --amber:#b76e00;  --purple:#7047c8; --gold:#c9a24b;
}

/* ---------- 2. BASE & BUTTONS ---------- */
*{ box-sizing:border-box; }

body{
  margin:0;
  background:var(--bg);
  font-family:"Segoe UI",system-ui,-apple-system,Roboto,Arial,sans-serif;
  color:var(--text);
}

button,input,select,textarea{ font:inherit; }

button{
  cursor:pointer;
  border:0;
  border-radius:8px;
  padding:10px 13px;
  font-weight:700;
  background:var(--blue);
  color:#fff;
  transition:transform .15s,box-shadow .15s,filter .15s,background .15s;
}
button:hover{ transform:translateY(-1px); box-shadow:0 6px 14px #0e7c8c30; filter:brightness(1.07); }
button:active{ transform:none; }

button.secondary{ background:#e1eef0; color:#0b4a55; }
button.danger   { background:var(--red) !important; color:#fff !important; }
button.success  { background:var(--green) !important; color:#fff !important; }
button.small    { padding:6px 9px; font-size:12px; }
button.ghost    { background:#fff; color:#233b65; border:1px solid #d0d7e2; }
button.ghost:hover{ background:#f3f6fb; }

button:focus-visible,input:focus-visible,select:focus-visible{
  outline:2px solid var(--blue);
  outline-offset:2px;
}

/* ---------- 3. HEADER & SIDEBAR ---------- */
header{
  background:linear-gradient(110deg,#081f29,#0b2a35 55%,#0e5560);
  border-bottom:3px solid var(--gold);
  color:#fff;
  padding:14px 24px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  flex-wrap:wrap;
}
.hd-brand{ display:flex; align-items:center; gap:14px; }
.logo{ width:54px; height:54px; flex:none; filter:drop-shadow(0 2px 6px #0006); }
header h1{ font-size:23px; margin:0 0 3px; }
header p{ margin:0; color:#b9d3d8; font-size:13px; }
.header-tag{
  border:1px solid #ffffff30;
  background:#ffffff14;
  padding:8px 12px;
  border-radius:20px;
  font-size:12px;
}
.hd-right{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.theme-toggle{
  border:1px solid #ffffff30; background:#ffffff14; color:#fff;
  padding:8px 14px; border-radius:20px; font-size:12px; font-weight:700;
  cursor:pointer;
}
@keyframes spin { 100% { transform:rotate(360deg); } }
.spinning { animation:spin 0.8s linear infinite; display:inline-block; }

.layout{ display:grid; grid-template-columns:220px minmax(0,1fr); min-height:calc(100vh - 82px); }

aside{
  background:linear-gradient(180deg,#0b2a35,#081f29);
  padding:18px 12px;
  color:#c4d6db;
}
aside .brand{
  font-weight:800;
  padding:10px 12px 22px;
  color:#fff;
  line-height:1.5;
}

nav button{
  display:flex;
  align-items:center;
  gap:11px;
  width:100%;
  text-align:left;
  background:transparent;
  color:#c4d6db;
  font-weight:600;
  margin:4px 0;
  padding:12px;
  border-left:3px solid transparent;
  border-radius:8px;
  transition:background .18s,transform .18s,color .18s;
}
nav button:hover{ background:#ffffff14; color:#fff; transform:translateX(4px); box-shadow:none; filter:none; }
nav button.active{
  background:linear-gradient(90deg,#0e7c8c66,#0e7c8c14);
  border-left-color:var(--gold);
  color:#fff;
}

/* ---------- SUMMARY REPORT DROPDOWN ---------- */
.nav-dropdown-wrap{ position:relative; margin:4px 0; }
.nav-dropdown-toggle{
  display:flex; align-items:center; gap:11px; width:100%;
  text-align:left; background:transparent; color:#c4d6db;
  font-weight:600; padding:12px; border-left:3px solid transparent;
  border-radius:8px; transition:background .18s,color .18s;
  box-shadow:none; filter:none;
}
.nav-dropdown-toggle:hover{ background:#ffffff14; color:#fff; transform:none; box-shadow:none; filter:none; }
.nav-dropdown-toggle.active{
  background:linear-gradient(90deg,#0e7c8c66,#0e7c8c14);
  border-left-color:var(--gold); color:#fff;
}
.nav-caret{ margin-left:auto; font-size:10px; opacity:.7; }
.nav-dropdown-menu{
  display:none;
  position:absolute;
  top:100%; left:0;
  min-width:180px;
  background:#0b2a35;
  border:1px solid #ffffff20;
  border-radius:10px;
  padding:5px;
  z-index:25;
  box-shadow:0 10px 26px #0007;
}
.nav-dropdown-menu.open{ display:block; }
.nav-dropdown-menu button{
  display:block; width:100%; text-align:left;
  background:transparent; color:#b8ccd4; font-weight:600;
  padding:10px 12px; border-radius:6px; border-left:0;
  font-size:13px; margin:2px 0;
  transition:background .15s,color .15s;
  box-shadow:none; filter:none;
}
.nav-dropdown-menu button:hover{ background:#ffffff14; color:#fff; transform:none; box-shadow:none; filter:none; }
.nav-dropdown-menu button.active{ background:#0e7c8c55; color:#fff; }

main{ padding:22px; min-width:0; }

/* ---------- 4. PAGES, PANELS, FORMS ---------- */
.page{ display:none; }
.page.active{ display:block; }

.page-title{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom:18px;
}
.page-title h2{ margin:0; font-size:24px; position:relative; padding-left:14px; }
.page-title h2:before{
  content:"";
  position:absolute;
  left:0; top:4px; bottom:4px;
  width:4px;
  border-radius:2px;
  background:var(--gold);
}

.muted{ color:var(--muted); font-size:13px; }

.cards{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:12px;
  margin-bottom:18px;
  min-width:0;
}

.stat,.panel{
  background:#fff;
  border:1px solid var(--line);
  border-radius:13px;
  padding:16px;
  box-shadow:0 1px 3px #0b2a3510;
  transition:transform .2s,box-shadow .2s,border-color .2s;
  min-width:0;
}
.stat{ border-top:3px solid var(--blue); }
.stat:hover{ transform:translateY(-3px); box-shadow:0 12px 26px #0b2a3519; border-color:#b5d3d8; }
.stat .label{ color:var(--muted); font-size:12px; }
.stat .value{ font-size:25px; font-weight:800; margin-top:8px; overflow-wrap:anywhere; }
.stat .hint{ font-size:11px; color:var(--muted); margin-top:5px; }

.panel{ margin-bottom:16px; }
.panel:hover{ box-shadow:0 6px 18px #0b2a3512; }
.panel h3{ margin:0 0 14px; font-size:16px; }

.section-grid{ display:grid; grid-template-columns:1.15fr .85fr; gap:16px; min-width:0; }

.form-grid{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.form-grid .full{ grid-column:1/-1; }

label{ display:block; font-size:12px; font-weight:700; color:#475467; margin-bottom:5px; }

input,select,textarea{
  width:100%;
  border:1px solid #d0d7e2;
  border-radius:8px;
  padding:10px;
  background:#fff;
  color:var(--text);
  outline:none;
  transition:border-color .15s,box-shadow .15s;
}
input:hover,select:hover,textarea:hover{ border-color:#9bbec4; }
input:focus,select:focus,textarea:focus{
  border-color:var(--blue);
  box-shadow:0 0 0 3px #0e7c8c24;
}

.actions{ display:flex; gap:8px; flex-wrap:wrap; margin-top:13px; }

.notice{
  background:#eaf5f6;
  border:1px solid #bfdde1;
  border-radius:9px;
  padding:11px 13px;
  color:#0b5560;
  font-size:12px;
  margin-bottom:14px;
}

.footer-note{ font-size:11px; color:var(--muted); margin-top:10px; }

/* small live nights counter shown under the booking dates */
.nights-hint{
  display:inline-flex;
  align-items:center;
  gap:7px;
  background:#e1eef0;
  border:1px solid #bfdde1;
  color:#0b4a55;
  border-radius:20px;
  padding:6px 12px;
  font-size:12px;
  font-weight:700;
}
.nights-hint b{ font-size:14px; }

/* ---------- 5. TABLES & STATUS PILLS ---------- */
.table-wrap{ overflow:auto; }

table{ width:100%; border-collapse:collapse; font-size:13px; min-width:650px; }
th,td{ text-align:left; padding:11px 10px; border-bottom:1px solid var(--line); vertical-align:top; }
th{
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.04em;
  color:#4a5f69;
  background:#f1f6f7;
}
tbody tr{ transition:background .12s; }
tbody tr:hover{ background:#f4fafb; }

td .sub{ display:block; font-size:11px; color:var(--muted); margin-top:4px; }
.money{ font-variant-numeric:tabular-nums; font-weight:700; }
.right{ text-align:right; }
.empty{ text-align:center; color:var(--muted); padding:25px; }
.row-actions{ display:flex; gap:6px; flex-wrap:wrap; }
.danger-text{ color:#b42318; }

/* status pills */
.pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  border-radius:20px;
  padding:5px 9px;
  font-size:11px;
  font-weight:800;
  white-space:nowrap;
}
.pill:before{ content:""; width:7px; height:7px; border-radius:50%; background:currentColor; }

.available{ background:#d9f8e6; color:#147a43; }
.waiting  { background:#fff0c2; color:#976100; }
.booked   { background:#dce8ff; color:#2457d6; }
.occupied { background:#f5d9ff; color:#7430a8; }
.cleaning { background:#ffe0df; color:#bd2929; }
.ready    { background:#d9f8e6; color:#147a43; }
.partial  { background:#fff0c2; color:#976100; }
.unpaid   { background:#ffe0df; color:#bd2929; }
.paid     { background:#d9f8e6; color:#147a43; }
.pill.danger, span.danger { background:#ffe0df; color:#bd2929; }
.completed{ background:#e0f2fe; color:#0369a1; }

.duty-tag{
  display:inline-flex;
  align-items:center;
  gap:5px;
  background:#f1f5f9;
  color:#334155;
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;
  font-size:11.5px;
  font-weight:700;
  padding:3px 8px;
  border-radius:6px;
  border:1px solid #cbd5e1;
  letter-spacing:0.3px;
}
html[data-theme="dark"] .duty-tag{
  background:#1e293b;
  color:#cbd5e1;
  border-color:#334155;
}


/* room cards */
.room-grid{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; }

.room{
  border:1px solid var(--line);
  border-radius:11px;
  padding:12px;
  background:#fff;
  min-height:120px;
  display:flex;
  flex-direction:column;
  gap:7px;
  transition:transform .2s,box-shadow .2s;
  min-width:0;
}
.room:hover{ transform:translateY(-3px); box-shadow:0 10px 22px #0b2a3518; }
.room strong{ font-size:16px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.room .room-type{ font-size:12px; color:var(--muted); }
.room .room-actions{ display:flex; gap:6px; flex-wrap:wrap; margin-top:auto; }
.room .room-actions button{ font-size:11.5px; padding:6px 8px; min-height:32px; min-width:0; }

.room.available-room{ border-top:5px solid #1d9a5a; }
.room.waiting-room  { border-top:5px solid #e2a100; }
.room.booked-room   { border-top:5px solid #2457d6; }
.room.occupied-room { border-top:5px solid #8e44ad; }
.room.cleaning-room { border-top:5px solid #d93939; }

.legend{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }

/* ---------- 6. BILLING / FINANCE WIDGETS ---------- */
.bf-tabs{
  display:flex;
  gap:4px;
  border-bottom:1px solid var(--line);
  margin-bottom:16px;
  overflow:auto;
}
.bf-tabs button{
  background:none;
  color:var(--muted);
  border-radius:0;
  padding:11px 18px;
  border-bottom:2px solid transparent;
  white-space:nowrap;
}
.bf-tabs button:hover{ color:var(--text); transform:none; box-shadow:none; filter:none; }
.bf-tabs button.on{ color:var(--blue); border-bottom-color:var(--blue); }

.bf-pane{ display:none; }
.bf-pane.on{ display:block; }

.bf-sum{
  background:#f8fafc;
  border:1px solid var(--line);
  border-radius:10px;
  padding:12px 14px;
  margin-top:14px;
}
.bf-sum div{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:5px 0;
  font-size:13px;
}
.bf-sum .tot{
  border-top:1px solid var(--line);
  margin-top:6px;
  padding-top:10px;
  font-weight:800;
  font-size:15px;
}

.bf-tools{ display:flex; gap:10px; flex-wrap:wrap; margin-bottom:12px; }
.bf-tools input,.bf-tools select{ width:auto; flex:1; min-width:150px; }

.stat.pos .value{ color:var(--green); }
.stat.neg .value{ color:var(--red); }

.salary-paid{ color:var(--green); font-weight:800; }
.salary-unpaid{ color:var(--red); font-weight:800; }

/* receipt / print sheet */
.receipt{
  max-width:320px;
  margin:0 auto;
  font-family:Arial,sans-serif;
  color:#000;
  font-size:12px;
}
.receipt .receipt-top-web{ text-align:center; font-size:12px; font-weight:700; letter-spacing:0.4px; margin:0 0 2px 0; color:#000; }
.receipt .receipt-top-phone{ text-align:center; font-size:13px; font-weight:800; letter-spacing:0.5px; margin:0 0 6px 0; color:#000; }
.receipt h2{ text-align:center; font-size:17px; margin:0; }
.receipt p{ text-align:center; margin:4px 0; }
.receipt hr{ border:0; border-top:1px dashed #555; margin:9px 0; }
.receipt table{ min-width:0; font-size:12px; }
.receipt th,.receipt td{ padding:5px 1px; border-bottom:1px dashed #aaa; background:#fff; color:#000; }
.receipt .total{ font-size:14px; font-weight:800; }

/* --- thermal receipt line items --- */
.receipt .kv{ display:flex; justify-content:space-between; gap:8px; margin:1px 0; }
.receipt .kv span{ color:#333; }
.receipt .kv b{ text-align:right; }
.receipt .ttl{ text-align:center; font-weight:800; letter-spacing:.6px; margin:6px 0; }
.receipt .grand{ text-align:right; font-weight:800; font-size:13px; margin:3px 0; }
.receipt .right{ text-align:right; white-space:nowrap; }
.receipt table th, .receipt table td{ padding:4px 1px; }

/* toast + modal */
.toast{
  position:fixed;
  right:18px;
  bottom:18px;
  background:#14263d;
  color:#fff;
  padding:12px 16px;
  border-radius:9px;
  border-left:4px solid var(--gold);
  box-shadow:0 5px 25px #0002;
  display:none;
  z-index:50;
}

.modal-backdrop{
  display:none;
  position:fixed;
  inset:0;
  background:#0d1b2acc;
  z-index:30;
  align-items:center;
  justify-content:center;
  padding:15px;
}
.modal-backdrop.show{ display:flex; }

.modal{
  background:#fff;
  border-radius:16px;
  padding:20px;
  max-width:650px;
  width:100%;
  max-height:90vh;
  overflow:auto;
}
.modal h3{ margin-top:0; }

.close-row{ display:flex; justify-content:space-between; align-items:center; }
.close-row button{ background:#e9eef8; color:#233b65; }

/* ---------- 7. DASHBOARD WIDGETS ---------- */
.dash-stat{ display:flex; gap:14px; align-items:center; min-width:0; }
.dash-stat > div{ min-width:0; flex:1; }
.dash-stat .ico{
  width:46px;
  height:46px;
  border-radius:12px;
  display:grid;
  place-items:center;
  flex:none;
  transition:transform .2s;
}
.dash-stat:hover .ico{ transform:scale(1.1) rotate(-5deg); }
.dash-stat .ico .ic{ width:22px; height:22px; }
.dash-stat .label{ overflow:hidden; text-overflow:ellipsis; }
.dash-stat .value{ margin-top:2px; font-size:21px; overflow-wrap:anywhere; }

.c-t{ background:#dff1f3; color:#0e7c8c; }
.c-g{ background:#dcf5e7; color:#16804a; }
.c-y{ background:#fff0c9; color:#a56a00; }
.c-p{ background:#f0e1fb; color:#7047c8; }
.c-r{ background:#fde2e0; color:#c62828; }
.c-b{ background:#dde8ff; color:#2457d6; }

.ic{ width:18px; height:18px; flex:none; }
span[data-ic]{ display:inline-flex; }
button>span[data-ic]{ margin-right:7px; vertical-align:-3px; }
nav button>span[data-ic]{ margin:0; }

/* ---------- 8. RESPONSIVE (desktop / laptop / tablet / mobile) & PRINT ---------- */
html {
  -webkit-text-size-adjust: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
button, input, select, textarea { touch-action: manipulation; }

/* Global container constraints & scrolling */
.layout, main, .page, .panel, .section-grid, .cards, .cards-3, .dash-section {
  min-width: 0;
  max-width: 100%;
}
.stat, .panel { min-width: 0; }

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
  position: relative;
  border-radius: 8px;
}
.table-wrap::-webkit-scrollbar { height: 6px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb { background: #c5d3d8; border-radius: 4px; }
html[data-theme="dark"] .table-wrap::-webkit-scrollbar-thumb { background: #2d424c; }

/* hamburger + drawer overlay (hidden on desktop/laptop) */
.menu-toggle {
  display: none;
  flex: none;
  width: 42px;
  height: 42px;
  padding: 0;
  align-items: center;
  justify-content: center;
  background: #ffffff14;
  border: 1px solid #ffffff30;
  border-radius: 10px;
  font-size: 22px;
  line-height: 1;
  color: #fff;
  cursor: pointer;
}
.menu-toggle:hover { transform: none; box-shadow: none; }
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #050f14b3;
  backdrop-filter: blur(2px);
  z-index: 40;
}
.nav-overlay.show { display: block; }

/* =========================================================================
   DEVICE BREAKPOINTS
   ========================================================================= */

/* ---- 1. Large desktop PC (>=1400px) ---- */
@media (min-width: 1400px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  main { padding: 28px 36px; }
  .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .room-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .section-grid { grid-template-columns: 1.15fr 0.85fr; }
}

/* ---- 2. Standard Laptop / Desktop (1151px - 1399px) ---- */
@media (max-width: 1399px) and (min-width: 1151px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); }
  main { padding: 20px 24px; }
  header h1 { font-size: 21px; }
  .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .room-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .section-grid { grid-template-columns: 1.15fr 0.85fr; }
}

/* ---- 3. Small Laptop / Large Tablet Landscape (1001px - 1150px) ---- */
@media (max-width: 1150px) and (min-width: 1001px) {
  .layout { grid-template-columns: 200px minmax(0, 1fr); }
  main { padding: 18px 20px; }
  header h1 { font-size: 20px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .room-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .section-grid { grid-template-columns: 1fr; gap: 16px; }
}

/* ---- 4. Tablet & below (<=1000px): Sidebar becomes slide-in drawer ---- */
@media (max-width: 1000px) {
  header {
    position: sticky;
    top: 0;
    z-index: 35;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    flex-wrap: nowrap;
  }
  .menu-toggle { display: inline-flex; }
  .hd-brand { min-width: 0; flex: 1; }
  .hd-brand > div { min-width: 0; }
  header h1 { font-size: 20px; }
  header p { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .logo { width: 44px; height: 44px; }
  .hd-right { flex: none; display: flex; align-items: center; gap: 8px; }

  .layout { grid-template-columns: 1fr; min-height: 0; }

  aside {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 85vw);
    z-index: 50;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: calc(18px + env(safe-area-inset-top, 0px)) 12px 24px;
    transform: translateX(-105%);
    transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: none;
  }
  aside.open {
    transform: none;
    box-shadow: 10px 0 35px rgba(0,0,0,0.45);
  }
  nav { display: block; }
  nav button { min-height: 46px; }
  #nav > button[data-page] { width: 100%; margin: 4px 0; }
  .nav-dropdown-wrap { margin: 4px 0; }
  .nav-dropdown-toggle { width: 100%; min-height: 46px; }
  .nav-dropdown-menu {
    position: static;
    min-width: 0;
    margin: 4px 0 4px 14px;
    box-shadow: none;
    background: #ffffff0d;
  }
  .nav-dropdown-menu button { min-height: 42px; }
  body.nav-open { overflow: hidden; }

  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .room-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .section-grid { grid-template-columns: 1fr; }

  /* Comfortable touch targets on mobile/tablet */
  button { min-height: 42px; }
  button.small, .room .room-actions button { min-height: 34px; }
  input, select, textarea { font-size: 16px; min-height: 42px; } /* Stops iOS zoom-on-focus */
  .toast {
    left: 14px;
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    text-align: center;
  }
}

/* ---- 5. Tablet Portrait (601px - 768px) ---- */
@media (max-width: 768px) {
  main { padding: 16px; }
  .header-tag { display: none; }
  .room-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .bf-tools input, .bf-tools select { min-width: 130px; }
  .bf-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .bf-tabs::-webkit-scrollbar { display: none; }
  .page-title { gap: 10px; }
  .page-title h2 { font-size: 21px; }
}

/* ---- 6. Mobile Phone (<=600px) ---- */
@media (max-width: 600px) {
  main {
    padding: 12px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
  header {
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    flex-wrap: wrap;
    gap: 8px;
  }
  .hd-brand { min-width: 0; flex: 1 1 auto; gap: 10px; }
  header h1 { font-size: 18px; margin-bottom: 1px; }
  header p { display: none; }
  .logo { width: 38px; height: 38px; }
  .menu-toggle { width: 38px; height: 38px; font-size: 19px; }
  .hd-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    justify-content: flex-end;
  }
  .theme-toggle { padding: 6px 10px; font-size: 11px; border-radius: 14px; }
  .admin-badge { padding: 4px 8px; font-size: 11px; gap: 4px; }
  .admin-badge strong {
    max-width: 75px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
  }
  .admin-logout-btn { padding: 4px 8px !important; font-size: 11px !important; }

  .cards { gap: 8px; }
  .cards-3 { grid-template-columns: 1fr; gap: 8px; }
  .stat { padding: 12px; border-radius: 11px; }
  .stat .value { font-size: 20px; }
  .panel { padding: 14px 12px; border-radius: 12px; margin-bottom: 14px; }
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .form-grid .full { grid-column: auto; }
  .page-title h2 { font-size: 19px; }
  .page-title > * { max-width: 100%; }
  .page-title .actions { width: 100%; margin-top: 6px !important; }
  .page-title .actions > button { flex: 1 1 100%; }
  .actions { gap: 8px; }
  .actions > button, .actions > label { flex: 1 1 130px; }

  .bf-tools { flex-direction: column; gap: 8px; align-items: stretch; }
  .bf-tools input, .bf-tools select, .bf-tools button {
    width: 100% !important;
    min-width: 0 !important;
    flex: none;
  }
  #finPeriod { width: 100% !important; min-width: 0 !important; }
  #attendanceSearch { width: 100% !important; min-width: 0 !important; }

  .bf-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .bf-tabs::-webkit-scrollbar { display: none; }
  .bf-tabs button { padding: 10px 14px; flex: 0 0 auto; white-space: nowrap; }

  .dash-stat .ico { width: 40px; height: 40px; border-radius: 10px; }
  .dash-section { padding: 12px 12px 4px; border-radius: 12px; margin-bottom: 14px; }
  .dash-stat .value { font-size: 18px; }

  th, td { padding: 9px 8px; }
  .table-wrap {
    -webkit-overflow-scrolling: touch;
    margin-left: -2px;
    margin-right: -2px;
  }
  .row-actions { flex-wrap: nowrap; }

  /* Room card actions stacked cleanly on mobile */
  .room { padding: 10px; min-height: 110px; }
  .room .room-actions { gap: 6px; }
  .room .room-actions button {
    flex: 1 1 calc(50% - 4px);
    padding: 6px 4px;
    font-size: 11px;
    text-align: center;
  }

  /* Modal becomes an elegant bottom sheet */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---- 7. Small phones (<=460px) ---- */
@media (max-width: 460px) {
  .cards { grid-template-columns: 1fr; }
  .cards-3 { grid-template-columns: 1fr; }
  .room-grid { grid-template-columns: 1fr; gap: 10px; }
  .room .room-actions button {
    flex: 1 1 auto;
    min-width: 0;
  }
  .admin-login-card {
    padding: 22px 16px;
    border-radius: 14px;
  }
  .admin-login-logo { width: 60px; height: 60px; margin-bottom: 10px; }
  .admin-login-title { font-size: 20px; }
  .admin-login-subtitle { font-size: 12px; margin-bottom: 16px; }
}

/* ---- 8. Ultra Small Phones (<=360px) ---- */
@media (max-width: 360px) {
  header { padding: 8px 10px; }
  .hd-brand h1 { font-size: 16px; }
  .logo { width: 34px; height: 34px; }
  .menu-toggle { width: 34px; height: 34px; font-size: 17px; }
  .hd-right { width: 100%; justify-content: flex-end; margin-top: 4px; }
  .actions > button, .actions > label { flex: 1 1 100%; }
}

/* ---- Landscape phones: keep the drawer scrollable & modal short ---- */
@media (max-height: 480px) and (orientation: landscape) {
  .modal { max-height: 96vh; }
  aside { padding-top: 10px; }
}

/* ---- Touch devices: no sticky hover lift ---- */
@media (hover: none) {
  button:hover, .stat:hover, .room:hover, nav button:hover { transform: none; box-shadow: none; }
}

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

@media print{
  body{ background:#fff; }
  .no-print,header,aside,main>.page-title,.cards,.panel:not(.print-panel),
  .modal-backdrop,.toast,.menu-toggle,.nav-overlay{ display:none!important; }
  .layout{ display:block; }
  main{ padding:0; }
  .page{ display:none!important; }
  #printPage{ display:block!important; }
  .print-panel{ display:block!important; border:0; box-shadow:none; padding:0; margin:0; }
  .receipt{ width:76mm; max-width:76mm; padding:2mm; margin:0 auto; font-size:11px; }
  .receipt h2{ font-size:16px; }
  .receipt-logo{ display:flex; justify-content:center; margin:0 auto 5px; }
  .receipt-logo img{ width:17mm; height:17mm; object-fit:contain; display:block; }
  .receipt table{ width:100%; }
  @page{ size:80mm auto; margin:0; }
}


/* ---------- DARK MODE THEME COLORS ---------- */
@media screen{
  html[data-theme="dark"]{
    --bg:#0f1a20; --text:#e3edf0; --muted:#93a8b0; --line:#25363f; --white:#16252d;
  }
  html[data-theme="dark"] body{ background:var(--bg); color:var(--text); }
  html[data-theme="dark"] .stat,
  html[data-theme="dark"] .panel,
  html[data-theme="dark"] .room,
  html[data-theme="dark"] .modal{ background:#16252d; border-color:var(--line); color:var(--text); }
  html[data-theme="dark"] input,
  html[data-theme="dark"] select,
  html[data-theme="dark"] textarea{ background:#0f1a20; color:var(--text); border-color:#2d424c; }
  html[data-theme="dark"] label{ color:#a9bdc4; }
  html[data-theme="dark"] th{ background:#1b2c35; color:#a9bdc4; }
  html[data-theme="dark"] tbody tr:hover{ background:#1b2c35; }
  html[data-theme="dark"] button.secondary{ background:#23404a; color:#cfe6ea; }
  html[data-theme="dark"] button.ghost{ background:#16252d; color:#cfe0e6; border-color:#2d424c; }
  html[data-theme="dark"] button.ghost:hover{ background:#1f333d; }
  html[data-theme="dark"] .close-row button{ background:#23404a; color:#cfe6ea; }
  html[data-theme="dark"] .notice{ background:#13333a; border-color:#1f5560; color:#a8dbe2; }
  html[data-theme="dark"] .nights-hint{ background:#23404a; border-color:#2d5560; color:#cfe6ea; }
  html[data-theme="dark"] .bf-sum{ background:#1b2c35; }
  html[data-theme="dark"] .stat:hover{ border-color:#2f6470; }
  html[data-theme="dark"] .bf-tabs button.on{ color:#4fc3d4; border-bottom-color:#4fc3d4; }
  html[data-theme="dark"] .danger-text{ color:#ff8a80; }
  html[data-theme="dark"] .c-t{ background:#15383f; color:#4fc3d4; }
  html[data-theme="dark"] .c-g{ background:#15342550; color:#5bd490; }
  html[data-theme="dark"] .c-y{ background:#3a3015; color:#f0bf55; }
  html[data-theme="dark"] .c-p{ background:#2d2140; color:#b394f0; }
  html[data-theme="dark"] .c-r{ background:#3d2020; color:#ff8a80; }
  html[data-theme="dark"] .c-b{ background:#1c2b4d; color:#82a6ff; }
  html[data-theme="dark"] .available,html[data-theme="dark"] .ready,html[data-theme="dark"] .paid{ background:#15402a; color:#5bd490; }
  html[data-theme="dark"] .waiting,html[data-theme="dark"] .partial{ background:#40340f; color:#f0bf55; }
  html[data-theme="dark"] .booked{ background:#1c2b4d; color:#82a6ff; }
  html[data-theme="dark"] .occupied{ background:#33204a; color:#c9a0f0; }
  html[data-theme="dark"] .cleaning,html[data-theme="dark"] .unpaid{ background:#431f1f; color:#ff8a80; }
  /* the receipt sheet always stays white/black like real paper */
  html[data-theme="dark"] .receipt{ background:#fff; padding:10px; border-radius:8px; }
}

/* ---- Dashboard: separate Revenue / Expenses sections ---- */
.cards-3{ grid-template-columns:repeat(3,minmax(0,1fr)); }
.dash-section{
  background:#fff; border:1px solid var(--line); border-radius:14px;
  padding:16px 16px 4px; margin-bottom:18px; box-shadow:0 1px 3px #0b2a3510;
}
.dash-section-head{ display:flex; align-items:center; gap:12px; margin-bottom:14px; }
.dash-section-head h3{ margin:0; font-size:16px; }
.dash-section-ico{
  width:38px; height:38px; border-radius:10px; display:grid; place-items:center;
  background:#dff1f3; color:var(--blue); flex:none;
}
.dash-section-ico .ic{ width:20px; height:20px; }
.dash-rev{ border-left:4px solid var(--green); }
.dash-rev .dash-section-ico{ background:#dcf5e7; color:var(--green); }
.dash-rev .stat{ border-top-color:var(--green); }
.dash-rev .stat .value{ color:var(--green); }
.dash-exp{ border-left:4px solid var(--red); }
.dash-exp .dash-section-ico{ background:#fde2e0; color:var(--red); }
.dash-exp .stat{ border-top-color:var(--red); }
.dash-exp .stat .value{ color:var(--red); }
.dash-section .stat{ box-shadow:none; background:#fafcfd; }
@media screen{
  html[data-theme="dark"] .dash-section{ background:#16252d; border-color:var(--line); }
  html[data-theme="dark"] .dash-section .stat{ background:#1a2d36; }
  html[data-theme="dark"] .dash-rev .dash-section-ico{ background:#15342550; color:#5bd490; }
  html[data-theme="dark"] .dash-exp .dash-section-ico{ background:#3d2020; color:#ff8a80; }
  html[data-theme="dark"] .dash-rev .stat .value{ color:#5bd490; }
  html[data-theme="dark"] .dash-exp .stat .value{ color:#ff8a80; }
}


/* ---------- 9. ADMIN LOGIN OVERLAY & LOGOUT ---------- */
.admin-login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 42, 53, 0.95);
  backdrop-filter: blur(8px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  opacity: 1;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.admin-login-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.admin-login-card {
  width: 100%;
  max-width: 420px;
  margin: auto;
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.35);
  padding: 32px 28px;
  border-top: 5px solid var(--gold);
  text-align: center;
  animation: loginCardPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes loginCardPop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.admin-login-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 14px;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.15));
}
.admin-login-title {
  margin: 0 0 4px;
  font-size: 24px;
  color: var(--navy);
  font-weight: 800;
}
.admin-login-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 22px;
}
.admin-login-form {
  text-align: left;
}
.admin-login-form .form-group {
  margin-bottom: 16px;
}
.admin-login-form label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}
.admin-login-form input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdfdfd;
  font-size: 14px;
  transition: border-color .2s;
}
.admin-login-form input:focus {
  border-color: var(--blue);
  outline: none;
}
.admin-login-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 10px;
  background: linear-gradient(135deg, var(--blue), var(--navy));
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}
.admin-login-error {
  background: #ffebee;
  color: var(--red);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
  border: 1px solid #ffcdd2;
}
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  color: #fff;
}
.admin-logout-btn {
  background: #c62828 !important;
  color: #fff !important;
  padding: 6px 12px !important;
  font-size: 12px !important;
  border-radius: 6px !important;
  cursor: pointer;
}
.admin-logout-btn:hover {
  background: #b71c1c !important;
}
html[data-theme="dark"] .admin-login-card {
  background: #16252d;
  border-color: #243b47;
}
html[data-theme="dark"] .admin-login-title {
  color: #fff;
}
html[data-theme="dark"] .admin-login-form input {
  background: #111e24;
  color: #fff;
  border-color: #243b47;
}
html[data-theme="dark"] .admin-login-error {
  background: #3d2020;
  color: #ff8a80;
  border-color: #5c2828;
}
