﻿:root {
  --primary: #ff6a00;
  --primary-dark: #e85d00;
  --primary-soft: #fff5ed;
  --accent: #0ea5a4;
  --info: #2563eb;
  --metric-blue: #2f80ed;
  --warning: #f59e0b;
  --danger: #dc2626;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f9fbfd;
  --line: #e8edf4;
  --text: #111827;
  --muted: #64748b;
  --soft-line: #edf1f6;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .022);
  --shadow-md: 0 14px 30px rgba(15, 23, 42, .06);
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  color: var(--text);
  background: var(--bg);
}

body::before {
  content: none;
}

button, input, select { font: inherit; }

input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
  display: none;
}

input[type="password"]::-webkit-credentials-auto-fill-button,
input[type="password"]::-webkit-caps-lock-indicator {
  visibility: hidden;
  pointer-events: none;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 20px 12px;
  backdrop-filter: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 22px;
}

.brand-logo {
  width: 78px;
  height: 48px;
  flex: 0 0 78px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

.brand strong, .brand span { display: block; }
.brand strong {
  width: 112px;
  min-height: 38px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  line-height: 1.16;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
  white-space: normal;
  word-break: keep-all;
}
.brand strong span {
  color: inherit;
  font-size: inherit;
  margin-top: 0;
}
.brand > div > span { color: var(--muted); font-size: 12px; margin-top: 3px; }

nav { display: grid; gap: 4px; }

.nav-item {
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: #667085;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 560;
  transition: background .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.nav-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  color: #7a8699;
  background: transparent;
  border: 1px solid transparent;
  font-size: 18px;
  font-weight: 650;
  line-height: 1;
}

.nav-icon svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.nav-icon-trend {
  font-size: 24px;
  font-weight: 900;
}

.nav-item.active {
  color: var(--primary-dark);
  background: #fff;
  box-shadow: inset 2px 0 0 var(--primary), 0 1px 2px rgba(15, 23, 42, .035);
}

.nav-item.active .nav-icon {
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-color: rgba(255, 106, 0, .18);
  box-shadow: none;
}

.main {
  width: min(100%, 1560px);
  min-width: 0;
  margin: 0 auto;
  padding: 22px 28px 34px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
  padding: 0 1px 14px;
  border-bottom: 1px solid rgba(230, 235, 242, .72);
}

h1 { margin: 0; font-size: 24px; letter-spacing: 0; }
h2 { margin: 0; font-size: 18px; letter-spacing: 0; }
p { margin: 6px 0 0; color: var(--muted); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 3px;
  color: #d95200;
  font-size: 12px;
  font-weight: 720;
  letter-spacing: .12em;
}

.eyebrow::before {
  content: "";
  width: 48px;
  height: 2.5px;
  border-radius: 999px;
  background: var(--primary);
}

.topbar > div:first-child {
  min-width: 0;
}

#pageTitle {
  font-size: clamp(24px, 1.55vw, 29px);
  line-height: 1.12;
  font-weight: 660;
  overflow-wrap: anywhere;
  color: #111827;
}

.page-title-row,
.login-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cloud-mark {
  width: 46px;
  height: 34px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  color: var(--primary);
}

.cloud-mark svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: currentColor;
}

.cloud-mark-small {
  width: 32px;
  height: 23px;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  padding-top: 10px;
}

.user-badge {
  position: relative;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  box-shadow: none;
}

.user-badge strong { color: var(--text); font-weight: 800; }

.top-timezone {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  color: #64748b;
  font-size: 13px;
  font-weight: 560;
  line-height: 36px;
  white-space: nowrap;
}

.account-button {
  height: 36px;
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr) 12px;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  border: 1px solid #e5ebf3;
  border-radius: 9px;
  padding: 0 12px 0 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  box-shadow: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.account-button:hover,
.user-badge.open .account-button {
  border-color: rgba(255, 106, 0, .35);
  box-shadow: 0 4px 12px rgba(15, 23, 42, .035);
}

.account-avatar {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-size: 12px;
  font-weight: 650;
}

.account-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 620;
}

.account-chevron {
  display: inline-grid;
  place-items: center;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0;
  line-height: 0;
}

.account-chevron::before,
.language-chevron::before,
.refresh-menu-button::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  transform: rotate(45deg) translate(-1px, -2px);
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 45;
  display: none;
  width: 220px;
  padding: 8px;
  border: 1px solid rgba(232, 237, 245, .98);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .10);
}

.user-badge.open .account-menu {
  display: grid;
  gap: 6px;
}

.account-menu-head {
  display: grid;
  gap: 2px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--soft-line);
}

.account-menu-head span {
  color: var(--muted);
  font-size: 12px;
}

.account-menu-head small {
  color: #64748b;
  font-size: 12px;
  line-height: 1.35;
}

.account-menu button {
  height: 38px;
  border: 0;
  border-radius: 9px;
  padding: 0 10px;
  background: transparent;
  color: #b91c1c;
  cursor: pointer;
  text-align: left;
  font-weight: 560;
}

.account-menu button.neutral {
  color: #334155;
}

.account-menu button:hover {
  background: #fef2f2;
}

.account-menu button.neutral:hover {
  background: #f8fafc;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid #e5ebf3;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  color: #475569;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .035);
}

.top-settings-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  align-self: center;
  border-color: #e5ebf3;
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
}

.top-settings-button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.top-settings-button:hover {
  color: var(--primary);
  border-color: rgba(255, 106, 0, .35);
  background: var(--primary-soft);
}

.alarm-sound-button {
  display: inline-grid;
  place-items: center;
  align-self: center;
  color: var(--danger);
}

.alarm-sound-button svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.alarm-sound-button .sound-off-icon,
.alarm-sound-button.muted .sound-on-icon {
  display: none;
}

.alarm-sound-button.muted {
  color: #64748b;
}

.alarm-sound-button.muted .sound-off-icon {
  display: block;
}

.refresh-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 34px;
  border: 1px solid #e5ebf3;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .035);
  overflow: visible;
}

.refresh-control::after {
  content: "";
  position: absolute;
  right: 11px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.8px solid #64748b;
  border-bottom: 1.8px solid #64748b;
  transform: translateY(-64%) rotate(45deg);
  pointer-events: none;
}

.refresh-button,
.refresh-menu-button {
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.refresh-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 104px;
  padding: 0 30px 0 12px;
  font-weight: 640;
  white-space: nowrap;
}

.refresh-button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  color: #334155;
}

.refresh-menu-button {
  position: absolute;
  inset: 1px 1px 1px auto;
  width: 32px;
  height: 32px;
  border-left: 0;
  color: #64748b;
  font-size: 0;
  line-height: 0;
  display: block;
  padding: 0 10px 0 0;
  border-radius: 7px;
}

.refresh-menu-button::before {
  content: none;
}

.refresh-menu-button:hover {
  background: transparent;
  color: #475569;
}

.refresh-control:hover,
.refresh-control.open {
  border-color: rgba(255, 106, 0, .35);
  box-shadow: 0 4px 12px rgba(15, 23, 42, .035);
}

.refresh-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 46;
  display: none;
  width: 150px;
  padding: 6px;
  border: 1px solid rgba(232, 237, 245, .98);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .10);
}

.refresh-control.open .refresh-menu {
  display: grid;
}

.refresh-menu button {
  height: 36px;
  border: 0;
  border-radius: 9px;
  padding: 0 10px;
  background: transparent;
  color: #475569;
  cursor: pointer;
  text-align: left;
  font-weight: 560;
}

.refresh-menu button:hover,
.refresh-menu button.active {
  background: #fff3e8;
  color: var(--primary-dark);
}

.segmented {
  display: inline-flex;
  border: 1px solid rgba(255, 106, 0, .20);
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .025);
}

.segmented button {
  border: 0;
  min-width: 42px;
  height: 38px;
  padding: 0 12px;
  background: transparent;
  cursor: pointer;
}

.segmented button.active {
  background: linear-gradient(135deg, var(--primary), #ff9a3d);
  color: #fff;
  box-shadow: 0 4px 10px rgba(255, 106, 0, .18);
}

.language-picker,
.language-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.native-lang-select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.language-button {
  height: 34px;
  min-width: 124px;
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr) 12px;
  align-items: center;
  gap: 10px;
  border: 1px solid #e5ebf3;
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .035);
  cursor: pointer;
  font-weight: 640;
}

.language-button:hover,
.language-dropdown.open .language-button {
  border-color: rgba(255, 106, 0, .35);
  box-shadow: 0 4px 12px rgba(15, 23, 42, .035);
}

.language-button span:nth-child(2) {
  min-width: 0;
  text-align: left;
}

.language-chevron {
  display: inline-grid;
  place-items: center;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0;
  line-height: 0;
}

.language-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: none;
  width: 174px;
  max-height: min(360px, calc(100vh - 120px));
  overflow-y: auto;
  padding: 6px;
  border: 1px solid rgba(232, 237, 245, .98);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .10);
}

.language-dropdown.open .language-menu {
  display: grid;
}

.language-menu button {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 9px;
  padding: 0 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-weight: 650;
}

.language-menu button:hover,
.language-menu button.active {
  background: #fff3e8;
  color: var(--primary-dark);
}

.flag-icon {
  position: relative;
  width: 22px;
  height: 16px;
  flex: 0 0 22px;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .16);
  line-height: 1;
  pointer-events: none;
}

.flag-cn {
  background-color: #de2910;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 20'%3E%3Crect width='30' height='20' fill='%23de2910'/%3E%3Cpath fill='%23ffde00' d='M5 2.35l.76 2.35h2.47l-2 1.45.76 2.35L5 7.05 3.01 8.5l.76-2.35-2-1.45h2.47z'/%3E%3Cpath fill='%23ffde00' d='M10.62 1.56l.25.77h.81l-.66.48.25.77-.65-.48-.66.48.25-.77-.65-.48h.81z' transform='rotate(23.2 10.62 2.56)'/%3E%3Cpath fill='%23ffde00' d='M13 3.84l.25.77h.81l-.66.48.25.77-.65-.48-.66.48.25-.77-.65-.48h.81z' transform='rotate(45.9 13 4.84)'/%3E%3Cpath fill='%23ffde00' d='M13 7.1l.25.77h.81l-.66.48.25.77-.65-.48-.66.48.25-.77-.65-.48h.81z' transform='rotate(69.9 13 8.1)'/%3E%3Cpath fill='%23ffde00' d='M10.62 9.38l.25.77h.81l-.66.48.25.77-.65-.48-.66.48.25-.77-.65-.48h.81z' transform='rotate(20.7 10.62 10.38)'/%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
}

.flag-gb {
  background:
    linear-gradient(27deg, transparent 0 41%, #fff 41% 47%, #c8102e 47% 53%, #fff 53% 59%, transparent 59%),
    linear-gradient(153deg, transparent 0 41%, #fff 41% 47%, #c8102e 47% 53%, #fff 53% 59%, transparent 59%),
    linear-gradient(90deg, transparent 0 40%, #fff 40% 45%, #c8102e 45% 55%, #fff 55% 60%, transparent 60%),
    linear-gradient(0deg, transparent 0 35%, #fff 35% 42%, #c8102e 42% 58%, #fff 58% 65%, transparent 65%),
    #012169;
}

.flag-fr {
  background: linear-gradient(90deg, #0055a4 0 33%, #fff 33% 66%, #ef4135 66%);
}

.flag-es {
  background: linear-gradient(#aa151b 0 25%, #f1bf00 25% 75%, #aa151b 75%);
}

.flag-pt {
  background:
    radial-gradient(circle at 39% 50%, #f7d117 0 12%, transparent 13%),
    linear-gradient(90deg, #046a38 0 40%, #da291c 40%);
}

.flag-ru {
  background: linear-gradient(#fff 0 33%, #0039a6 33% 66%, #d52b1e 66%);
}

.flag-ar {
  background:
    linear-gradient(90deg, transparent 0 35%, rgba(255,255,255,.9) 35% 39%, transparent 39%),
    linear-gradient(#006c35, #006c35);
}

body[data-lang="ar"] .login-card,
body[data-lang="ar"] .view,
body[data-lang="ar"] .admin-modal,
body[data-lang="ar"] .language-menu {
  direction: rtl;
}

body[data-lang="ar"] .app,
body[data-lang="ar"] .login-page,
body[data-lang="ar"] .sidebar,
body[data-lang="ar"] .topbar,
body[data-lang="ar"] .actions {
  direction: ltr;
}

body[data-lang="ar"] input,
body[data-lang="ar"] textarea,
body[data-lang="ar"] select,
body[data-lang="ar"] .device-id,
body[data-lang="ar"] code,
body[data-lang="ar"] .metric-chart-svg {
  direction: ltr;
}

body[data-lang="ar"] .chart-title,
body[data-lang="ar"] .trend-summary-panel article {
  direction: rtl;
  text-align: right;
}

body[data-lang="ar"] .chart-card svg,
body[data-lang="ar"] .chart-empty,
body[data-lang="ar"] .time-cell {
  direction: ltr;
}

body[data-lang="ar"] .help-card {
  direction: rtl;
  text-align: right;
}

body[data-lang="ar"] .help-card-head {
  grid-template-columns: minmax(0, 1fr) 34px;
}

body[data-lang="ar"] .help-card-head .help-icon {
  grid-column: 2;
  grid-row: 1;
}

body[data-lang="ar"] .help-card-head strong {
  grid-column: 1;
  grid-row: 1;
}

body[data-lang="ar"] .help-card ul {
  padding-left: 0;
  padding-right: 18px;
}

.view { display: none; }
.view.active { display: block; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.kpi {
  position: relative;
  overflow: hidden;
  min-height: 74px;
  display: grid;
  align-content: center;
  background: #fff;
  border: 1px solid rgba(224, 231, 240, .96);
  border-radius: 8px;
  padding: 12px 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .026);
  cursor: pointer;
  filter: none;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  height: auto;
  background: #94a3b8;
  opacity: .72;
}

.kpi::after {
  content: none;
}

.kpi.success::before { background: var(--accent); }
.kpi.danger::before { background: var(--danger); }
.kpi.muted::before { background: #64748b; }
.kpi:hover,
.kpi.active {
  background: #fff;
  border-color: rgba(255, 106, 0, .18);
  box-shadow: 0 8px 18px rgba(15, 23, 42, .04);
  transform: translateY(-1px);
}

.kpi.active::before {
  width: 3px;
  background: var(--primary);
  opacity: .9;
}

body.status-filter-active .kpi:not(.active) {
  opacity: .48;
  filter: grayscale(.9);
  box-shadow: none;
}

body.status-filter-active .kpi.active {
  opacity: 1;
  filter: none;
}

.kpi span { position: relative; z-index: 1; display: block; color: var(--muted); font-size: 12px; font-weight: 600; line-height: 1.2; }
.kpi strong { position: relative; z-index: 1; display: block; margin-top: 8px; color: #475569; font-size: 27px; line-height: .95; font-weight: 660; letter-spacing: 0; }
.kpi.success strong { color: var(--accent); }
.kpi.danger strong { color: var(--danger); }
.kpi.muted strong { color: var(--muted); }
.kpi-subline {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  color: #94a3b8;
  font-size: 11.5px;
  font-weight: 620;
}
.kpi-subline span {
  display: inline;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}
.kpi-subline b {
  color: #64748b;
  font-size: 12.5px;
  font-weight: 700;
}

.panel {
  background: var(--surface);
  border: 1px solid rgba(224, 231, 240, .92);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.view > .panel + .panel {
  margin-top: 16px;
}

.device-groups-panel .relation-note {
  margin-bottom: 12px;
}

.management-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.management-stats article {
  position: relative;
  min-height: 72px;
  padding: 13px 14px;
  border: 1px solid var(--soft-line);
  border-radius: 9px;
  background: linear-gradient(180deg, #fff, #fbfdff);
}

.management-stats article::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: var(--primary);
  opacity: .7;
}

.management-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 620;
}

.management-stats strong {
  display: block;
  margin-top: 8px;
  color: #172033;
  font-size: 24px;
  line-height: 1;
  font-weight: 680;
}

.management-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.management-main {
  min-width: 0;
}

.group-tree-card {
  border: 1px solid var(--soft-line);
  border-radius: 10px;
  background: #fbfdff;
  overflow: hidden;
}

.tree-card-head {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--soft-line);
  background: #fff;
}

.tree-card-head strong {
  color: #172033;
  font-size: 13px;
  font-weight: 680;
}

.tree-card-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 620;
}

.group-tree {
  display: grid;
  gap: 4px;
  max-height: 340px;
  overflow: auto;
  padding: 8px;
}

.group-tree-item {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 9px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.group-tree-item:hover {
  background: #fff;
  border-color: #e7edf5;
}

.group-tree-item.active {
  border-color: rgba(255, 106, 0, .28);
  background: #fff7ed;
}

.group-tree-item.muted {
  color: #64748b;
}

.tree-node-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #94a3b8;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, .11);
}

.tree-node-dot.root {
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 106, 0, .13);
}

.tree-node-main {
  min-width: 0;
}

.tree-node-main strong,
.tree-node-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-node-main strong {
  font-size: 13px;
  font-weight: 660;
}

.tree-node-main small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.tree-count {
  min-width: 28px;
  min-height: 24px;
  display: inline-grid;
  place-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 650;
}

.compact-table-wrap table {
  min-width: 1120px;
}

.sync-state {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.sync-state.local {
  color: #b45309;
  background: #fff7ed;
}

.panel-head {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head h2 {
  flex: 0 0 auto;
  font-size: 17px;
  font-weight: 660;
  color: #111827;
}

.overview-device-panel {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  padding: 2px 0 0;
}

.overview-device-panel .panel-head {
  min-height: 34px;
  margin-bottom: 12px;
  padding: 0;
}

.overview-device-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.overview-device-actions .select {
  min-width: 180px;
}

.overview-device-search {
  width: min(320px, 28vw);
  min-width: 220px;
}

.monitor-mode-button {
  white-space: nowrap;
}

.top-monitor-button {
  height: 34px;
  border-color: #e5ebf3;
  border-radius: 8px;
  padding: 0 15px;
  color: #1f2937;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .035);
  font-weight: 660;
}

.top-monitor-button:hover {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

.monitor-mode-exit-button {
  display: none;
}

.overview-device-panel .device-grid {
  gap: 12px;
  max-height: max(300px, calc(100vh - 340px));
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 2px 8px 0;
  scrollbar-gutter: auto;
}

.overview-device-panel .device-grid::-webkit-scrollbar {
  width: 4px;
}

.overview-device-panel .device-grid::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #d7dee8;
}

.overview-device-panel .device-grid::-webkit-scrollbar-track {
  background: transparent;
}

body.monitor-mode {
  background: #f5f7fa;
  overflow: hidden;
}

body.monitor-mode .app {
  display: block;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

body.monitor-mode .sidebar {
  display: none;
}

body.monitor-mode .main {
  width: 100vw;
  height: 100vh;
  padding: clamp(18px, 1.6vw, 28px) clamp(24px, 2vw, 42px) clamp(18px, 1.5vw, 30px);
  overflow: hidden;
}

body.monitor-mode .topbar {
  align-items: center;
  margin-bottom: clamp(14px, 1.2vw, 22px);
  padding: 0 1px clamp(12px, 1vw, 18px);
}

body.monitor-mode .actions {
  padding-top: 0;
}

body.monitor-mode .top-monitor-button {
  color: var(--primary-dark);
  border-color: rgba(255, 106, 0, .30);
  background: #fff7ed;
}

body.monitor-mode .kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(12px, 1.25vw, 20px);
  margin-bottom: clamp(18px, 1.45vw, 26px);
}

body.monitor-mode .kpi {
  min-height: clamp(86px, 8.4vh, 120px);
  padding: clamp(14px, 1.05vw, 20px) clamp(16px, 1.2vw, 24px);
}

body.monitor-mode .kpi strong {
  margin-top: clamp(8px, .65vw, 12px);
  font-size: clamp(30px, 2.2vw, 44px);
}

body.monitor-mode .view:not(#overview) {
  display: none !important;
}

body.monitor-mode .overview-device-panel {
  height: calc(100vh - clamp(214px, 23vh, 288px));
  padding: 0;
  overflow: hidden;
}

body.monitor-mode .overview-device-panel .panel-head {
  min-height: 40px;
  margin-bottom: 12px;
}

body.monitor-mode .overview-device-panel .device-grid {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  max-height: none;
  height: calc(100% - 52px);
  gap: clamp(10px, .9vw, 16px);
  padding: 1px 2px 6px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

body.monitor-mode .device-card {
  aspect-ratio: auto;
  min-height: clamp(168px, 21vh, 236px);
  padding: clamp(8px, .7vw, 12px);
}

body.monitor-mode .metric {
  min-height: 42px;
  padding: 6px 8px;
}

body.monitor-mode .metric b {
  font-size: 13.5px;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--info);
  font-size: 12px;
  white-space: nowrap;
}

.pill.danger { background: #fef2f2; color: var(--danger); }

.device-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
  gap: 12px;
}

.device-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  aspect-ratio: 1.618 / 1;
  min-height: 0;
  border: 1px solid rgba(224, 231, 240, .92);
  border-radius: 8px;
  padding: 8px 9px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.device-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 106, 0, .62), rgba(14, 165, 164, .32));
}

.device-card:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, .42);
  box-shadow: 0 8px 18px rgba(15, 23, 42, .04);
}

.device-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  margin-bottom: 5px;
  padding-right: 0;
}

.device-card strong { display: block; font-size: 15px; font-weight: 650; letter-spacing: 0; }
.device-card small { color: var(--muted); }

.device-title {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  align-content: start;
}

.device-title small {
  display: block;
}

.device-ids {
  display: grid;
  gap: 2px;
  margin-top: 2px;
}

.device-ids small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px;
  align-items: center;
  gap: 4px;
  width: 100%;
  max-width: 100%;
}

.device-name-row strong {
  min-width: 0;
  overflow: hidden;
  line-height: 1.16;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.name-edit-button {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: .62;
}

.name-edit-button svg,
.settings-button svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.device-card:hover .name-edit-button,
.name-edit-button:focus-visible,
.name-edit-button:hover {
  opacity: 1;
  color: var(--primary);
  border-color: rgba(255, 106, 0, .28);
  background: #fff3e8;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(14, 165, 164, .08);
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status.alarm { color: var(--danger); background: rgba(220, 38, 38, .08); }
.status.offline { color: var(--muted); background: rgba(100, 116, 139, .08); }
.status.inactive { color: #b7791f; background: rgba(245, 158, 11, .11); }

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 5px;
  flex: 1 1 auto;
  margin-top: 0;
}

.metric {
  min-height: 40px;
  padding: 6px 8px;
  display: grid;
  align-content: center;
  background: #f9fbfe;
  border: 1px solid #eef2f7;
  border-radius: 7px;
}

.metric span { display: block; color: var(--muted); font-size: 11px; font-weight: 560; }
.metric b { display: block; margin-top: 2px; color: var(--metric-blue); font-size: 14px; font-weight: 660; letter-spacing: 0; }

.device-time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 5px;
  border-top: 1px solid var(--soft-line);
}

.device-time {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.timezone-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  font-size: 11px;
  font-weight: 560;
  white-space: nowrap;
}

.mobile-timezone-badge {
  display: none;
}

.metric-button {
  width: 100%;
  border: 0;
  text-align: left;
  cursor: pointer;
}

.metric-button:hover {
  outline: 0;
  border-color: rgba(47, 128, 237, .22);
  background: #f7fbff;
}

.settings-button {
  position: static;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  cursor: pointer;
}

.device-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex: 0 0 auto;
  min-width: 0;
  margin-left: 6px;
}

.settings-button:hover {
  color: var(--primary);
  border-color: rgba(255, 106, 0, .35);
  background: #fff3e8;
}

.settings-button.danger-button:hover {
  color: var(--danger);
  border-color: rgba(220, 38, 38, .28);
  background: #fef2f2;
}

.danger-text {
  color: var(--danger);
}

.table-name {
  justify-content: center;
}

.inline-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-head > .inline-controls {
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
}

.search, .select {
  height: 38px;
  min-width: 220px;
  border: 1px solid #dfe6ef;
  border-radius: 7px;
  padding: 0 12px;
  background-color: #fff;
  color: #263247;
  box-shadow: none;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 14 14' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 5.4 7 8.4l3-3' fill='none' stroke='%2364758b' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px 14px;
}

.search:focus,
.select:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 3px solid rgba(255, 106, 0, .12);
  border-color: rgba(255, 106, 0, .50);
}

.wide-search {
  min-width: 320px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #e4e9f0;
  border-radius: 8px;
  background: #fff;
}
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 10px 12px; border-bottom: 1px solid #edf1f6; text-align: center; white-space: nowrap; }
th { color: #59677a; font-size: 12px; font-weight: 650; background: #f5f7fa; text-transform: none; letter-spacing: 0; }
td { color: #253044; font-size: 13px; }
tbody tr:hover { background: #fff9f2; }
tbody tr:last-child td { border-bottom: 0; }

#devices table {
  min-width: 1040px;
  table-layout: fixed;
}

#devices th,
#devices td {
  overflow: hidden;
  text-overflow: ellipsis;
}

#devices th:nth-child(1) { width: 14%; }
#devices th:nth-child(2) { width: 10.5%; }
#devices th:nth-child(3) { width: 10.5%; }
#devices th:nth-child(4) { width: 15%; }
#devices th:nth-child(5) { width: 12%; }
#devices th:nth-child(6) { width: 12%; }
#devices th:nth-child(7) { width: 10%; }
#devices th:nth-child(8) { width: 8%; }
#devices th:nth-child(9) { width: 8%; }

#devices td:nth-child(6),
#devices td:nth-child(8),
#devices td:nth-child(9) {
  overflow: visible;
}

#devices .table-name {
  max-width: 100%;
  justify-content: center;
}

#devices .link-button {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#devices .table-select {
  width: 100%;
  min-width: 0;
}

#devices .status {
  margin-inline: auto;
  max-width: none;
}

.account-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.account-table th,
.account-table td {
  padding: 10px 8px;
  white-space: normal;
}

.account-table th:nth-child(1) { width: 9.5%; }
.account-table th:nth-child(2) { width: 11%; }
.account-table th:nth-child(3) { width: 12%; }
.account-table th:nth-child(4) { width: 15%; }
.account-table th:nth-child(5) { width: 15%; }
.account-table th:nth-child(6) { width: 9.5%; }
.account-table th:nth-child(7) { width: 7%; }
.account-table th:nth-child(8) { width: 12%; }
.account-table th:nth-child(9) { width: 9%; }

.account-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-table td:nth-child(4) {
  position: relative;
  overflow: visible;
  z-index: 2;
}

.account-table td:nth-child(1) strong,
.account-table td:nth-child(2),
.account-table td:nth-child(3) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-table td:nth-child(1) strong {
  display: block;
  min-width: 0;
}

.chart {
  height: 210px;
  border: 1px solid var(--soft-line);
  border-radius: 10px;
  background: #fff;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chart-summary {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 9px 14px 4px 72px;
  color: #718096;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.chart svg {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: block;
  overflow: hidden;
}

.trend-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 9px;
}

.trend-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.trend-head .inline-controls {
  justify-content: flex-end;
  flex-wrap: nowrap;
  min-width: 0;
}

.trend-head .wide-search {
  flex: 1 1 360px;
  min-width: 300px;
  max-width: 480px;
}

.trend-head .select {
  flex: 0 1 300px;
  min-width: 220px;
}

.trend-head .secondary-button {
  flex: 0 0 auto;
  min-width: 86px;
  white-space: nowrap;
}

#trends > .panel {
  padding: 15px 15px 10px;
}

.chart-card {
  border: 1px solid rgba(226, 232, 240, .92);
  border-radius: 8px;
  padding: 10px;
  background: linear-gradient(180deg, #fff, #fcfdff);
  box-shadow: var(--shadow-sm);
}

.chart-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.chart-heading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chart-heading strong {
  color: #172033;
  font-size: 16px;
  font-weight: 620;
}

.chart-title span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #e6ebf2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 560;
}

.chart-title span.hidden {
  display: none;
}

.chart-stat {
  min-width: 0;
  display: block;
  color: #718096;
  font-size: 12px;
  font-weight: 560;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.chart-stat:empty {
  display: none;
}

.trend-summary-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-top: 10px;
}

.trend-summary-panel article {
  min-height: 72px;
  padding: 12px 13px;
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fbfdff);
  box-shadow: var(--shadow-sm);
}

.trend-summary-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 620;
}

.trend-summary-panel strong {
  display: block;
  margin-top: 6px;
  color: #172033;
  font-size: 18px;
  line-height: 1.1;
  font-weight: 680;
}

.trend-summary-panel small {
  display: block;
  margin-top: 5px;
  color: #8a96aa;
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-empty {
  height: 100%;
  display: grid;
  place-content: center;
  gap: 6px;
  text-align: center;
  color: #94a3b8;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(135deg, rgba(255, 106, 0, .10), rgba(14, 165, 164, .08)) border-box;
}

.chart-empty strong {
  color: #64748b;
  font-size: 15px;
}

.chart-empty span {
  font-size: 12px;
}

.history-table {
  min-width: 1060px;
}

.history-page {
  padding-bottom: 16px;
}

.history-head {
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.history-head .inline-controls {
  grid-column: auto;
  justify-content: flex-end;
  flex-wrap: nowrap;
  min-width: 0;
}

.history-head .wide-search {
  flex: 0 1 300px;
  min-width: 240px;
  max-width: 300px;
}

.history-head .select {
  flex: 0 1 220px;
  min-width: 180px;
}

.history-head #historyDeviceSelect {
  flex-basis: 300px;
  min-width: 260px;
}

.history-head .secondary-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.history-title-block {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.history-title-block h2 {
  margin: 0;
  white-space: nowrap;
}

.history-range {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #e6edf6;
  border-radius: 999px;
  background: rgba(255, 106, 0, .09);
  border-color: rgba(255, 106, 0, .14);
  color: #c66b1e;
  font-size: 13px;
  font-weight: 560;
  white-space: nowrap;
}

.history-range-switch {
  border-radius: 999px;
}

.history-range-switch button {
  height: 28px;
  min-width: 48px;
  padding: 0 10px;
  color: #9a5a16;
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}

.history-range-switch button.active {
  background: linear-gradient(135deg, var(--primary), #ff9a3d);
  color: #fff;
}

.history-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #e6edf6;
  border-radius: 999px;
  background: #f8fafc;
  color: #64748b;
  font-size: 13px;
  font-weight: 560;
  white-space: nowrap;
}

.history-table-shell {
  border: 1px solid var(--soft-line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.history-table-wrap {
  max-height: 560px;
  border: 0;
  border-radius: 0;
}

.history-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  box-shadow: inset 0 -1px 0 var(--soft-line);
  text-align: center;
}

.history-table tbody tr:nth-child(even) {
  background: #fbfdff;
}

.history-table tbody tr:hover {
  background: #fffaf5;
}

.history-table td {
  font-size: 13px;
  text-align: center;
  vertical-align: middle;
}

.history-table .time-cell {
  color: #334155;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.history-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--soft-line);
  background: #fbfdff;
}

.group-pager,
.device-pager,
.user-pager {
  border: 1px solid #e4e9f0;
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

#groups .table-wrap,
#devices .table-wrap,
#accounts .table-wrap {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

.history-pager input[type="range"] {
  width: min(26vw, 300px);
  min-width: 150px;
  accent-color: var(--primary);
}

.history-pager input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: #e8edf4;
}

.history-pager input[type="range"]::-webkit-slider-thumb {
  margin-top: -5px;
}

.history-pager .secondary-button {
  height: 34px;
  min-width: 76px;
  border-radius: 9px;
}

.history-pager span {
  min-width: 58px;
  color: var(--muted);
  font-weight: 560;
  text-align: center;
}

.history-pager button:disabled {
  opacity: .48;
  cursor: not-allowed;
}

.device-pager .history-count {
  min-width: 96px;
  justify-content: center;
}

.export-button {
  min-width: 116px;
}

.alarm-filter-controls {
  justify-content: flex-end;
}

.alarm-settings-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid #e6ebf2;
  border-radius: 8px;
  background: #f8fafc;
}

.switch-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 8px;
  row-gap: 2px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid #edf1f6;
  border-radius: 8px;
  background: #fff;
  color: #172033;
  font-weight: 680;
}

.switch-line input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.switch-line small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 520;
}

.alarm-list { display: grid; gap: 10px; }

.alarm-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 14px;
  border: 1px solid #fecaca;
  background: #fff7f7;
  border-radius: 8px;
}

.alarm-item.active-alarm {
  position: relative;
}

body.alarm-attention-on .alarm-item.active-alarm {
  animation: alarmPulse 1s ease-in-out infinite;
}

@keyframes alarmPulse {
  0%, 100% {
    border-color: #fecaca;
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
    background: #fff7f7;
  }
  50% {
    border-color: #dc2626;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, .12);
    background: #fff1f1;
  }
}

.primary-button {
  height: 38px;
  border: 0;
  border-radius: 7px;
  padding: 0 16px;
  color: #fff;
  background: #ff6a00;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
  font-weight: 650;
}

.primary-button:hover { background: #e85d00; }

.secondary-button {
  height: 38px;
  border: 1px solid #d9e1ec;
  border-radius: 7px;
  padding: 0 14px;
  color: #344054;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}

.secondary-button:hover {
  color: var(--primary);
  border-color: rgba(255, 106, 0, .35);
  background: #fff3e8;
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: .58;
  cursor: not-allowed;
  box-shadow: none;
}

.actions .top-monitor-button {
  height: 34px;
  border-color: #e5ebf3;
  border-radius: 8px;
  padding: 0 15px;
  color: #1f2937;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .035);
  font-weight: 660;
}

.actions .top-monitor-button:hover {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

body.monitor-mode .actions .top-monitor-button {
  color: var(--primary-dark);
  border-color: rgba(255, 106, 0, .30);
  background: #fff7ed;
}

.text-button,
.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
}

.text-button {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
}

.link-button {
  font-weight: 560;
  color: var(--text);
}

.table-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.table-edit {
  width: 22px;
  height: 22px;
  font-size: 13px;
}

.table-select {
  height: 32px;
  min-width: 138px;
  border: 1px solid #d9e1ec;
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
  color: #344054;
}

.chip-list {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-right: 8px;
}

.account-groups-cell {
  min-width: 0;
  max-width: none;
}

.account-group-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.account-group-chips {
  min-width: 0;
  max-width: 100%;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  justify-content: center;
  overflow: hidden;
  margin-right: 0;
}

.account-group-edit {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid #dbeafe;
  border-radius: 7px;
  color: #2f80ed;
  background: #eff6ff;
  cursor: pointer;
}

.account-group-edit svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.account-group-edit:hover {
  color: #ff6a00;
  border-color: rgba(255, 106, 0, .28);
  background: #fff3e8;
}

.account-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px 6px;
  white-space: normal;
  flex-wrap: wrap;
  width: 100%;
}

.account-actions-cell {
  white-space: normal;
  overflow: visible;
}

.account-actions-cell .table-action {
  margin: 0 2px;
  font-size: 13px;
  line-height: 1.35;
}

.account-contact-cell {
  white-space: normal;
}

.account-contact-stack {
  display: grid;
  gap: 3px;
  justify-items: center;
  line-height: 1.25;
}

.account-contact-stack span,
.account-contact-stack small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-contact-stack small {
  color: #64748b;
  font-size: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: #475467;
  background: #f7f9fc;
  border: 1px solid #e4e9f0;
  font-size: 12px;
  font-weight: 650;
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-email-stack {
  display: grid;
  gap: 2px;
  justify-items: center;
  min-width: 0;
  line-height: 1.25;
}

.account-email-stack span,
.account-email-stack small {
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-email-stack small {
  color: #64748b;
  font-size: 12px;
}

.chip-more {
  max-width: none;
  color: #64748b;
  background: #eef3f8;
}

.table-action {
  margin-top: 0;
  white-space: nowrap;
}

.delete-text {
  color: #64748b;
  font-weight: 620;
}

.delete-text:hover {
  color: var(--danger);
}

.muted-cell {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.password-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: none;
  min-width: 0;
  justify-content: center;
}

.password-cell code {
  display: inline-block;
  max-width: 180px;
  min-width: 78px;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 12px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.password-cell code[data-hidden="true"] {
  max-width: 92px;
  min-width: 56px;
}

.password-cell code[data-hidden="false"] {
  max-width: none;
  min-width: 128px;
  overflow: visible;
  text-overflow: clip;
}

.password-eye-button {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e4e9f0;
  border-radius: 7px;
  color: #667085;
  background: #fff;
  cursor: pointer;
}

.password-eye-button svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.password-eye-button:hover,
.password-eye-button.active {
  color: #2563eb;
  border-color: #bfdbfe;
  background: #eff6ff;
}

@media (max-width: 900px) {
  .alarm-settings-card {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px;
    margin-bottom: 12px;
  }
  .alarm-settings-card .switch-line {
    min-height: 46px;
    padding: 8px 10px;
  }
  .alarm-settings-card .switch-line small {
    font-size: 11px;
    line-height: 1.25;
  }
}

.link-button:hover,
.text-button:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.config-page {
  margin-top: -4px;
  padding: 12px 14px 14px;
}

.config-head {
  display: grid;
  grid-template-columns: minmax(180px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  min-height: 34px;
}

.config-head .inline-controls {
  justify-content: flex-end;
  flex-wrap: nowrap;
  min-width: 0;
}

.config-head .wide-search {
  flex: 0 1 320px;
  min-width: 230px;
  max-width: 340px;
}

.config-head .select {
  flex: 0 1 300px;
  min-width: 220px;
}

.config-head .icon-button {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.config-section {
  padding: 10px 12px 12px;
  border: 1px solid rgba(226, 232, 240, .86);
  border-radius: 10px;
  background: linear-gradient(180deg, #fff, #fcfdff);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .026);
}

.config-section-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--soft-line);
}

.config-section-head h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.25;
  color: #111827;
  font-weight: 700;
}

.config-section-head span {
  color: #7b8798;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.config-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 7px;
}

.config-section:nth-child(1) .config-section-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.config-section:nth-child(2) .config-section-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.config-section:nth-child(3) .config-section-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field label { font-size: 13px; color: var(--muted); }
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  background: #fff;
  color: #273244;
  font: inherit;
}

.field input,
.field select {
  height: 34px;
  padding: 0 10px;
}

.field textarea {
  min-height: 86px;
  padding: 10px 12px;
  resize: vertical;
}

.field small {
  min-height: 16px;
  line-height: 1.35;
  color: #94a3b8;
  font-size: 11px;
}

.config-field {
  min-height: 70px;
  padding: 8px 10px;
  border: 1px solid rgba(226, 232, 240, .88);
  border-radius: 10px;
  background: #fff;
  align-content: start;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.config-field:has(.config-check:checked) {
  border-color: rgba(255, 106, 0, .32);
  background: #fffaf6;
  box-shadow: inset 0 0 0 1px rgba(255, 106, 0, .045);
}

.config-field .select {
  min-width: 0;
}

.config-select-wrap {
  position: relative;
  display: block;
  width: 100%;
}

.config-select-wrap::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.7px solid #64748b;
  border-bottom: 1.7px solid #64748b;
  transform: translateY(-62%) rotate(45deg);
  pointer-events: none;
  opacity: .86;
}

.config-select {
  width: 100%;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px !important;
  background-color: #fff;
  background-image: none;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--text) !important;
  font-weight: 680;
  line-height: 1.2;
}

.check-label input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

.input-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid #dfe7f1;
  border-radius: 9px;
  overflow: hidden;
  background: #fff;
}

.input-with-unit input {
  border: 0;
  border-radius: 0;
}

.input-with-unit span {
  min-width: 48px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  border-left: 1px solid var(--line);
  background: #f9fafb;
}

.config-field .field input,
.config-field .field select,
.config-field input,
.config-field select,
.config-field .select {
  height: 32px;
  border-radius: 8px;
}

.config-field small { display: none; }

.option-strip {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding: 1px 1px 4px;
  scrollbar-width: thin;
}

.option-choice {
  flex: 0 0 auto;
  margin: 0;
  color: var(--text) !important;
  cursor: pointer;
}

.option-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-choice span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #dfe7f1;
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: border-color .15s ease, box-shadow .15s ease, color .15s ease, background .15s ease;
}

.option-choice input:checked + span {
  border-color: rgba(249, 115, 22, .52);
  background: #fff8f1;
  color: #c2410c;
  box-shadow: 0 0 0 2px rgba(249, 115, 22, .09);
}

.relation-note {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  color: #9a3412;
  background: #fff3e8;
  font-size: 13px;
}

.account-relation-map {
  margin-bottom: 10px;
  border: 1px solid rgba(226, 232, 240, .92);
  border-radius: 10px;
  background: linear-gradient(180deg, #fff, #fbfdff);
  overflow: hidden;
}

.relation-map-head {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px;
  border-bottom: 1px solid var(--soft-line);
}

.relation-map-head strong {
  color: #172033;
  font-size: 14px;
  font-weight: 680;
  white-space: nowrap;
}

.relation-map-head span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relation-map-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.relation-map-grid article {
  position: relative;
  min-height: 66px;
  padding: 11px 16px;
  border-right: 1px solid var(--soft-line);
}

.relation-map-grid article:last-child {
  border-right: 0;
}

.relation-map-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 620;
}

.relation-map-grid strong {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 6px;
  color: #172033;
  font-size: 19px;
  line-height: 1;
  font-weight: 680;
}

.relation-map-grid small {
  color: #64748b;
  font-size: 11px;
  font-weight: 620;
}

.relation-map-grid p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.chip-button {
  height: 25px;
  border: 1px solid #e6ebf2;
  cursor: pointer;
  font-size: 12px;
}

.chip-button:hover {
  color: var(--primary);
  border-color: rgba(255, 106, 0, .34);
  background: #fff7ed;
}

.account-tree {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.account-tree-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--soft-line);
  border-radius: 10px;
  background: linear-gradient(180deg, #fff, #fbfdff);
}

.account-tree-main {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.account-tree-avatar {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-weight: 700;
}

.account-tree-main strong,
.account-tree-main small,
.sub-account-item strong,
.sub-account-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-tree-main strong,
.sub-account-item strong {
  color: #172033;
  font-size: 13px;
  font-weight: 670;
}

.account-tree-main small,
.sub-account-item small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.account-tree-groups,
.sub-account-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.sub-account-list {
  display: grid;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--soft-line);
}

.sub-account-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) minmax(120px, .9fr);
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 8px;
  background: #f8fafc;
}

.sub-account-item > span:first-child {
  width: 10px;
  height: 10px;
  justify-self: center;
  border-left: 2px solid #cbd5e1;
  border-bottom: 2px solid #cbd5e1;
  border-bottom-left-radius: 4px;
}

.sub-account-empty {
  padding: 9px;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
}

.relation-grid,
.help-grid {
  display: grid;
  gap: 12px;
}

.relation-grid {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.help-grid {
  grid-template-columns: repeat(3, minmax(240px, 1fr));
}

.relation-box,
.help-card {
  display: grid;
  gap: 9px;
  align-content: start;
  padding: 18px;
  border: 1px solid var(--soft-line);
  border-radius: 10px;
  background: #fff;
}

.help-card {
  gap: 10px;
}

.help-card-head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.help-icon {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  color: var(--primary-dark);
  background: #fff7ed;
  border: 1px solid rgba(255, 106, 0, .16);
}

.help-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.relation-box span,
.help-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.help-card strong {
  color: #172033;
  font-size: 15.5px;
  font-weight: 680;
  line-height: 1.25;
}

.help-card ul {
  margin: 0;
  padding-left: 17px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.62;
}

.help-card li {
  margin: 4px 0;
}

.config-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid rgba(226, 232, 240, .86);
  border-radius: 10px;
  background: #fbfdff;
}

.config-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.config-dev-note {
  margin-top: -2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.config-record-toggle {
  height: 38px;
  min-width: 96px;
  border-radius: 9px;
  background: #fff;
}

.config-record-toggle.active {
  color: var(--primary-dark);
  border-color: rgba(255, 106, 0, .32);
  background: #fff7ed;
}

.cs-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-height: 34px;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
}

.cs-preview span {
  color: var(--text);
  font-weight: 700;
}

.cs-preview code {
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-weight: 600;
}

.cs-preview.success {
  color: #047857;
  background: rgba(16, 185, 129, .08);
  border-color: rgba(16, 185, 129, .18);
}

.cs-preview.waiting,
.cs-preview.selected {
  background: #fff7ed;
  border-color: rgba(255, 106, 0, .22);
}

.cs-preview.waiting span,
.cs-preview.selected span {
  color: var(--primary-dark);
}

.task-result {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  background: #f9fafb;
  border: 1px solid var(--line);
  max-width: 100%;
  overflow: hidden;
}

.config-footer .primary-button {
  min-width: 108px;
  height: 38px;
  border-radius: 9px;
}

.config-records-panel {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: 10px;
  background: #fff;
}

.config-records-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.config-records-head strong {
  color: #111827;
  font-size: 14px;
}

.config-records-head span {
  color: #8a96a8;
  font-size: 12px;
}

.config-records-list {
  display: grid;
  gap: 8px;
}

.config-record {
  display: grid;
  grid-template-columns: minmax(160px, .7fr) minmax(280px, 1.6fr) minmax(180px, .8fr);
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid #edf1f6;
  border-radius: 9px;
  background: #fbfdff;
}

.config-record-meta,
.config-record-main,
.config-record-foot {
  min-width: 0;
}

.config-record-meta,
.config-record-foot {
  display: grid;
  gap: 4px;
  color: #7b8798;
  font-size: 12px;
}

.config-record-meta b {
  font-size: 12px;
  font-weight: 700;
}

.config-record-meta b.waiting { color: var(--primary-dark); }
.config-record-meta b.success { color: #047857; }
.config-record-meta b.failed { color: #b91c1c; }

.config-record-main {
  display: grid;
  gap: 4px;
}

.config-record-main code {
  color: #275db3;
  font-weight: 700;
}

.config-record-main span {
  color: #4b5563;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.task-result strong {
  flex: 0 0 auto;
  font-weight: 620;
}

.task-result span {
  min-width: 0;
  flex: 1 1 280px;
  color: inherit;
  opacity: .9;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.task-result.success {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.task-result.danger {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

.task-result code {
  min-width: 0;
  color: inherit;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.result {
  min-height: 48px;
  margin: 14px 0 0;
  padding: 12px;
  border-radius: 12px;
  background: #111827;
  color: #d1fae5;
  overflow: auto;
}

.login-page {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(380px, .92fr);
  padding: 30px;
  gap: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .98) 0%, rgba(248, 250, 252, .98) 54%, rgba(240, 246, 246, .96) 100%);
}

.login-page.hidden,
.hidden {
  display: none !important;
}

.login-card {
  align-self: center;
  justify-self: center;
  width: min(430px, 100%);
  padding: 32px;
  border: 1px solid rgba(226, 232, 240, .96);
  border-radius: 14px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 18px 38px rgba(15, 23, 42, .065);
  backdrop-filter: blur(14px);
}

.login-lang {
  position: fixed;
  top: 28px;
  right: 28px;
  z-index: 85;
  box-shadow: 0 8px 22px rgba(31, 41, 55, .06);
}

.login-visual {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 56px);
  padding: 56px;
  border-radius: 18px;
  color: #111827;
  background:
    linear-gradient(135deg, rgba(255,255,255,.94), rgba(255,255,255,.82)),
    linear-gradient(120deg, rgba(255,106,0,.10), rgba(14,165,164,.08));
  border: 1px solid rgba(230, 235, 242, .92);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.72);
}

.login-visual::before {
  content: "";
  position: absolute;
  inset: 34px 34px auto auto;
  width: 146px;
  height: 146px;
  border-radius: 30px;
  border: 1px solid rgba(255, 106, 0, .16);
  background:
    linear-gradient(135deg, rgba(255,255,255,.74), rgba(255,255,255,.20)),
    repeating-linear-gradient(45deg, rgba(255,106,0,.14) 0 2px, transparent 2px 16px);
  transform: rotate(8deg);
  opacity: .46;
}

.login-visual::after {
  content: "";
  position: absolute;
  inset: auto -12% -18% 28%;
  height: 42%;
  background:
    repeating-linear-gradient(90deg, rgba(255,106,0,.24) 0 2px, transparent 2px 28px),
    repeating-linear-gradient(0deg, rgba(14,165,164,.16) 0 2px, transparent 2px 28px);
  transform: rotate(-8deg);
  opacity: .28;
}

.login-brand-label {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  color: var(--primary-dark);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .08em;
}

.login-brand-label::before {
  content: "";
  width: 58px;
  height: 3px;
  border-radius: 999px;
  background: var(--primary);
}

.login-icp {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
}

.login-icp a {
  color: var(--muted);
  text-decoration: none;
}

.login-icp a:hover { color: var(--primary-dark); }

.toggle-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.account-toggle-line {
  width: fit-content;
  min-height: 34px;
  margin-top: -2px;
  padding: 0 10px;
  border: 1px solid #e6ebf2;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-weight: 620;
}

.account-toggle-line input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.login-visual h1 {
  max-width: 650px;
  font-size: clamp(42px, 4.6vw, 64px);
  line-height: 1.06;
  margin: 0 0 14px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.login-title-row {
  align-items: flex-start;
  margin-bottom: 14px;
}

.login-title-row h1 {
  margin: 0;
}

.login-visual p {
  max-width: 560px;
  color: #64748b;
  font-size: 17px;
  line-height: 1.5;
}

.login-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.login-highlights span {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(230, 235, 242, .94);
  color: var(--muted);
  font-size: 13px;
}

.login-card-head h2 {
  margin: 0;
  font-size: 28px;
  color: #111827;
}

.login-card-head p {
  margin-top: 8px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-form input {
  height: 44px;
  border: 1px solid #d9e1ec;
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: #111827;
  caret-color: var(--primary);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.login-form input:focus {
  outline: 0;
  border-color: rgba(255, 106, 0, .42);
  box-shadow: 0 0 0 3px rgba(255, 106, 0, .10);
  background: #fff;
}

.login-password-wrap {
  position: relative;
  height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  border: 1px solid #d9e1ec;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.login-password-wrap:focus-within {
  border-color: rgba(255, 106, 0, .38);
  box-shadow: 0 0 0 3px rgba(255, 106, 0, .10);
}

.login-password-wrap input {
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 0;
  border-radius: 0;
  padding: 0 12px;
  background: transparent;
  color: #111827;
  -webkit-text-fill-color: #111827;
  caret-color: var(--primary);
}

.login-password-wrap input:focus {
  outline: none;
}

.login-password-toggle {
  position: static;
  z-index: 2;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  transform: none;
}

.login-password-toggle svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.login-password-toggle:hover,
.login-password-toggle.active {
  color: var(--primary-dark);
  border-color: rgba(255, 106, 0, .22);
  background: #fff7ed;
}

.remember-login {
  display: inline-flex !important;
  grid-template-columns: none !important;
  align-items: center;
  justify-content: flex-start;
  gap: 8px !important;
  min-width: 0;
  margin-top: -2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 560;
  cursor: pointer;
}

.remember-login span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remember-login input {
  position: relative;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  accent-color: var(--primary);
  cursor: pointer;
}

.login-form .remember-login input {
  width: 18px !important;
  min-width: 18px !important;
  max-width: 18px !important;
  height: 18px !important;
  min-height: 18px !important;
  max-height: 18px !important;
  padding: 0 !important;
}

.remember-login input:checked {
  border-color: var(--primary);
  background: var(--primary);
}

.remember-login input:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(42deg);
}

.login-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: -2px;
}

.text-button {
  flex: 0 0 auto;
  border: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}

.text-button:hover {
  color: var(--primary-dark);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 14px;
  color: var(--muted);
  font-size: 12px;
}

.login-divider::before,
.login-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.login-assist-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 46px;
}

#wechatLoginBtn,
.wechat-alarm-line,
#bindWechatBtn,
.account-menu-head small:nth-of-type(2),
.account-table th:nth-child(7),
.account-table td:nth-child(7) {
  display: none !important;
}

@media (max-width: 900px) {
  .alarm-prompt-line {
    display: none !important;
  }
}

.wechat-button {
  width: fit-content;
  min-width: 0;
  height: 34px;
  margin: 0;
  padding: 0 13px 0 10px;
  border: 1px solid rgba(203, 213, 225, .85);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #475569;
  background: rgba(255, 255, 255, .86);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.legacy-platform-button {
  text-decoration: none;
}

.legacy-platform-button::after {
  content: "\2197";
  font-size: 13px;
  line-height: 1;
  color: #64748b;
}

.wechat-button:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  box-shadow: 0 6px 14px rgba(15, 23, 42, .08);
}

.wechat-button:disabled {
  cursor: wait;
  opacity: .62;
}

.wechat-mark {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #fff;
  background: #22c55e;
}

.wechat-mark svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.email-bind-mark {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #fff;
  background: #2563eb;
}

.email-bind-mark svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.wechat-choice-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, .35);
}

.modal-card {
  width: min(720px, 100%);
  padding: 20px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(230, 235, 242, .95);
  box-shadow: 0 18px 42px rgba(15, 23, 42, .08);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
}

.modal-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.modal-card .config-grid {
  grid-template-columns: 1fr;
}

.modal-card .select {
  width: 100%;
}

.modal-card .primary-button {
  margin-top: 14px;
}

.admin-modal-card {
  width: min(880px, 100%);
  max-height: min(820px, calc(100vh - 28px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  padding-bottom: 0;
}

.modal-form {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0;
  min-height: 0;
}

#adminModalBody {
  min-height: 0;
  overflow: auto;
  padding: 0 2px 16px 0;
}

.modal-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.account-preference-grid {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--soft-line);
}

.account-preference-grid .field {
  min-width: 0;
}

.account-preference-preview {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.account-preference-card {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  background: #fbfdff;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.account-preference-card.active {
  border-color: rgba(37, 99, 235, .45);
  background: #f5f9ff;
  box-shadow: inset 3px 0 0 #2563eb;
}

.account-preference-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.account-preference-card-head strong {
  color: #172033;
  font-size: 13px;
  font-weight: 760;
}

.account-preference-card-head span {
  color: #64748b;
  font-size: 12px;
  white-space: nowrap;
}

.account-preference-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 12px;
  margin: 0;
}

.account-preference-card dl div {
  min-width: 0;
}

.account-preference-card dt,
.account-preference-card dd {
  margin: 0;
}

.account-preference-card dt {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
}

.account-preference-card dd {
  overflow: hidden;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-group-field {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--soft-line);
}

.account-group-field > label {
  color: #64748b;
  font-weight: 680;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 -20px;
  padding: 12px 20px 16px;
  border-top: 1px solid #edf1f6;
  background: #fff;
  box-shadow: 0 -10px 24px rgba(15, 23, 42, .04);
}

.modal-actions .primary-button {
  margin-top: 0;
}

.form-note {
  padding: 10px 12px;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  color: #9a3412;
  background: #fff3e8;
  font-size: 13px;
  line-height: 1.5;
}

.muted-note {
  border-color: #e2e8f0;
  color: #64748b;
  background: #f8fafc;
}

.error-note {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fef2f2;
}

.email-bind-card {
  width: min(520px, 100%);
}

.email-bind-form {
  display: grid;
  gap: 14px;
}

.email-bind-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.email-bind-form input {
  height: 42px;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  padding: 0 12px;
  color: var(--text);
  font: inherit;
}

.email-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.email-code-row .secondary-button {
  height: 42px;
  white-space: nowrap;
}

.group-picker {
  position: relative;
  margin-top: 7px;
}

.group-picker details {
  position: relative;
}

.group-picker summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.group-picker summary::-webkit-details-marker {
  display: none;
}

.group-picker summary span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.group-picker summary small {
  color: var(--muted);
  white-space: nowrap;
}

.group-picker-menu {
  display: grid;
  gap: 6px;
  max-height: min(360px, 42vh);
  overflow: auto;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}

.group-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.group-check:hover {
  border-color: rgba(255, 106, 0, .42);
  background: #fffaf5;
}

.group-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.group-check strong,
.group-check small {
  display: block;
}

.group-check small {
  margin-top: 2px;
  color: var(--muted);
}

.account-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--soft-line);
  border-radius: 12px;
  background: #f8fafc;
}

.account-summary span,
.empty-state {
  color: var(--muted);
}

.logo-upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.logo-preview-wrap {
  width: 180px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #fff;
}

.logo-preview-wrap img {
  max-width: 160px;
  max-height: 46px;
  object-fit: contain;
}

@media (max-width: 1280px) {
  .device-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1080px) {
  .device-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  :root {
    --mobile-nav-bottom: max(6px, env(safe-area-inset-bottom));
    --mobile-nav-height: 64px;
    --mobile-browser-reserve: max(26px, env(safe-area-inset-bottom));
    --mobile-nav-clearance: calc(var(--mobile-nav-height) + var(--mobile-nav-bottom) + var(--mobile-browser-reserve));
  }

  .account-preference-preview,
  .account-preference-card dl {
    grid-template-columns: 1fr;
  }

  .account-preference-card-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .account-preference-card-head span {
    white-space: normal;
  }

  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
    scroll-padding-bottom: calc(var(--mobile-nav-clearance) + 52px);
  }
  input,
  select,
  textarea {
    font-size: 16px;
  }
  body::after {
    content: "";
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 29;
    height: calc(var(--mobile-nav-bottom) + var(--mobile-browser-reserve));
    background: var(--bg);
    pointer-events: none;
  }
  .app {
    grid-template-columns: 1fr;
  }
  .app::after {
    content: "";
    position: fixed;
    left: 0;
    right: 0;
    top: var(--mobile-cover-top, calc(100dvh - var(--mobile-nav-bottom) - var(--mobile-nav-height) - 18px));
    bottom: 0;
    z-index: 31;
    height: auto;
    background: var(--bg);
    pointer-events: none;
  }
  .sidebar {
    position: fixed;
    top: auto;
    height: auto;
    left: 12px;
    right: 12px;
    bottom: var(--mobile-nav-bottom);
    z-index: 32;
    border: 1px solid rgba(226, 232, 240, .92);
    border-radius: 18px;
    padding: 6px 8px 9px;
    background: #fff;
    backdrop-filter: none;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .10);
    overflow: hidden;
  }
  .brand { display: none; }
  nav { display: flex; gap: 2px; overflow: hidden; padding-bottom: 2px; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  .nav-item[data-view="groups"],
  .nav-item[data-view="accounts"],
  .nav-item[data-view="product"] {
    display: none;
  }
  .nav-item { flex: 1 1 0; min-width: 0; }
  .nav-item { height: 48px; justify-content: center; padding: 0; flex-direction: column; gap: 3px; font-size: 11px; border-radius: 10px; }
  .nav-icon { width: 23px; height: 23px; flex-basis: 23px; font-size: 14px; border-radius: 8px; }
  .nav-icon svg { width: 15px; height: 15px; }
  .nav-icon-trend { font-size: 18px; }
  .nav-item b { display: block; width: 100%; max-width: 100%; overflow: hidden; text-overflow: clip; white-space: nowrap; font-size: 10px; line-height: 1.05; text-align: center; }
  .main { padding: 14px 14px calc(var(--mobile-nav-clearance) + 18px); overflow-x: hidden; }
  #overview.view.active {
    min-height: 0;
    display: block;
    padding-bottom: 0;
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 9;
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
    padding: 0 4px 2px;
    background: #f6f8fb;
  }
  .topbar > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
  }
  .panel-head { align-items: stretch; flex-direction: column; gap: 10px; }
  .panel-head h2 { font-size: 20px; }
  #devices .panel-head .inline-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }
  #devices .panel-head .secondary-button,
  #devices .panel-head .select,
  #devices .panel-head .search {
    width: 100%;
    min-width: 0;
    max-width: none;
  }
  #devices .panel-head .select,
  #devices .panel-head .search {
    grid-column: 1 / -1;
  }
  #devices .panel-head #syncDevicesBtn.sync-owned-only {
    grid-column: 1 / -1;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 30px;
  }
  .kpi {
    min-height: 78px;
    align-content: center;
    border: 1px solid rgba(226, 232, 240, .86);
    border-radius: 8px;
    padding: 13px 14px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .028);
  }
  .kpi.active {
    border-color: rgba(255, 106, 0, .22);
    box-shadow: 0 5px 13px rgba(15, 23, 42, .035);
  }
  .kpi:nth-child(odd) {
    transform: translateY(3px);
  }
  .kpi:nth-child(odd):hover,
  .kpi:nth-child(odd).active {
    transform: translateY(2px);
  }
  body.status-filter-active .kpi:not(.active) {
    opacity: .48;
    filter: grayscale(.55);
    background: #f8fafc;
    border-color: #e8edf4;
    box-shadow: none;
  }
  .device-grid {
    display: flex;
    grid-template-columns: none;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
    padding: 2px 0 6px;
    margin: 0;
    scrollbar-width: none;
  }
  .device-grid::-webkit-scrollbar { display: none; }
  .config-grid { grid-template-columns: 1fr; }
  .config-section:nth-child(1) .config-section-grid,
  .config-section:nth-child(2) .config-section-grid,
  .config-section:nth-child(3) .config-section-grid {
    grid-template-columns: 1fr;
  }
  .trend-grid { grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 10px; }
  .trend-summary-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-card { min-width: 0; overflow: hidden; padding: 11px 10px; border-radius: 10px; }
  .chart-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: flex-start;
    justify-content: stretch;
    gap: 6px;
  }
  .chart-heading { width: 100%; min-width: 0; }
  .chart-heading strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
  .chart-stat {
    justify-self: start;
    max-width: 100%;
    min-height: 21px;
    padding: 3px 9px;
    border: 1px solid #e6ebf2;
    border-radius: 999px;
    background: #f8fafc;
    font-size: 10.2px;
    line-height: 1.25;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    text-align: left;
  }
  .chart {
    width: 100%;
    min-width: 0;
    height: 178px;
    border-radius: 9px;
  }
  .chart-summary {
    min-width: 0;
    min-height: 24px;
    padding: 7px 10px 2px;
    font-size: 10.5px;
    white-space: normal;
  }
  .chart svg { max-width: 100%; }
  .panel { padding: 14px; border-radius: 14px; }
  #trends > .panel { padding: 12px 10px 10px; overflow: hidden; }
  .overview-device-panel {
    position: relative;
    display: block;
    flex: 0 0 auto;
    margin-top: 0;
    padding: 2px 0 0;
    min-height: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .overview-device-panel .panel-head {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 16px;
    min-height: 0;
    margin-bottom: 14px;
    padding: 0;
  }
  .overview-device-panel .panel-head h2 {
    font-size: 21px;
    line-height: 1.25;
  }
  .overview-device-actions {
    display: grid;
    grid-template-columns: minmax(132px, .82fr) minmax(0, 1.18fr);
    gap: 8px;
    width: 100%;
  }
  .overview-device-actions .select,
  .overview-device-search {
    display: block !important;
    width: 100%;
    min-width: 0;
    max-width: none;
    height: 46px;
    border-radius: 9px;
    font-size: 16px;
  }
  .overview-device-actions .select {
    order: 1;
  }
  .overview-device-search {
    display: block !important;
    order: 2;
    margin-top: 0;
    background-color: #fff;
  }
  .overview-device-actions .monitor-mode-exit-button {
    order: 3;
  }
  .overview-device-panel .device-grid {
    flex: 0 0 auto;
    gap: 12px;
    min-height: 0;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 0 20px;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 5px;
  }
  .overview-device-panel::before,
  .overview-device-panel::after {
    position: absolute;
    top: 209px;
    z-index: 3;
    width: 22px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 0;
    color: rgba(100, 116, 139, .24);
    background: transparent;
    border: 0;
    box-shadow: none;
    font-size: 30px;
    font-weight: 260;
    line-height: 1;
    pointer-events: none;
  }
  .overview-device-panel::before {
    content: "‹";
    left: -10px;
  }
  .overview-device-panel::after {
    content: "›";
    right: -10px;
  }
  .overview-device-panel:not(:has(.device-card))::before,
  .overview-device-panel:not(:has(.device-card))::after {
    display: none;
  }
  .actions { width: auto; flex: 0 0 auto; justify-content: flex-end; flex-wrap: nowrap; gap: 12px; padding-top: 0; min-width: 0; }
  .user-badge {
    display: inline-flex !important;
    flex: 0 0 auto;
    min-height: 34px;
    overflow: visible;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
  }
  .user-badge *,
  .user-badge *::before,
  .user-badge *::after {
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none;
  }
  .top-timezone { display: none; }
  .top-monitor-button,
  .monitor-mode-exit-button,
  .alarm-sound-button {
    display: none !important;
  }
  .account-button {
    max-width: 34px;
    width: 34px;
    height: 34px;
    display: inline-grid;
    grid-template-columns: 1fr;
    place-items: center;
    padding: 0;
    justify-content: center;
    border-radius: 999px;
    border: 0;
    outline: 0;
    overflow: hidden;
    appearance: none;
    -webkit-appearance: none;
    background: transparent !important;
    box-shadow: none !important;
    filter: none !important;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .account-button:hover,
  .account-button:active,
  .account-button:focus,
  .account-button:focus-visible,
  .user-badge.open .account-button {
    border-color: transparent;
    outline: 0;
    box-shadow: none !important;
    filter: none !important;
    background: transparent !important;
  }
  .account-button::before,
  .account-button::after,
  .account-avatar::before,
  .account-avatar::after {
    display: none !important;
    content: none !important;
  }
  .account-avatar {
    width: 31px;
    height: 31px;
    font-size: 11px;
    outline: 0;
    box-shadow: none !important;
    filter: none !important;
    -webkit-tap-highlight-color: transparent;
    pointer-events: none;
  }
  .account-name,
  .account-chevron {
    display: none;
  }
  .account-menu { left: auto; right: 0; }
  #settingsBtn { display: none; }
  .refresh-control { display: none; }
  .refresh-button {
    min-width: 38px;
    width: 38px;
    padding: 0;
    justify-content: center;
  }
  .refresh-button span { display: none; }
  .refresh-menu { left: 0; right: auto; }
  .inline-controls, .select { width: 100%; }
  .wide-search { min-width: 0; }
  .alarm-filter-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
  }
  .alarm-filter-controls .select {
    width: 100%;
    min-width: 0;
  }
  .management-shell,
  .account-tree {
    grid-template-columns: 1fr;
  }
  .management-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .management-stats article {
    min-height: 64px;
    padding: 11px 12px;
  }
  .management-stats strong {
    font-size: 21px;
  }
  .group-tree {
    max-height: 260px;
  }
  .sub-account-item {
    grid-template-columns: 18px minmax(0, 1fr);
  }
  .sub-account-groups {
    grid-column: 2;
  }
  .relation-grid,
  .help-grid { grid-template-columns: 1fr; }
  .config-footer { align-items: stretch; flex-direction: column; }
  .config-footer-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .config-footer .primary-button,
  .config-record-toggle { width: 100%; }
  .config-record {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 7px;
  }
  .config-record-foot {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
  }
  #pageTitle { display: none; }
  .page-title-row { align-items: flex-start; gap: 8px; }
  .cloud-mark-small { width: 28px; height: 20px; margin-top: 2px; }
  .eyebrow {
    display: inline-flex;
    margin-bottom: 0;
    max-width: 100%;
    font-size: 13px;
    line-height: 34px;
    white-space: nowrap;
  }
  .eyebrow::before {
    width: 34px;
    height: 2px;
  }
  .actions { width: auto; justify-content: flex-end; padding-top: 0; }
  .language-picker {
    flex: 0 0 auto;
    min-width: 0;
    margin-right: 10px;
  }
  .language-button {
    min-width: 0;
    width: 80px;
    max-width: 80px;
    height: 34px;
    grid-template-columns: auto minmax(0, 1fr) 10px;
    padding: 0 8px;
    gap: 5px;
    border-radius: 10px;
    font-size: 11.5px;
  }
  .login-lang .language-button {
    width: 104px;
    max-width: 104px;
    height: 32px;
    font-size: 13px;
  }
  .language-button span:nth-child(2) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .language-menu { width: 168px; left: 0; right: auto; z-index: 80; }
  .login-lang .language-menu { left: auto; right: 0; }
  .language-menu button { justify-content: flex-start; }
  .language-menu .flag-icon { display: inline-grid; }
  .icon-button { flex: 0 0 38px; }
  .login-card { padding: 24px; border-radius: 16px; }
  .login-lang { top: 14px; right: 14px; }
  .login-page {
    grid-template-columns: 1fr;
    align-content: start;
    justify-items: center;
    width: 100%;
    min-height: 100dvh;
    padding: 92px 14px calc(118px + env(safe-area-inset-bottom));
    gap: 14px;
    overflow: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-padding-bottom: calc(118px + env(safe-area-inset-bottom));
  }
  .login-visual {
    display: grid;
    gap: 8px;
    width: min(430px, 100%);
    min-height: 0;
    height: 82px;
    padding: 0 10px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }
  .login-visual::before { display: none; }
  .login-visual::after { display: none; }
  .login-brand-label {
    gap: 9px;
    margin-bottom: 7px;
    font-size: 12px;
    letter-spacing: .06em;
  }
  .login-brand-label::before {
    width: 34px;
    height: 2px;
  }
  .login-title-row { gap: 8px; margin-bottom: 7px; }
  .login-title-row {
    display: block;
  }
  .login-title-row .cloud-mark { width: 34px; height: 25px; margin-top: 2px; }
  .login-visual h1 {
    max-width: 100%;
    font-size: 28px;
    line-height: 1.08;
    margin: 0;
    color: #111827;
    font-weight: 820;
  }
  .login-visual p {
    display: none;
  }
  .login-highlights {
    display: none;
  }
  .login-card {
    width: min(430px, 100%);
    padding: 24px 20px 22px;
    border-radius: 18px;
    border-color: rgba(226, 232, 240, .98);
    box-shadow: 0 16px 34px rgba(15, 23, 42, .075);
  }
  .login-card-head h2 {
    font-size: 23px;
    line-height: 1.18;
  }
  .login-card-head p {
    margin-top: 5px;
    font-size: 13px;
  }
  .login-form {
    gap: 11px;
    margin-top: 16px;
  }
  .login-form input {
    height: 43px;
    border-radius: 10px;
    font-size: 16px !important;
    line-height: normal;
    -webkit-text-size-adjust: 100%;
    transform: translateZ(0);
    color: #111827;
    -webkit-text-fill-color: #111827;
  }
  .login-password-wrap {
    height: 43px;
    grid-template-columns: minmax(0, 1fr) 40px;
    border-radius: 10px;
  }
  .login-password-wrap input {
    position: relative;
    z-index: 1;
    min-width: 0;
    font-size: 16px !important;
    line-height: normal;
    pointer-events: auto;
    -webkit-user-select: text;
    user-select: text;
    color: #111827;
    -webkit-text-fill-color: #111827;
  }
  .login-password-toggle {
    position: relative;
    z-index: 2;
    width: 30px;
    height: 30px;
  }
  .login-options-row {
    gap: 8px;
    min-height: 28px;
  }
  .remember-login,
  .text-button {
    font-size: 12px;
  }
  .login-form .remember-login input {
    width: 18px;
    min-width: 18px;
    max-width: 18px;
    height: 18px;
    min-height: 18px;
    max-height: 18px;
    flex-basis: 18px;
    padding: 0;
    border-radius: 6px;
  }
  .wechat-button {
    height: 32px;
    border-radius: 999px;
    padding-inline: 12px;
  }
  .login-assist-actions {
    gap: 12px 30px;
  }
  .wechat-choice-actions {
    grid-template-columns: 1fr;
  }
  .mobile-brand-field { display: none; }
  .kpi span { font-size: 12px; line-height: 1.18; }
  .kpi strong { margin-top: 6px; font-size: 25px; line-height: .95; }
  .kpi-subline {
    display: inline-flex;
    margin-top: 4px;
    font-size: 10.5px;
    line-height: 1.1;
    opacity: 1;
  }
  .kpi-subline b {
    font-size: 11.5px;
  }
  .kpi::after {
    width: 66px;
    height: 66px;
    right: -22px;
    top: -24px;
  }
  .device-card {
    flex: 0 0 min(390px, calc(100vw - 24px));
    max-width: 100%;
    aspect-ratio: auto;
    min-width: 0;
    min-height: 0;
    height: auto;
    padding: 13px 15px 12px;
    border-radius: 10px;
    border-color: rgba(224, 231, 240, .95);
    box-shadow: 0 5px 16px rgba(15, 23, 42, .045);
    scroll-snap-align: center;
    scroll-margin-inline: 5px;
    overflow: hidden;
  }
  .device-card::before {
    content: none;
  }
  .overview-device-panel .device-card {
    flex-basis: min(390px, calc(100vw - 24px));
    min-height: 300px;
    height: auto;
    max-height: none;
  }
  .device-card header {
    min-height: 52px;
    margin-bottom: 16px;
    align-items: flex-start;
  }
  .device-name-row {
    grid-template-columns: minmax(0, 1fr) 18px;
    gap: 4px;
  }
  .device-card strong { font-size: 16px; font-weight: 720; line-height: 1.18; }
  .device-ids {
    margin-top: 4px;
  }
  .device-ids small {
    font-size: 12px;
  }
  .name-edit-button {
    width: 18px;
    height: 18px;
    color: var(--primary);
    opacity: .72;
  }
  .metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    flex: 1 1 auto;
    gap: 10px;
  }
  .metric {
    min-width: 0;
    min-height: 94px;
    padding: 16px 15px;
    row-gap: 9px;
    align-content: center;
    border: 1px solid rgba(233, 238, 246, .88);
    border-radius: 7px;
    background: linear-gradient(180deg, #fafbfe 0%, #f5f7fb 100%);
  }
  .metric span { font-size: 13px; line-height: 1.2; font-weight: 560; color: #7b8493; }
  .metric b { margin-top: 0; color: var(--metric-blue); font-size: 18px; line-height: 1.18; font-weight: 760; overflow-wrap: anywhere; }
  .device-actions {
    display: grid;
    grid-template-columns: auto 28px;
    gap: 7px;
    align-items: center;
  }
  .settings-button {
    display: inline-grid !important;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 8px;
    color: #64748b;
    background: #f8fafc;
    border-color: #e4eaf2;
    box-shadow: none;
    opacity: 1;
  }
  .settings-button svg {
    width: 14px;
    height: 14px;
  }
  .status {
    min-height: 24px;
    padding: 0;
    background: transparent !important;
    font-size: 13px;
    font-weight: 760;
  }
  .status::before {
    width: 8px;
    height: 8px;
  }
  .device-time-row {
    display: flex;
    flex: 0 0 auto;
    min-height: 22px;
    margin-top: 7px;
    padding-top: 6px;
  }
  .device-time {
    font-size: 10.5px;
  }
  .mobile-timezone-badge {
    display: inline-flex;
    font-size: 9.5px;
    padding: 0 5px;
  }

  @media (max-height: 780px) {
    .main {
      padding-top: 12px;
      padding-bottom: calc(var(--mobile-nav-clearance) - 8px);
    }

    .topbar {
      margin-bottom: 14px;
    }

    .kpi-grid {
      gap: 10px;
      margin-bottom: 20px;
    }

    .kpi {
      min-height: 68px;
      padding: 10px 12px;
    }

    .kpi span {
      font-size: 11px;
    }

    .kpi strong {
      margin-top: 4px;
      font-size: 22px;
    }

    .overview-device-panel .panel-head {
      gap: 12px;
      margin-bottom: 10px;
    }

    .overview-device-panel .panel-head h2 {
      font-size: 19px;
    }

    .overview-device-actions .select,
    .overview-device-search {
      height: 38px;
      font-size: 13px;
    }

    .overview-device-panel .device-card {
      min-height: 268px;
      padding: 12px 14px;
    }

    .device-card header {
      min-height: 42px;
      margin-bottom: 10px;
    }

    .metrics {
      gap: 8px;
    }

    .metric {
      min-height: 62px;
      padding: 8px 12px;
      row-gap: 5px;
    }

    .metric span {
      font-size: 12px;
    }

    .metric b {
      color: var(--metric-blue);
      font-size: 15px;
    }

    .device-time-row {
      min-height: 21px;
      margin-top: 6px;
      padding-top: 5px;
    }
  }

  .admin-modal-card {
    max-height: calc(100dvh - 18px);
    width: 100%;
  }

  #adminModalBody {
    padding-right: 0;
  }
  .modal-form-grid { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .primary-button,
  .modal-actions .secondary-button { width: 100%; }
  .email-code-row { grid-template-columns: 1fr; }
  .email-code-row .secondary-button { width: 100%; }
  .history-head {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
  }
  .trend-head {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
  }
  .history-title-block {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: stretch;
    gap: 10px;
  }
  .history-range-switch {
    justify-self: end;
    width: 112px;
  }
  .history-range-switch button {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 8px;
  }
  .history-head .inline-controls,
  .trend-head .inline-controls,
  .config-head .inline-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    gap: 8px;
  }
  .history-head .wide-search,
  .trend-head .wide-search,
  .config-head .wide-search,
  .history-head #historyDeviceSelect,
  .trend-head #trendDeviceSelect,
  .history-head .select,
  .trend-head .select,
  .config-head .select,
  .history-head .secondary-button,
  .trend-head .secondary-button,
  .config-head .icon-button {
    width: 100%;
    min-width: 0;
    max-width: none;
  }
  .history-head .wide-search,
  .trend-head .wide-search,
  .history-head #historyDeviceSelect,
  .trend-head #trendDeviceSelect,
  .history-head .secondary-button,
  .trend-head .secondary-button {
    grid-column: 1 / -1;
  }
  .history-head #historyGroupFilter,
  .trend-head #trendGroupFilter {
    grid-column: 1 / -1;
  }
  .config-page {
    gap: 10px;
    margin-bottom: 112px;
  }
  .config-head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .config-head .inline-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .config-head .wide-search,
  .config-head .select {
    grid-column: 1 / -1;
  }
  .config-head .icon-button {
    min-height: 36px;
  }
  .config-section {
    padding: 10px;
    border-radius: 10px;
  }
  .config-section-head {
    min-height: 30px;
    margin-bottom: 8px;
  }
  .config-section-head h3 {
    font-size: 14px;
  }
  .config-section-grid {
    gap: 8px;
  }
  .config-field {
    padding: 9px;
    border-radius: 9px;
  }
  .config-field label {
    gap: 7px;
    font-size: 12px;
  }
  .config-field input,
  .config-field select,
  .config-field .select {
    min-height: 34px;
    font-size: 13px;
  }
  .history-count {
    grid-column: 1 / -1;
    grid-row: auto;
    justify-content: center;
    flex-wrap: wrap;
    min-width: 0;
    width: 100%;
  }
  .history-table-wrap { max-height: 520px; }
  #history.view.active {
    padding-bottom: 72px;
  }
  #history .history-table-shell {
    margin-bottom: 52px;
  }
  .history-pager {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    justify-content: stretch;
    gap: 8px;
  }
  .history-pager input[type="range"] {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    order: 4;
  }
  .history-pager #historyPageInfo {
    grid-column: 2;
    order: 2;
    justify-content: center;
    width: 100%;
  }
  .history-pager #historyPrevBtn {
    grid-column: 1;
    order: 1;
  }
  .history-pager #historyNextBtn {
    grid-column: 3;
    order: 3;
  }
  .history-pager #historyPrevBtn,
  .history-pager #historyNextBtn,
  .history-pager #downloadHistoryBtn {
    width: 100%;
    min-width: 0;
  }
  .history-pager #downloadHistoryBtn {
    grid-column: 1 / -1;
    order: 6;
  }
  .history-pager .history-count { order: 5; }
  .history-pager span { min-width: 0; }
}

