:root {
  --primary: #F30F40;
  --primary-soft: #FFE8ED;
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --line: #E5E7EB;
  --text: #111827;
  --muted: #6B7280;
  --ok: #16A34A;
  --ok-soft: #DCFCE7;
  --warn: #D97706;
  --warn-soft: #FEF3C7;
  --err: #DC2626;
  --err-soft: #FEE2E2;
  --info: #2563EB;
  --info-soft: #DBEAFE;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --side: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* Layout */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: #0B1622; color: #E5E7EB; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; font-weight: 700; letter-spacing: .01em; }
.brand img { width: 28px; height: 28px; }
.brand small { display: block; font-weight: 500; color: #9CA3AF; font-size: 11px; letter-spacing: .04em; }
.side select { width: 100%; margin: 0 0 12px; background: #13202F; color: #fff; border: 1px solid #22303F; border-radius: 9px; padding: 8px 10px; font: inherit; }
.nav a { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 8px 10px; border-radius: 8px; color: #C7CDD6; font-weight: 500; }
.nav a:hover { background: #13202F; color: #fff; }
.nav a.on { background: var(--primary); color: #fff; }
.nav .sep { margin: 14px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6B7686; }
.nav svg { width: 17px; height: 17px; flex: none; }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid #1E2B3A; font-size: 12px; color: #9CA3AF; }
.side .me .row { margin-top: 8px; gap: 4px; }
.main { padding: 24px 28px 48px; min-width: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head .sub { color: var(--muted); margin-top: 2px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g21 { grid-template-columns: 2fr 1fr; align-items: start; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g21, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; } .g4, .g2 { grid-template-columns: 1fr; } .main { padding: 18px 14px; } }

/* Cards & tiles */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card > .card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.kpi .note { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 10px; border: 1px solid var(--line); }
.bar span { display: block; height: 100%; background: var(--primary); }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: #166534; }
.pill.warn { background: var(--warn-soft); color: #92400E; }
.pill.error { background: var(--err-soft); color: #991B1B; }
.pill.info { background: var(--info-soft); color: #1E40AF; }
.pill.grey { background: #F3F4F6; color: #374151; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* Buttons & forms */
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; padding: 7px 13px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--err); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 7px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.ghost { border-color: transparent; background: transparent; color: #C7CDD6; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type=color] { padding: 2px; width: 44px; height: 36px; }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 5px; font-weight: 600; font-size: 13px; }
.form label .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 8px; font-weight: 500 !important; }
.search { min-width: 240px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #FCFCFD; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; max-height: 70vh; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* Rooms grid */
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.room { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; text-align: left; font: inherit; color: inherit; position: relative; box-shadow: var(--shadow); }
.room:hover { border-color: #CBD5E1; }
.room .no { font-size: 17px; font-weight: 700; }
.room .who { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room .meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; }
.room.online { border-left: 4px solid var(--ok); }
.room.idle { border-left: 4px solid #D1D5DB; }
.room .flag { position: absolute; top: 8px; right: 10px; color: var(--err); font-weight: 700; font-size: 12px; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 12.5px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Drawer & modal */
.scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 41; box-shadow: -10px 0 30px rgba(0,0,0,.12); overflow-y: auto; padding: 22px; }
.modal { position: fixed; left: 50%; top: 8vh; transform: translateX(-50%); width: min(560px, 94vw); max-height: 84vh; overflow-y: auto; background: var(--surface); border-radius: 14px; z-index: 41; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.x { float: right; }
.section { margin-top: 20px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.device { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.device.removed { opacity: .5; }

/* Alerts / events */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; font-size: 13px; }
.alert.error { background: var(--err-soft); color: #7F1D1D; }
.alert.warn { background: var(--warn-soft); color: #78350F; }
.alert.ok { background: var(--ok-soft); color: #14532D; }
.event { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.event:last-child { border-bottom: 0; }

/* Chart */
.chart svg { width: 100%; height: 220px; display: block; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 11px; }

/* Property board */
.prop-card { cursor: pointer; }
.prop-card:hover { border-color: #CBD5E1; }

/* Toasts */
#toasts { position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: 380px; font-size: 13.5px; }
.toast.err { background: var(--err); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: #0B1622; padding: 20px; }
.login .card { width: min(380px, 100%); padding: 28px; }
.login img { width: 40px; height: 40px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 9px 12px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--text); border-color: var(--primary); }

/* Codes print sheet */
.print-only { display: none; }
@media print {
  .side, .head .row, .no-print, #toasts { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .print-only { display: block; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
.voucher-sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.voucher { border: 1.5px dashed #9CA3AF; border-radius: 10px; padding: 14px; text-align: center; break-inside: avoid; }
.voucher .code { font: 700 22px ui-monospace, Menlo, monospace; letter-spacing: .08em; margin: 6px 0; }
.form input:not([type=checkbox]):not([type=color]), .form select, .form textarea { width: 100%; min-width: 0; }
.form .two > *, .form label { min-width: 0; }
