/* IoTiq app demo — tokens mirror apps/web/src/app/design-system.css */
:root {
  --canvas: #f4f6f5; --surface: #ffffff; --inset: #eef2f0;
  --text: #15231e; --text-2: #40524a; --muted: #5b6963;
  --border: #d7dedb; --border-subtle: #e7ece9;
  --brand: #176b52; --brand-hover: #105641; --brand-soft: #e2f0ea;
  --success: #187452; --success-soft: #e4f3ec;
  --warning: #95620d; --warning-soft: #f7eedc;
  --danger: #b23a3a; --danger-soft: #f8e7e4;
  --info: #24658a; --info-soft: #e7f0f5;
  --offline: #8a443e; --offline-soft: #f3e6e4;
  --stale: #735d21; --stale-soft: #f3ecd4;
  --pending: #426775; --pending-soft: #e4eef2;
  --nav: #12261f; --nav-text: #bacac4; --nav-active: #e6f0ec; --nav-active-text: #143d30;
  --radius: 14px; --shadow: 0 1px 2px rgba(16, 38, 31, .06), 0 4px 16px rgba(16, 38, 31, .05);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--canvas); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid #1674a8; outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }

.demo-banner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; background: #0c1c16; color: #d7e6e0; font-size: 13px; padding: 8px 16px; }
.demo-banner a { color: #fff; margin-left: 16px; font-weight: 600; }
.demo-banner strong { color: #7fe0b9; }

.app { display: grid; grid-template-columns: 248px 1fr; min-height: calc(100vh - 38px); }
.sidebar { background: var(--nav); color: var(--nav-text); padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: calc(100vh - 38px); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; color: #fff; }
.brand-mark svg { stroke-width: 2.4; }
.brand-name { color: #fff; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.property-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; padding: 0 6px; }
.property-select { margin: 2px 0 14px; background: rgba(255,255,255,.07); color: #fff; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; padding: 9px 10px; font: inherit; }
.property-select option { color: #111; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: 0; color: var(--nav-text); padding: 9px 10px; border-radius: 10px; text-align: left; font-weight: 500; }
.nav button:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav button[aria-current="page"] { background: var(--nav-active); color: var(--nav-active-text); font-weight: 650; }
.sidebar-foot { margin-top: auto; padding: 14px 6px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; }
.conn { display: flex; align-items: center; gap: 8px; color: #dfeee8; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok { background: #3ccf8e; box-shadow: 0 0 0 3px rgba(60,207,142,.18); }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 18px 28px; background: var(--canvas); position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--border-subtle); }
.topbar .page-title { font-size: 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.eyebrow { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; }
.menu-btn { display: none; }
.badge-count { position: absolute; top: -5px; right: -5px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 4px; }
.chip { font-size: 13px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; }

.view { padding: 24px 28px 64px; max-width: 1280px; outline: none; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 17px; }
.card { background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h3 { font-size: 15px; }
.stat .v { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin-top: 6px; }
.stat .l { color: var(--muted); font-size: 13px; }

.hero { display: flex; gap: 18px; align-items: center; background: linear-gradient(135deg, #12261f, #1b4a3a); color: #eaf6f1; border: 0; }
.hero .ring { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.1); flex-shrink: 0; }
.hero .ring svg { width: 26px; height: 26px; }
.hero h2 { font-size: 20px; color: #fff; }
.hero p { margin: 4px 0 0; color: #bfd6cd; }
.hero.attn { background: linear-gradient(135deg, #3d2a07, #6b4a12); }

.scenes { display: flex; gap: 10px; flex-wrap: wrap; }
.scene { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; font-weight: 600; }
.scene:hover { border-color: var(--brand); color: var(--brand); }
.scene.running { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge svg { width: 13px; height: 13px; }
.b-ok { background: var(--success-soft); color: var(--success); }
.b-warn { background: var(--warning-soft); color: var(--warning); }
.b-danger { background: var(--danger-soft); color: var(--danger); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-offline { background: var(--offline-soft); color: var(--offline); }
.b-stale { background: var(--stale-soft); color: var(--stale); }
.b-pending { background: var(--pending-soft); color: var(--pending); }
.b-neutral { background: var(--inset); color: var(--text-2); }

.attn-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border-subtle); }
.attn-item:first-of-type { border-top: 0; padding-top: 4px; }
.attn-item .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.attn-item p { margin: 2px 0 0; color: var(--text-2); font-size: 14px; }

.room { cursor: pointer; text-align: left; border: 1px solid var(--border-subtle); }
.room:hover { border-color: var(--brand); }
.room .meta { display: flex; gap: 12px; color: var(--muted); font-size: 13px; margin-top: 8px; flex-wrap: wrap; }
.room .meta span { display: inline-flex; align-items: center; gap: 4px; }
.room .meta svg { width: 15px; height: 15px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.input { border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; font: inherit; background: var(--surface); min-width: 220px; }
.seg { display: inline-flex; background: var(--inset); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 8px; font-weight: 600; color: var(--text-2); font-size: 13.5px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.device { display: flex; flex-direction: column; gap: 12px; }
.device-top { display: flex; gap: 12px; align-items: flex-start; }
.device-ic { width: 40px; height: 40px; border-radius: 11px; background: var(--inset); display: grid; place-items: center; color: var(--text-2); flex-shrink: 0; }
.device-ic.on { background: var(--brand-soft); color: var(--brand); }
.device-ic.alert { background: var(--danger-soft); color: var(--danger); }
.device-name { font-weight: 650; }
.device-sub { color: var(--muted); font-size: 13px; }
.device-state { font-size: 14px; color: var(--text-2); min-height: 21px; }
.device-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cmd { font-size: 12px; color: var(--pending); display: inline-flex; align-items: center; gap: 6px; }
.cmd.ok { color: var(--success); }
.spinner { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.switch { position: relative; width: 46px; height: 26px; border-radius: 999px; background: var(--border); border: 0; padding: 0; transition: background .2s; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--brand); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch:disabled { opacity: .45; cursor: not-allowed; }
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-hover); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { background: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.stepper button { border: 0; background: var(--surface); width: 36px; height: 34px; font-size: 18px; font-weight: 700; }
.stepper button:hover { background: var(--inset); }
.stepper span { padding: 0 10px; font-weight: 700; min-width: 64px; text-align: center; }
input[type=range] { accent-color: var(--brand); width: 140px; }

.auto { display: flex; gap: 14px; align-items: flex-start; }
.auto-body { flex: 1; min-width: 0; }
.flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0 6px; font-size: 13px; }
.flow .step { background: var(--inset); border-radius: 8px; padding: 4px 9px; }
.flow .step b { color: var(--muted); font-weight: 600; margin-right: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.flow .arrow { color: var(--muted); }

.mode { display: flex; gap: 10px; flex-wrap: wrap; }
.mode button { flex: 1; min-width: 120px; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 14px; text-align: left; font-weight: 650; }
.mode button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.mode button small { display: block; font-weight: 500; color: var(--muted); }
.cam { aspect-ratio: 16/9; border-radius: 12px; background: linear-gradient(160deg, #1d2f29, #0f1a16); position: relative; overflow: hidden; display: grid; place-items: center; color: #9bb5ab; }
.cam svg.scene-svg { position: absolute; inset: 0; width: 100%; height: 100%; stroke: none; }
.cam .live { position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,.45); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; display: flex; align-items: center; gap: 6px; }
.cam .live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #ff5a5a; }
.cam .ts { position: absolute; bottom: 10px; right: 10px; color: #fff; font-size: 11px; background: rgba(0,0,0,.45); padding: 2px 7px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.cam .note { position: absolute; bottom: 10px; left: 10px; color: #cfe1da; font-size: 11px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 6px; border-bottom: 1px solid var(--border-subtle); }
.bar-chart { width: 100%; height: 200px; }
.bar-chart rect.bar { fill: #9ccbb8; }
.bar-chart rect.bar.peak { fill: #e0a24d; }
.bar-chart rect.bar.now { fill: var(--brand); }
.bar-chart text { font-size: 10px; fill: var(--muted); stroke: none; }
.meter { height: 8px; background: var(--inset); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); align-items: flex-start; }
.feed li.new { animation: flash 1.6s ease; }
@keyframes flash { from { background: var(--brand-soft); } to { background: transparent; } }
.feed .t { color: var(--muted); font-size: 12.5px; width: 64px; flex-shrink: 0; font-variant-numeric: tabular-nums; padding-top: 2px; }
.feed .ic { width: 30px; height: 30px; border-radius: 9px; background: var(--inset); display: grid; place-items: center; flex-shrink: 0; color: var(--text-2); }
.feed .ic svg { width: 16px; height: 16px; }

.welcome { display: flex; gap: 18px; align-items: flex-start; border: 1px dashed #9cc9b6; background: #f6fbf9; }
.welcome ol { margin: 8px 0 0; padding-left: 18px; color: var(--text-2); }
.welcome .close { margin-left: auto; }

.toast-region { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: calc(100vw - 36px); }
.toast { background: #10221b; color: #e9f6f1; padding: 11px 14px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 14px; display: flex; gap: 10px; align-items: center; animation: up .25s ease; }
.toast svg { color: #7fe0b9; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(7,18,14,.56); display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--surface); border-radius: 16px; padding: 22px; max-width: 420px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h2 { font-size: 18px; }
.modal p { color: var(--text-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.disclaimer { margin-top: 36px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border-subtle); padding-top: 14px; }

.bottom-nav { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; height: 100vh; z-index: 40; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(7,18,14,.5); }
  .menu-btn { display: grid; }
  .topbar { padding: 12px 16px; }
  .topbar .page-title { font-size: 20px; }
  .view { padding: 16px 16px 96px; }
  #clock { display: none; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 30; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; }
  .bottom-nav button[aria-current="page"] { color: var(--brand); font-weight: 700; }
  .g2 { grid-template-columns: 1fr; }
  .input { min-width: 0; width: 100%; }
  .demo-banner a { margin-left: 0; margin-right: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
