@font-face { font-family: Montserrat; font-style: normal; font-weight: 400 800; font-display: swap; src: url(/montserrat-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Montserrat; font-style: normal; font-weight: 400 800; font-display: swap; src: url(/montserrat-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --card: #ffffff;
  --soft: #f1f3f7;
  --soft-2: #e8ebf1;
  --line: rgba(30, 40, 60, .08);
  --text: #2e2d2c;
  --muted: #6e6e6b;
  --faint: #9a9a96;
  --blue: #2c68ff;
  --green: #00b856;
  --green-bg: rgba(0, 221, 104, .12);
  --orange: #f08a00;
  --orange-bg: rgba(255, 159, 10, .14);
  --red: #e5383b;
  --red-bg: rgba(229, 56, 59, .11);
  --grey-bg: rgba(110, 110, 107, .12);
  --grad: linear-gradient(45deg, #2c68ff, #00dd68);
  --shadow: 0 1px 2px rgba(30, 40, 60, .04), 0 8px 24px rgba(30, 40, 60, .06);
  --radius: 22px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1114;
    --card: #181b20;
    --soft: #20242a;
    --soft-2: #2a2f36;
    --line: rgba(255, 255, 255, .08);
    --text: #f3f4f2;
    --muted: #a3a6a2;
    --faint: #7d817c;
    --green: #2fd37a;
    --orange: #ffa53a;
    --red: #ff5a5d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Montserrat, -apple-system, BlinkMacSystemFont, system-ui, sans-serif; min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 86%, transparent); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; }
.brand-name { font-size: 22px; font-weight: 700; letter-spacing: -.03em; }
.brand-tag { font-size: 11px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); padding: 4px 9px; border-radius: 999px; background: var(--soft); }
.top-nav { display: flex; align-items: center; gap: 6px; }
.top-nav a, .top-nav .link { color: var(--muted); font-weight: 600; font-size: 14px; padding: 8px 12px; border-radius: 999px; border: 0; background: none; cursor: pointer; text-decoration: none; }
.top-nav a:hover, .top-nav .link:hover { color: var(--text); background: var(--soft); }
.top-nav a.active { color: var(--text); background: var(--card); box-shadow: var(--shadow); }

main.wrap { padding-top: 28px; padding-bottom: 80px; }

/* buttons & fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 700; font-size: 14px; cursor: pointer; background: var(--soft); color: var(--text); text-decoration: none !important; white-space: nowrap; transition: filter .15s, background .15s, transform .1s; }
.btn:hover { background: var(--soft-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(44, 104, 255, .22); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--red); }
.btn.small { padding: 7px 13px; font-size: 13px; }
.btn svg { flex: none; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea, .input { border: 1px solid var(--line); background: var(--soft); border-radius: 12px; padding: 11px 13px; font-size: 15px; font-weight: 500; color: var(--text); outline: none; min-width: 0; width: 100%; }
.field textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
.field input:focus, .field textarea:focus, .field select:focus, .input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(44, 104, 255, .15); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid2 .full { grid-column: 1 / -1; }
.error-box { background: var(--red-bg); color: var(--red); border-radius: 12px; padding: 10px 14px; font-weight: 600; font-size: 14px; }

/* login */
.login { min-height: calc(100vh - 120px); display: grid; place-items: center; }
.login-card { position: relative; overflow: hidden; background: var(--card); border-radius: 28px; padding: 40px 32px 32px; width: 100%; max-width: 400px; box-shadow: var(--shadow); text-align: center; }
.login-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 5px; background: var(--grad); }
.login-card h1 { font-size: 26px; font-weight: 800; margin: 18px 0 4px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; text-align: left; }
.login-card .btn { width: 100%; padding: 13px; font-size: 15px; }
.tagline { margin-top: 22px; font-size: 11px; font-weight: 700; letter-spacing: .32em; text-transform: uppercase; color: var(--faint); }

/* page head */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 34px; font-weight: 800; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.back { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 14px; margin-bottom: 8px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--card); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow); border: 0; text-align: left; cursor: pointer; transition: transform .12s; }
.kpi:hover { transform: translateY(-1px); }
.kpi.active { outline: 2px solid var(--blue); }
.kpi b { display: block; font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.kpi span { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi.ok b { color: var(--green); }
.kpi.attention b { color: var(--orange); }
.kpi.offline b { color: var(--red); }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.toolbar .input { max-width: 320px; background: var(--card); border-radius: 999px; padding: 10px 16px; }

/* home cards */
.homes { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.home-card { position: relative; display: flex; flex-direction: column; gap: 12px; background: var(--card); border-radius: var(--radius); padding: 18px 20px 16px; box-shadow: var(--shadow); color: var(--text); text-decoration: none !important; transition: transform .12s, box-shadow .2s; min-width: 0; overflow: hidden; }
.home-card:hover { transform: translateY(-2px); }
.home-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--state, var(--faint)); }
.hc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hc-name { font-size: 18px; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.hc-sub { color: var(--muted); font-size: 13px; }
.hc-alert { font-size: 13.5px; font-weight: 600; color: var(--state-text, var(--muted)); display: flex; gap: 6px; align-items: flex-start; }
.hc-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line); padding-top: 10px; }
.bar { height: 6px; border-radius: 99px; background: var(--soft-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--green); }
.devline { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; }
.devline .bar { flex: 1; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.s-ok { --state: var(--green); --state-text: var(--green); }
.s-attention { --state: var(--orange); --state-text: var(--orange); }
.s-offline { --state: var(--red); --state-text: var(--red); }
.s-new { --state: var(--faint); --state-text: var(--muted); }
.pill.s-ok { color: var(--green); background: var(--green-bg); }
.pill.s-attention { color: var(--orange); background: var(--orange-bg); }
.pill.s-offline { color: var(--red); background: var(--red-bg); }
.pill.s-new { color: var(--muted); background: var(--grey-bg); }

.empty { background: var(--card); border-radius: var(--radius); padding: 48px 24px; text-align: center; box-shadow: var(--shadow); }
.empty h2 { font-size: 20px; margin: 12px 0 6px; }
.empty p { color: var(--muted); max-width: 440px; margin: 0 auto 18px; }

/* detail */
.detail { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.card { background: var(--card); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card h2 { font-size: 17px; font-weight: 700; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.alerts li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; font-size: 14px; font-weight: 600; }
.alerts .l-offline { background: var(--red-bg); color: var(--red); }
.alerts .l-attention { background: var(--orange-bg); color: var(--orange); }
.alerts .l-info { background: var(--soft); color: var(--muted); }
.allgood { display: flex; align-items: center; gap: 10px; color: var(--green); font-weight: 700; }

table.devices { width: 100%; border-collapse: collapse; font-size: 14px; }
.devices th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 8px 8px 0; }
.devices td { padding: 9px 8px 9px 0; border-top: 1px solid var(--line); vertical-align: top; }
.devices td:last-child, .devices th:last-child { padding-right: 0; text-align: right; }
.devices .dname { font-weight: 600; }
.devices .derr { color: var(--red); font-size: 12.5px; }
.devices .dalert { color: var(--orange); font-size: 12.5px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--green); }
.dot.off { background: var(--red); }
.seg { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

.avail { display: grid; grid-template-columns: repeat(168, 1fr); gap: 1px; height: 34px; border-radius: 8px; overflow: hidden; }
.avail i { display: block; background: var(--soft-2); }
.avail i.a6 { background: var(--green); }
.avail i.a1, .avail i.a2, .avail i.a3, .avail i.a4, .avail i.a5 { background: var(--orange); }
.avail i.a0.seen { background: var(--red); }
.avail-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }
.avail-pct { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }

dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); font-weight: 600; }
dl.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-weight: 600; }
.ok-text { color: var(--green); }
.bad-text { color: var(--red); }
.warn-text { color: var(--orange); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; display: flex; gap: 12px; align-items: flex-start; }
.list li:first-child { border-top: 0; }
.list .when { flex: none; color: var(--muted); font-size: 12.5px; min-width: 92px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.list .what { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.list .x { flex: none; border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px; }
.list .x:hover { color: var(--red); }
.logs li { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.logs .lv-error { color: var(--red); }
.logs .lv-warn { color: var(--orange); }
.svc-form { display: grid; grid-template-columns: 150px 1fr; gap: 10px; margin-bottom: 12px; }
.svc-form .full { grid-column: 1 / -1; display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.svc-form .field { flex-direction: row; align-items: center; gap: 8px; }
.svc-form .field input { width: auto; }
.more { margin-top: 10px; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(15, 20, 30, .42); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal-card { position: relative; background: var(--card); border-radius: 26px; padding: 26px 26px 22px; width: 100%; max-width: 620px; box-shadow: 0 30px 80px rgba(0, 0, 0, .25); }
.modal-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 16px; }
.modal-card .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.close { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--soft); cursor: pointer; font-size: 20px; line-height: 1; color: var(--muted); }
.code { font-size: 34px; font-weight: 800; letter-spacing: .12em; text-align: center; padding: 18px; border-radius: 18px; background: var(--soft); margin: 10px 0 14px; font-variant-numeric: tabular-nums; user-select: all; }
.steps { margin: 0; padding-left: 20px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.steps b { color: var(--text); }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 10px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: #2e2d2c; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: calc(100vw - 32px); }
.toast.bad { background: var(--red); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.toggle-row:first-of-type { border-top: 0; }
.toggle-row b { display: block; font-size: 15px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--soft-2); transition: background .2s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px rgba(44, 104, 255, .35); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--soft-2); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
  .detail { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  main.wrap { padding-top: 18px; }
  .top-in { height: 60px; }
  .brand-tag, .brand-name { display: none; }
  .top-nav { gap: 2px; }
  .top-nav a, .top-nav .link { padding: 7px 9px; font-size: 13px; }
  .page-head h1 { font-size: 28px; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi b { font-size: 24px; }
  .kpi:last-child { grid-column: 1 / -1; }
  .homes { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .card { padding: 18px 16px; }
  .devices .room-col, .devices .seen-col { display: none; }
  .svc-form { grid-template-columns: 1fr; }
  .toolbar .input { max-width: none; flex: 1 1 100%; }
  .modal-card { padding: 22px 18px 18px; }
  .list .when { min-width: 74px; }
}

.accounts li { align-items: center; }
.acct-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.upload { position: relative; overflow: hidden; }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.backups li { align-items: center; }
.backups .acct-actions { flex-wrap: wrap; justify-content: flex-end; }
