:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #f8f9fb;
  --text: #17181b;
  --muted: #6b7078;
  --border: #e3e5e9;
  --accent: #151515;
  --accent-soft: #eeeeef;
  --success: #147a4a;
  --success-bg: #eaf7f0;
  --danger: #b42318;
  --danger-bg: #fff0ee;
  --radius: 16px;
  --shadow: 0 12px 36px rgba(22, 24, 29, 0.07);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(0, 0, 0, 0.035), transparent 28rem),
    var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(227, 229, 233, 0.9);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  width: min(1180px, calc(100% - 40px));
  min-height: 68px;
  margin: 0 auto;
}

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

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 11px;
  background: #111;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 14px;
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.main-nav {
  display: flex;
  align-self: stretch;
  align-items: center;
  gap: 6px;
}

.main-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 13px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.main-nav a:hover,
.main-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.inline-form {
  display: inline;
  margin: 0;
}

.readonly-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #bfe4ce;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.readonly-badge span {
  font-size: 8px;
}

.readonly-badge-large {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

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

.button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(21, 21, 21, 0.18);
  outline-offset: 2px;
}

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

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

.button-primary:hover {
  background: #303033;
}

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

.button-secondary:hover,
.button-ghost:hover {
  background: var(--accent-soft);
}

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

.button-block {
  width: 100%;
}

.page-shell {
  width: min(1180px, calc(100% - 40px));
  min-height: calc(100vh - 142px);
  margin: 0 auto;
  padding: 42px 0 56px;
}

.page-heading {
  margin-bottom: 28px;
}

.split-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.page-heading h1,
.panel-heading h2,
.login-heading h1 {
  margin: 0;
  letter-spacing: -0.035em;
}

.page-heading h1 {
  font-size: clamp(28px, 4vw, 42px);
}

.page-heading p,
.panel-heading p,
.login-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.connection-card {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 300px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(22, 24, 29, 0.04);
}

.connection-card .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #a9adb4;
  box-shadow: 0 0 0 4px #f0f1f3;
}

.connection-card.is-connected .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-bg);
}

.connection-card div {
  min-width: 0;
  flex: 1;
}

.connection-card strong,
.connection-card small {
  display: block;
}

.connection-card strong {
  font-size: 14px;
}

.connection-card small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

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

.stat-card,
.panel,
.login-card {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-card {
  min-height: 154px;
  padding: 22px;
  border-radius: var(--radius);
}

.stat-card > span,
.stat-card > small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat-card strong {
  display: block;
  margin: 14px 0 17px;
  font-size: 32px;
  letter-spacing: -0.04em;
}

.stat-card a {
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.panel {
  overflow: hidden;
  border-radius: var(--radius);
}

.panel-heading,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.panel-heading h2 {
  font-size: 19px;
}

.panel-heading p {
  font-size: 12px;
}

.text-link {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 750;
}

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

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

th,
td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

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

tbody tr:hover {
  background: #fafafb;
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
  font-size: 11px;
  font-weight: 700;
}

.primary-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 360px;
}

.primary-cell img {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-muted);
  object-fit: cover;
}

.primary-cell strong {
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar {
  padding-top: 16px;
  padding-bottom: 16px;
}

.search-field {
  flex: 1;
  max-width: 380px;
}

.search-field input,
.field input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

.search-field input {
  padding: 0 14px;
}

.search-field input::placeholder,
.field input::placeholder {
  color: #a0a4aa;
}

.record-count,
.sync-note {
  color: var(--muted);
  font-size: 12px;
}

.sync-note {
  margin: 14px 4px 0;
  text-align: right;
}

.empty-state {
  padding: 58px 24px;
  text-align: center;
}

.empty-state strong {
  display: block;
  font-size: 16px;
}

.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 13px 15px;
  border: 1px solid;
  border-radius: 12px;
  font-size: 13px;
}

.notice-error {
  border-color: #fac7c2;
  background: var(--danger-bg);
  color: var(--danger);
}

.notice-success {
  border-color: #bfe4ce;
  background: var(--success-bg);
  color: var(--success);
}

.notice button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.login-page {
  background:
    radial-gradient(circle at 18% 10%, rgba(0, 0, 0, 0.055), transparent 24rem),
    #f4f5f7;
}

.login-page .site-header {
  position: static;
  background: transparent;
  backdrop-filter: none;
}

.login-shell {
  display: grid;
  min-height: calc(100vh - 142px);
  place-items: center;
  padding-top: 42px;
}

.login-card {
  width: min(100%, 430px);
  padding: 34px;
  border-radius: 22px;
}

.login-heading h1 {
  font-size: 31px;
}

.login-heading p {
  font-size: 14px;
}

.form-stack {
  display: grid;
  gap: 17px;
  margin-top: 28px;
}

.field > span {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
}

.field input {
  padding: 0 12px;
}

.readonly-callout {
  display: grid;
  gap: 4px;
  margin-top: 22px;
  padding: 13px 14px;
  border: 1px solid #d8dcdf;
  border-radius: 12px;
  background: var(--surface-muted);
}

.readonly-callout strong {
  font-size: 12px;
}

.readonly-callout span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1180px, calc(100% - 40px));
  min-height: 72px;
  margin: 0 auto;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
}

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

[hidden] {
  display: none !important;
}

.content-grid {
  display: grid;
  gap: 20px;
  margin-bottom: 20px;
}

.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stack-form input,
.stack-form select,
.stack-form textarea,
.operation-confirm input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}

.stack-form textarea {
  min-height: 170px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.button-danger {
  background: #b42318;
  border-color: #b42318;
  color: #fff;
}

.operation-confirm {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 360px;
}

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

.compact-action {
  align-items: center;
  display: flex;
  gap: 6px;
}

.compact-action input[type="number"] {
  width: 82px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 8px;
}

.filter-form {
  margin-left: auto;
}

.filter-form label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.filter-form select {
  min-height: 36px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 12px 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.package-card {
  display: flex;
  min-height: 180px;
  flex-direction: column;
  align-items: flex-start;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 120ms ease, border-color 120ms ease;
}

.package-card:hover {
  transform: translateY(-2px);
  border-color: #c5c8ce;
}

.package-card strong {
  margin-top: 16px;
  font-size: 17px;
}

.package-card p {
  flex: 1;
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.package-card small {
  font-weight: 750;
}

.success-pill {
  border-color: #bfe4ce;
  background: var(--success-bg);
  color: var(--success);
}

.business-panel {
  margin-bottom: 20px;
  scroll-margin-top: 90px;
}

.heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.sales-chart {
  display: grid;
  gap: 9px;
  margin: 20px 0 28px;
}

.sales-bar-row {
  display: grid;
  grid-template-columns: 105px minmax(120px, 1fr) 72px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.sales-bar-row strong {
  text-align: right;
}

.sales-bar-track {
  width: 100%;
  height: 12px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: #edf1f7;
}

.sales-bar-track::-webkit-progress-bar {
  background: #edf1f7;
}

.sales-bar-track::-webkit-progress-value {
  background: linear-gradient(90deg, #111827, #4f6ef7);
}

.sales-bar-track::-moz-progress-bar {
  background: linear-gradient(90deg, #111827, #4f6ef7);
}

.upload-guide ol {
  margin: 18px 0 24px;
  padding-left: 22px;
  color: var(--muted);
}

.upload-guide li + li {
  margin-top: 10px;
}

.upload-guide code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #f2f4f8;
}

.pending-panel {
  margin-top: 20px;
}

.pending-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 20px 22px;
}

@media (max-width: 900px) {
  .package-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-columns { grid-template-columns: 1fr; }
  .header-inner {
    flex-wrap: wrap;
    gap: 10px 18px;
    padding: 12px 0;
  }

  .main-nav {
    order: 3;
    width: 100%;
  }

  .main-nav a {
    flex: 1;
    justify-content: center;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .connection-card {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .package-grid { grid-template-columns: 1fr; }
  .header-inner,
  .page-shell,
  .site-footer {
    width: min(100% - 24px, 1180px);
  }

  .header-actions .readonly-badge {
    display: none;
  }

  .brand small {
    display: none;
  }

  .page-shell {
    padding-top: 28px;
  }

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

  .stat-card {
    min-height: 130px;
  }

  .panel-heading,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .search-field {
    width: 100%;
    max-width: none;
  }

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

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
  }
}
