/* PH Place — design system
   A theme = 4 base colors (--brand, --brand-2, --brand-ink, --accent); everything else derives from them.
   html[data-theme=...] picks the palette, html[data-mode=dark] switches the neutrals. */
:root {
  --brand: #0f766e; --brand-2: #0d9488; --brand-ink: #0b3b36; --accent: #2dd4bf;
  --brand-soft: color-mix(in srgb, var(--brand-2) 11%, #fff);
  --brand-hover: color-mix(in srgb, var(--brand) 84%, #000);
  --link: var(--brand); --on-soft: var(--brand-ink);
  --side-1: color-mix(in srgb, var(--brand) 50%, var(--brand-ink)); --side-2: var(--brand-ink); --side-3: color-mix(in srgb, var(--brand-ink) 72%, #000);
  --side-ink: color-mix(in srgb, var(--accent) 18%, #e9eeed); --side-muted: color-mix(in srgb, var(--accent) 38%, #b3bfbc); --side-group: color-mix(in srgb, var(--accent) 42%, #7a8784);
  --hero-1: var(--brand); --hero-2: color-mix(in srgb, var(--brand) 55%, var(--brand-ink)); --hero-ink: color-mix(in srgb, var(--accent) 28%, #fff);
  --chart-1: var(--brand); --chart-2: color-mix(in srgb, var(--brand-2) 40%, #fff); --chart-3: #f59e0b;

  --bg: #f3f5f4; --surface: #fff; --surface-2: #f8faf9; --raise: #fff; --line: #e4e9e7; --line-2: #eef2f0;
  --field: #fff; --field-line: #d8e0dd; --line-hover: #cbd5d1; --row-hover: #fafcfb; --row-done: #f7fbf9;
  --glass: rgba(255,255,255,.92); --top-bg: rgba(243, 245, 244, .85);
  --ink: #0f1f1c; --ink-2: #3d4f4b; --muted: #74857f;
  --green: #15803d; --green-bg: #e8f6ec; --amber: #b45309; --amber-bg: #fdf3e3;
  --red: #c2410c; --red-bg: #fdeee7; --blue: #1d4ed8; --blue-bg: #e9effd; --gray-bg: #eef1f0;
  --green-ink: #14532d; --red-ink: #7c2d12; --amber-ink: #78350f; --blue-ink: #1e3a8a;
  --green-line: #c6ebd1; --red-line: #f7cfbd; --amber-line: #f3dcb2;
  --r: 14px; --r-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 31, 28, .04), 0 2px 8px rgba(15, 31, 28, .04);
  --shadow-lg: 0 12px 40px rgba(15, 31, 28, .14);
  --font: 'IBM Plex Sans Thai', 'Inter', system-ui, sans-serif;
  --num: 'Inter', 'IBM Plex Sans Thai', system-ui, sans-serif;
  color-scheme: light;
}
/* ---------- Color themes */
[data-theme=yellow] { --brand: #a16207; --brand-2: #ca8a04; --brand-ink: #3d2803; --accent: #facc15; --chart-3: #0ea5e9; }
[data-theme=orange] { --brand: #c2410c; --brand-2: #ea580c; --brand-ink: #3b1206; --accent: #fb923c; --chart-3: #0ea5e9; }
[data-theme=red]    { --brand: #be123c; --brand-2: #e11d48; --brand-ink: #3f0617; --accent: #fb7185; }
[data-theme=pink]   { --brand: #be185d; --brand-2: #db2777; --brand-ink: #43061f; --accent: #f472b6; }
[data-theme=purple] { --brand: #6d28d9; --brand-2: #8b5cf6; --brand-ink: #24104f; --accent: #a78bfa; }
[data-theme=blue]   { --brand: #1d4ed8; --brand-2: #3b82f6; --brand-ink: #0f1d4a; --accent: #60a5fa; }
[data-theme=sky]    { --brand: #0369a1; --brand-2: #0ea5e9; --brand-ink: #082f49; --accent: #38bdf8; }
[data-theme=green]  { --brand: #15803d; --brand-2: #22c55e; --brand-ink: #0a2e17; --accent: #4ade80; }
[data-theme=brown]  { --brand: #8a5a2b; --brand-2: #b07a45; --brand-ink: #2e1d0e; --accent: #e0b07a; }
[data-theme=slate]  { --brand: #334155; --brand-2: #64748b; --brand-ink: #111827; --accent: #94a3b8; }

/* ---------- Dark mode (neutrals only; theme colors still apply) */
[data-mode=dark] {
  color-scheme: dark;
  --bg: #0f1214; --surface: #171b1e; --surface-2: #1c2124; --raise: #23292d; --line: #2a3135; --line-2: #22282c;
  --field: #12161a; --field-line: #333b40; --line-hover: #3d464c; --row-hover: #1d2327; --row-done: color-mix(in srgb, #22c55e 8%, #171b1e);
  --glass: rgba(23,27,30,.92); --top-bg: rgba(15, 18, 20, .82);
  --ink: #e7ecee; --ink-2: #bcc5c9; --muted: #87939a;
  --brand-soft: color-mix(in srgb, var(--brand-2) 20%, #171b1e);
  --link: color-mix(in srgb, var(--accent) 80%, #fff); --on-soft: var(--link);
  --side-1: color-mix(in srgb, var(--brand) 30%, transparent); --side-2: #13171a; --side-3: #0b0e10;
  --green: #4ade80; --green-bg: rgba(34,197,94,.14); --amber: #fbbf24; --amber-bg: rgba(245,158,11,.14);
  --red: #fb923c; --red-bg: rgba(249,115,22,.15); --blue: #93c5fd; --blue-bg: rgba(59,130,246,.16); --gray-bg: #242a2e;
  --green-ink: #bbf7d0; --red-ink: #fed7aa; --amber-ink: #fde68a; --blue-ink: #bfdbfe;
  --green-line: rgba(74,222,128,.25); --red-line: rgba(251,146,60,.28); --amber-line: rgba(251,191,36,.25);
  --chart-2: color-mix(in srgb, var(--brand-2) 45%, #171b1e);
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
}
[data-mode=dark] .side { border-right: 1px solid var(--line-2); }
[data-mode=dark] .kpi-ic, [data-mode=dark] .task .t-ic, [data-mode=dark] .badge-teal { color: var(--link); }
/* printed documents always stay light */
[data-mode=dark] .doc { --surface-2: #f8faf9; --line: #e4e9e7; --brand-soft: color-mix(in srgb, var(--brand-2) 11%, #fff); --on-soft: var(--brand-ink); --green: #15803d; --red: #c2410c; --muted: #74857f; --ink: #111; color-scheme: light; }

/* ---------- Theme picker */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.theme-opt { position: relative; cursor: pointer; }
.theme-opt input { position: absolute; opacity: 0; pointer-events: none; }
.theme-opt > span { display: flex; flex-direction: column; gap: 8px; padding: 9px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 13px; color: var(--ink-2); transition: .15s; }
.theme-opt:hover > span { border-color: var(--line-hover); }
.theme-opt input:checked + span { border-color: var(--brand); color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); font-weight: 500; }
.theme-opt i { display: flex; height: 34px; border-radius: 8px; overflow: hidden; }
.theme-opt i b { flex: 1; } .theme-opt i b:first-child { flex: 1.6; }
.theme-quick { display: flex; gap: 6px; padding: 0 6px 12px; flex-wrap: wrap; }
.theme-quick button { width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; box-shadow: 0 0 0 1px rgba(255,255,255,.15); }
.theme-quick button.on { border-color: #fff; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--link); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 600; }
h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.green { color: var(--green); } .red { color: var(--red); } .amber { color: var(--amber); }
.ic { flex: none; }
.hide { display: none !important; }

/* ---------- App shell */
.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; color: var(--side-ink);
  background: radial-gradient(120% 60% at 0% 0%, var(--side-1) 0%, transparent 60%), linear-gradient(180deg, var(--side-2), var(--side-3)); padding: 18px 14px; }
.brand { display: flex; gap: 12px; align-items: center; color: #fff; padding: 4px 8px 18px; }
.brand b { display: block; font-size: 16px; letter-spacing: .2px; }
.brand small { display: block; font-size: 12px; color: var(--side-muted); max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font: 700 14px var(--num);
  background: linear-gradient(135deg, var(--accent), var(--brand)); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 6px 18px rgba(0,0,0,.25); }
.side nav { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.nav-group { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-group); margin: 16px 10px 6px; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; color: var(--side-ink); font-size: 14.5px; transition: .15s; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.nav-link span { flex: 1; }
.pill-red { font: 600 11px var(--num); font-style: normal; background: #f97316; color: #fff; border-radius: 99px; padding: 1px 7px; }
.side-foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid rgba(255,255,255,.08); padding: 14px 6px 0; }
.me { display: flex; gap: 10px; align-items: center; }
.me b { display: block; color: #fff; font-size: 14px; } .me small { color: var(--side-muted); font-size: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--brand) 55%, var(--side-2)); color: #fff; font-weight: 600; }
.side .icon-btn { color: var(--side-muted); } .side .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 14px 28px;
  background: var(--top-bg); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid transparent; }
.top-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.top h1 { font-size: 21px; letter-spacing: -.01em; }
.top-title p { font-size: 13px; color: var(--muted); }
.back { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 0 12px; width: 280px; color: var(--muted); }
.search input { border: 0; outline: 0; background: none; padding: 9px 0; width: 100%; font: inherit; font-size: 14px; color: var(--ink); }
.top-actions { display: flex; gap: 8px; }
.content { padding: 8px 28px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 1360px; width: 100%; }
.only-m { display: none; }
.tabbar, .scrim { display: none; }

/* ---------- Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 500 14px var(--font); cursor: pointer; white-space: nowrap; transition: .15s; text-decoration: none; }
.btn:hover { border-color: var(--line-hover); background: var(--surface-2); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 4px 12px color-mix(in srgb, var(--brand) 25%, transparent); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { color: var(--red); } .btn-danger:hover { background: var(--red-bg); border-color: var(--red-line); }
.btn-ghost { border-color: transparent; background: transparent; } .btn-ghost:hover { background: var(--gray-bg); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15.5px; border-radius: 12px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--gray-bg); }

label.f { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
label.f small { font-weight: 400; color: var(--muted); }
.input, input[type=text], input[type=number], input[type=date], input[type=month], input[type=password], input[type=tel], input[type=time], select, textarea {
  font: 15px var(--font); color: var(--ink); background: var(--field); border: 1px solid var(--field-line); border-radius: 10px; padding: 9px 12px; width: 100%; outline: 0; transition: .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 18%, transparent); }
textarea { min-height: 76px; resize: vertical; }
input.num-in { font-family: var(--num); text-align: right; font-variant-numeric: tabular-nums; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 16px; }
.grid-form .span2 { grid-column: span 2; } .grid-form .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 6px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--gray-bg); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a, .seg label { padding: 6px 13px; border-radius: 9px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.seg a.on, .seg input:checked + span { background: var(--raise); color: var(--ink); box-shadow: var(--shadow); font-weight: 500; }
.seg label { padding: 0; } .seg label span { display: block; padding: 6px 13px; border-radius: 9px; } .seg input { display: none; }
.seg em { font-style: normal; font: 600 11.5px var(--num); color: var(--muted); margin-left: 4px; }

/* ---------- Cards, KPI */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.card.pad { padding: 20px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.card-h p { font-size: 13px; color: var(--muted); }
.card-b { padding: 18px 20px; }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); overflow: hidden; }
.kpi-ic { position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { font: 600 25px/1.25 var(--num); letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 14px; color: var(--muted); font-weight: 500; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi.hero { background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); color: #fff; border: 0; }
.kpi.hero .kpi-label, .kpi.hero .kpi-sub { color: var(--hero-ink); } .kpi.hero .kpi-ic { background: rgba(255,255,255,.14); color: #fff; }
.kpi.warn .kpi-ic { background: var(--red-bg); color: var(--red); }
.kpi.ok .kpi-ic { background: var(--green-bg); color: var(--green); }
.bar { height: 7px; background: var(--line-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--brand)); border-radius: 99px; }
.kpi.hero .bar { background: rgba(255,255,255,.18); } .kpi.hero .bar i { background: var(--accent); }

/* ---------- Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { background: var(--green-bg); color: var(--green); } .badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); } .badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-gray { background: var(--gray-bg); color: var(--muted); } .badge-teal { background: var(--brand-soft); color: var(--brand); }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 6px; background: var(--gray-bg); color: var(--ink-2); }

/* ---------- Tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--row-hover); }
.tbl tr.clickable { cursor: pointer; }
.tbl th.right, .tbl td.right { text-align: right; }
.tbl tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); }
.tbl .sub { display: block; font-size: 12.5px; color: var(--muted); }
.room-no { display: inline-grid; place-items: center; min-width: 46px; height: 28px; padding: 0 8px; border-radius: 8px; background: var(--brand-soft); color: var(--on-soft); font: 600 13.5px var(--num); }

/* ---------- Rooms grid */
.floor { margin-bottom: 6px; }
.floor-h { display: flex; align-items: baseline; gap: 10px; margin: 4px 2px 12px; } .floor-h h2 { font-size: 15px; }
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 14px; }
.room { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); color: var(--ink); transition: .15s; overflow: hidden; }
.room::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand-2); }
.room.vacant::before { background: #cbd5d1; } .room.repair::before { background: #f59e0b; } .room.debt::before { background: #ea580c; }
.room:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--line-hover); }
.room-top { display: flex; justify-content: space-between; align-items: center; }
.room-num { font: 700 22px var(--num); letter-spacing: -.02em; }
.room-ten { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.room-debt { font-size: 12.5px; color: var(--red); font-weight: 500; }

/* ---------- Lists */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line-2); color: var(--ink); }
.li:last-child { border-bottom: 0; } a.li:hover { background: var(--surface-2); }
.li-main { flex: 1; min-width: 0; } .li-main b { font-weight: 500; } .li-main small { display: block; color: var(--muted); font-size: 12.5px; }
.li-end { text-align: right; }
.task { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink); }
.task:hover { border-color: var(--line); background: var(--raise); }
.task .t-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.task.warn .t-ic { background: var(--red-bg); color: var(--red); } .task.amber .t-ic { background: var(--amber-bg); color: var(--amber); }
.task-list { display: flex; flex-direction: column; gap: 10px; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 14px; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; }

/* ---------- Misc */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.toolbar .grow { flex: 1; }
.month-picker { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.month-picker form { position: relative; }
.month-picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.month-picker span { display: block; padding: 0 12px; font-weight: 600; font-size: 14.5px; min-width: 130px; text-align: center; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 12px; font-size: 14px; background: var(--green-bg); color: var(--green-ink); border: 1px solid var(--green-line); animation: drop .35s ease; }
.toast-err { background: var(--red-bg); color: var(--red-ink); border-color: var(--red-line); }
.toast-warn { background: var(--amber-bg); color: var(--amber-ink); border-color: var(--amber-line); }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }
.note { padding: 12px 14px; border-radius: 12px; background: var(--amber-bg); color: var(--amber-ink); font-size: 13.5px; display: flex; gap: 10px; }
.note.info { background: var(--blue-bg); color: var(--blue-ink); } .note.ok { background: var(--green-bg); color: var(--green-ink); }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty h3 { color: var(--ink); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); padding: 0; background: var(--surface-2); cursor: zoom-in; display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.file { cursor: pointer; font-size: 10px; color: var(--muted); }
.lightbox { position: fixed; inset: 0; background: rgba(6, 20, 18, .86); display: none; place-items: center; z-index: 100; cursor: zoom-out; padding: 24px; }
.lightbox.show { display: grid; } .lightbox img { max-width: 100%; max-height: 92vh; border-radius: 12px; box-shadow: var(--shadow-lg); }
.divider { height: 1px; background: var(--line-2); margin: 14px 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sum-line { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; }
.sum-line.total { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 12px; font-size: 17px; font-weight: 600; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font: 11px var(--num); fill: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
details.more summary { cursor: pointer; color: var(--link); font-size: 13.5px; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
.timeline { display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding: 10px 20px; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.tl time { color: var(--muted); font-size: 12.5px; font-family: var(--num); }
.meter-row.done td { background: var(--row-done); }
.meter-row input.num-in { max-width: 120px; min-width: 88px; }
.meter-row .sub { white-space: nowrap; font-size: 11.5px; }
.units { font: 600 15px var(--num); }
.units.bad { color: var(--red); }
.msg-box { white-space: pre-wrap; font-size: 13.5px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; max-height: 260px; overflow: auto; }
.sticky-bar { position: sticky; bottom: 12px; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); }

/* ---------- Auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-art { position: relative; padding: 48px; color: #e6f4f1; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden;
  background: radial-gradient(80% 60% at 20% 10%, var(--brand) 0%, transparent 60%), radial-gradient(60% 50% at 90% 90%, var(--brand-2) 0%, transparent 60%), var(--side-3); }
.auth-art h2 { font-size: 34px; line-height: 1.25; color: #fff; max-width: 440px; letter-spacing: -.01em; }
.auth-art p { color: var(--side-muted); max-width: 420px; margin-top: 12px; }
.auth-art ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.auth-art li { display: flex; gap: 10px; align-items: center; color: var(--side-ink); }
.auth-art li .ic { color: var(--accent); }
.auth-form { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.auth-form form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.auth-form h1 { font-size: 26px; }

/* ---------- Print documents */
.doc { background: #fff; max-width: 820px; margin: 0 auto; padding: 40px 44px; border-radius: var(--r); border: 1px solid var(--line); box-shadow: var(--shadow); color: #111; }
.doc-h { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 2px solid var(--brand); }
.doc-h h2 { font-size: 20px; color: var(--brand-ink); }
.doc-title { text-align: right; } .doc-title h1 { font-size: 24px; color: var(--brand); letter-spacing: .02em; }
.doc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 20px 0; font-size: 14px; }
.doc-meta .box { background: var(--surface-2); border-radius: 12px; padding: 12px 16px; }
.doc table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc th { background: var(--brand-ink); color: #fff; font-weight: 500; padding: 9px 12px; text-align: left; }
.doc td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.doc .grand td { font-size: 17px; font-weight: 700; border-bottom: 0; background: var(--brand-soft); color: var(--on-soft); }
.doc-foot { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; margin-top: 22px; font-size: 13.5px; }
.sign { text-align: center; padding-top: 44px; } .sign div { border-top: 1px dotted #999; padding-top: 6px; margin: 0 20px; }
.stamp { display: inline-block; border: 3px solid var(--green); color: var(--green); border-radius: 10px; padding: 4px 14px; font-weight: 700; font-size: 18px; transform: rotate(-6deg); }
body.print-mode { background: #e9eeec; }
body.print-mode .content { max-width: none; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; }
  .side, .top, .tabbar, .no-print, .toast { display: none !important; }
  .app { display: block; } .content { padding: 0; }
  .doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .doc th, .doc .grand td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Responsive */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main, .g3 { grid-template-columns: 1fr; }
  .top .search { display: none; }
  .top-title p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
.tbl td > b { white-space: nowrap; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 60; left: 0; width: 272px; transform: translateX(-100%); transition: transform .25s ease; }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; }
  .only-m { display: inline-grid; }
  .top { padding: 10px 14px; gap: 8px; }
  .top h1 { font-size: 18px; }
  .search { display: none; }
  .content { padding: 6px 14px 96px; gap: 16px; }
  .g2 { grid-template-columns: 1fr; }
  .kpis { gap: 12px; } .kpi { padding: 14px; } .kpi-value { font-size: 20px; } .kpi-ic { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: var(--glass);
    backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px; }
  .rooms { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .room { padding: 12px 12px 12px 15px; } .room-num { font-size: 19px; }
  .auth { grid-template-columns: 1fr; } .auth-art { display: none; }
  .grid-form .span2 { grid-column: auto; }
  .dl { grid-template-columns: 110px 1fr; }
  .doc { padding: 20px; } .doc-meta, .doc-foot { grid-template-columns: 1fr; }
  .tl { grid-template-columns: 1fr; gap: 2px; }
  .card-h, .card-b, .li { padding-left: 14px; padding-right: 14px; }
  .sticky-bar { bottom: 76px; }
  .hide-m { display: none !important; }
}

/* off-screen copy of an invoice/receipt used to make a PNG: always the A4 desktop layout, light colors */
.doc.doc-snap { width: 820px; max-width: none; margin: 0; padding: 40px 44px; border: 0; border-radius: 0; box-shadow: none;
  --surface-2: #f8faf9; --line: #e4e9e7; --brand-soft: color-mix(in srgb, var(--brand-2) 11%, #fff); --on-soft: var(--brand-ink);
  --green: #15803d; --red: #c2410c; --muted: #74857f; --ink: #111; color: #111; color-scheme: light; }
.doc.doc-snap .doc-meta { grid-template-columns: 1fr 1fr; } .doc.doc-snap .doc-foot { grid-template-columns: 1.3fr 1fr; }
.doc.doc-snap .doc-title h1, .doc.doc-snap .doc-title > div { white-space: nowrap; }
.doc.doc-snap .doc-h > div:first-child { min-width: 0; }
.stamp { white-space: nowrap; }
