:root {
  color-scheme: light;
  --bg: #eef2f6;
  --shell: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --surface-strong: #edf3f8;
  --text: #17212b;
  --text-strong: #0d1720;
  --muted: #657487;
  --line: #d8e1ea;
  --line-soft: #e8edf3;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --accent: #b45309;
  --danger: #b42318;
  --success: #15803d;
  --warn: #a15c07;
  --shadow: 0 16px 36px rgba(22, 34, 45, 0.09);
  --shadow-soft: 0 8px 22px rgba(22, 34, 45, 0.06);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #e8eef4 0, #f6f8fb 220px, #eef2f6 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 18px;
  background: #13202a;
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-title p,
.section-header p,
.scanner-actions,
.empty-copy span {
  margin: 0;
  color: var(--muted);
}

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

.nav-button,
.app-download-link {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  text-decoration: none;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 800;
}

.nav-button {
  background: transparent;
  color: #dce5ed;
}

.nav-button.active,
.nav-button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.app-download-link {
  display: block;
  background: #f59e0b;
  color: #18212b;
}

.safe-download {
  background: rgba(255, 255, 255, 0.1);
  color: #e8eef5;
}

.logout-button {
  color: #fca5a5;
}

.stats-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto;
}

.stats-panel div {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

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

.stats-panel span {
  display: block;
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
}

.stats-panel small {
  display: block;
  margin-top: 6px;
  color: #aebcca;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #f3f7fb;
}

.auth-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 20px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0 0 6px;
  color: var(--text-strong);
  font-size: 24px;
}

.auth-card p {
  margin: 0 0 16px;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 12px;
}

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

.auth-message {
  min-height: 22px;
  margin-top: 10px;
  color: #b91c1c;
  font-size: 13px;
}

.auth-message.ok {
  color: #166534;
}

.auth-link {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.auth-link a {
  color: var(--text-strong);
  font-weight: 900;
  text-decoration: none;
}

.home-page {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.10), rgba(243, 247, 251, 0) 340px),
    #f3f7fb;
}

.home-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 28px 18px 34px;
}

.home-hero {
  min-height: calc(100vh - 96px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 28px;
  align-items: center;
}

.home-copy {
  display: grid;
  gap: 18px;
}

.home-eyebrow {
  margin: 0;
  color: var(--primary-dark);
  font-weight: 900;
}

.home-copy h1 {
  margin: 0;
  color: var(--text-strong);
  font-size: 52px;
  line-height: 1.05;
}

.home-lead {
  max-width: 660px;
  margin: 0;
  color: #405064;
  font-size: 18px;
  line-height: 1.8;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.home-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

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

.home-device-bar {
  width: 42%;
  height: 10px;
  border-radius: 999px;
  background: #d8e1ea;
  margin: 0 auto 16px;
}

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

.home-photo-grid div {
  aspect-ratio: 1.2;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.16), rgba(180, 83, 9, 0.12)),
    #f7f9fc;
}

.home-scan-card {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}

.home-scan-card strong {
  color: var(--text-strong);
  font-size: 20px;
}

.home-scan-card span {
  color: var(--muted);
  font-weight: 800;
}

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

.home-features article {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.home-features b {
  color: var(--text-strong);
  font-size: 18px;
}

.home-features span {
  color: var(--muted);
  line-height: 1.7;
}

.settings-page {
  min-height: 100vh;
}

.settings-page .nav .active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.settings-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.settings-main {
  background:
    linear-gradient(180deg, #e8eef4 0, #f6f8fb 220px, #eef2f6 100%);
}

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

.settings-header h1,
.settings-panel h2 {
  margin: 0;
  color: var(--text-strong);
}

.settings-header h1 {
  font-size: 26px;
}

.settings-header p,
.settings-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.settings-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.settings-panel h2 {
  font-size: 20px;
}

.settings-form {
  display: grid;
  gap: 12px;
}

.settings-form label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-weight: 900;
}

.settings-form input {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  color: var(--text);
}

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

.settings-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 8px 10px;
  font-weight: 900;
}

.settings-list-item button {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: #fee2e2;
  color: var(--danger);
  padding: 6px 10px;
  font-weight: 900;
}

.settings-empty {
  min-height: 42px;
  display: grid;
  place-items: center start;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px 12px;
  color: var(--muted);
}

.settings-message {
  min-height: 22px;
  margin: 0;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 800;
}

.settings-message.ok {
  color: #166534;
}

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

.admin-toolbar input,
.admin-verify input,
.admin-table input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

.admin-verify {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(130px, 180px) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #f8fbff;
  padding: 10px;
}

.admin-verify-text {
  display: grid;
  gap: 3px;
  color: var(--text);
  font-weight: 900;
}

.admin-verify-text span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.admin-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
  background: #f8fbff;
  white-space: nowrap;
}

.admin-table td {
  color: var(--text);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 260px;
}

.admin-actions button {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: #e7edf3;
  color: #263443;
  padding: 6px 9px;
  font-weight: 900;
}

.main {
  min-width: 0;
  padding: 26px;
  overflow: auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.section-header.compact {
  margin-top: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2,
h3 {
  margin: 0;
  color: var(--text-strong);
}

h2 {
  font-size: 28px;
  line-height: 1.18;
}

h3 {
  font-size: 17px;
  line-height: 1.35;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  gap: 14px;
  align-items: start;
}

.photo-panel {
  grid-row: span 3;
}

.details-panel,
.tag-panel,
.form-actions {
  min-width: 0;
}

.panel,
.result-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.panel-title {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.step {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #dff5f1;
  color: var(--primary-dark);
  font-weight: 900;
}

.panel-title p {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.5;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: #354354;
  font-size: 13px;
  font-weight: 800;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c7d2dd;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.upload-zone {
  display: grid;
  gap: 0;
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.native-upload,
.native-upload label {
  display: grid;
  gap: 10px;
}

.upload-zone input {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  padding: 12px;
  font-weight: 900;
}

.upload-zone small {
  color: var(--muted);
}

.photo-preview,
.gallery,
.result-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.photo-summary {
  grid-column: 1 / -1;
  border: 1px solid #a9ddd1;
  border-radius: 8px;
  background: #e7f8f5;
  color: #0b5f59;
  padding: 10px 12px;
  font-weight: 900;
}

.photo-tile,
.gallery-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  aspect-ratio: 4 / 3;
}

.photo-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 16px;
  text-align: center;
  background: var(--surface-strong);
  color: var(--text);
}

.photo-fallback span {
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-tile img,
.gallery-card img,
.result-photos img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.photo-tile img {
  position: relative;
  z-index: 1;
  opacity: 0;
}

.photo-tile.has-image img {
  opacity: 1;
}

.photo-status {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.94);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.photo-status.pending {
  background: rgba(180, 83, 9, 0.94);
}

.photo-status.error {
  background: rgba(180, 35, 24, 0.94);
}

.remove-photo,
.remove-tag {
  border: 0;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
}

.remove-photo {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  width: 28px;
  height: 28px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr);
  gap: 14px;
}

.existing-material-picker {
  position: relative;
  max-width: 100%;
  margin-bottom: 14px;
}

.existing-material-picker select {
  display: none;
}

.material-picker-toggle {
  width: 100%;
  border: 1px solid #c7d2dd;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  text-align: left;
}

.material-picker-toggle span,
.material-picker-toggle small {
  display: block;
}

.material-picker-toggle span {
  color: var(--text-strong);
  font-weight: 900;
}

.material-picker-toggle small {
  margin-top: 4px;
  color: var(--muted);
}

.material-picker-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 8px;
}

.material-picker-item {
  width: 100%;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 8px;
  text-align: left;
}

.material-picker-item:hover,
.material-picker-item.active {
  background: var(--surface-soft);
}

.material-picker-thumb {
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  object-fit: cover;
}

.empty-thumb {
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

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

.material-picker-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.picker-empty {
  padding: 12px;
  color: var(--muted);
}

.tag-entry,
.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.scanner-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.scanner-box {
  width: min(480px, 100%);
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 18, 24, 0.62);
}

.scanner-dialog {
  width: min(520px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 54px rgba(10, 18, 24, 0.24);
}

.scanner-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.scanner-dialog-head strong {
  color: var(--text-strong);
}

.scanner-overlay-body {
  padding: 12px;
}

.scanner-overlay-body .scanner-box {
  width: 100%;
  margin: 0;
  border: 0;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  border: 1px solid #b7ded6;
  border-radius: 999px;
  background: #e7f8f5;
  color: #0b5f59;
  padding: 6px 8px 6px 12px;
  font-weight: 900;
}

.remove-tag {
  width: 22px;
  height: 22px;
  line-height: 20px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

#formMessage {
  margin: 0;
  color: var(--primary);
  font-weight: 900;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 10px 15px;
  font-weight: 900;
}

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

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

.secondary-button {
  background: #253547;
  color: #fff;
}

.ghost-button {
  background: #e7edf3;
  color: #263443;
}

.danger-button {
  background: #fee2e2;
  color: var(--danger);
}

.search-panel {
  padding: 16px;
}

.gallery {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.gallery-card {
  cursor: pointer;
  min-height: 235px;
  aspect-ratio: auto;
  display: grid;
  grid-template-rows: minmax(150px, 1fr) auto;
  box-shadow: var(--shadow-soft);
}

.gallery-card img {
  aspect-ratio: 4 / 3;
}

.gallery-meta {
  padding: 12px;
  background: #fff;
}

.gallery-meta strong {
  display: block;
  color: var(--text-strong);
  line-height: 1.35;
}

.gallery-meta span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  min-height: 210px;
  display: grid;
  place-items: center;
  border: 1px dashed #9db0c2;
  border-radius: 8px;
  background: var(--surface-soft);
}

.empty-copy {
  display: grid;
  gap: 6px;
  text-align: center;
}

.empty-copy strong {
  color: var(--text-strong);
}

.result-panel {
  margin-top: 16px;
}

.result-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.result-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.result-title strong {
  display: block;
  color: var(--text-strong);
  font-size: 23px;
  line-height: 1.25;
}

.result-title span {
  color: var(--muted);
}

.tag-count {
  flex: 0 0 auto;
  border-radius: 8px;
  background: #fff4e6;
  color: #8a4b10;
  padding: 9px 12px;
  font-weight: 900;
}

.result-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.detail-box {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.detail-box small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
}

.detail-box strong {
  color: var(--text-strong);
}

.detail-subtitle {
  margin-top: 16px;
  font-size: 15px;
}

.photo-tile img,
.result-photos img,
.material-picker-thumb {
  cursor: zoom-in;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 18, 24, 0.84);
}

.image-viewer img {
  max-width: min(100%, 1100px);
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

.image-viewer-close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}

.scan-layout {
  display: grid;
  gap: 14px;
}

.summary-top,
.rfid-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.summary-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

.summary-item b {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.summary-item span {
  color: var(--text-strong);
  font-size: 24px;
  font-weight: 900;
}

.rfid-match-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.7fr) minmax(440px, 1.3fr);
  gap: 14px;
  align-items: start;
}

.rfid-match-layout > .hidden + .scan-result {
  grid-column: 1 / -1;
}

.handheld-scan-box {
  display: grid;
  gap: 14px;
}

.handheld-rfid-input {
  min-height: 58px;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 0;
}

.rfid-reader-toolbar,
.scan-top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
}

.scan-top-nav {
  justify-content: flex-end;
}

.scan-top-nav .ghost-button,
.app-download-button {
  min-height: 36px;
  padding: 8px 12px;
}

.app-download-button {
  display: inline-flex;
  align-items: center;
  background: #f59e0b;
  color: #17212b;
  text-decoration: none;
}

.app-download-button.safe-download {
  background: #e7edf3;
  color: #263443;
}

.compact-field {
  display: grid;
  gap: 4px;
  width: 108px;
}

.compact-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.compact-field input {
  min-height: 42px;
  padding: 9px;
}

.scan-result:empty::before {
  content: "还没有任何 RFID 结果";
  display: block;
  color: var(--muted);
}

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

.rfid-match-card {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.rfid-match-photos {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  width: 128px;
  min-height: 124px;
  background: var(--surface-strong);
}

.rfid-match-photos img {
  width: 100%;
  height: 100%;
  min-height: 124px;
  object-fit: cover;
}

.rfid-match-photos img:not(:first-child) {
  display: none;
}

.rfid-photo-empty {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
}

.rfid-match-info {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 12px 8px;
}

.rfid-match-info strong,
.rfid-match-info span {
  display: block;
}

.rfid-match-info strong {
  color: var(--text-strong);
}

.rfid-match-info span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.rfid-match-count {
  flex: 0 0 auto;
  border-radius: 8px;
  background: #fff4e6;
  color: #8a4b10;
  padding: 8px 10px;
  font-weight: 900;
}

.rfid-match-card .tag-list {
  grid-column: 2;
  margin: 0;
  padding: 0 12px 12px;
}

.rfid-unbound-box {
  margin-top: 14px;
  border: 1px dashed #9db0c2;
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.rfid-table-wrap {
  overflow-x: auto;
  margin-top: 18px;
}

.rfid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.rfid-table th,
.rfid-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.rfid-table th {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  background: var(--surface-soft);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 900;
}

.status-bound {
  background: #dcfce7;
  color: #166534;
}

.status-unbound {
  background: #f3f4f6;
  color: #4b5563;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .stats-panel {
    margin-top: 0;
  }

  .workbench,
  .rfid-match-layout {
    grid-template-columns: 1fr;
  }

  .photo-panel {
    grid-row: auto;
  }
}

@media (max-width: 720px) {
  body {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
  }

  body.home-page {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .home-shell {
    padding: 18px 14px 24px;
  }

  .home-hero {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: start;
  }

  .home-copy h1 {
    font-size: 36px;
  }

  .home-lead {
    font-size: 16px;
    line-height: 1.7;
  }

  .home-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .home-actions a:first-child {
    grid-column: 1 / -1;
  }

  .home-features {
    grid-template-columns: 1fr;
    margin-top: 16px;
  }

  body.settings-page {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .settings-page .main {
    padding: 14px 14px calc(92px + env(safe-area-inset-bottom));
  }

  .settings-header {
    align-items: flex-start;
  }

  .settings-header h1 {
    font-size: 23px;
  }

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

  .settings-panel {
    padding: 14px;
  }

  .main {
    padding: 14px 14px calc(92px + env(safe-area-inset-bottom));
  }

  .sidebar {
    gap: 0;
    padding: 10px 12px 8px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    border-right: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(22, 34, 45, 0.06);
  }

  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    display: flex;
    grid-template-columns: none;
    gap: 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid var(--line);
    box-shadow: 0 -12px 30px rgba(22, 34, 45, 0.12);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-button,
  .app-download-link {
    flex: 0 0 auto;
    min-width: 64px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 6px 8px;
    background: #f7f9fc;
    color: #344255;
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    box-shadow: none;
  }

  .nav-button.active,
  .app-download-link.active {
    background: #e7f8f5;
    border-color: #a9ddd1;
    color: var(--primary-dark);
  }

  .app-download-link,
  .safe-download {
    background: #fff4e6;
    color: #8a4b10;
  }

  .app-download-link.safe-download {
    background: #eef2f7;
    color: #344255;
  }

  .app-download-link.safe-download.active {
    background: #e7f8f5;
    border-color: #a9ddd1;
    color: var(--primary-dark);
  }

  .stats-panel {
    display: none;
  }

  .section-header {
    display: grid;
    gap: 10px;
  }

  h2 {
    font-size: 23px;
  }

  .panel,
  .result-panel,
  .form-actions {
    padding: 14px;
  }

  .tag-entry,
  .search-row {
    grid-template-columns: 1fr;
  }

  .photo-preview,
  .gallery,
  .result-photos {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .result-header,
  .result-actions,
  .form-actions {
    display: grid;
  }

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

  .summary-item {
    padding: 10px;
  }

  .summary-item span {
    font-size: 20px;
  }

  .rfid-reader-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .rfid-reader-toolbar .compact-field {
    width: auto;
  }

  .admin-verify {
    grid-template-columns: 1fr;
  }

  .scan-top-nav {
    justify-content: flex-start;
  }

  .rfid-match-grid {
    grid-template-columns: 1fr;
  }

  .rfid-match-card {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .rfid-match-photos {
    width: 96px;
    min-height: 108px;
  }

  .rfid-match-photos img {
    min-height: 108px;
  }

  .scanner-overlay {
    align-items: end;
    padding: 12px 12px calc(88px + env(safe-area-inset-bottom));
  }

  .scanner-dialog {
    width: 100%;
  }
}
