:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  --ec-bg: #f3f5f8;
  --ec-surface: #fff;
  --ec-border: #cfd6df;
  --ec-grid: #bcc5cf;
  --ec-text: #111827;
  --ec-body: #334155;
  --ec-muted: #64748b;
  --ec-primary: #0f172a;
  --ec-blue: #1d4ed8;
  --ec-blue-soft: #eff6ff;
  --ec-invoice: #edf7e9;
  --ec-review: #fff7cc;
  --ec-color-yellow: #fff1b8;
  --ec-color-green: #dff3df;
  --ec-color-blue: #dcecff;
  --ec-color-pink: #f9e0ea;
  --ec-color-gray: #e8ebef;
  --ec-danger: #b42318;
  --ec-focus: 0 0 0 2px rgba(37, 99, 235, .18);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  background: var(--ec-bg);
  color: var(--ec-body);
  font-size: 13px;
  line-height: 1.4;
  margin: 0;
  min-width: 320px;
}
button, input, select {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: var(--ec-text);
  font: inherit;
  min-height: 34px;
  padding: 7px 9px;
}
button { cursor: pointer; font-weight: 700; white-space: nowrap; }
button:hover:not(:disabled) { background: #f8fafc; border-color: #94a3b8; }
button:disabled { cursor: not-allowed; opacity: .5; }
button:focus-visible, input:focus, select:focus {
  border-color: #2563eb;
  box-shadow: var(--ec-focus);
  outline: none;
}
.ec-primary { background: var(--ec-primary); border-color: var(--ec-primary); color: #fff; }
.ec-primary:hover:not(:disabled) { background: #1e293b; border-color: #1e293b; }
.ec-wechat-login {
  align-items: center;
  border: 1px solid var(--ec-primary);
  border-radius: 6px;
  display: flex;
  justify-content: center;
  min-height: 38px;
  text-decoration: none;
}
.ec-empty { color: var(--ec-muted); padding: 42px 16px !important; text-align: center !important; }

.ec-topbar {
  align-items: center;
  background: var(--ec-primary);
  color: #fff;
  display: flex;
  height: 54px;
  justify-content: space-between;
  padding: 0 18px;
}
.ec-brand { align-items: center; display: flex; gap: 10px; }
.ec-brand > span {
  background: #fff;
  border-radius: 5px;
  color: var(--ec-primary);
  font-size: 12px;
  font-weight: 900;
  padding: 5px 7px;
}
.ec-brand strong { font-size: 16px; }
.ec-top-actions { align-items: center; display: flex; gap: 7px; }
.ec-top-actions a, .ec-top-actions button {
  background: transparent;
  border: 1px solid #475569;
  border-radius: 6px;
  color: #fff;
  min-height: 32px;
  padding: 6px 9px;
  text-decoration: none;
}
.ec-user { color: #cbd5e1; margin-right: 4px; }

.ec-sheet-tabs {
  align-items: center;
  background: #e9edf2;
  border-bottom: 1px solid #c4ccd6;
  display: flex;
  min-height: 43px;
  padding: 7px 12px 0;
}
.ec-sheet-tabs > span { color: var(--ec-muted); flex: 0 0 auto; font-weight: 700; padding: 0 9px 7px 0; }
.ec-sheet-tabs-scroll {
  display: flex;
  flex: 1 1 auto;
  gap: 3px;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.ec-sheet-tabs button {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  flex: 0 0 auto;
  min-height: 35px;
  padding: 6px 12px;
}
.ec-sheet-tabs .ec-sheet-scroll-control {
  align-self: stretch;
  border-radius: 5px;
  flex: 0 0 30px;
  font-size: 18px;
  line-height: 1;
  margin: 0 4px 7px;
  min-height: 28px;
  padding: 0;
}
.ec-sheet-tabs .ec-sheet-scroll-control:last-child { margin-left: 4px; margin-right: 0; }
.ec-sheet-tabs button.is-active {
  background: #fff;
  border-bottom-color: #fff;
  color: var(--ec-blue);
  position: relative;
  z-index: 2;
}

.ec-sheet-shell { padding: 12px; }
.ec-command-bar {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 8px;
}
.ec-search-form { align-items: center; display: flex; gap: 6px; min-width: 0; }
.ec-search-form input[name="search"] { min-width: 260px; width: min(32vw, 460px); }
.ec-main-actions { display: flex; gap: 6px; }
.ec-save-status {
  align-items: center;
  color: #047857;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  min-width: 74px;
  padding: 0 4px;
}
.ec-save-status.is-saving { color: #1d4ed8; }
.ec-save-status.is-error { color: var(--ec-danger); }
.ec-style-bar {
  align-items: center;
  background: #fff;
  border: 1px solid var(--ec-border);
  border-bottom: 0;
  display: flex;
  gap: 9px;
  min-height: 40px;
  padding: 5px 10px;
}
.ec-style-bar > strong { color: var(--ec-text); flex: 0 0 auto; }
.ec-style-target {
  color: var(--ec-muted);
  flex: 0 1 230px;
  min-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ec-color-palette { align-items: center; display: flex; gap: 5px; }
.ec-color-swatch {
  align-items: center;
  border-radius: 4px;
  display: inline-flex;
  height: 28px;
  justify-content: center;
  min-height: 28px;
  padding: 3px;
  width: 28px;
}
.ec-color-swatch > span { border: 1px solid rgba(15, 23, 42, .16); border-radius: 3px; height: 18px; width: 18px; }
.ec-color-swatch.is-yellow > span { background: var(--ec-color-yellow); }
.ec-color-swatch.is-green > span { background: var(--ec-color-green); }
.ec-color-swatch.is-blue > span { background: var(--ec-color-blue); }
.ec-color-swatch.is-pink > span { background: var(--ec-color-pink); }
.ec-color-swatch.is-gray > span { background: var(--ec-color-gray); }
.ec-color-swatch.is-default > span { background: #fff; border-color: #94a3b8; }
.ec-color-swatch.is-active { border-color: #2563eb; box-shadow: var(--ec-focus); }
.ec-summary-line {
  align-items: center;
  background: #fff;
  border: 1px solid var(--ec-border);
  border-bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  min-height: 38px;
  padding: 8px 10px;
}
.ec-summary-line strong { color: var(--ec-text); }
.ec-summary-line span { color: var(--ec-muted); }
.ec-summary-line .is-review { color: #a16207; font-weight: 700; }

.ec-grid-wrap {
  background: #fff;
  border: 1px solid var(--ec-border);
  height: calc(100vh - 268px);
  min-height: 430px;
  overflow: auto;
}
.ec-grid {
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ec-text);
  table-layout: fixed;
  width: 3720px;
}
.ec-grid th, .ec-grid td {
  border-bottom: 1px solid var(--ec-grid);
  border-right: 1px solid var(--ec-grid);
  height: 36px;
  overflow: hidden;
  padding: 7px 8px;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}
.ec-grid th {
  background: #eef1f4;
  color: #273548;
  font-size: 12px;
  font-weight: 800;
  position: sticky;
  text-align: center;
  top: 0;
  z-index: 5;
}
.ec-grid .ec-header-row th { top: 0; }
.ec-grid .ec-filter-row th {
  background: #f8fafc;
  height: 32px;
  padding: 3px;
  top: 36px;
  z-index: 6;
}
.ec-filter-row input {
  border-color: #d6dde6;
  border-radius: 3px;
  font-size: 11px;
  height: 25px;
  min-height: 25px;
  padding: 3px 5px;
  width: 100%;
}
.ec-filter-row .ec-row-action button {
  color: var(--ec-muted);
  font-size: 15px;
  line-height: 1;
  min-height: 24px;
  padding: 0 7px;
}
.ec-grid td.is-number { font-variant-numeric: tabular-nums; text-align: right; }
.ec-grid .is-invoice { background: var(--ec-invoice); }
.ec-grid tbody tr:hover td { background: #f5f9ff; }
.ec-grid tbody tr:hover td.is-invoice { background: #e5f3df; }
.ec-grid .ec-row-action {
  background: #f8fafc;
  left: 0;
  position: sticky;
  text-align: center;
  z-index: 4;
}
.ec-grid th.ec-row-action { background: #e6eaf0; z-index: 7; }
.ec-grid .ec-filter-row th.ec-row-action { background: #eef1f4; z-index: 8; }
.ec-grid tbody .ec-row-action { font-variant-numeric: tabular-nums; padding: 0; }
.ec-row-action > span { color: var(--ec-muted); display: block; text-align: center; width: 100%; }
.ec-row-action button { border: 0; color: var(--ec-blue); min-height: 24px; padding: 2px 5px; }
.ec-row-action i {
  background: #d97706;
  border-radius: 50%;
  font-size: 0;
  font-style: normal;
  height: 7px;
  position: absolute;
  right: 5px;
  top: 5px;
  width: 7px;
}
.ec-review-row td { background: var(--ec-review); }
.ec-review-row td.is-invoice { background: #eef3c4; }
.ec-grid .is-color-yellow { background: var(--ec-color-yellow); }
.ec-grid .is-color-green { background: var(--ec-color-green); }
.ec-grid .is-color-blue { background: var(--ec-color-blue); }
.ec-grid .is-color-pink { background: var(--ec-color-pink); }
.ec-grid .is-color-gray { background: var(--ec-color-gray); }
.ec-grid th[data-style-column], .ec-grid td[data-style-row] { cursor: pointer; }
.ec-grid .is-style-selected { box-shadow: inset 0 0 0 2px #2563eb; position: relative; z-index: 3; }
.ec-grid tr.is-style-row-selected > td { box-shadow: inset 0 2px 0 #2563eb, inset 0 -2px 0 #2563eb; }
.ec-grid td.is-style-column-selected { box-shadow: inset 1px 0 0 rgba(37, 99, 235, .45), inset -1px 0 0 rgba(37, 99, 235, .45); }
.ec-grid tbody td:not(.ec-row-action) { padding: 0; }
.ec-cell-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
  height: 35px;
  min-height: 35px;
  padding: 6px 8px;
  width: 100%;
}
.ec-cell-input:focus {
  background: #fff;
  border-color: #2563eb;
  box-shadow: inset 0 0 0 1px #2563eb;
}
.ec-cell-input.is-saving { background: #eff6ff; }
.ec-cell-input.is-save-error { background: #fef2f2; border-color: #ef4444; }
.ec-cell-input[readonly] { cursor: default; }
.ec-cell-input.is-number { text-align: right; }

.ec-pagination {
  align-items: center;
  display: flex;
  gap: 7px;
  justify-content: flex-end;
  padding: 9px 0 0;
}
.ec-pagination > span { color: var(--ec-muted); margin-right: 6px; }
.ec-pagination label { align-items: center; color: var(--ec-muted); display: flex; gap: 4px; }
.ec-pagination select { min-height: 32px; padding: 5px; }

.ec-import-shell { margin: 0 auto; max-width: 1480px; padding: 18px; }
.ec-import-head { align-items: center; display: flex; justify-content: space-between; margin-bottom: 12px; }
.ec-import-head h1 { color: var(--ec-text); font-size: 20px; margin: 0; }
.ec-import-layout { display: grid; gap: 12px; grid-template-columns: 360px minmax(0, 1fr); }
.ec-import-panel, .ec-import-preview {
  background: #fff;
  border: 1px solid var(--ec-border);
  border-radius: 7px;
  margin-bottom: 12px;
  padding: 15px;
}
.ec-import-panel h2, .ec-import-preview h2 { color: var(--ec-text); font-size: 15px; margin: 0 0 10px; }
.ec-import-panel input[type="file"] { margin-bottom: 9px; width: 100%; }
.ec-check { align-items: center; display: flex; gap: 7px; margin: 12px 0; }
.ec-check input { min-height: auto; width: 18px; }
.ec-import-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ec-import-summary span { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 5px; padding: 7px 9px; }
.ec-import-summary .is-review { color: #a16207; }
.ec-sheet-list > div { border-bottom: 1px solid #e5e7eb; display: grid; gap: 8px; grid-template-columns: 1fr auto auto; padding: 7px 0; }
.ec-sheet-list span { color: var(--ec-muted); }
.ec-import-preview h3 { color: var(--ec-text); font-size: 14px; margin: 18px 0 7px; }
.ec-import-samples { max-height: 430px; overflow: auto; }
.ec-import-samples table { border-collapse: collapse; min-width: 900px; width: 100%; }
.ec-import-samples th, .ec-import-samples td { border: 1px solid var(--ec-border); padding: 7px; text-align: left; }
.ec-batch { align-items: center; border-bottom: 1px solid #e5e7eb; display: grid; gap: 4px; grid-template-columns: 1fr auto; padding: 8px 0; }
.ec-batch strong { overflow-wrap: anywhere; }
.ec-batch span { color: var(--ec-muted); grid-column: 1; }
.ec-batch button { grid-column: 2; grid-row: 1 / span 2; }

.ec-login-page { align-items: center; display: flex; justify-content: center; min-height: 100vh; padding: 20px; }
.ec-login { background: #fff; border: 1px solid var(--ec-border); border-radius: 7px; max-width: 360px; padding: 24px; width: 100%; }
.ec-login h1 { color: var(--ec-text); font-size: 20px; margin: 0 0 4px; }
.ec-login p { color: var(--ec-muted); margin: 0 0 18px; }
.ec-login label { display: block; margin-bottom: 11px; }
.ec-login label span { color: var(--ec-muted); display: block; font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.ec-login input, .ec-login button { width: 100%; }
.ec-form-error { background: #fef2f2; border-radius: 5px; color: var(--ec-danger); margin-bottom: 10px; padding: 8px; }
.ec-denied { margin: 20vh auto 0; max-width: 520px; text-align: center; }
.ec-denied h1 { color: var(--ec-text); }
.ec-denied p { color: var(--ec-muted); }
.ec-toast {
  background: #0f172a;
  border-radius: 7px;
  bottom: 22px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .24);
  color: #fff;
  left: 50%;
  max-width: calc(100vw - 30px);
  padding: 10px 14px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 100;
}
.ec-toast.is-error { background: #991b1b; }
.ec-toast.is-success { background: #065f46; }
.ec-toast.is-hidden { display: none; }

.ec-modal-backdrop {
  align-items: center;
  background: rgba(15, 23, 42, .42);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 90;
}
.ec-modal {
  background: #fff;
  border: 1px solid var(--ec-border);
  border-radius: 7px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, .22);
  padding: 16px;
  width: min(390px, 100%);
}
.ec-modal-head { align-items: center; display: flex; justify-content: space-between; margin-bottom: 14px; }
.ec-modal-head strong { color: var(--ec-text); font-size: 16px; }
.ec-modal-head button { border: 0; font-size: 20px; line-height: 1; min-height: 28px; padding: 0 7px; }
.ec-modal label { display: block; margin-bottom: 12px; }
.ec-modal label > span { color: var(--ec-muted); display: block; font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.ec-modal input, .ec-modal select { width: 100%; }
.ec-modal-actions { display: flex; gap: 7px; justify-content: flex-end; margin-top: 16px; }

@media (max-width: 900px) {
  .ec-command-bar { align-items: stretch; flex-direction: column; }
  .ec-search-form { flex-wrap: wrap; }
  .ec-search-form input[name="search"] { flex: 1 1 100%; width: 100%; }
  .ec-main-actions { justify-content: flex-end; }
  .ec-grid-wrap { height: calc(100vh - 350px); }
  .ec-import-layout { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .ec-topbar { padding: 0 10px; }
  .ec-user, .ec-top-actions a { display: none; }
  .ec-sheet-tabs { padding-left: 8px; }
  .ec-sheet-shell { padding: 8px; }
  .ec-main-actions { display: grid; grid-template-columns: repeat(2, 1fr); }
  .ec-save-status { justify-content: center; }
  .ec-style-bar { flex-wrap: wrap; }
  .ec-style-target { flex: 1 1 160px; }
  .ec-summary-line { gap: 6px 12px; }
  .ec-grid-wrap { height: calc(100vh - 410px); min-height: 360px; }
  .ec-pagination { flex-wrap: wrap; }
}
