:root {
  --red: #bd0014;
  --red-dark: #8f0b12;
  --brown: #311612;
  --gold: #f2c15f;
  --gold-soft: #fff4d3;
  --bg: #f6f1e8;
  --card: #fffdf8;
  --ink: #15110e;
  --muted: #75675b;
  --line: #eadfce;
  --green: #16834a;
  --orange: #a05f00;
  --shadow: 0 16px 42px rgba(55, 33, 12, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.modal-backdrop[hidden] {
  display: none !important;
  pointer-events: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 20% 20%, rgba(242, 193, 95, 0.28), transparent 28%),
    linear-gradient(135deg, #240f0d 0%, #9e0612 52%, #d4071d 100%);
}

.login-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 26px 70px rgba(21, 10, 8, 0.28);
}

.login-logo {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: #fff;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.login-card h1 {
  margin-top: 18px;
  font-size: 30px;
}

.login-copy {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 26px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(189, 0, 20, 0.12);
}

input[readonly] {
  background: #f8f3ec;
  color: var(--muted);
}

.field-note {
  padding: 12px 14px;
  border: 1px dashed #e4d3bd;
  border-radius: 8px;
  background: #fff8e6;
  color: #8a6a45;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.field-help {
  color: #9a8065;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

.field-display {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  box-sizing: border-box;
}

.field-display span {
  color: var(--muted);
  font-size: 13px;
}

.field-display strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 14px;
}

.image-upload-field {
  gap: 10px;
}

.image-upload-box {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.image-upload-box img,
.image-upload-placeholder {
  width: 120px;
  height: 90px;
  border-radius: 8px;
}

.image-upload-box img {
  object-fit: cover;
  background: #f6efe4;
}

.image-upload-placeholder {
  display: grid;
  place-items: center;
  border: 1px dashed #e4d3bd;
  background: #fff8e6;
  color: #9a8065;
  text-align: center;
  font-size: 12px;
}

.multi-image-upload-field {
  display: grid;
  gap: 8px;
}

.multi-image-upload-box {
  display: grid;
  gap: 10px;
}

.multi-image-upload-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.multi-image-upload-grid img,
.multi-image-upload-placeholder {
  width: 100%;
  min-height: 96px;
  border-radius: 8px;
  box-sizing: border-box;
}

.multi-image-upload-grid img {
  height: 96px;
  object-fit: cover;
  background: #f6efe4;
}

.multi-image-upload-placeholder {
  display: grid;
  place-items: center;
  border: 1px dashed #e4d3bd;
  background: #fff8e6;
  color: #9a8065;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.app-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: linear-gradient(180deg, #2b1713 0%, #140d0b 100%);
  color: #fff8ec;
  overflow-x: hidden;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
  min-width: 0;
}

.brand img {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #fff;
}

.brand strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
}

.brand span,
.sidebar-foot {
  color: #dfc17d;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 7px;
  padding-bottom: 22px;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 248, 236, 0.22);
}

.nav button {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #f9ead2;
  text-align: left;
  font-weight: 800;
}

.nav button.active,
.nav button:hover {
  background: rgba(242, 193, 95, 0.18);
  color: #fff;
}

.sidebar-foot {
  position: absolute;
  right: 22px;
  bottom: 22px;
  left: 22px;
  padding: 14px;
  border: 1px solid rgba(242, 193, 95, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.topbar h2 {
  font-size: 28px;
}

.topbar p:last-child {
  margin-top: 6px;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-badge {
  padding: 8px 10px;
  border-radius: 999px;
  background: #fff;
  color: var(--brown);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 800;
}

.primary-button,
.ghost-button,
.small-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

.primary-button {
  padding: 12px 16px;
  background: var(--red);
  color: #fff;
}

.primary-button.danger {
  background: #8f0b12;
}

.ghost-button {
  padding: 10px 14px;
  background: #fff;
  color: var(--red);
  box-shadow: var(--shadow);
}

.ghost-button.danger {
  color: #7b1b12;
}

.small-button {
  padding: 8px 10px;
  background: var(--brown);
  color: #fff;
  font-size: 12px;
}

.small-button.secondary {
  background: #fff4d3;
  color: #714a0a;
}

.small-button.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.small-button.danger {
  border: 1px solid #f1c6c2;
  background: #fff0ef;
  color: #a12a1f;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--red);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon-button {
  width: 34px;
  height: 34px;
  background: #f6efe4;
  color: var(--brown);
  font-size: 24px;
  line-height: 1;
}

.status-bar {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff4d3;
  color: #714a0a;
  font-weight: 800;
}

.status-bar.error {
  background: #fff0f1;
  color: var(--red);
}

.content {
  margin-top: 22px;
}

.settings-grid {
  display: grid;
  gap: 16px;
}

.panel,
.metric-card,
.table-card {
  border: 1px solid rgba(145, 92, 20, 0.12);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px 0;
}

.section-title-row h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
}

.section-title-row span {
  color: var(--muted);
  font-size: 13px;
}

.recharge-review-panel {
  margin-top: 14px;
}

.recharge-review-panel .section-title-row {
  align-items: center;
}

.recharge-review-panel .section-title-row > div {
  display: grid;
  gap: 4px;
}

.recharge-review-panel + .points-ledger-card {
  margin-top: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.boss-kpi-grid {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.dashboard-trend-stack {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.metric-card {
  padding: 18px;
}

.dashboard-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.metric-button {
  width: 100%;
  border: 1px solid rgba(145, 92, 20, 0.12);
  text-align: left;
}

.metric-button:hover {
  border-color: rgba(189, 0, 20, 0.32);
  box-shadow: 0 18px 48px rgba(189, 0, 20, 0.12);
}

.metric-button em {
  display: block;
  margin-top: 12px;
  color: #9a8065;
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  color: var(--red);
  font-size: 30px;
  line-height: 1;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.chart-list,
.todo-list,
.ledger-list,
.timeline {
  display: grid;
  gap: 10px;
}

.chart-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: #f2e6d4;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  width: var(--w);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--gold));
}

.line-chart {
  display: grid;
  gap: 8px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 6px 2px 2px;
}

.line-chart svg {
  width: var(--chart-width, 960px);
  height: 230px;
  overflow: visible;
}

.line-chart-area {
  fill: rgba(242, 193, 95, 0.16);
  stroke: none;
}

.line-chart-line {
  fill: none;
  stroke: var(--red);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-chart circle {
  fill: var(--card);
  stroke: var(--red);
  stroke-width: 3;
}

.line-chart-labels {
  display: grid;
  grid-template-columns: repeat(var(--count, 7), minmax(0, 1fr));
  gap: 6px;
  width: var(--chart-width, 960px);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.chart-list.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-list.compact .chart-row {
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fffaf2;
}

.chart-row-button {
  width: 100%;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chart-row-button:hover,
.chart-row-button:focus-visible {
  background: #fff2dd;
  outline: 2px solid rgba(185, 38, 30, 0.18);
}

.line-chart circle[data-action] {
  cursor: pointer;
}

.chart-list.compact .chart-row strong {
  color: var(--red);
}

.todo-item,
.timeline-item,
.ledger-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.todo-item strong,
.timeline-item strong,
.ledger-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-item span,
.timeline-item span,
.ledger-item span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.toolbar .filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.toolbar input,
.toolbar select {
  width: min(240px, 100%);
}

.toolbar-note {
  align-self: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.dashboard-detail-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.dashboard-detail-tools > input {
  flex: 1 1 220px;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 240px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.inline-field input {
  flex: 1;
}

.dashboard-detail-table table {
  min-width: 720px;
}

.shipping-info-box {
  white-space: pre-wrap;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  color: var(--ink);
  line-height: 1.7;
  font-weight: 700;
}

.table-card {
  overflow: hidden;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

td:nth-child(4),
td:nth-child(5) {
  max-width: 320px;
  white-space: normal;
  word-break: break-word;
}

th {
  color: var(--muted);
  font-size: 12px;
}

td strong,
td span {
  display: block;
}

td span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.table-total-row td {
  background: #fff8e6;
  font-weight: 800;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(145, 92, 20, 0.12);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.pagination div {
  display: flex;
  gap: 8px;
}

.product-cell {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.product-cell img,
.product-thumb {
  width: 54px;
  height: 54px;
  border-radius: 8px;
}

.product-cell img {
  object-fit: cover;
  background: #f6efe4;
}

.product-thumb {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--gold-soft), var(--red));
  color: #fff;
  font-weight: 900;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f3eee6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  word-break: keep-all;
}

.tag.red {
  background: #fff0f1;
  color: var(--red);
}

.tag.green {
  background: #e8f7ee;
  color: var(--green);
}

.tag.gold {
  background: var(--gold-soft);
  color: #714a0a;
}

.tag.orange {
  background: #fff4d3;
  color: var(--orange);
}

.payload {
  max-width: 520px;
  max-height: 180px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-radius: 8px;
  background: #211614;
  color: #ffe7ad;
  font-size: 12px;
  line-height: 1.5;
}

.mqtt-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 16px;
}

.config-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.config-list div {
  padding: 13px;
  border-radius: 8px;
  background: #fff;
}

.config-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.config-list strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.inline-error {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff0f1;
  color: var(--red);
  font-weight: 800;
}

.empty {
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.skeleton {
  display: grid;
  gap: 14px;
}

.skeleton-line,
.skeleton-card {
  border-radius: 10px;
  background: linear-gradient(90deg, #f0e7da 25%, #fff8eb 37%, #f0e7da 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
}

.skeleton-line {
  height: 18px;
}

.skeleton-card {
  height: 120px;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 10, 8, 0.52);
}

.modal {
  width: min(760px, 100%);
  max-height: min(86vh, 860px);
  overflow: auto;
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

#modalBody {
  padding: 20px;
}

.modal-form {
  display: grid;
  gap: 14px;
}

.form-section-title {
  display: grid;
  gap: 4px;
  padding-top: 6px;
  border-top: 1px solid rgba(145, 92, 20, 0.12);
}

.form-section-title:first-child {
  padding-top: 0;
  border-top: 0;
}

.form-section-title strong {
  color: var(--brown);
  font-size: 15px;
  font-weight: 900;
}

.form-section-title span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.form-field-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  overflow: hidden;
}

.form-field-group summary {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  color: var(--brown);
  cursor: pointer;
  list-style-position: inside;
}

.form-field-group summary strong {
  font-size: 14px;
  font-weight: 900;
}

.form-field-group summary span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.form-field-group-body {
  display: grid;
  gap: 14px;
  padding: 0 14px 14px;
}

.city-input-field {
  display: grid;
  gap: 8px;
}

.city-input-field label {
  display: grid;
  gap: 6px;
}

.city-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.city-option-chip {
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

.city-option-chip:hover,
.city-option-chip.active {
  border-color: rgba(189, 0, 20, 0.34);
  background: #fff4d3;
  color: var(--red);
}

.multi-select-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.multi-select-label {
  color: var(--muted);
}

.multi-select-dropdown {
  position: relative;
}

.multi-select-dropdown summary {
  min-height: 45px;
  padding: 12px 38px 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.multi-select-dropdown summary::-webkit-details-marker {
  display: none;
}

.multi-select-dropdown summary::after {
  content: "⌄";
  position: absolute;
  top: 12px;
  right: 14px;
  color: var(--muted);
  font-size: 14px;
}

.multi-select-dropdown[open] summary {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(189, 0, 20, 0.12);
}

.multi-select-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.multi-select-option:hover {
  background: #fff4d3;
}

.multi-select-option input {
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 0;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.modal-feedback {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff8e6;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.modal-feedback.error {
  background: #fff0f1;
  color: var(--red);
}

.export-result {
  display: grid;
  gap: 14px;
}

.export-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.export-preview {
  min-height: 180px;
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffaf1;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
}

.export-download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.danger-confirm {
  display: grid;
  gap: 14px;
}

.danger-copy {
  padding: 12px 14px;
  border: 1px solid #f1c6c2;
  border-radius: 8px;
  background: #fff0ef;
  color: #7b1b12;
  font-size: 13px;
  line-height: 1.6;
}

.danger-summary {
  display: grid;
  gap: 10px;
}

.danger-summary > div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}

.danger-summary span {
  color: var(--muted);
  font-size: 13px;
}

.danger-summary strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 14px;
}

.bind-ticket {
  display: grid;
  gap: 14px;
}

.bind-code {
  width: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff8e6;
  color: var(--red);
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 4px;
  box-sizing: border-box;
}

.bind-code-image {
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.bind-code-image img,
.bind-code-image canvas {
  width: min(260px, 100%);
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.bind-code-image canvas {
  image-rendering: pixelated;
}

.detail-image {
  margin-bottom: 14px;
}

.detail-image img {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 8px;
  background: #f6efe4;
}

.device-code-cell {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.device-code-cell img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.device-code-cell span {
  color: var(--muted);
  font-size: 12px;
}

.device-code-panel {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}

.device-code-preview {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.device-code-preview img {
  width: min(190px, 100%);
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.device-code-empty {
  color: var(--muted);
  font-size: 14px;
}

.device-code-info {
  display: grid;
  gap: 10px;
}

.device-code-info h3 {
  margin: 0;
}

.device-code-info p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.device-code-meta {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
}

.device-code-meta span {
  color: var(--muted);
  font-size: 13px;
}

.device-code-meta strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
}

.device-code-error {
  padding: 10px 12px;
  border: 1px solid #ffd5b3;
  border-radius: 8px;
  background: #fff4e8;
  color: var(--red);
  font-size: 13px;
  line-height: 1.6;
}

.qr-device-field {
  display: grid;
  gap: 8px;
}

.qr-device-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  max-width: 100%;
}

.qr-device-row input[type="text"] {
  min-width: 0;
}

.qr-upload-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  background: #fff2cf;
  color: var(--brown);
  font-size: 14px;
  font-weight: 800;
  overflow: hidden;
  cursor: pointer;
  box-sizing: border-box;
}

.qr-upload-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.qr-device-feedback {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.qr-device-feedback.success {
  color: #16824d;
}

.qr-device-feedback.error {
  color: var(--red);
}

.detail-image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-image-grid img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 8px;
  background: #f6efe4;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-grid strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .sidebar-foot {
    position: static;
    margin-top: 16px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .toolbar,
  .section-head,
  .pagination,
  .mqtt-grid,
  .grid-2 {
    display: grid;
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .config-list,
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  th:last-child,
  td:last-child {
    position: sticky;
    right: 0;
    background: var(--card);
    box-shadow: -10px 0 18px rgba(52, 26, 11, 0.08);
  }
}

@media (max-width: 640px) {
  .main {
    padding: 18px;
  }

  .metric-grid,
  .config-list,
  .device-code-panel,
  .detail-grid,
  .nav {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions button {
    width: 100%;
  }
}
