:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --text: #18212b;
  --muted: #687583;
  --line: #dfe6eb;
  --primary: #146c5a;
  --primary-dark: #0d5748;
  --primary-soft: #e4f3ef;
  --danger: #b22f2f;
  --shadow: 0 12px 40px rgba(20, 36, 50, 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.25;
}

h2 {
  font-size: 21px;
  line-height: 1.3;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 15%, rgba(20, 108, 90, 0.14), transparent 34%),
    radial-gradient(circle at 88% 80%, rgba(45, 115, 160, 0.10), transparent 30%),
    #eef3f4;
}

.login-card {
  width: min(100%, 430px);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(20, 35, 48, 0.13);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 22px;
  border-radius: 17px;
  color: #fff;
  background: linear-gradient(145deg, #19836c, #105f50);
  box-shadow: 0 9px 24px rgba(20, 108, 90, 0.24);
  font-size: 26px;
  font-weight: 800;
}

.brand-mark-small {
  width: 38px;
  height: 38px;
  margin: 0;
  border-radius: 11px;
  font-size: 18px;
  box-shadow: none;
}

.login-heading {
  margin-bottom: 27px;
}

.login-heading h1 {
  margin-bottom: 8px;
}

.login-heading p:last-child {
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 17px;
}

.login-form label,
.field {
  display: grid;
  gap: 7px;
}

.login-form label > span,
.field > span {
  color: #34414d;
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid #cfd9df;
  border-radius: 10px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 108, 90, 0.11);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 0.12s, background 0.18s, border-color 0.18s;
}

.button:active {
  transform: translateY(1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.button-primary {
  color: #fff;
  background: var(--primary);
}

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

.button-secondary {
  border-color: var(--line);
  color: #2b3a46;
  background: #fff;
}

.button-secondary:hover {
  border-color: #bdcbd3;
  background: var(--surface-soft);
}

.button-ghost {
  min-height: 36px;
  border-color: var(--line);
  color: #4a5966;
  background: transparent;
}

.button-ghost:hover {
  background: #f3f6f7;
}

.button-block {
  width: 100%;
  min-height: 46px;
}

.button-small {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 13px;
}

.form-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.form-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.login-help {
  display: grid;
  gap: 7px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 12px max(20px, calc((100vw - 1280px) / 2));
  border-bottom: 1px solid rgba(218, 226, 231, 0.95);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

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

.brand > div:last-child {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 15px;
}

.brand span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 13px;
}

.user-badge {
  display: grid;
  justify-items: end;
  gap: 1px;
}

.user-name {
  max-width: 180px;
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-label {
  color: var(--muted);
  font-size: 11px;
}

.tabs {
  display: flex;
  gap: 5px;
  padding: 12px max(20px, calc((100vw - 1280px) / 2)) 0;
}

.tab {
  min-height: 40px;
  padding: 8px 18px;
  border: 0;
  border-radius: 10px 10px 0 0;
  color: #5c6874;
  background: transparent;
  font-weight: 700;
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.65);
}

.tab.active {
  color: var(--primary);
  background: var(--surface);
  box-shadow: 0 -1px 0 var(--line), 1px 0 0 var(--line), -1px 0 0 var(--line);
}

.main-content {
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: 0 20px 48px;
}

.page {
  display: none;
  padding: 29px 4px;
}

.page.active {
  display: block;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.page-description,
.section-heading p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.count-pill {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid #d9e5e2;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 13px;
  font-weight: 700;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 13px;
}

.search-box {
  display: grid;
  flex: 1;
  gap: 6px;
}

.search-box > span {
  color: #4b5864;
  font-size: 12px;
  font-weight: 700;
}

.search-box input {
  min-height: 40px;
}

.table-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 13px 15px;
  border-bottom: 1px solid #edf1f3;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: #596672;
  background: #f8fafb;
  font-size: 12px;
  font-weight: 800;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fbfcfc;
}

.action-column {
  width: 1%;
  text-align: right;
}

.mono {
  font-family: Consolas, "SFMono-Regular", monospace;
  letter-spacing: 0.01em;
}

.muted {
  color: var(--muted);
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 48px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: #3d4a55;
}

.admin-panel {
  margin-top: 34px;
  padding-top: 6px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 15px;
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 27, 38, 0.48);
  backdrop-filter: blur(5px);
}

.modal {
  width: min(100%, 520px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 25px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(13, 27, 38, 0.25);
}

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

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #56636e;
  background: #fff;
  font-size: 24px;
  line-height: 1;
}

.device-summary {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.device-summary div {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 12px;
}

.device-summary dt {
  color: var(--muted);
  font-size: 12px;
}

.device-summary dd {
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
}

.success-badge {
  display: inline-flex;
  margin-bottom: 20px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 800;
}

.result-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.code-result {
  padding: 17px;
  border: 1px dashed #9ac8bd;
  border-radius: 12px;
  color: #0c5647;
  background: #f0faf7;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 18px;
  font-weight: 800;
  overflow-wrap: anywhere;
  text-align: center;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.result-meta strong {
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.toast {
  position: fixed;
  z-index: 200;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 11px 15px;
  border-radius: 10px;
  color: #fff;
  background: #26343f;
  box-shadow: 0 12px 35px rgba(12, 24, 34, 0.2);
  font-size: 13px;
}

@media (max-width: 720px) {
  h1 {
    font-size: 24px;
  }

  .login-page {
    padding: 14px;
  }

  .login-card {
    padding: 26px 20px;
    border-radius: 18px;
  }

  .topbar {
    min-height: 60px;
    padding: 10px 14px;
  }

  .brand span,
  .role-label {
    display: none;
  }

  .user-actions {
    gap: 8px;
  }

  .user-name {
    max-width: 100px;
  }

  .tabs {
    padding: 8px 10px 0;
  }

  .tab {
    flex: 1;
    padding-inline: 8px;
  }

  .main-content {
    padding: 0 10px 35px;
  }

  .page {
    padding-top: 22px;
  }

  .page-heading {
    align-items: flex-start;
    margin-bottom: 18px;
  }

  .page-description {
    font-size: 12px;
  }

  .toolbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .search-box {
    flex-basis: 100%;
  }

  .toolbar .button {
    width: 100%;
  }

  th,
  td {
    padding: 12px;
  }

  .modal-backdrop {
    place-items: end center;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  }

  .modal-actions .button {
    flex: 1;
  }
}

select {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid #cfd9df;
  border-radius: 10px;
  color: var(--text);
  background: #fff;
  outline: none;
}

select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 108, 90, 0.11);
}

.admin-main {
  width: min(100%, 1500px);
}

.panel {
  border: 1px solid #d9e2e7;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(20, 36, 50, 0.055);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 10px 13px;
  border-bottom: 1px solid #e4eaee;
  background: #f8fafb;
}

.panel-title > span,
.panel-title > div > span {
  color: #25333e;
  font-size: 14px;
  font-weight: 800;
}

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

.workbench-top {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(390px, 1.35fr) minmax(310px, 0.95fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid #d9e2e7;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(20, 36, 50, 0.07);
}

.workbench-top .panel {
  border: 0;
  border-right: 1px solid #d9e2e7;
  border-radius: 0;
  box-shadow: none;
}

.workbench-top .panel:last-child {
  border-right: 0;
}

.query-panel,
.generate-panel,
.stats-panel {
  min-height: 315px;
  padding-bottom: 14px;
}

.query-panel .panel-title,
.generate-panel .panel-title,
.stats-panel .panel-title {
  margin: 0;
}

.query-row,
.generate-panel > label,
.date-mode-row,
.panel-actions {
  margin: 16px 15px 0;
}

.query-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.query-row label,
.generate-panel label,
.date-mode-row label {
  display: grid;
  gap: 6px;
}

.query-row label > span,
.generate-panel label > span,
.date-mode-row label > span {
  color: #52606b;
  font-size: 12px;
  font-weight: 700;
}

.query-row label:first-child {
  flex: 0 0 118px;
}

.grow {
  flex: 1;
}

.panel-actions {
  display: flex;
  gap: 9px;
}

.generate-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 15px;
}

.generate-row label {
  flex: 1;
}

.generate-main-button {
  min-width: 118px;
  min-height: 42px;
}

.readonly-code {
  color: #0d5d4e;
  background: #f0faf7;
  font-weight: 800;
}

.date-mode-row {
  display: grid;
  grid-template-columns: 1fr 110px 1.15fr;
  align-items: end;
  gap: 10px;
}

.mode-tip {
  display: grid;
  gap: 4px;
  min-height: 61px;
  padding: 9px 11px;
  border: 1px solid #d9e6e2;
  border-radius: 10px;
  background: #f5faf8;
}

.mode-tip span {
  color: var(--muted);
  font-size: 10px;
}

.mode-tip strong {
  color: #31514a;
  font-size: 11px;
  line-height: 1.45;
}

.stats-panel {
  padding: 0;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 62px 64px;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid #e5ebef;
  color: #3f5362;
  background: #fff;
  text-align: left;
}

.stat-row:last-child {
  border-bottom: 0;
}

.stat-row:hover {
  background: #f8fbfa;
}

.stat-row span {
  font-size: 12px;
  font-weight: 700;
}

.stat-row strong {
  color: #3155a0;
  font-size: 18px;
  text-align: center;
}

.stat-row em {
  padding: 7px 6px;
  border: 1px solid #d5dde2;
  border-radius: 7px;
  color: #4f5b64;
  background: #fff;
  font-size: 11px;
  font-style: normal;
  text-align: center;
}

.stat-row.warning strong {
  color: #d38118;
}

.stat-row.danger strong,
.stat-row.expired strong {
  color: #d34d4d;
}

.workbench-bottom {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(340px, 0.9fr);
  gap: 0;
  overflow: hidden;
  margin-top: 14px;
  border: 1px solid #d9e2e7;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(20, 36, 50, 0.06);
}

.workbench-bottom .panel {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.archive-panel {
  border-right: 1px solid #d9e2e7 !important;
}

.table-title > div {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.workbench-table-wrap {
  max-height: 520px;
  overflow: auto;
}

.compact-table {
  min-width: 940px;
}

.unlock-panel .compact-table {
  min-width: 610px;
}

.compact-table th,
.compact-table td {
  padding: 9px 10px;
  font-size: 12px;
}

.compact-table thead th {
  position: sticky;
  z-index: 2;
  top: 0;
}

.compact-empty {
  padding: 34px 20px;
}

.edit-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(290px, 0.8fr);
  gap: 14px;
}

.edit-form {
  padding: 18px;
}

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

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

.form-grid label > span {
  color: #46545f;
  font-size: 12px;
  font-weight: 700;
}

.edit-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.current-dog-card {
  padding-bottom: 16px;
}

.current-dog-value {
  margin: 20px 16px 8px;
  padding: 22px 12px;
  border: 1px dashed #b8c9c4;
  border-radius: 10px;
  color: #0e5f50;
  background: #f4faf8;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  word-break: break-all;
}

.current-dog-card > p {
  margin: 0 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.current-dog-tip {
  margin: 18px 16px 0;
  padding: 12px;
  border-radius: 10px;
  background: #f4f7f8;
}

.current-dog-tip span {
  color: #42525e;
  font-size: 12px;
  font-weight: 800;
}

.current-dog-tip p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.account-role-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 15px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
}

.account-role-line strong {
  color: var(--text);
}

.admin-only[hidden],
.sales-only[hidden] {
  display: none !important;
}

@media (max-width: 1120px) {
  .workbench-top {
    grid-template-columns: 1fr 1fr;
  }

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

  .workbench-top .query-panel {
    border-bottom: 1px solid #d9e2e7;
  }

  .workbench-top .generate-panel {
    border-right: 0;
    border-bottom: 1px solid #d9e2e7;
  }

  .workbench-bottom {
    grid-template-columns: 1fr;
  }

  .archive-panel {
    border-right: 0 !important;
    border-bottom: 1px solid #d9e2e7 !important;
  }
}

@media (max-width: 760px) {
  .workbench-top,
  .edit-layout {
    grid-template-columns: 1fr;
  }

  .workbench-top .query-panel,
  .workbench-top .generate-panel {
    border-right: 0;
    border-bottom: 1px solid #d9e2e7;
  }

  .query-panel,
  .generate-panel,
  .stats-panel {
    min-height: auto;
  }

  .query-row,
  .generate-row,
  .panel-actions,
  .edit-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .query-row label:first-child {
    flex: auto;
  }

  .date-mode-row,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .generate-main-button {
    width: 100%;
  }

  .stat-row {
    grid-template-columns: 1fr 50px 58px;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    flex: 0 0 auto;
  }

  .workbench-table-wrap {
    max-height: 430px;
  }
}

.device-toolbar {
  align-items: flex-end;
}

.display-options {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  white-space: nowrap;
}

.display-options > span {
  color: #4b5864;
  font-size: 12px;
  font-weight: 700;
}

.display-options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #34414d;
  font-size: 12px;
  cursor: pointer;
}

.display-options input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
}

.mobile-device-list,
.mobile-device-empty {
  display: none;
}

.device-mobile-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 9px 28px rgba(20, 36, 50, 0.07);
}

.device-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 15px;
  border-bottom: 1px solid #e8edf0;
  background: #f8fafb;
}

.device-card-code {
  min-width: 0;
  color: #173a49;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.device-card-validity {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  color: #0d5d4e;
  background: #e7f5f1;
  font-size: 11px;
  font-weight: 700;
}

.device-card-details {
  display: grid;
  gap: 0;
  padding: 5px 15px;
}

.device-card-details > div {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #edf1f3;
}

.device-card-details > div:last-child {
  border-bottom: 0;
}

.device-card-details dt {
  color: var(--muted);
  font-size: 12px;
}

.device-card-details dd {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.device-mobile-card > .button {
  width: calc(100% - 30px);
  margin: 0 15px 15px;
}

@media (max-width: 760px) {
  .desktop-device-table {
    display: none !important;
  }

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

  .mobile-device-empty {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
  }

  .device-toolbar {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .device-toolbar .search-box {
    grid-column: 1 / -1;
  }

  .display-options {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .device-toolbar > .button {
    width: auto;
  }
}

.action-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.device-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  padding: 0 15px 15px;
}

a.button {
  text-decoration: none;
}

.backup-actions {
  display: flex;
  gap: 9px;
}

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

.backup-summary > div {
  display: grid;
  gap: 6px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(20, 36, 50, 0.05);
}

.backup-summary span {
  color: var(--muted);
  font-size: 11px;
}

.backup-summary strong {
  color: #204c42;
  font-size: 15px;
}

@media (max-width: 760px) {
  .action-buttons {
    flex-direction: column;
  }

  .device-card-actions {
    grid-template-columns: 1fr;
  }

  .backup-actions {
    width: 100%;
  }

  .backup-actions .button {
    flex: 1;
  }

  .backup-summary {
    grid-template-columns: 1fr;
  }
}

.table-wrap {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.link-button {
  padding: 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}

.link-button:hover {
  text-decoration: underline;
}

.selected-row {
  background: #eaf6f3 !important;
}

.mobile-admin-list {
  display: none;
}

.admin-mobile-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.admin-mobile-card.selected {
  border-color: #6eb8a8;
  box-shadow: 0 0 0 2px rgba(20, 108, 90, 0.09);
}

.admin-mobile-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 13px;
  border-bottom: 1px solid #e8edf0;
  background: #f8fafb;
}

.admin-mobile-card-header > span {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 999px;
  color: #0d5d4e;
  background: #e7f5f1;
  font-size: 10px;
  font-weight: 700;
}

.admin-mobile-details {
  display: grid;
  padding: 4px 13px;
}

.admin-mobile-details > div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 9px;
  padding: 8px 0;
  border-bottom: 1px solid #edf1f3;
}

.admin-mobile-details > div:last-child {
  border-bottom: 0;
}

.admin-mobile-details dt {
  color: var(--muted);
  font-size: 11px;
}

.admin-mobile-details dd {
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.panel-actions-inline {
  display: flex;
  gap: 6px;
}

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

.password-cell {
  color: #0b5d4d;
  font-weight: 800;
}

.device-card-actions.single {
  grid-template-columns: 1fr;
}

@media (max-width: 760px) {
  .desktop-admin-table {
    display: none !important;
  }

  .mobile-admin-list {
    display: grid;
    gap: 10px;
    padding: 10px;
  }

  .compact-empty + .mobile-admin-list:not(:empty) {
    display: grid;
  }

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

  .panel-actions-inline {
    flex-wrap: wrap;
  }
}

.user-devices-modal{width:min(800px,94vw);max-height:90vh;overflow:auto}.transfer-toolbar{display:flex;align-items:flex-end;gap:16px;flex-wrap:wrap}.transfer-toolbar .field{flex:1;min-width:180px}.user-devices-list{max-height:48vh;overflow:auto}.user-device-item{border:1px solid #dce3eb;border-radius:10px;padding:14px;margin:10px 0}.user-device-choice,.select-all-devices{display:flex;align-items:center;gap:10px}.user-device-item .form-note{overflow-wrap:anywhere}.user-device-item button{margin-top:6px}

.user-device-choice input[type="checkbox"],.select-all-devices input[type="checkbox"]{width:18px;height:18px;min-height:0;flex:0 0 18px;margin:0;padding:0}.user-device-choice{justify-content:flex-start}.select-all-devices{justify-content:flex-start;width:max-content;white-space:nowrap;margin:12px 0}

.reports-query{display:flex;flex-wrap:wrap;align-items:flex-end;gap:14px;margin:20px 0}.reports-query .field{flex:1;min-width:150px}.reports-query-actions{display:flex;gap:8px;padding-bottom:2px}.reports-pagination{display:flex;align-items:center;justify-content:center;gap:16px;margin:20px 0}.reports-table td{max-width:330px;white-space:normal;overflow-wrap:anywhere}.reports-mobile-list{display:none}.report-detail-modal{max-height:90vh;overflow:auto}.report-detail-modal dd{overflow-wrap:anywhere}@media(max-width:760px){.reports-table{display:none}.reports-mobile-list{display:grid;gap:12px}.reports-query .field{min-width:42%}.reports-query-actions{width:100%}}

.reports-table{display:block;overflow-x:auto}.reports-table table{width:100%;table-layout:fixed}.reports-table th:nth-child(1){width:26%}.reports-table th:nth-child(2){width:20%}.reports-table th:nth-child(3){width:54%}.reports-mobile-list{display:none!important}@media(max-width:760px){.reports-table{display:block}.reports-table th:nth-child(1){width:29%}.reports-table th:nth-child(2){width:22%}.reports-table th:nth-child(3){width:49%}.reports-table td,.reports-table th{padding:10px 7px;font-size:13px}}

.scale-snapshot-row>td{background:#f6f9fb;padding:16px!important;max-width:none!important}.scale-snapshot-table{overflow:auto;margin-top:12px}.scale-snapshot-table table{table-layout:auto;min-width:420px}.scale-snapshot-table th,.scale-snapshot-table td{width:auto!important;max-width:none!important;padding:9px!important;white-space:normal}.scale-snapshot-table td:nth-child(3),.scale-snapshot-table td:nth-child(4){font-variant-numeric:tabular-nums;overflow-wrap:anywhere}.reports-table .link-button{white-space:normal;text-align:left}

/* 请求授权消息 */
#requestMessagesButton.has-unread{color:#9b3417;background:#fff1e7;border-color:#f4b183;font-weight:700}
.request-messages-modal{width:min(600px,calc(100vw - 32px))}
.request-messages-list{display:grid;gap:10px;max-height:44vh;overflow:auto}
.request-message-item{display:grid;grid-template-columns:1fr auto;gap:6px 12px;text-align:left;padding:14px;border:1px solid var(--border,#dce4ec);border-radius:10px;background:#fff;cursor:pointer;color:inherit}
.request-message-item:hover{background:#f1f7fb}.request-message-item small{grid-column:1/-1;color:#64748b}
.request-message-detail{margin-top:16px;padding:18px;border:1px solid #bfd9e7;border-radius:10px;background:#f3f9fc}
.request-message-detail>span,.request-message-detail>strong{display:block}.request-message-detail>strong{font-size:24px;word-break:break-all;margin-top:8px}
@media(max-width:600px){.request-message-item{grid-template-columns:1fr}.request-message-item small{grid-column:auto}}

/* 手机管理页面：账号菜单、导航、卡片和弹窗统一适配 */
.account-menu-toggle{display:none}.account-menu-panel{display:flex;align-items:center;gap:13px}
@media(max-width:760px){
 body{min-width:0}.app-shell,.main-content,.page,.panel,.workbench-top,.workbench-bottom,.edit-layout{min-width:0}
 input,select,textarea{min-width:0;max-width:100%;font-size:16px}
 .topbar{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;min-height:0;padding:12px;position:sticky;top:0}
 .brand{grid-column:1;grid-row:1;min-width:0;gap:8px}.brand strong{font-size:14px}.brand span{display:none}.brand-mark-small{width:34px;height:34px;flex-shrink:0}
 .user-actions{display:contents}.account-menu-toggle{display:inline-flex;grid-column:2;grid-row:1;min-height:38px;background:#f5f8f9}
 #requestMessagesButton{grid-column:1/-1;grid-row:2;width:100%;min-height:40px;white-space:normal;text-align:center;font-size:13px}
 .account-menu-panel{display:none;position:absolute;right:12px;top:58px;z-index:30;width:min(280px,calc(100vw - 24px));padding:14px;gap:8px;border:1px solid var(--line);border-radius:14px;background:#fff;box-shadow:0 14px 36px #152d4026}
 .account-menu-open .account-menu-panel{display:grid}.account-menu-panel .user-badge{justify-items:start;padding:2px 4px 10px;border-bottom:1px solid var(--line);margin-bottom:2px}.account-menu-panel .user-name{max-width:100%;font-size:14px}.account-menu-panel .role-label{display:block}.account-menu-panel>.button{width:100%;min-height:42px;justify-content:flex-start;border:0;background:#f5f8f9}
 .tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;overflow:visible;padding:12px 12px 0}
 .tab{width:100%;min-width:0;min-height:40px;flex:initial;padding:8px 4px;border:1px solid transparent;border-radius:10px;font-size:13px;white-space:normal;box-shadow:none}
 .tab.active{border-color:#c8ddd5;background:#e4f3ef;box-shadow:none}
 .main-content{padding:0 12px 32px}.page{padding:18px 0}.page-heading,.section-header,.section-heading{display:flex;flex-wrap:wrap;align-items:center;gap:12px;margin-bottom:16px}.page-heading>div:first-child,.section-header>div:first-child,.section-heading>div:first-child{flex:1 1 100%;min-width:0}
 h1{font-size:23px}h2{font-size:20px}.eyebrow{font-size:10px}.page-description,.form-note{line-height:1.65}.section-header>.button,.page-heading>.button{min-height:40px}
 .toolbar{gap:10px}.device-toolbar{grid-template-columns:minmax(0,1fr) auto}.display-options{min-width:0;gap:8px;padding:8px}.device-card-actions{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.device-card-actions .button{min-width:0;font-size:13px;padding:10px 6px;white-space:normal}.device-card-actions .button:first-child{grid-column:1/-1}
 .device-card-header,.admin-mobile-card-header{flex-wrap:wrap}.device-card-validity{font-size:11px}.device-card-details>div{grid-template-columns:80px minmax(0,1fr)}
 .panel-title{flex-wrap:wrap;gap:8px}.table-title>div{flex-wrap:wrap;gap:4px 8px}.query-row,.generate-row,.date-mode-row,.panel-actions{margin:12px}.query-row label,.generate-row label{min-width:0}.date-mode-row{grid-template-columns:repeat(2,minmax(0,1fr))}.mode-tip{grid-column:1/-1}.stat-row{min-height:48px;grid-template-columns:minmax(0,1fr) 46px 58px}
 .backup-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.backup-actions .button{min-width:0;white-space:normal;font-size:13px}.backup-actions #createBackupButton{grid-column:1/-1}
 #accountsView .table-card,#backupsView .table-card,#recordsView .table-card{border:0;background:transparent;box-shadow:none;overflow:visible}
 #accountsView .table-wrap,#backupsView .table-wrap,#recordsView .table-wrap{overflow:visible}
 #accountsView table,#backupsView table,#recordsView table{display:block;width:100%;min-width:0}
 #accountsView thead,#backupsView thead,#recordsView thead{display:none}
 #accountsView tbody,#backupsView tbody,#recordsView tbody{display:grid;gap:12px}
 #accountsView tbody>tr,#backupsView tbody>tr,#recordsView tbody>tr{display:block;width:100%;padding:8px 14px;border:1px solid var(--line);border-radius:14px;background:#fff}
 #accountsView td,#backupsView td,#recordsView td{display:grid;grid-template-columns:88px minmax(0,1fr);gap:10px;width:100%;max-width:none;padding:11px 0;white-space:normal;border:0;border-bottom:1px solid #edf1f3;overflow-wrap:anywhere;text-align:left;font-size:13px}
 #accountsView td::before,#backupsView td::before,#recordsView td::before{content:attr(data-label);color:var(--muted);font-size:12px;font-weight:400}
 #accountsView td:last-child,#backupsView td:last-child,#recordsView td:last-child{border-bottom:0}
 #accountsView .action-buttons,#backupsView .action-buttons{display:grid;gap:7px}.action-buttons>.button{white-space:normal;min-height:38px}
 .reports-query{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:16px 0}.reports-query .field{min-width:0;width:100%}.reports-query .field:first-child{grid-column:1/-1}.reports-query-actions{grid-column:1/-1;display:grid;grid-template-columns:1fr 1fr;width:100%}.reports-query input{min-width:0;width:100%}
 .reports-table{border:1px solid var(--line);border-radius:12px;background:#fff}.reports-table td,.reports-table th{font-size:12px;padding:12px 7px;line-height:1.5}.reports-table .link-button{font-size:12px;line-height:1.55}.reports-pagination{gap:10px}.reports-pagination .button{padding:9px 12px;font-size:13px}
 .scale-snapshot-row>td{padding:12px 8px!important}.scale-snapshot-row strong{font-size:13px}.scale-snapshot-table{margin-top:8px;max-width:100%}.scale-snapshot-table table{min-width:0;width:100%;table-layout:fixed}.scale-snapshot-table th,.scale-snapshot-table td{padding:8px 5px!important;font-size:12px;overflow-wrap:anywhere}.scale-snapshot-table th:first-child{width:44%!important}.scale-snapshot-table th:nth-child(2),.scale-snapshot-table th:nth-child(3){width:28%!important}
 .modal-backdrop{padding:0;place-items:end center}.modal,.request-messages-modal,.user-devices-modal,.report-detail-modal{width:100%;max-width:100%;max-height:92vh;max-height:92dvh;overflow-y:auto;overscroll-behavior:contain;border-radius:18px 18px 0 0;padding:20px 16px calc(20px + env(safe-area-inset-bottom))}
 .modal-header{align-items:center;gap:12px}.modal-header h2{min-width:0;font-size:20px}.modal-header .icon-button{flex-shrink:0}.modal-actions{gap:8px;flex-wrap:wrap}.modal-actions .button{min-width:0;white-space:normal;min-height:42px}.request-messages-list{max-height:38vh;max-height:38dvh}.request-message-item{grid-template-columns:1fr;padding:14px;gap:7px}.request-message-item span{overflow-wrap:anywhere}.request-message-detail{padding:14px}.request-message-detail>strong{font-size:23px}.request-message-detail>.button{width:100%;margin-top:8px}
 .transfer-toolbar{display:grid;grid-template-columns:1fr;gap:10px}.transfer-toolbar .field{min-width:0}.user-device-choice{align-items:flex-start}.user-device-choice span{min-width:0;overflow-wrap:anywhere}.user-device-item{padding:12px}.user-devices-list{max-height:44vh}
 .login-card{padding:28px 22px}.login-heading h1{font-size:24px}
}
@media(min-width:721px) and (max-width:760px){.brand span{display:none}}

@media(max-width:760px){#accountsView td.action-column{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}#accountsView td.action-column::before{grid-column:1/-1}#accountsView td.action-column>.button{width:100%;font-size:12px;padding:9px 6px}}

/* 手机账号列表：每个账号默认一行，详情按需展开。 */
.account-row-more{display:none}
@media(max-width:760px){
 #accountsView table tbody{display:block}
 #accountsView table tbody>tr{display:grid;grid-template-columns:minmax(0,1fr) 64px;gap:0;padding:0 12px;border-radius:0;border-width:0 0 1px;}
 #accountsView table tbody>tr:first-child{border-top:1px solid var(--line)}
 #accountsView table td{display:none}
 #accountsView table td:first-child{display:flex;align-items:center;gap:8px;min-width:0;padding:12px 0;border:0;font-size:14px}
 #accountsView table td:first-child::before,#accountsView table td:nth-child(4)::before{display:none}
 #accountsView table td:first-child>.link-button{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:left}
 #accountsView .account-row-more{display:inline-flex;flex:none;margin-left:auto;padding:7px 5px;color:var(--muted);font-size:12px}
 #accountsView table td:nth-child(4){display:flex;justify-content:flex-end;align-items:center;border:0;padding:12px 0;white-space:nowrap}
 #accountsView table tr.account-expanded td:not(:first-child):not(:nth-child(4)){display:grid;grid-column:1/-1}
 #accountsView table tr.account-expanded td:first-child>.link-button{white-space:normal;overflow-wrap:anywhere}
 #accountsView table tr.account-expanded td.action-column{display:grid;padding-bottom:14px}
 #requestMessageDetail>.button{margin:4px 6px 4px 0}
}
