:root {
  --bg: #eef3f6;
  --sidebar: #101923;
  --sidebar-soft: #172431;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #697789;
  --line: #dce5ec;
  --blue: #2563eb;
  --cyan: #0891b2;
  --green: #14a06f;
  --orange: #d97706;
  --red: #dc2626;
  --shadow: 0 14px 38px rgba(20, 35, 50, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button, input, select, textarea { font: inherit; }

button {
  border: 0;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
}

button.secondary { background: #edf2f7; color: var(--ink); }
button.danger { background: #fee2e2; color: var(--red); }

h1, h2, p { margin: 0; }
h1 { font-size: 26px; letter-spacing: 0; }
h2 { font-size: 18px; }

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

.sidebar {
  background: var(--sidebar);
  color: #dbe7ef;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1d9bf0, #13b981);
  font-weight: 900;
  color: #fff;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }

.brand strong { display: block; font-size: 17px; }
.brand span { display: block; color: #8fa3b4; font-size: 12px; margin-top: 4px; }

.nav {
  display: grid;
  gap: 6px;
  padding-top: 16px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.nav-section { display: grid; gap: 4px; }
.nav-parent { display: flex; align-items: center; justify-content: space-between; width: 100%; color: #d7e2ea !important; font-weight: 800 !important; }
.nav-parent i { color: #6f8495; font-size: 15px; font-style: normal; transition: transform .16s ease; }
.nav-section.open .nav-parent { background: rgba(255,255,255,.045); color: #fff !important; }
.nav-section.contains-active .nav-parent { color: #8ec5ff !important; }
.nav-section.open .nav-parent i { transform: rotate(180deg); }
.nav-submenu { display: none; gap: 3px; padding: 2px 0 6px 10px; border-left: 1px solid rgba(255,255,255,.09); margin-left: 12px; }
.nav-section.open .nav-submenu { display: grid; }
.nav-submenu button { height: 36px; padding-left: 18px; font-size: 13px; }

.nav button {
  height: 42px;
  padding: 0 12px;
  background: transparent;
  color: #aab8c5;
  text-align: left;
  border-radius: 7px;
  font-weight: 650;
}

.nav button.active,
.nav button:hover {
  background: var(--sidebar-soft);
  color: #fff;
}

.workspace {
  min-width: 0;
  padding: 18px;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

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

.eyebrow {
  margin-bottom: 4px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.view { display: none; }
.view.active { display: grid; gap: 16px; min-height: 0; height: 100%; overflow: hidden; }

.backend-page { grid-template-rows: minmax(0, 1fr); }
#view-members.active, #view-ota.active, #view-app-push.active, #view-ota-editor.active { grid-template-rows: repeat(2, minmax(0, 1fr)); }
.view > .panel, .view > .split, .view > .dashboard-grid { min-height: 0; }
.page-panel { min-height: 0; overflow: auto; }
.view > .split, .view > .dashboard-grid { height: 100%; overflow: hidden; }
.view > .split > .panel, .view > .dashboard-grid > .panel { height: 100%; }
#view-overview.active { grid-template-rows: auto minmax(0, 1fr); }
#view-overview .dashboard-grid { min-height: 0; }
#view-overview .dashboard-grid { grid-template-rows: repeat(2, minmax(0, 1fr)); }
#view-overview .feed, #view-overview .table, #view-overview .check-list { max-height: 100%; overflow: auto; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

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

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

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

.stat-card {
  min-height: 118px;
  display: grid;
  align-content: space-between;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.stat-card strong { font-size: 30px; }
.stat-card span { color: var(--muted); font-size: 13px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.3fr .8fr;
  gap: 16px;
}

.span-2 { grid-column: span 2; }

.split {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.form-tabs { display: flex; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.form-tabs button { background: #edf2f7; color: var(--muted); }
.form-tabs button.active { background: var(--blue); color: #fff; }
.form-section-hidden { display: none !important; }

.sub-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.compact-form {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

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

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
}

textarea { min-height: 96px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.check input { width: auto; }

.device-list, .card-list, .feed, .log-list { display: grid; gap: 10px; }

.device-card, .contact-card, .event-card, .log-row, .reminder-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.device-card { cursor: pointer; }
.device-card.active { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(37,99,235,.12); }
.device-card header, .contact-card header, .event-card header, .reminder-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.meta, .empty-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin-top: 8px;
}

.empty-hint {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.status, .pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status.online, .pill.ok { background: #e8f8f1; color: var(--green); }
.status.offline, .pill.muted { background: #eef2f6; color: var(--muted); }
.pill.warn { background: #fff4df; color: var(--orange); }
.pill.danger { background: #fee2e2; color: var(--red); }

.table { display: grid; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.table-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr .8fr;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  align-items: center;
  font-size: 13px;
}
.table-row:last-child { border-bottom: 0; }
.table-row.head { background: #f6f9fc; color: var(--muted); font-weight: 800; }
.firmware-table .table-row { grid-template-columns: 1.1fr .9fr .8fr 1.2fr .7fr .55fr 1fr; }
.firmware-table a { color: var(--blue); font-weight: 800; text-decoration: none; overflow-wrap: anywhere; }
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.inline-actions button { padding: 8px 10px; }

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

.button-row, .app-card, .release-card, .info-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.button-row h3, .app-card h3 { margin: 0 0 10px; font-size: 15px; }

.push-upload-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid #cfe0f2;
  border-radius: 8px;
  background: linear-gradient(135deg, #f8fbff, #eef9f7);
}

.push-upload-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.push-upload-card p {
  color: var(--muted);
  line-height: 1.6;
}

.file-drop {
  padding: 14px;
  border: 1px dashed #93b4d7;
  border-radius: 8px;
  background: #f8fbff;
}

.file-drop small {
  color: var(--muted);
  line-height: 1.6;
}

.success-box, .error-box {
  padding: 12px;
  border-radius: 8px;
  font-weight: 800;
}

.success-box {
  background: #e8f8f1;
  color: var(--green);
  border: 1px solid #bbe8d4;
}

.error-box {
  background: #fee2e2;
  color: var(--red);
  border: 1px solid #fecaca;
}

.vitals-grid, .info-grid, .app-matrix {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.vital-card {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.vital-card span { color: var(--muted); font-size: 12px; }
.vital-card strong { font-size: 24px; }
.vital-card small { color: var(--muted); }

.action-row, .event-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 12px;
}

.tenant-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.tenant-switcher select {
  min-width: 150px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.notice-box { margin-top: 10px; }
.notice-box:empty { display: none; }

.secret-value, .bind-code {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.secret-value code {
  overflow-wrap: anywhere;
  background: #f2f6f9;
  padding: 10px;
  border-radius: 6px;
}

.bind-code strong { color: var(--blue); font-size: 26px; letter-spacing: 3px; }
.bind-code a { color: var(--blue); font-weight: 800; text-decoration: none; }

.check-list { display: grid; gap: 10px; }
.check-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.timeline { display: grid; gap: 12px; }
.timeline div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-left: 3px solid var(--blue);
  background: #f8fbff;
  border-radius: 0 8px 8px 0;
}
.timeline span { color: var(--muted); font-size: 13px; }

#platformAgentRuntimePanel { display: grid; gap: 16px; margin-bottom: 16px; }
.runtime-panel { border-color: #bfd4ea; background: linear-gradient(180deg, #fbfdff, #f5f9fd); }
.flow-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0 16px;
  padding: 12px;
  border: 1px solid #cfe0f2;
  border-radius: 8px;
  background: #fff;
}
.flow-strip b { padding: 7px 10px; border-radius: 6px; background: #eaf3ff; color: #174f8f; }
.flow-strip i { color: var(--muted); font-style: normal; font-size: 12px; }
.model-admin-grid { display: grid; grid-template-columns: minmax(280px, .9fr) minmax(420px, 1.4fr); gap: 16px; }
.model-list { display: grid; gap: 12px; max-height: 720px; overflow: auto; padding-right: 4px; }
.model-list section { display: grid; gap: 7px; }
.model-list h3 { margin: 4px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.model-item { display: grid; gap: 4px; width: 100%; text-align: left; background: #fff; color: var(--text); border: 1px solid var(--line); }
.model-item:hover, .model-item.active { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(43, 90, 255, .08); }
.model-item span, .model-item small { overflow-wrap: anywhere; color: var(--muted); font-size: 12px; }
.credential-box { display: grid; gap: 5px; padding: 12px; border: 1px solid #d8e3ee; border-radius: 8px; background: #fff; }
.credential-box span { color: var(--muted); font-size: 13px; }
.permission-hint { padding: 10px 12px; border: 1px solid #cfe0f2; border-radius: 8px; background: #eef6ff; color: #174f8f; font-size: 13px; font-weight: 700; }
.brand-logo-preview { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 10px; border: 1px dashed #b7c9dc; border-radius: 8px; background: #fff; }
.brand-logo-preview img { width: 64px; height: 64px; object-fit: contain; border-radius: 8px; }
.button-link { display: inline-flex; align-items: center; justify-content: center; padding: 8px 10px; border-radius: 7px; background: #eef4fb; color: var(--blue); font-size: 12px; font-weight: 800; text-decoration: none; }
.danger-button { background: #fff1f1; color: var(--red); border-color: #fecaca; }
.tenant-login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.tenant-login-brand h1, .tenant-login-brand p { margin: 0; }
.tenant-login-brand p { margin-top: 5px; }

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

.mini-page, .login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 18px;
}
.login-page { grid-template-rows: minmax(0, 1fr) auto; }
.login-page .login-card { align-self: center; }
.login-card, .mini-card {
  width: min(460px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.login-card p, .mini-card p { margin: 10px 0 18px; color: var(--muted); }
.mini-form { display: grid; gap: 12px; }
.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding-top: 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover, .site-footer a:focus-visible { color: var(--blue); text-decoration: underline; }

@media (max-width: 760px) {
  body { overflow: hidden; }
  .shell { grid-template-columns: 1fr; grid-template-rows: 112px minmax(0, 1fr); height: 100vh; min-height: 0; overflow: hidden; }
  .sidebar { position: static; height: 112px; padding: 8px 10px; overflow: hidden; }
  .brand { padding: 4px 6px 8px; height: 52px; }
  .brand-mark { width: 36px; height: 36px; }
  .nav { display: flex; gap: 6px; padding-top: 6px; overflow-x: auto; overflow-y: hidden; }
  .nav-section { display: flex; flex: 0 0 auto; align-items: center; gap: 4px; }
  .nav-parent { flex: 0 0 auto; width: auto; height: 36px; padding: 0 11px; }
  .nav-parent i { display: none; }
  .nav-submenu { display: none; flex: 0 0 auto; align-items: center; gap: 4px; padding: 0 0 0 4px; margin: 0; border: 0; }
  .nav-section.open .nav-submenu { display: flex; }
  .nav-submenu button { flex: 0 0 auto; height: 34px; padding: 0 10px; }
  .workspace { height: auto; min-height: 0; padding: 10px; overflow: hidden; }
  .topbar { margin-bottom: 10px; }
  .topbar h1 { font-size: 20px; }
  .top-actions { gap: 6px; font-size: 12px; }
  .top-actions button { padding: 8px 10px; }
  .tenant-switcher select { min-width: 110px; }
  .view.active, .view > .split, .view > .dashboard-grid { height: 100%; min-height: 0; overflow: hidden; }
  .split { grid-template-columns: minmax(190px, .8fr) minmax(0, 1.2fr); }
  .dashboard-grid { grid-template-columns: 1.25fr .85fr; }
  .panel { padding: 12px; }
  .stat-grid { gap: 8px; margin-bottom: 8px; }
  .stat-card { min-height: 82px; padding: 10px; }
  .stat-card strong { font-size: 22px; }
  .vitals-grid, .info-grid, .app-matrix, .release-panel, .button-editor { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .push-upload-card { align-items: stretch; flex-direction: column; }
  .model-admin-grid { grid-template-columns: minmax(190px, .8fr) minmax(0, 1.2fr); }
}
