:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #172033;
  --muted: #697386;
  --line: #dce3ee;
  --brand: #2563eb;
  --brand-dark: #1f2a44;
  --cyan: #0891b2;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --violet: #7c3aed;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.field-hint {
  display: block;
  min-height: 18px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.field-hint.error {
  color: var(--red);
}

svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}

.svg-defs {
  display: none;
}

.hidden {
  display: none !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 480px);
  padding: 32px;
  gap: 24px;
}

.auth-hero {
  min-height: calc(100vh - 64px);
  border-radius: 8px;
  padding: 56px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(31, 42, 68, 0.96), rgba(8, 145, 178, 0.82)),
    url("data:image/svg+xml,%3Csvg width='1200' height='900' viewBox='0 0 1200 900' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.16'%3E%3Cpath d='M90 625h1020M160 557c30-76 92-118 178-118h524c92 0 160 47 184 130' stroke-width='22' stroke-linecap='round'/%3E%3Cpath d='M248 505h704v170H248z' stroke-width='18'/%3E%3Cpath d='M338 505v170M600 505v170M862 505v170M278 675h644' stroke-width='16'/%3E%3Cpath d='M350 250c90 0 124 76 124 144M850 250c-90 0-124 76-124 144' stroke-width='14' stroke-linecap='round'/%3E%3Ccircle cx='600' cy='308' r='76' stroke-width='14'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 66px;
  height: 66px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--brand-dark);
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  background: var(--brand-dark);
  color: #fff;
  font-size: 13px;
}

.auth-hero h1 {
  max-width: 720px;
  margin: auto 0 16px;
  font-size: 52px;
  line-height: 1.05;
  letter-spacing: 0;
}

.auth-hero p {
  max-width: 580px;
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 18px;
  line-height: 1.7;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 48px;
}

.hero-metrics div {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.1);
}

.hero-metrics strong {
  display: block;
  font-size: 22px;
}

.hero-metrics span {
  display: block;
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
}

.auth-panel {
  align-self: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: 8px;
  background: var(--panel-soft);
  margin-bottom: 24px;
}

.auth-tab {
  border-radius: 7px;
  padding: 11px 16px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.auth-tab.active {
  background: #fff;
  color: var(--brand-dark);
  box-shadow: 0 4px 16px rgba(23, 32, 51, 0.08);
}

.auth-form {
  display: none;
  gap: 16px;
}

.auth-form.active {
  display: grid;
}

.auth-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.check-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.check-line input {
  width: auto;
}

.demo-account {
  color: var(--brand);
  white-space: nowrap;
}

.primary,
.ghost,
.danger,
.soft,
.icon-btn {
  min-height: 38px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  font-weight: 700;
}

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

.primary:hover {
  background: #1d4ed8;
}

.ghost {
  background: #fff;
  color: var(--brand-dark);
  border: 1px solid var(--line);
}

.soft {
  background: var(--panel-soft);
  color: var(--brand-dark);
}

.danger {
  background: #fff;
  color: var(--red);
  border: 1px solid #fecaca;
}

.wide {
  width: 100%;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 22px 18px;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 6px 24px;
}

.side-brand strong,
.side-brand span {
  display: block;
}

.side-brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: #eef5ff;
  color: var(--brand);
}

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

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

.topbar h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

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

.search-box {
  width: min(360px, 28vw);
  min-width: 220px;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
}

.search-box input {
  border: 0;
  padding: 0;
  box-shadow: none;
  min-width: 0;
}

.current-user {
  min-width: 122px;
  border-left: 1px solid var(--line);
  padding-left: 12px;
}

.current-user span,
.current-user small {
  display: block;
}

.current-user small {
  margin-top: 3px;
  color: var(--muted);
}

.view-root {
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(23, 32, 51, 0.05);
}

.panel-head {
  min-height: 58px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h3 {
  margin: 0;
  font-size: 16px;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-body {
  padding: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
}

.stat {
  min-height: 128px;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

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

.stat strong {
  display: block;
  font-size: 34px;
  line-height: 1;
}

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

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
}

.stat-icon.blue { background: var(--brand); }
.stat-icon.green { background: var(--green); }
.stat-icon.amber { background: var(--amber); }
.stat-icon.red { background: var(--red); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 18px;
}

.bar-list {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 42px;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #edf2f7;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.bar-fill.green { background: var(--green); }
.bar-fill.amber { background: var(--amber); }
.bar-fill.red { background: var(--red); }
.bar-fill.violet { background: var(--violet); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.filters input,
.filters select {
  width: auto;
  min-width: 160px;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  background: #f8fafc;
  font-weight: 700;
  white-space: nowrap;
}

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

.cell-title {
  font-weight: 800;
}

.cell-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.green {
  color: #047857;
  background: #d1fae5;
}

.badge.red {
  color: #b91c1c;
  background: #fee2e2;
}

.badge.amber {
  color: #b45309;
  background: #fef3c7;
}

.badge.blue {
  color: #1d4ed8;
  background: #dbeafe;
}

.badge.gray {
  color: #475569;
  background: #e2e8f0;
}

.badge.violet {
  color: #6d28d9;
  background: #ede9fe;
}

.actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.icon-btn {
  min-width: 36px;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand-dark);
}

.icon-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.icon-btn.danger {
  color: var(--red);
  border-color: #fecaca;
}

.empty {
  padding: 42px 18px;
  text-align: center;
  color: var(--muted);
}

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

.form-grid .wide-field {
  grid-column: 1 / -1;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.5);
}

.modal {
  width: min(720px, 100%);
  max-height: min(820px, calc(100vh - 48px));
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.24);
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 18px;
}

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

.settings-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.nfc-guide {
  display: grid;
  gap: 16px;
}

.nfc-note {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 8px;
  background: #eff6ff;
}

.nfc-note strong {
  font-size: 14px;
}

.nfc-note span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

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

.guide-block {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.guide-block h4 {
  margin: 0;
  font-size: 15px;
}

.guide-block p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

code {
  display: inline-block;
  max-width: 100%;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--brand-dark);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.guide-block code {
  display: block;
}

.action-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-tags span {
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--brand-dark);
  font-size: 12px;
  line-height: 1.3;
}

.json-preview {
  min-height: 190px;
  margin: 0;
  padding: 16px;
  border-radius: 8px;
  overflow: auto;
  background: #0f172a;
  color: #dbeafe;
  font-size: 13px;
  line-height: 1.6;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.timeline-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.timeline-time {
  color: var(--muted);
  font-size: 12px;
}

.timeline-title {
  font-weight: 800;
}

.timeline-desc {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 48px));
  border-radius: 8px;
  padding: 13px 16px;
  background: var(--brand-dark);
  color: #fff;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
}

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

  .auth-hero {
    min-height: 420px;
  }

  .app-shell {
    grid-template-columns: 80px minmax(0, 1fr);
  }

  .side-brand div:not(.brand-mark),
  .nav-item span {
    display: none;
  }

  .sidebar {
    padding: 18px 12px;
  }

  .nav-item {
    justify-content: center;
  }

  .topbar,
  .top-actions {
    flex-wrap: wrap;
  }

  .search-box {
    width: 100%;
  }

  .stats-grid,
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .auth-shell {
    padding: 16px;
  }

  .auth-hero {
    min-height: 360px;
    padding: 28px;
  }

  .auth-hero h1 {
    font-size: 36px;
  }

  .hero-metrics,
  .stats-grid,
  .dashboard-grid,
  .guide-grid,
  .form-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-brand {
    padding-bottom: 12px;
  }

  .side-brand div:not(.brand-mark),
  .nav-item span {
    display: block;
  }

  .side-nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .nav-item {
    justify-content: flex-start;
    min-height: 42px;
  }

  .workspace {
    padding: 16px;
  }

  .top-actions,
  .filters,
  .toolbar {
    width: 100%;
  }

  .filters input,
  .filters select,
  .toolbar .primary,
  .top-actions .ghost,
  .current-user {
    width: 100%;
  }

  .current-user {
    border-left: 0;
    padding-left: 0;
  }
}
