:root {
  color-scheme: light;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  color: #172033;
  background: #eef3f8;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #172033;
  --muted: #667085;
  --line: #d8e1ea;
  --panel: #ffffff;
  --panel-strong: #f8fafc;
  --blue: #0069a8;
  --cyan: #0588a8;
  --teal: #138a72;
  --green: #15803d;
  --amber: #bd8b00;
  --yellow: #f2d72f;
  --red: #dc2626;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #eef3f6;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.glyph {
  display: inline-grid;
  flex: 0 0 auto;
  width: 1.45em;
  height: 1.45em;
  place-items: center;
  font-weight: 800;
  line-height: 1;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 22px;
  color: #e5edf6;
  background: #102b3c;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong {
  display: block;
  color: #ffffff;
  font-size: 22px;
  letter-spacing: 0;
}

.brand span,
.domain-card span {
  display: block;
  color: #a8b7cc;
  font-size: 13px;
  line-height: 1.5;
}

.brand > div:last-child span {
  color: #f2d72f;
  font-size: 10px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 3px solid #f2d72f;
  border-radius: 8px;
  color: #0069a8;
  background: #ffffff;
  box-shadow: 7px 7px 0 #f2d72f;
  font-size: 22px;
  font-weight: 900;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #cbd5e1;
  background: transparent;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  border-color: rgba(242, 215, 47, 0.4);
  color: #ffffff;
  background: rgba(0, 105, 168, 0.42);
}

.domain-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.14);
}

.domain-card strong {
  display: block;
  margin: 6px 0;
  color: #ffffff;
  font-size: 16px;
  word-break: break-word;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.status-pill,
.device-badge,
.result {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.ready {
  color: #065f46;
  background: #dcfce7;
}

.status-pill.pending {
  color: #594a00;
  background: #fff8c5;
}

.source-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 11px 14px;
  border-left: 4px solid var(--yellow);
  color: #314158;
  background: #ffffff;
}

.source-banner small {
  color: var(--muted);
  white-space: nowrap;
}

.source-banner.error {
  border-color: var(--red);
  color: #991b1b;
  background: #fff7f7;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
}

.logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 700;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 136px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card::before {
  width: 4px;
  align-self: stretch;
  border-radius: 3px;
  background: var(--yellow);
  content: "";
}

.metric-card > div {
  margin-right: auto;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.metric-card strong {
  display: block;
  margin: 10px 0 8px;
  color: var(--ink);
  font-size: 34px;
  line-height: 1;
}

.metric-card.green .glyph {
  color: var(--green);
}

.metric-card.amber .glyph {
  color: var(--amber);
}

.metric-card.blue .glyph {
  color: var(--blue);
}

.metric-card.cyan .glyph {
  color: var(--cyan);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.78fr) minmax(420px, 1.38fr) minmax(300px, 0.84fr);
  gap: 16px;
  align-items: start;
}

.surface {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.device-panel,
.detail-panel,
.control-panel,
.alerts-panel {
  padding: 18px;
}

.right-rail {
  display: grid;
  gap: 16px;
  align-content: start;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-heading.compact {
  align-items: center;
  margin: 8px 0 12px;
}

.panel-heading h2,
.panel-heading h3 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.2;
}

.panel-heading h3 {
  font-size: 18px;
}

.panel-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.device-panel .panel-heading {
  align-items: stretch;
  flex-direction: column;
}

.device-panel .search-box {
  width: 100%;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 160px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #ffffff;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
}

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

.device-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 66px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: #ffffff;
  text-align: left;
}

.device-row.selected {
  border-left: 4px solid var(--blue);
  background: #eef8fd;
}

.device-row strong,
.device-row small {
  display: block;
}

.device-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.status-dot.online,
.device-badge.online {
  color: #065f46;
  background: #dcfce7;
}

.status-dot.warning,
.device-badge.warning {
  color: #92400e;
  background: #fef3c7;
}

.status-dot.offline,
.device-badge.offline {
  color: #991b1b;
  background: #fee2e2;
}

.status-dot.unknown,
.device-badge.unknown {
  color: #475569;
  background: #e2e8f0;
}

.status-dot.unknown {
  background: #94a3b8;
}

.status-dot.online {
  background: var(--green);
}

.status-dot.warning {
  background: var(--amber);
}

.status-dot.offline {
  background: var(--red);
}

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

.detail-header h2 {
  margin: 4px 0;
  font-size: 28px;
}

.detail-header span {
  color: var(--muted);
  font-size: 14px;
}

.device-account-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
  border-block: 1px solid var(--line);
}

.device-account-summary > div {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  border-inline-end: 1px solid var(--line);
}

.device-account-summary > div:last-child {
  border-inline-end: 0;
}

.device-account-summary span,
.device-account-summary small {
  color: var(--muted);
  font-size: 12px;
}

.device-account-summary strong {
  overflow-wrap: anywhere;
  font-size: 15px;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.telemetry-tile {
  display: grid;
  gap: 6px;
  min-height: 106px;
  padding: 14px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.telemetry-tile:last-child {
  border-right: 0;
}

.telemetry-tile .glyph {
  color: var(--cyan);
}

.telemetry-tile.alert {
  border-color: rgba(189, 139, 0, 0.45);
  background: #fffbeb;
}

.telemetry-tile span {
  color: var(--muted);
  font-size: 14px;
}

.telemetry-tile strong {
  font-size: 20px;
}

.telemetry-tile:last-child strong {
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.35;
}

.chart-panel {
  padding-top: 2px;
}

.sync-label {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.trend-chart {
  display: block;
  width: 100%;
  min-height: 220px;
}

.chart-empty {
  display: grid;
  min-height: 220px;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  background: #f7fafc;
}

.chart-empty strong {
  color: var(--ink);
}

.chart-empty span {
  max-width: 460px;
  line-height: 1.6;
}

.chart-legend text {
  fill: #475569;
  font-size: 13px;
}

.control-panel {
  display: grid;
  gap: 16px;
}

.lock-indicator {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  color: #991b1b;
  background: #fee2e2;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 52px;
  height: 30px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  width: 100%;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 180ms ease;
}

.switch span::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
  content: "";
  transition: transform 180ms ease;
}

.switch input:checked + span {
  background: var(--teal);
}

.switch input:checked + span::after {
  transform: translateX(22px);
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.command-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 700;
}

.command-button.success {
  background: var(--green);
}

.command-button.danger {
  background: var(--red);
}

.command-button.warning {
  background: var(--amber);
}

.command-button.neutral,
.primary-button {
  background: var(--blue);
}

.range-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.range-control span {
  color: var(--muted);
}

.range-control input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--teal);
}

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

.alert-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border-left: 4px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.alert-item strong,
.alert-item span {
  display: block;
}

.alert-item span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.alert-item em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  white-space: nowrap;
}

.alert-item.level-高,
.alert-item.severity-high {
  border-left-color: var(--red);
}

.alert-item.level-中,
.alert-item.severity-medium {
  border-left-color: var(--amber);
}

.alert-item.level-低 {
  border-left-color: var(--cyan);
}

.history-section,
.settings-section {
  margin-top: 16px;
  padding: 18px;
}

.table-wrap {
  overflow-x: auto;
}

.customers-section {
  min-width: 0;
  padding: 18px;
}

.customer-search {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 12px;
}

.customer-search .search-box {
  width: min(100%, 380px);
}

.customer-search .primary-button {
  min-width: 108px;
}

.account-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.account-sort select {
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.secondary-button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue);
  background: #ffffff;
  font-weight: 700;
}

.customers-table {
  min-width: 1160px;
}

.presence-state {
  font-weight: 700;
  white-space: nowrap;
}

.presence-state.online { color: #107445; }
.presence-state.offline { color: #b52b32; }
.presence-state.unknown { color: #64748b; }

.presence-devices { margin-top: 4px; font-size: 12px; }
.presence-devices summary { color: var(--blue); cursor: pointer; white-space: nowrap; }
.presence-devices ul { margin: 6px 0 0; padding: 0; list-style: none; }
.presence-devices li { display: flex; gap: 8px; align-items: baseline; white-space: nowrap; }
.presence-devices code { font-size: 11px; }
.presence-devices time { color: #64748b; }

.customer-actions {
  display: flex;
  gap: 14px;
  white-space: nowrap;
}

.customer-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 140px;
}

.customer-identity strong,
.customer-phone {
  overflow-wrap: anywhere;
}

.customer-avatar {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #edf4f7;
  object-fit: cover;
}

.customer-avatar.placeholder {
  color: var(--blue);
}

.customer-pagination,
.customer-pagination > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.customer-pagination {
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.pagination-controls,
.pagination-pages {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination-page {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.pagination-page:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--blue);
}

.pagination-page.is-current {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  cursor: default;
  opacity: 1;
}

.pagination-ellipsis {
  display: grid;
  width: 24px;
  height: 36px;
  place-items: center;
}

@media (max-width: 720px) {
  .pagination-edge,
  .pagination-ellipsis {
    display: none;
  }

  .pagination-controls,
  .pagination-pages {
    gap: 4px;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 700;
}

.result {
  min-height: 28px;
  padding: 0 10px;
  font-size: 13px;
}

.result-成功,
.result-本地记录 {
  color: #065f46;
  background: #dcfce7;
}

.result-发送中 {
  color: #1d4ed8;
  background: #dbeafe;
}

.result-失败 {
  color: #991b1b;
  background: #fee2e2;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: #ffffff;
}

.field input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.12);
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  grid-column: 1 / -1;
}

.settings-actions span {
  color: var(--muted);
  font-size: 14px;
}

.mapping-grid {
  display: grid;
}

.mapping-row {
  display: grid;
  grid-template-columns: minmax(190px, 0.7fr) minmax(260px, 1.4fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 70px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  border-top: 0;
  border-right: 0;
  border-left: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.mapping-row:hover,
.mapping-row.selected {
  background: #f0f8fc;
}

.mapping-row.selected {
  box-shadow: inset 3px 0 var(--blue);
}

.mapping-row:disabled { cursor: wait; }

.mapping-row code {
  color: var(--blue);
  font-size: 14px;
  font-weight: 800;
}

.mapping-row strong,
.mapping-row span {
  display: block;
}

.mapping-row div span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.mapping-state {
  color: #166534;
  font-size: 13px;
  font-weight: 800;
}

.collection-explorer {
  min-width: 0;
  padding-top: 20px;
}

.collection-explorer h3 { margin: 0; font-size: 18px; }
.collection-explorer .panel-heading p { margin: 4px 0 0; color: var(--muted); }
.collection-table { min-width: 680px; table-layout: fixed; }
.collection-table td { vertical-align: top; overflow-wrap: anywhere; }
.collection-table th { overflow-wrap: anywhere; }
.collection-table td:has(.skin-result) { min-width: 280px; }
.skin-result summary { color: var(--blue); cursor: pointer; }
.skin-indicator { padding: 10px 0; border-bottom: 1px solid var(--line); }
.skin-indicator p { margin: 6px 0; line-height: 1.5; }

.privacy-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  border-left: 4px solid var(--green);
  color: #14532d;
  background: #f0fdf4;
}

.empty-row {
  padding: 24px 12px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 14px 16px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 8px;
  color: #064e3b;
  background: #ccfbf1;
  box-shadow: var(--shadow);
}

.topbar-language-select,
.login-language-select,
.settings-language-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.topbar-language-select select,
.login-language-select select,
.settings-language-select select {
  min-height: 38px;
  padding: 0 32px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
}

.device-focus-grid {
  grid-template-columns: minmax(280px, 0.65fr) minmax(0, 1.6fr);
}

.remote-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.8fr) minmax(320px, 1.2fr);
  gap: 16px;
  align-items: start;
}

.alerts-page .alerts-panel {
  min-height: 420px;
}

.settings-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.setting-block {
  display: grid;
  align-content: start;
  gap: 9px;
  min-height: 148px;
  padding: 20px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.setting-block > span,
.setting-block small {
  color: var(--muted);
  font-size: 13px;
}

.setting-block strong {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 18px;
}

.language-setting .settings-language-select {
  justify-content: flex-start;
}

.language-setting .settings-language-select > span {
  display: none;
}

.password-change-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.password-change-form h3 {
  margin: 0 0 5px;
  font-size: 18px;
}

.password-change-form p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.password-change-fields label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.password-change-fields input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
}

.password-change-form > button {
  justify-self: start;
  min-width: 140px;
  padding: 0 16px;
}

.cloud-config {
  display: grid;
  gap: 0;
  margin-top: 24px;
  border-top: 1px solid var(--line);
}

.cloud-config-band {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.cloud-config-band h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.cloud-config-band > p,
.cloud-policy-form small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.cloud-config-band > p {
  margin: 0 0 16px;
}

.cloud-policy-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 22px;
}

.cloud-policy-form small {
  flex-basis: 100%;
}

.cloud-policy-form label,
.cloud-checkbox {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.cloud-policy-form input[type="checkbox"],
.cloud-config-form input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.cloud-config-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  max-width: 820px;
}

.cloud-config-form > label:not(.cloud-checkbox) {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.cloud-config-form input:not([type="checkbox"]),
.cloud-config-form select,
.cloud-config-form textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
}

.cloud-config-form textarea {
  resize: vertical;
}

.cloud-config-form .cloud-full {
  grid-column: 1 / -1;
}

.cloud-config-form .cloud-checkbox {
  align-self: end;
  min-height: 44px;
}

.cloud-policy-form button,
.cloud-config-form button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  color: #ffffff;
  background: var(--blue);
  font-weight: 700;
}

.cloud-config-form > button {
  justify-self: start;
}

.cloud-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  grid-column: 1 / -1;
}

.cloud-form-actions button:last-child {
  color: var(--blue);
  background: #ffffff;
}

.cloud-policy-form button:disabled,
.cloud-config-form button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.recharge-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.8fr) minmax(0, 1.35fr);
  gap: 16px;
  align-items: start;
  min-width: 0;
}

.recharge-generator,
.recharge-history {
  min-width: 0;
  padding: 18px;
}

.recharge-form {
  display: grid;
  gap: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.recharge-form label {
  display: grid;
  gap: 7px;
}

.recharge-form label > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.recharge-form input,
.recharge-form select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  color: var(--ink);
  background: #ffffff;
}

.recharge-form input:focus,
.recharge-form select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(5, 136, 168, 0.12);
}

.recharge-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--blue);
  font-weight: 800;
}

.recharge-error {
  margin-top: 14px;
  padding: 11px 12px;
  border-left: 4px solid var(--red);
  color: #991b1b;
  background: #fff7f7;
}

.recharge-result {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.result-heading span {
  font-weight: 800;
}

.result-heading small {
  color: var(--muted);
}

.password-output-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.password-output {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 112px;
  padding: 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.password-output > span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.password-output strong {
  overflow-wrap: anywhere;
  font-size: 25px;
  font-variant-numeric: tabular-nums;
}

.copy-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue);
  background: #ffffff;
}

.recharge-security {
  margin-top: 18px;
}

.recharge-history-table table {
  min-width: 900px;
}

.recharge-history-table code {
  color: var(--blue);
  font-weight: 800;
}

.users-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.7fr) minmax(0, 1.3fr);
  gap: 16px;
  align-items: start;
  min-width: 0;
}

.users-create,
.users-list {
  min-width: 0;
  padding: 18px;
}

.user-scope-notice {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-inline-start: 3px solid #cfab20;
  color: #544216;
  background: #fff9e8;
  font-size: 13px;
  line-height: 1.55;
}

.user-create-form {
  display: grid;
  gap: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

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

.user-create-form input,
.user-create-form select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  color: var(--ink);
  background: #ffffff;
}

.user-create-form input:focus,
.user-create-form select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(5, 136, 168, 0.12);
}

.permission-fieldset {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
}

.permission-fieldset legend {
  padding: 0 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.permission-fieldset small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.permission-list {
  display: grid;
  gap: 4px;
}

.permission-option,
.user-create-form .permission-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.permission-option input,
.user-create-form .permission-option input {
  flex: 0 0 17px;
  width: 17px;
  min-height: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--blue);
}

.user-create-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--blue);
  font-weight: 800;
}

.user-credential {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.user-credential > div:first-child {
  display: grid;
  gap: 4px;
}

.user-credential span {
  color: var(--muted);
  font-size: 13px;
}

.user-credential-value {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.user-credential-value code {
  grid-column: 1;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.user-credential-value code:nth-child(2) {
  color: var(--blue);
  font-size: 17px;
  font-weight: 800;
}

.user-credential-value button {
  grid-column: 2;
  grid-row: 1 / 3;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue);
  background: #ffffff;
}

.users-count {
  color: var(--blue);
  font-size: 18px;
  font-weight: 800;
}

.users-table {
  min-width: 760px;
}

.user-permissions-cell {
  min-width: 220px;
  max-width: 360px;
  line-height: 1.5;
  white-space: normal;
}

.permission-dialog {
  width: min(100%, 460px);
}

.permission-dialog .permission-list {
  margin: 18px 0;
}

.user-status {
  color: var(--muted);
  font-weight: 700;
}

.user-status.enabled {
  color: var(--green);
}

.user-actions {
  white-space: nowrap;
}

.user-actions button + button {
  margin-inline-start: 8px;
}

.user-actions button,
.user-confirm-actions button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  white-space: nowrap;
}

.user-actions button:last-child {
  color: #9f1d1d;
}

.user-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.42);
}

.user-confirm-dialog {
  width: min(100%, 420px);
  padding: 24px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.user-confirm-dialog h3 {
  margin: 0 0 8px;
  font-size: 20px;
}

.user-confirm-dialog p {
  margin: 0 0 24px;
  color: var(--muted);
}

.user-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.user-confirm-actions button:last-child {
  border-color: var(--blue);
  color: #ffffff;
  background: var(--blue);
}

.people-heading-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.table-action {
  border: 0;
  padding: 6px 0;
  color: var(--blue);
  background: transparent;
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.sync-dialog {
  width: min(100%, 480px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
}

.pairing-dialog {
  width: min(100%, 460px);
}

.pairing-code-box {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--yellow);
  border-radius: 6px;
  background: #f8fafc;
}

.pairing-code-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pairing-code-box strong {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 36px;
  line-height: 1.2;
  letter-spacing: 0;
}

.pairing-code-loading {
  min-height: 92px;
  display: grid;
  place-items: center;
  margin: 18px 0;
  color: var(--muted);
  background: #f8fafc;
}

.pairing-dialog .pairing-instructions {
  margin-bottom: 10px;
  line-height: 1.6;
}

.pairing-dialog .sync-note {
  display: block;
  margin-bottom: 20px;
}

.sync-dialog label {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
  font-weight: 700;
}

.sync-dialog input,
.sync-dialog select {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  font-weight: 400;
}

.customer-dialog {
  width: min(100%, 560px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
}

.customer-dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.customer-dialog-heading h3 {
  margin: 0;
}

.customer-dialog form label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-weight: 700;
}

.customer-dialog input,
.customer-dialog select,
.customer-dialog textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  font-weight: 400;
}

.customer-dialog textarea {
  resize: vertical;
}

.customer-detail-list {
  display: grid;
  gap: 0;
  margin: 0 0 18px;
}

.customer-detail-list > div,
.customer-owner-line {
  display: grid;
  grid-template-columns: minmax(110px, 0.35fr) minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.customer-detail-list dt,
.customer-owner-line span {
  color: var(--muted);
}

.customer-detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.customer-owner-line {
  margin-bottom: 18px;
}

.sync-note {
  display: block;
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.boot-screen {
  display: grid;
  min-height: 100vh;
  place-content: center;
  gap: 28px;
  background: #102b3c;
}

.brand-dark {
  color: #ffffff;
}

.brand-dark > div:last-child span {
  color: var(--yellow);
}

.loading-line {
  width: 210px;
  height: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.2);
}

.loading-line span {
  display: block;
  width: 42%;
  height: 100%;
  background: var(--yellow);
  animation: loading-slide 1.1s ease-in-out infinite alternate;
}

@keyframes loading-slide {
  from { transform: translateX(0); }
  to { transform: translateX(138px); }
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(440px, 1.1fr);
  min-height: 100vh;
  background: #ffffff;
}

.login-brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 46px;
  color: #ffffff;
  background: #102b3c;
}

.login-brand-copy {
  max-width: 640px;
  padding: 72px 0;
}

.login-brand-copy p {
  margin: 0 0 18px;
  color: #b8c7d6;
  font-size: 15px;
  font-weight: 700;
}

.login-brand-copy h1 {
  margin: 0 0 20px;
  max-width: 640px;
  font-size: 48px;
  line-height: 1.12;
  letter-spacing: 0;
}

.login-brand-copy > span {
  color: var(--yellow);
  font-size: 18px;
  font-weight: 800;
}

.login-band {
  display: grid;
  gap: 8px;
  width: 100%;
}

.login-band span:first-child {
  width: 76%;
  height: 10px;
  margin-left: auto;
  background: #0069a8;
}

.login-band span:last-child {
  width: 100%;
  height: 5px;
  background: var(--yellow);
}

.login-form-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 34px 56px;
}

.login-toolbar {
  display: flex;
  justify-content: flex-end;
}

.login-form {
  display: grid;
  align-content: center;
  width: min(100%, 460px);
  min-height: calc(100vh - 106px);
  margin: 0 auto;
}

.login-form h2 {
  margin: 8px 0 10px;
  color: var(--ink);
  font-size: 34px;
  line-height: 1.2;
  letter-spacing: 0;
}

.login-subtitle {
  margin: 0 0 30px;
  color: var(--muted);
  line-height: 1.6;
}

.login-field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

.login-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  outline: 0;
  background: #ffffff;
}

.login-field input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(5, 136, 168, 0.12);
}

.login-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  margin-top: 6px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--blue);
  font-weight: 800;
}

.login-text-button {
  justify-self: start;
  margin-top: 16px;
  padding: 4px 0;
  border: 0;
  color: var(--blue);
  background: transparent;
  font-weight: 700;
}

.recovery-message {
  margin-top: 16px;
  padding: 12px;
  border-left: 4px solid var(--green);
  color: #14532d;
  background: #effdf4;
  line-height: 1.5;
}

.login-error {
  margin: -2px 0 12px;
  padding: 11px 12px;
  border-left: 4px solid var(--red);
  color: #991b1b;
  background: #fef2f2;
  font-size: 14px;
}

.security-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.security-note .glyph {
  color: var(--green);
}

html[dir="rtl"] .nav-item,
html[dir="rtl"] th,
html[dir="rtl"] td,
html[dir="rtl"] .device-row {
  text-align: right;
}

html[dir="rtl"] .device-row.selected {
  border-right: 4px solid var(--blue);
  border-left: 0;
}

html[dir="rtl"] .source-banner,
html[dir="rtl"] .privacy-note,
html[dir="rtl"] .login-error,
html[dir="rtl"] .recharge-error {
  border-right: 4px solid var(--yellow);
  border-left: 0;
}

html[dir="rtl"] .source-banner.error,
html[dir="rtl"] .login-error,
html[dir="rtl"] .recharge-error {
  border-right-color: var(--red);
}

html[dir="rtl"] .privacy-note {
  border-right-color: var(--green);
}

html[dir="rtl"] .alert-item {
  border-right: 4px solid var(--line);
  border-left: 0;
}

html[dir="rtl"] .alert-item.severity-high {
  border-right-color: var(--red);
}

html[dir="rtl"] .alert-item.severity-medium {
  border-right-color: var(--amber);
}

html[dir="rtl"] .login-band span:first-child {
  margin-right: auto;
  margin-left: 0;
}

html[dir="rtl"] .users-table th,
html[dir="rtl"] .users-table td,
html[dir="rtl"] .customers-table th,
html[dir="rtl"] .customers-table td {
  text-align: right;
}

@media (max-width: 1500px) {
  .users-layout {
    grid-template-columns: 1fr;
  }

  .user-create-form {
    max-width: 420px;
  }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .sidebar {
    align-items: center;
    padding: 22px 12px;
  }

  .brand div:last-child,
  .nav-item span,
  .domain-card {
    display: none;
  }

  .nav-item {
    justify-content: center;
    width: 46px;
    padding: 0;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
  }

  .alerts-panel {
    grid-column: auto;
  }

  .right-rail {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .telemetry-grid,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .device-focus-grid {
    grid-template-columns: minmax(260px, 0.7fr) minmax(0, 1.3fr);
  }

  .remote-layout {
    grid-template-columns: 1fr 1fr;
  }

  .recharge-layout {
    grid-template-columns: 1fr;
  }

  .users-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: block;
    padding: 12px;
  }

  .brand {
    margin-bottom: 10px;
  }

  .brand div:last-child {
    display: block;
  }

  .nav-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(44px, 1fr));
    gap: 6px;
  }

  .nav-item {
    flex-direction: column;
    gap: 3px;
    width: 100%;
    min-height: 54px;
    font-size: 12px;
  }

  .nav-item span {
    display: inline;
  }

  .workspace {
    padding: 18px 14px 26px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .source-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .source-banner small {
    white-space: normal;
  }

  .summary-grid,
  .main-grid,
  .device-account-summary,
  .telemetry-grid,
  .settings-grid,
  .remote-layout,
  .settings-summary-grid {
    grid-template-columns: 1fr;
  }

  .password-output-grid {
    grid-template-columns: 1fr;
  }

  .password-change-fields {
    grid-template-columns: 1fr;
  }

  .cloud-config-form {
    grid-template-columns: 1fr;
  }

  .cloud-config-form .cloud-full,
  .cloud-form-actions {
    grid-column: auto;
  }

  .result-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .right-rail {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .mapping-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .telemetry-tile {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .device-account-summary > div {
    border-inline-end: 0;
    border-block-end: 1px solid var(--line);
  }

  .device-account-summary > div:last-child {
    border-block-end: 0;
  }

  .panel-heading,
  .detail-header {
    flex-direction: column;
  }

  .search-box {
    width: 100%;
  }

  .customer-search .search-box,
  .customer-search .account-sort,
  .customer-search .primary-button {
    width: 100%;
  }

  .customer-search .account-sort select {
    flex: 1;
  }

  .command-grid {
    grid-template-columns: 1fr;
  }

  .trend-chart {
    min-height: 170px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-language-select > span {
    display: none;
  }

  .logout-button span {
    display: none;
  }

  .login-shell {
    display: block;
  }

  .login-brand-panel {
    min-height: 240px;
    padding: 20px;
  }

  .login-brand-copy {
    padding: 30px 0 20px;
  }

  .login-brand-copy h1 {
    font-size: 30px;
  }

  .login-form-panel {
    padding: 22px 20px 34px;
  }

  .login-form {
    min-height: auto;
    padding: 26px 0 10px;
  }

  .login-form h2 {
    font-size: 28px;
  }

  .login-subtitle {
    margin-bottom: 20px;
  }

  .login-field {
    margin-bottom: 12px;
  }

  .login-field input {
    min-height: 44px;
  }

  .security-note {
    margin-top: 12px;
  }
}
