:root {
  color-scheme: light;
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --text: #15201d;
  --muted: #66736f;
  --line: #dce5e1;
  --green: #0f8f72;
  --green-deep: #086451;
  --amber: #bd7a16;
  --red: #c24132;
  --blue: #2b6cb0;
  --shadow: 0 18px 44px rgba(22, 33, 29, .10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(15, 143, 114, .12), transparent 28rem),
    linear-gradient(135deg, #f5f8f7, var(--bg));
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

body.auth-checking .app-shell,
body.auth-locked .app-shell {
  display: none;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 20% 18%, rgba(15, 143, 114, .20), transparent 26rem),
    linear-gradient(135deg, #f6faf8, #e8f0ed);
}

body.auth-checking .auth-overlay,
body.auth-locked .auth-overlay {
  display: grid;
}

.auth-card {
  width: min(440px, 100%);
  padding: 30px;
  border: 1px solid rgba(220, 229, 225, .95);
  border-radius: 28px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-card .brand-mark {
  margin-bottom: 18px;
}

.auth-card h1 {
  margin: 4px 0 10px;
  font-size: clamp(30px, 5vw, 44px);
}

.auth-card p {
  color: var(--muted);
  line-height: 1.7;
}

.auth-card label {
  display: grid;
  gap: 8px;
  margin: 18px 0 14px;
  color: var(--muted);
}

.auth-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  color: var(--text);
  background: #fff;
}

.auth-card .primary-button {
  width: 100%;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar,
.workspace {
  background: rgba(255, 255, 255, .88);
  border: 1px solid rgba(220, 229, 225, .9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

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

.app-shell.sidebar-hidden .sidebar {
  display: none;
}

.sidebar {
  border-radius: 24px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(135deg, var(--green), #1aa3a3);
  font-weight: 700;
}

.brand small,
.sync-card small,
.eyebrow,
.panel p,
.metric-card span,
.metric-card small,
.soft {
  color: var(--muted);
}

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

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

.nav-item,
.subnav-item,
.ghost-button,
.primary-button,
.quick-actions button {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
}

.nav-item {
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.nav-item.active,
.nav-item:hover,
.subnav-item.active,
.subnav-item:hover {
  color: var(--green-deep);
  background: #e7f4ef;
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .72);
}

.subnav-item {
  color: var(--muted);
  background: transparent;
}

.purchase-page {
  display: none;
}

.purchase-page.active,
.operation-page.active {
  display: block;
}

.operation-page {
  display: none;
}

.sync-card {
  margin-top: auto;
  display: grid;
  gap: 7px;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.workspace {
  border-radius: 28px;
  padding: 22px;
  min-width: 0;
}

.topbar,
.panel-head,
.top-actions,
.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 12px;
}

h1,
h2 {
  margin: 0;
}

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

h2 {
  font-size: 20px;
}

.ghost-button {
  color: var(--green-deep);
  background: #e9f5f1;
}

.save-status {
  align-self: center;
  padding: 9px 12px;
  border-radius: 999px;
  color: var(--green-deep);
  background: #e7f4ef;
  font-size: 13px;
  white-space: nowrap;
}

.save-status.saving {
  color: var(--amber);
  background: #fff6e9;
}

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

.full {
  width: 100%;
}

.view {
  display: none;
  margin-top: 22px;
}

.view.active {
  display: block;
}

.section-toolbar {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, .72);
}

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

.metric-card,
.panel,
.phone-metric,
.phone-alert {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.metric-card {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metric-card strong {
  font-size: 30px;
}

.up {
  color: var(--green) !important;
}

.warn {
  color: var(--amber) !important;
}

.dashboard-grid,
.module-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: 14px;
  margin-top: 14px;
}

.operation-data-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
}

.inventory-page-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
}

.inventory-connect-panel {
  display: grid;
  gap: 10px;
}

.operation-data-layout .panel.wide {
  padding: 22px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.wide {
  grid-column: span 1;
}

.panel p {
  margin: 6px 0 0;
}

select,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface-soft);
  color: var(--text);
}

label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
}

.timeline {
  display: grid;
  grid-template-columns: repeat(6, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.timeline-item {
  position: relative;
  min-height: 96px;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

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

.timeline-item strong {
  margin-top: 20px;
}

.timeline-item.done {
  border-color: rgba(15, 143, 114, .35);
  background: #edf8f4;
}

.timeline-item.current {
  border-color: rgba(189, 122, 22, .45);
  background: #fff6e9;
}

.alert-list,
.ai-box,
.quick-actions,
.task-list,
.plain-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.alert {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--surface-soft);
  text-align: left;
}

.danger {
  color: var(--red);
}

.warning {
  color: var(--amber);
}

.info {
  color: var(--blue);
}

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

.quick-actions button {
  color: var(--green-deep);
  background: #e9f5f1;
}

table {
  width: 100%;
  margin-top: 18px;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 16px;
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-weight: 500;
  background: var(--surface-soft);
}

.table-sort-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  padding: 0;
  color: var(--green-deep);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.table-sort-button span {
  color: var(--muted);
  font-size: 12px;
}

.table-filter-input {
  margin-top: 8px;
  font-size: 12px;
}

.editable-table {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}

.editable-table table {
  min-width: 1280px;
}

.sticky-product-table {
  max-height: 680px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.sticky-product-table table {
  margin-top: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.sticky-product-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  border-bottom: 1px solid #c8d9d4;
  box-shadow: 0 2px 0 rgba(16, 92, 77, .06);
}

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

.table-pagination strong {
  color: var(--green-deep);
}

.table-pagination span {
  margin-left: 8px;
}

.table-pagination-actions {
  display: flex;
  gap: 8px;
}

.table-pagination button {
  border: 0;
  border-radius: 12px;
  padding: 9px 14px;
  color: var(--green-deep);
  background: #e9f5f1;
  cursor: pointer;
}

.table-pagination button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.feishu-mirror-table table {
  min-width: 1100px;
  border: 1px solid #cfded9;
  border-collapse: separate;
  border-spacing: 0;
}

.feishu-mirror-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  min-width: 150px;
  padding: 12px;
  border-right: 1px solid #cfded9;
  border-bottom: 1px solid #c3d6d0;
  background: #eef8f4;
  color: var(--green-deep);
}

.feishu-mirror-table .feishu-group-row th {
  top: 0;
  z-index: 3;
  text-align: center;
  font-size: 14px;
  letter-spacing: .02em;
  background: #dff1eb;
  color: #075f50;
}

.feishu-mirror-table thead tr:nth-child(2) th {
  top: 43px;
}

.feishu-mirror-table td {
  min-width: 120px;
  max-width: 280px;
  padding: 12px;
  border-right: 1px solid #dce8e4;
  border-bottom: 1px solid #dce8e4;
  white-space: pre-wrap;
  vertical-align: top;
  background: #fff;
}

.feishu-mirror-table tbody tr:nth-child(even) td {
  background: #fbfefd;
}

.feishu-mirror-table tbody tr:hover td {
  background: #eef8f4;
}

.feishu-mirror-table .table-filter-input {
  min-width: 130px;
  border-color: #c3d6d0;
  background: #fff;
}

.feishu-table-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 8px;
}

.feishu-table-meta span {
  padding: 8px 11px;
  border-radius: 999px;
  color: var(--green-deep);
  background: #e9f5f1;
  font-size: 13px;
}

.editable-table input {
  min-width: 118px;
  padding: 9px 10px;
  background: #fff;
}

.product-thumb-cell {
  display: grid;
  grid-template-columns: 54px;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.product-thumb-cell img,
.table-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.product-thumb-cell span {
  color: var(--muted);
  font-size: 12px;
}

.todo-checkbox {
  min-width: auto !important;
  width: 20px;
  height: 20px;
}

.editable-table th:last-child,
.editable-table td:last-child {
  width: 116px;
  text-align: center;
}

.row-actions {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.delete-row,
.split-row {
  border: 0;
  border-radius: 12px;
  padding: 9px 11px;
}

.delete-row {
  color: var(--red);
  background: #fff1ee;
}

.split-row {
  color: var(--green-deep);
  background: #e9f5f1;
}

.empty-state {
  margin-top: 18px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  background: var(--surface-soft);
}

.file-import {
  display: grid;
  margin-top: 16px;
}

.file-import input {
  display: none;
}

.file-import span {
  display: block;
  padding: 16px;
  border: 1px dashed var(--green);
  border-radius: 16px;
  color: var(--green-deep);
  background: #e9f5f1;
  text-align: center;
  cursor: pointer;
}

.import-hint {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  color: var(--muted);
  background: var(--surface-soft);
}

.import-hint.error {
  color: var(--red);
  background: #fff1ee;
}

.erp-grid {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.erp-grid span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--muted);
}

.erp-grid b {
  color: var(--green-deep);
  font-weight: 500;
}

.mini-stat-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.mini-stat-list.horizontal {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mini-stat-list span {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: var(--surface-soft);
}

.mini-stat-list b {
  color: var(--green-deep);
  font-size: 18px;
}

.lingxing-config {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
  margin-top: 12px;
}

.lingxing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.remember-secret {
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.remember-secret input {
  width: auto;
}

.sync-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.lingxing-result {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.lingxing-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.lingxing-kpis span {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: var(--surface-soft);
}

.lingxing-kpis b {
  color: var(--green-deep);
  font-size: 22px;
}

.lingxing-result span,
.api-map span {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: var(--surface-soft);
  word-break: break-word;
}

.api-map {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.api-map b {
  color: var(--green-deep);
  font-weight: 500;
}

.compact-table {
  margin-top: 0;
}

.progress-board {
  display: grid;
  gap: 18px;
  margin-top: 16px;
}

.store-progress-group {
  display: grid;
  gap: 12px;
}

.store-progress-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.store-progress-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  color: var(--green-deep);
  background: #e7f4ef;
}

.store-progress-title span {
  color: var(--muted);
  font-size: 13px;
}

.progress-item {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}

.progress-item.expanded {
  grid-column: 1 / -1;
  padding: 18px;
  border-color: rgba(15, 143, 114, .34);
  background: #fbfffd;
  box-shadow: 0 18px 38px rgba(21, 54, 45, .11);
}

.progress-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.progress-card-head strong {
  display: block;
  margin-bottom: 4px;
}

.progress-card-head span {
  color: var(--muted);
  font-size: 13px;
}

.mini-button {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.progress-track {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
}

.progress-step {
  min-height: 46px;
  display: grid;
  place-items: center;
  padding: 8px 6px;
  border-radius: 12px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  text-align: center;
  font-size: 12px;
}

.progress-step.done {
  color: var(--green-deep);
  background: #e7f4ef;
  border-color: rgba(15, 143, 114, .28);
}

.progress-step.current {
  color: #6d460b;
  background: #fff6e9;
  border-color: rgba(189, 122, 22, .36);
}

.progress-meta {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.progress-item.expanded .progress-meta {
  display: grid;
}

.progress-item.expanded .progress-step {
  min-height: 64px;
  font-size: 13px;
}

.progress-meta span {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.progress-meta b {
  color: var(--green-deep);
  font-size: 12px;
  font-weight: 600;
}

.optimization-panel {
  margin-top: 14px;
}

.optimization-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.optimization-grid span {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: var(--surface-soft);
}

.result-card {
  margin-top: 16px;
  padding: 16px;
  border-radius: 16px;
  color: var(--green-deep);
  background: #e7f4ef;
}

.profit-panel {
  align-self: start;
}

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

.profit-hero {
  display: grid;
  gap: 12px;
  margin: 18px 0 16px;
  padding: 22px;
  border: 1px solid rgba(15, 143, 114, .28);
  border-radius: 22px;
  background: linear-gradient(135deg, #e3f7f0, #f6fffb);
}

.profit-hero .profit-label {
  color: var(--muted);
}

.profit-hero .profit-value {
  display: block;
  margin-top: 4px;
  color: var(--green-deep);
  font-size: clamp(42px, 5vw, 68px);
  line-height: 1;
}

.profit-hero .profit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profit-hero .profit-meta span,
.profit-hero .cost-line {
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .72);
  color: var(--muted);
}

.profit-hero .cost-breakdown {
  display: grid;
  gap: 8px;
}

.chart-bars {
  height: 230px;
  display: flex;
  align-items: end;
  gap: 12px;
  margin-top: 24px;
  padding: 18px;
  border-radius: 20px;
  background: var(--surface-soft);
}

.chart-bars span {
  flex: 1;
  min-width: 22px;
  border-radius: 12px 12px 4px 4px;
  background: linear-gradient(180deg, #18a58a, #8bc9bd);
}

.creative-board {
  display: grid;
  grid-template-columns: .8fr 1.2fr;
  gap: 14px;
  margin-top: 16px;
}

.upload-zone,
.script-card {
  min-height: 210px;
  border-radius: 20px;
  padding: 18px;
  border: 1px dashed var(--green);
  background: var(--surface-soft);
}

.upload-zone {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.script-card {
  display: grid;
  align-content: center;
  gap: 12px;
}

.task-list span,
.file-grid span {
  padding: 13px;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.task-list b {
  float: right;
  color: var(--green-deep);
  font-weight: 500;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

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

  .sidebar {
    position: static;
  }

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

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .creative-board,
  .dashboard-grid,
  .module-layout,
  .mini-stat-list.horizontal {
    grid-template-columns: 1fr;
    display: grid;
  }

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

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

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

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 520px) {
  body {
    background: var(--bg);
  }

  .sidebar {
    display: none;
  }

  .workspace {
    border-radius: 22px;
    padding: 16px;
  }

  .metric-grid,
  .quick-actions,
  .file-grid,
  .lingxing-config,
  .lingxing-kpis,
  .sync-controls,
  .profit-input-grid,
  .optimization-grid,
  .progress-track {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 30px;
  }
}
