/* The Chennai Residency HMS – maroon & gold brand, light and dark themes */
:root {
  --brand: #6b0f1f; --brand-2: #8a1a2e; --brand-ink: #fff; --gold: #c79a3b; --gold-soft: #f4e3bd;
  --bg: #f5f2ee; --panel: #ffffff; --panel-2: #faf7f3; --line: #e6ddd3; --line-2: #d8cbbd;
  --ink: #23191a; --ink-2: #5d5050; --ink-3: #8b7d7b; --focus: #c79a3b;
  --ok: #2e7d4f; --ok-bg: #e5f4ea; --warn: #b26a00; --warn-bg: #fff2dc; --bad: #c62839; --bad-bg: #fde6e8; --info: #1f63b5; --info-bg: #e3eefb;
  --shadow: 0 1px 2px rgba(40, 20, 20, .06), 0 6px 18px rgba(40, 20, 20, .06);
  --radius: 10px; --side: 236px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #161112; --panel: #211a1b; --panel-2: #1b1516; --line: #3a2e2f; --line-2: #4a3b3c;
  --ink: #f3ebe6; --ink-2: #cdbfba; --ink-3: #9a8b88; --brand: #9b2338; --brand-2: #b3304a;
  --ok-bg: #173323; --warn-bg: #3a2a0f; --bad-bg: #3d1419; --info-bg: #13263d; --ok: #6fd39a; --warn: #f0b75a; --bad: #ff7a87; --info: #7fb4f2;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3); color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161112; --panel: #211a1b; --panel-2: #1b1516; --line: #3a2e2f; --line-2: #4a3b3c;
    --ink: #f3ebe6; --ink-2: #cdbfba; --ink-3: #9a8b88; --brand: #9b2338; --brand-2: #b3304a;
    --ok-bg: #173323; --warn-bg: #3a2a0f; --bad-bg: #3d1419; --info-bg: #13263d; --ok: #6fd39a; --warn: #f0b75a; --bad: #ff7a87; --info: #7fb4f2;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-2); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
.muted { color: var(--ink-3); } .small { font-size: 12px; } .nowrap { white-space: nowrap; } .right { text-align: right; } .center { text-align: center; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: linear-gradient(180deg, #4a0a16, #2b0610); color: #f3e3d0; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side .brand { display: flex; gap: 10px; align-items: center; padding: 16px 16px 14px; border-bottom: 1px solid rgba(199,154,59,.3); }
.side .brand img { width: 34px; height: 34px; object-fit: contain; background: #fff8ec; border-radius: 8px; padding: 3px; }
.side .brand b { font: italic 700 15px/1.1 var(--serif); color: #f6d58d; display: block; }
.side .brand span { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: #d9bfa3; }
.nav { padding: 8px 8px 16px; flex: 1; }
.nav .grp { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: #c9a98d; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; color: #f1e2d4; text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; }
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a.active { background: linear-gradient(90deg, rgba(199,154,59,.28), rgba(199,154,59,.08)); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav a .ic { width: 18px; text-align: center; opacity: .9; }
.nav a .badge { margin-left: auto; }
.side .foot { padding: 10px 16px 14px; font-size: 11px; color: #bfa48c; border-top: 1px solid rgba(199,154,59,.2); }

.main-col { min-width: 0; }
.top { position: sticky; top: 0; z-index: 30; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 8px 18px; min-height: 56px; }
.top .bd { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 5px 10px; }
.top .bd small { display: block; font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; }
.top .bd b { font-size: 13px; white-space: nowrap; }
.top .spacer { flex: 1; }
.top .search { position: relative; flex: 0 1 320px; }
.top .search input { padding-left: 32px; }
.top .search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.top .user { display: flex; align-items: center; gap: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.iconbtn { position: relative; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; font-size: 16px; }
.iconbtn:hover { background: var(--panel-2); }
.iconbtn .dot { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.menu-toggle { display: none; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.live.on i { background: #2fb466; box-shadow: 0 0 0 3px rgba(47,180,102,.2); }
main.page { padding: 18px; max-width: 1500px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { font-family: var(--serif); font-size: 22px; color: var(--brand-2); }
:root[data-theme="dark"] .page-head h1 { color: #f1c97d; }
.page-head .sub { color: var(--ink-3); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- controls ---------- */
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; min-height: 36px; }
textarea { min-height: 64px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--brand); }
label.f { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field { margin-bottom: 10px; min-width: 0; }
.field .hint { font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.req::after { content: " *"; color: var(--bad); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 12px; }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; } .spanall { grid-column: 1 / -1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; min-height: 36px; font: 600 13px var(--font); cursor: pointer; background: var(--brand); color: var(--brand-ink); text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--brand-2); }
.btn.gold { background: var(--gold); color: #2a1a05; } .btn.gold:hover { filter: brightness(1.05); }
.btn.ghost { background: var(--panel); color: var(--ink); border-color: var(--line-2); } .btn.ghost:hover { background: var(--panel-2); }
.btn.ok { background: var(--ok); color: #fff; } .btn.danger { background: var(--bad); color: #fff; }
.btn.wa { background: #1f9d55; color: #fff; }
.btn.sm { padding: 4px 9px; min-height: 28px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: transparent; padding: 7px 12px; font: 600 12.5px var(--font); color: var(--ink-2); cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: var(--panel); border-radius: 999px; padding: 4px 11px; font-size: 12px; cursor: pointer; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; } .badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; } .badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge.gold { background: var(--gold-soft); color: #6b4a0b; border-color: transparent; }

/* ---------- cards & tables ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; min-width: 0; }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { font-size: 15px; } .card-head .actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.cols { display: grid; gap: 14px; }
.cols.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols.c21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } .cols.c12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi small { display: block; color: var(--ink-3); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi b { display: block; font-size: 24px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; color: var(--ink-3); }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--gold)); }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); background: var(--panel-2); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--panel-2); }
.tbl tfoot td { font-weight: 700; background: var(--panel-2); border-top: 2px solid var(--line-2); }
.tbl tr.rev td { color: var(--ink-3); text-decoration: line-through; }
.tbl tr.planned td { color: var(--ink-3); font-style: italic; }
.tbl tr.click { cursor: pointer; }
.empty { padding: 28px 12px; text-align: center; color: var(--ink-3); }
.list { display: flex; flex-direction: column; gap: 8px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; }
.alert .lv { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--info); }
.alert.critical { background: var(--bad-bg); border-color: transparent; } .alert.critical .lv { background: var(--bad); }
.alert.warning { background: var(--warn-bg); border-color: transparent; } .alert.warning .lv { background: var(--warn); }
.alert .act { margin-left: auto; flex: none; }
.feed { display: flex; flex-direction: column; }
.feed .it { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.feed .it:last-child { border-bottom: 0; }
.feed .t { color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.note { background: var(--info-bg); color: var(--ink); border-radius: 9px; padding: 9px 12px; font-size: 12.5px; }
.note.warn { background: var(--warn-bg); } .note.bad { background: var(--bad-bg); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; font-weight: 600; }

/* ---------- room grid (tape chart) ---------- */
.grid-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.grid-toolbar input[type=date] { width: 150px; }
.tape { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); max-height: calc(100vh - 230px); }
.tape .r { display: grid; grid-template-columns: 112px repeat(var(--days), minmax(56px, 1fr)); min-width: calc(112px + var(--days) * 56px); position: relative; }
.tape .hd { position: sticky; top: 0; z-index: 6; background: var(--panel-2); }
.tape .hd > div { padding: 6px 4px; text-align: center; font-size: 11px; color: var(--ink-3); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tape .hd > div b { display: block; color: var(--ink); font-size: 13px; }
.tape .hd > div.today { background: var(--gold-soft); color: #6b4a0b; } .tape .hd > div.today b { color: #6b4a0b; }
.tape .hd > div.wk { background: color-mix(in srgb, var(--panel-2) 80%, var(--brand) 6%); }
.tape .room { position: sticky; left: 0; z-index: 4; background: var(--panel); border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line); padding: 6px 8px; display: flex; flex-direction: column; justify-content: center; grid-row: 1; grid-column: 1; }
.tape .room b { font-size: 14px; } .tape .room small { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tape .room .hk { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-left: 4px; vertical-align: middle; }
.tape .cell { grid-row: 1; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-height: 42px; cursor: pointer; }
.tape .cell:hover { background: var(--panel-2); }
.tape .cell.today { background: rgba(199, 154, 59, .10); }
.tape .bar { grid-row: 1; z-index: 3; margin: 6px 3px; border-radius: 7px; padding: 4px 8px; font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.18); display: flex; align-items: center; gap: 6px; }
.tape .bar .tag { font-size: 9.5px; font-weight: 800; background: rgba(255,255,255,.28); padding: 1px 5px; border-radius: 4px; }
.tape .bar.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; }
.tape .bar.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }
.tape .bar.style-border { background: var(--panel) !important; color: var(--ink); border: 2px solid var(--c); }
.tape .grp-row { display: flex; position: sticky; left: 0; background: var(--panel-2); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); padding: 6px 10px; border-bottom: 1px solid var(--line); min-width: calc(112px + var(--days) * 56px); }
.legend { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.ctx { position: fixed; z-index: 90; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 12px 34px rgba(0,0,0,.22); padding: 6px; min-width: 210px; }
.ctx .h { font-size: 11px; color: var(--ink-3); padding: 4px 10px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.ctx button { display: flex; width: 100%; gap: 10px; align-items: center; border: 0; background: none; padding: 8px 10px; border-radius: 7px; font: 13px var(--font); color: var(--ink); cursor: pointer; text-align: left; }
.ctx button:hover { background: var(--panel-2); }
.tip { position: fixed; z-index: 95; pointer-events: none; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.2); padding: 10px 12px; font-size: 12.5px; min-width: 240px; max-width: 320px; }
.tip h4 { margin-bottom: 6px; font-size: 14px; }

/* ---------- room board tiles ---------- */
.floor { margin-bottom: 16px; }
.floor h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); margin: 0 0 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { border-radius: 11px; padding: 10px 11px; background: var(--panel); border: 1px solid var(--line); border-top: 5px solid var(--c); cursor: pointer; box-shadow: var(--shadow); min-height: 104px; display: flex; flex-direction: column; gap: 3px; position: relative; text-align: left; font: inherit; color: inherit; }
.tile:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(0,0,0,.12); }
.tile.full { background: var(--c); color: #fff; border-color: transparent; }
.tile.full .muted { color: rgba(255,255,255,.85); }
.tile .no { font-size: 22px; font-weight: 800; line-height: 1; }
.tile .st { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--c); }
.tile.full .st { color: #fff; }
.tile .gname { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .req { position: absolute; top: 8px; right: 8px; }

/* ---------- modal & drawer ---------- */
.overlay { position: fixed; inset: 0; z-index: 85; background: rgba(20, 8, 10, .5); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 16px; overflow-y: auto; animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--panel); border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.35); width: min(620px, 100%); display: flex; flex-direction: column; max-height: 92vh; }
.modal.wide { width: min(980px, 100%); } .modal.xwide { width: min(1180px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, var(--brand), #3d0710); color: #fff; border-radius: 14px 14px 0 0; }
.modal-head h2 { font-size: 16px; } .modal-head .sub { font-size: 12px; opacity: .8; }
.modal-head .x { margin-left: auto; background: rgba(255,255,255,.14); border: 0; color: #fff; width: 32px; height: 32px; border-radius: 8px; font-size: 18px; cursor: pointer; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.modal-foot .left { margin-right: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(860px, 100%); z-index: 72; background: var(--bg); box-shadow: -18px 0 50px rgba(0,0,0,.3); display: flex; flex-direction: column; animation: slide .16s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: .4; } }
.drawer-head { background: linear-gradient(90deg, var(--brand), #3d0710); color: #fff; padding: 14px 18px; display: flex; gap: 14px; align-items: center; }
.drawer-head .roomno { font-size: 30px; font-weight: 800; background: rgba(255,255,255,.12); border-radius: 10px; padding: 4px 12px; }
.drawer-head .x { margin-left: auto; background: rgba(255,255,255,.14); border: 0; color: #fff; width: 34px; height: 34px; border-radius: 8px; font-size: 18px; cursor: pointer; }
.drawer-body { overflow-y: auto; padding: 14px 18px; flex: 1; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 12px; font: 600 13px var(--font); color: var(--ink-3); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--brand-2); border-bottom-color: var(--gold); }
:root[data-theme="dark"] .tabs button.on { color: #f1c97d; }
.ci { display: grid; grid-template-columns: 270px 1fr; min-height: 0; }
.ci-side { background: linear-gradient(180deg, #3a0711, #1e0409); color: #f6e7d6; padding: 18px; border-radius: 0 0 0 14px; }
.ci-side .big { font-size: 44px; font-weight: 800; text-align: center; letter-spacing: .02em; color: #fff; background: rgba(255,255,255,.07); border: 1px solid rgba(199,154,59,.4); border-radius: 12px; padding: 8px; }
.ci-side .typ { text-align: center; margin: 8px 0 14px; } .ci-side .typ span { background: rgba(199,154,59,.25); color: #f6d58d; border-radius: 999px; padding: 3px 12px; font-size: 12px; font-weight: 700; }
.ci-side dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; font-size: 12.5px; margin: 0; }
.ci-side dt { color: #cfb59d; } .ci-side dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.ci-side .tot { border-top: 1px solid rgba(199,154,59,.35); margin-top: 10px; padding-top: 10px; font-size: 18px; font-weight: 800; color: #f6d58d; display: flex; justify-content: space-between; }
.ci-main { padding: 14px 18px; overflow-y: auto; max-height: calc(92vh - 140px); }
.sec { border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px 4px; margin-bottom: 12px; background: var(--panel); }
.sec > h3 { font-size: 13px; color: var(--brand-2); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
:root[data-theme="dark"] .sec > h3 { color: #f1c97d; }
.room-line { display: grid; grid-template-columns: 1.4fr 1fr .7fr .7fr .7fr auto; gap: 8px; align-items: end; padding-bottom: 8px; border-bottom: 1px dashed var(--line); margin-bottom: 8px; }
.found { border: 1px solid var(--gold); background: rgba(199, 154, 59, .14); color: var(--ink); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.cam { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.cam video, .cam img.ph { width: 160px; height: 120px; object-fit: cover; border-radius: 9px; background: #000; border: 1px solid var(--line); }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 120; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: #2a1d1e; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.3); font-size: 13px; border-left: 4px solid var(--gold); animation: fade .15s; }
.toast.ok { border-left-color: #2fb466; } .toast.bad { border-left-color: #ff5a6a; }
.chatbox { position: fixed; right: 16px; top: 64px; width: min(360px, calc(100vw - 32px)); height: min(520px, calc(100vh - 90px)); z-index: 60; background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.25); display: flex; flex-direction: column; }
.chatbox .msgs { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.chatbox .msg { max-width: 85%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 13px; }
.chatbox .msg.me { align-self: flex-end; background: var(--gold-soft); color: #2a1a05; border-color: transparent; }
.chatbox .msg small { display: block; font-size: 10.5px; color: var(--ink-3); }
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(120% 90% at 50% 0%, #7a1626 0%, #2b0610 70%); padding: 16px; }
.login .box { width: min(400px, 100%); background: rgba(255,250,244,.97); border-radius: 18px; padding: 28px; box-shadow: 0 30px 70px rgba(0,0,0,.45); color: #23191a; }
.login .box input { background: #fff; color: #23191a; border-color: #d8cbbd; }
.login h1 { font: italic 700 24px var(--serif); color: #6b0f1f; text-align: center; margin-top: 10px; }
.login .tag { text-align: center; font-size: 11px; letter-spacing: .25em; text-transform: uppercase; color: #8b6b4a; margin: 4px 0 20px; }
.login img { display: block; margin: 0 auto; width: 64px; }
.chk-item { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); align-items: center; }
.chk-item .nm b { display: block; } .chk-item .nm small { color: var(--ink-3); }
.chk-item .extra { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.svgchart { width: 100%; height: auto; display: block; }
.bar-legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.bar-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

@media (max-width: 1100px) {
  .cols.c3 { grid-template-columns: 1fr 1fr; } .cols.c21, .cols.c12 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 80; transform: translateX(-100%); transition: transform .18s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  .menu-toggle { display: grid; }
  .top { padding: 8px 12px; gap: 6px; } .top .search { display: none; } .top .bd small { display: none; } .live span { display: none; }
  .top .bd { padding: 4px 8px; } .top .bd b { white-space: nowrap; font-size: 12px; } .top .bd > span { display: none; }
  .top .bd + .bd, #topBook, #themeBtn, .top .user { display: none; }
  .top .btn { padding: 6px 10px; min-height: 34px; } .iconbtn { width: 34px; height: 34px; }
  main.page { padding: 12px 16px; }
  .cols.c2, .cols.c3 { grid-template-columns: 1fr; }
  .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ci { grid-template-columns: 1fr; } .ci-side { border-radius: 0; } .ci-main { max-height: none; }
  .room-line { grid-template-columns: 1fr 1fr; }
  .modal-body, .ci-main { padding: 12px; }
  .top .user .who { display: none; }
}
@media (max-width: 520px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } .span2, .span3 { grid-column: auto; } .kpi b { font-size: 20px; } }
@media print { .side, .top, .no-print { display: none !important; } .shell { display: block; } body { background: #fff; } }

/* ===================== v4.1 – calendar, analysis tables ===================== */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-h { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); text-align: center; padding: 4px 0; }
.cal-day { min-height: 104px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day.blank { background: transparent; border-color: transparent; }
.cal-day.sel { box-shadow: inset 0 0 0 2px var(--brand-2); }
.cal-day[data-d]:hover { border-color: var(--gold); }
.cal-day.today { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: color-mix(in srgb, var(--gold-soft) 35%, var(--panel)); }
.cal-n { font-weight: 700; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.cal-occ { font-size: 10px; font-weight: 700; color: var(--info); background: var(--info-bg); border-radius: 999px; padding: 0 6px; }
.cal-ev { font-size: 10.5px; line-height: 1.3; padding: 2px 5px; border-radius: 5px; background: #f3e6f7; color: #6a1b7a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid #9c27b0; }
.cal-ev.eb { background: var(--bad-bg); color: var(--bad); border-left-color: var(--bad); font-weight: 700; }
.cal-ev.done { opacity: .55; text-decoration: line-through; }
.cal-ev.bill { background: var(--gold-soft); color: #6b4a0b; border-left-color: var(--gold); }
.cal-ev.stay { background: var(--info-bg); color: var(--info); border-left-color: var(--info); }
:root[data-theme="dark"] .cal-ev:not(.eb):not(.bill):not(.stay) { background: #3a2142; color: #e5b8f0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cal-ev:not(.eb):not(.bill):not(.stay) { background: #3a2142; color: #e5b8f0; } }
@media (max-width: 860px) { .cal { gap: 3px; } .cal-day { min-height: 70px; padding: 3px; } .cal-ev { font-size: 9px; padding: 1px 3px; } .cal-h { font-size: 9px; } }
.tbl.dense th, .tbl.dense td { padding: 5px 7px; font-size: 12px; }
.tbl.dense thead th { position: sticky; top: 0; z-index: 2; }
.hbar { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.hbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--gold)); border-radius: 99px; }
select[multiple] { min-height: 120px; padding: 4px; }
select[multiple] option { padding: 3px 6px; border-radius: 5px; }

/* ===================== v4.1 – elegance layer ===================== */
:root { --radius: 14px; --shadow: 0 1px 1px rgba(60, 20, 20, .04), 0 2px 6px rgba(60, 20, 20, .05), 0 12px 28px -12px rgba(60, 20, 20, .12); --ring: 0 0 0 3px rgba(199, 154, 59, .22); }
body { background: radial-gradient(1100px 520px at 100% -8%, rgba(199, 154, 59, .10), transparent 60%), radial-gradient(900px 480px at -10% 110%, rgba(107, 15, 31, .06), transparent 60%), var(--bg); background-attachment: fixed; letter-spacing: .005em; }
.side { background: linear-gradient(185deg, #551020 0%, #3a0913 45%, #22050c 100%); box-shadow: inset -1px 0 0 rgba(199, 154, 59, .22); }
.side .brand { padding: 18px 16px 16px; border-bottom: 0; background: linear-gradient(180deg, rgba(199, 154, 59, .10), transparent); position: relative; }
.side .brand::after { content: ""; position: absolute; left: 16px; right: 16px; bottom: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(246, 213, 141, .55), transparent); }
.side .brand img { width: 38px; height: 38px; border-radius: 10px; box-shadow: 0 4px 12px rgba(0, 0, 0, .35), 0 0 0 1px rgba(246, 213, 141, .4); }
.side .brand b { font-size: 16px; letter-spacing: .01em; }
.nav .grp { color: #d8b98c; opacity: .75; font-weight: 600; padding-top: 16px; }
.nav a { border-radius: 10px; padding: 7px 10px; transition: background .15s, color .15s, transform .15s; }
.nav a .ic { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; background: rgba(255, 255, 255, .05); font-size: 13px; flex: none; }
.nav a:hover { background: rgba(255, 255, 255, .06); transform: translateX(2px); }
.nav a.active { background: linear-gradient(90deg, rgba(246, 213, 141, .22), rgba(246, 213, 141, .04)); box-shadow: inset 2px 0 0 #f6d58d; }
.nav a.active .ic { background: linear-gradient(135deg, #f6d58d, #c79a3b); color: #3a1608; box-shadow: 0 2px 8px rgba(199, 154, 59, .45); }
.top { background: color-mix(in srgb, var(--panel) 82%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.top .bd { border-radius: 12px; background: linear-gradient(180deg, var(--panel), var(--panel-2)); }
.top .search input { border-radius: 999px; background: var(--panel-2); }
.page-head { padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid transparent; border-image: linear-gradient(90deg, rgba(199, 154, 59, .55), rgba(199, 154, 59, 0) 60%) 1; }
.page-head h1 { font-size: 26px; letter-spacing: .01em; }
.page-head .sub { max-width: 820px; line-height: 1.5; margin-top: 2px; }
.card { border-color: color-mix(in srgb, var(--line) 80%, transparent); }
.card-head h2, .card > h2 { font-family: var(--serif); font-style: italic; font-weight: 700; font-size: 17px; color: var(--brand-2); }
:root[data-theme="dark"] .card-head h2, :root[data-theme="dark"] .card > h2 { color: #f1c97d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .card-head h2, :root:not([data-theme="light"]) .card > h2, :root:not([data-theme="light"]) .page-head h1 { color: #f1c97d; } }
.kpi { border-radius: var(--radius); padding: 14px 16px 13px 18px; transition: transform .18s ease, box-shadow .18s ease; background: linear-gradient(160deg, var(--panel) 60%, color-mix(in srgb, var(--accent, var(--gold)) 7%, var(--panel))); }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -14px rgba(60, 20, 20, .28); }
.kpi::after { width: 3px; top: 12px; bottom: 12px; left: 0; border-radius: 0 3px 3px 0; }
.kpi b { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.tbl-wrap { border-radius: 12px; }
.tbl th { font-weight: 700; letter-spacing: .06em; font-size: 11px; }
.tbl tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--panel-2) 45%, transparent); }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--gold-soft) 30%, var(--panel)); }
:root[data-theme="dark"] .tbl tbody tr:hover td { background: #2b2223; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tbl tbody tr:hover td { background: #2b2223; } }
input, select, textarea { border-radius: 10px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: var(--ring); }
.btn { border-radius: 10px; transition: transform .12s, box-shadow .15s, background .15s, filter .15s; box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset, 0 2px 6px -2px rgba(107, 15, 31, .45); }
.btn:active { transform: translateY(1px); }
.btn.gold { background: linear-gradient(180deg, #e2bd67, #c79a3b); box-shadow: 0 1px 0 rgba(255, 255, 255, .35) inset, 0 3px 10px -3px rgba(199, 154, 59, .7); }
.btn.ghost { box-shadow: none; }
.btn.ok { box-shadow: 0 2px 8px -3px rgba(46, 125, 79, .6); }
.seg { border-radius: 11px; } .seg button.on, .chip.on { background: linear-gradient(180deg, var(--brand-2), var(--brand)); }
.tabs button { border-radius: 8px 8px 0 0; transition: color .15s, background .15s; }
.tabs button:hover { background: var(--panel-2); color: var(--ink); }
.overlay { background: radial-gradient(circle at 50% 20%, rgba(40, 10, 16, .45), rgba(20, 6, 9, .62)); backdrop-filter: blur(3px); }
.modal { border-radius: 18px; overflow: hidden; box-shadow: 0 40px 90px -20px rgba(0, 0, 0, .55), 0 0 0 1px rgba(199, 154, 59, .25); animation: pop .16s ease-out; }
@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: .3; } }
.modal-head, .drawer-head { background: linear-gradient(110deg, #6b0f1f 0%, #4a0a16 55%, #2e0610 100%); position: relative; }
.modal-head::after, .drawer-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: linear-gradient(90deg, transparent, #f6d58d, transparent); opacity: .8; }
.modal-head h2 { font-family: var(--serif); font-style: italic; font-size: 18px; letter-spacing: .01em; }
.modal-foot { background: var(--panel-2); }
.sec { border-radius: 14px; }
.badge { letter-spacing: .02em; }
.alert { border-radius: 12px; }
.toast { border-radius: 12px; backdrop-filter: blur(8px); background: rgba(38, 24, 26, .94); }
.login { background: radial-gradient(90% 70% at 50% 0%, #8a1a2e 0%, #4a0a16 45%, #1e0409 100%); }
.login .box { border-radius: 22px; box-shadow: 0 40px 90px rgba(0, 0, 0, .5), 0 0 0 1px rgba(246, 213, 141, .35); position: relative; }
.login .box::before { content: ""; position: absolute; inset: 10px; border: 1px solid rgba(199, 154, 59, .28); border-radius: 16px; pointer-events: none; }
.tile { border-radius: 14px; transition: transform .15s, box-shadow .15s; }
label.row { flex-wrap: nowrap; align-items: flex-start; gap: 8px; } label.row > input[type=checkbox] { margin-top: 3px; flex: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { body { background: #fff !important; } }

/* ===================== v4.3 – water, cameras, building strip ===================== */
.tanks { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; margin-bottom: 14px; }
.tanks .card + .card { margin-top: 0; }
.motor { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 12px; letter-spacing: .08em; }
.motor i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.motor.on { color: #1f9d55; } .motor.on i { background: #35d07f; box-shadow: 0 0 0 4px rgba(53,208,127,.25), 0 0 14px #35d07f; animation: pulse 1.6s infinite; }
.motor.off { color: #e5484d; } .motor.off i { background: #e5484d; box-shadow: 0 0 0 4px rgba(229,72,77,.18); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(53,208,127,.08), 0 0 20px #35d07f; } }
.camwall { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.camwall figure { margin: 0; background: #000; border-radius: 10px; overflow: hidden; position: relative; aspect-ratio: 16 / 9; }
.camwall img { width: 100%; height: 100%; object-fit: cover; display: block; }
.camwall figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px; font-size: 11.5px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.camwall figcaption.err { top: 40%; bottom: auto; background: none; text-align: center; color: #ffb4b4; }
.camwall figcaption.err:empty { display: none; }
.bldg { display: flex; gap: 8px; flex-wrap: wrap; margin: -4px 0 14px; }
.bldg:empty { display: none; }
.bchip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: 12.5px; box-shadow: var(--shadow); }
.bchip:hover { border-color: var(--gold); }
code { font-size: 11.5px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; word-break: break-all; }
