:root {
  --bg: #f6f4ef;
  --surface: #fffdf8;
  --ink: #1d2520;
  --muted: #68736f;
  --line: #ded8cc;
  --brand: #16745f;
  --brand-dark: #10211c;
  --yellow: #f2be4b;
  --coral: #e4562e;
  --shadow: 0 18px 48px rgba(40, 35, 24, 0.12);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(29, 37, 32, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(29, 37, 32, 0.04) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
}

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

button {
  border: 0;
  cursor: pointer;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(29, 37, 32, 0.58);
  backdrop-filter: blur(10px);
}

.login-overlay.show {
  display: grid;
}

.login-card {
  position: relative;
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-close {
  position: absolute;
  top: 26px;
  right: 30px;
  width: 36px !important;
  min-height: 36px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0 !important;
  border-radius: 0;
  color: #0d1110;
  background: transparent;
  font-size: 38px;
  font-weight: 500;
  line-height: 0.8;
}

.login-close:hover {
  background: transparent;
  color: #000;
}

.login-card h2,
.login-card p {
  margin: 10px 0 0;
}

.login-card p {
  color: var(--muted);
  line-height: 1.6;
}

.login-card label {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  font-weight: 800;
}

.login-card input {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.password-field {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 4px;
  min-height: 58px;
  padding: 0 12px 0 16px;
  border: 1px solid #d7deeb;
  border-radius: 14px;
  background: #eaf1ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.password-field input {
  min-width: 0;
  min-height: 56px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 900;
}

.password-field button {
  width: 42px;
  min-height: 42px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  color: #8b95a6;
  background: transparent;
  font-weight: 900;
  line-height: 1;
}

.password-lock {
  display: grid;
  place-items: center;
  color: #9aa3b2;
}

.password-lock svg,
.password-field button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-field button svg {
  width: 25px;
  height: 25px;
}

.login-card button {
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
}

.login-card .login-close {
  top: 26px;
  right: 30px;
  width: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  color: #0d1110;
  background: transparent;
  font-size: 38px;
  font-weight: 500;
  line-height: 0.8;
}

.login-card .password-field button {
  width: 42px;
  min-height: 42px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  color: #8b95a6;
  background: transparent;
  line-height: 1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 244, 239, 0.94);
  backdrop-filter: blur(14px);
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
  font-weight: 900;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.15;
}

.brand p {
  color: var(--muted);
  font-size: 12px;
}

.mode-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.mode-tabs button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.mode-tabs button.active {
  color: #fff;
  background: var(--ink);
}

.app {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.mode-view,
.merchant-page {
  display: none;
}

.mode-view.active,
.merchant-page.active {
  display: block;
}

.home-hero {
  min-height: 230px;
  display: grid;
  align-content: end;
  padding: 18px;
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(10, 16, 12, 0.04), rgba(10, 16, 12, 0.74)),
    url("/assets/poster-ui-hero.png") center / cover;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.home-hero h2 {
  max-width: 9em;
  margin: 0;
  font-size: clamp(30px, 8vw, 52px);
  line-height: 1.02;
}

.home-hero p {
  max-width: 32em;
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.86);
  line-height: 1.65;
}

.entry-grid,
.case-grid,
.plan-grid,
.metric-grid,
.quota-grid {
  display: grid;
  gap: 10px;
}

.entry-grid,
.case-grid,
.quota-grid,
.metric-grid {
  grid-template-columns: repeat(2, 1fr);
}

.entry-card {
  min-height: 104px;
  padding: 14px;
  display: grid;
  align-content: space-between;
  justify-items: start;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #0f6f60, #11231f);
}

.entry-card.muted {
  background: linear-gradient(135deg, #343a35, #151817);
  opacity: 0.78;
}

.entry-card strong {
  font-size: 20px;
}

.entry-card span {
  color: rgba(255, 255, 255, 0.74);
  font-size: 12px;
}

.entry-card i {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  font-style: normal;
  font-weight: 900;
}

.section-title,
.page-head,
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin: 16px 0 10px;
}

.section-title h3,
.page-head h2,
.panel-head h3 {
  margin: 0;
}

.page-head p,
.panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.section-title button {
  color: var(--brand);
  background: transparent;
  font-weight: 900;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 10px;
}

.chip-row button,
.badge {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--muted);
  background: #ebe7dd;
  font-weight: 900;
  white-space: nowrap;
}

.chip-row button.active {
  color: #fff;
  background: var(--brand);
}

.badge {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
}

.case-card {
  min-height: 0;
  aspect-ratio: 3 / 4;
  padding: 12px;
  display: grid;
  align-content: end;
  position: relative;
  text-align: left;
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.02) 34%, rgba(0, 0, 0, 0.7) 100%),
    var(--cover) center / contain no-repeat,
    #eee8dc;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.case-card b {
  position: relative;
  z-index: 1;
  font-size: 24px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.38);
}

.case-card span {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.84);
  font-size: 12px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.36);
}

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

.draw-grid {
  display: grid;
  gap: 14px;
}

.draw-grid.single {
  max-width: 760px;
  margin: 0 auto;
}

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

label {
  display: grid;
  gap: 6px;
  color: #35413c;
  font-weight: 900;
}

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

textarea {
  min-height: 86px;
  resize: vertical;
}

.upload {
  min-height: 86px;
  padding: 14px;
  border: 1px dashed #bfb6a6;
  border-radius: 8px;
  background: #fbfaf5;
  color: var(--ink);
}

.upload input {
  min-height: auto;
  padding: 0;
  border: 0;
}

.upload span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.hint-box {
  min-height: 44px;
  padding: 10px 12px;
  border-left: 4px solid var(--yellow);
  border-radius: 8px;
  color: #655231;
  background: #fff7e1;
  font-size: 12px;
  line-height: 1.65;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.actions button,
.primary,
.plan-card {
  min-height: 44px;
  border-radius: 8px;
  color: var(--ink);
  background: #ebe7dd;
  font-weight: 900;
}

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

.full {
  width: 100%;
  margin-top: 12px;
}

.poster {
  width: min(100%, 390px);
  aspect-ratio: 3 / 4;
  margin: 0 auto;
  padding: 22px;
  display: grid;
  align-content: space-between;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(145deg, #125b4c, #1d7a61 46%, #f0aa37);
  box-shadow: 0 16px 36px rgba(29, 37, 32, 0.24);
}

.poster[data-ratio="朋友圈方图 1:1"] { aspect-ratio: 1 / 1; }
.poster[data-ratio="小红书/竖版 4:5"] { aspect-ratio: 4 / 5; }
.poster[data-ratio="门店屏幕横版 16:9"] {
  width: min(100%, 520px);
  aspect-ratio: 16 / 9;
}

.poster span {
  display: inline-flex;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--ink);
  background: #ffe7a8;
  font-weight: 900;
}

.poster h3 {
  max-width: 9em;
  margin: 14px 0 0;
  font-size: clamp(32px, 8vw, 52px);
  line-height: 1;
}

.poster .price b {
  font-size: clamp(44px, 10vw, 70px);
}

.poster small {
  display: block;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.88);
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.work-side {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.delete-work,
.retry-work {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #8d2c22;
  background: #ffe0dc;
  font-size: 12px;
  font-weight: 900;
}

.retry-work {
  color: #0f5b37;
  background: #dbf2e4;
}

.list-item:hover {
  border-color: var(--brand);
}

.thumb {
  width: 54px;
  height: 54px;
  border-radius: 7px;
  background: linear-gradient(145deg, var(--brand), var(--yellow));
  object-fit: cover;
}

.list-item b,
.list-item p {
  margin: 0;
}

.list-item p {
  color: var(--muted);
  font-size: 12px;
}

.list-item .error-text {
  color: #b44235;
}

.progress-pill {
  min-width: 72px;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.done-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 999px;
  color: #0f5b37;
  background: #dbf2e4;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.done-pill.failed {
  color: #8d2c22;
  background: #ffe0dc;
}

.bar {
  height: 7px;
  border-radius: 999px;
  background: #ebe7dd;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: var(--value);
  background: linear-gradient(90deg, var(--brand), var(--yellow));
}

.quota-grid div,
.metric-grid .panel {
  min-height: 96px;
}

.quota-grid span,
.metric-grid span {
  color: var(--muted);
  font-weight: 900;
}

.quota-grid strong,
.metric-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

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

.plan-card {
  padding: 14px;
  text-align: left;
  background: #fbfaf5;
  border: 1px solid var(--line);
}

.plan-card.hot {
  color: #fff;
  background: var(--brand);
}

.plan-card b,
.plan-card span {
  display: block;
}

.plan-card b {
  font-size: 26px;
}

.plan-card span {
  margin-top: 8px;
  color: inherit;
  opacity: 0.82;
  font-size: 13px;
}

.plan-card em {
  display: inline-block;
  margin-top: 12px;
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
}

.plan-card.hot em {
  color: rgba(255, 255, 255, 0.86);
}

.plan-card.readonly {
  cursor: default;
}

.txn-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

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

.txn-item b,
.txn-item p {
  margin: 0;
}

.txn-item p,
.empty-line {
  color: var(--muted);
  font-size: 13px;
}

.txn-item strong {
  font-size: 22px;
  white-space: nowrap;
}

.txn-item .plus {
  color: #0f5b37;
}

.txn-item .minus {
  color: #b44235;
}

.bottom-nav {
  position: sticky;
  bottom: 10px;
  z-index: 12;
  width: min(420px, 100%);
  margin: 16px auto 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 14px 36px rgba(40, 35, 24, 0.18);
  backdrop-filter: blur(14px);
}

.bottom-nav button {
  min-height: 40px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.bottom-nav button.active {
  color: #fff;
  background: var(--brand);
}

.admin-hero {
  display: grid;
  gap: 14px;
  padding: 0;
  overflow: hidden;
}

.admin-hero img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.admin-hero div {
  padding: 0 16px 16px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 50;
  transform: translate(-50%, 120%);
  min-width: min(320px, calc(100% - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: rgba(29, 37, 32, 0.94);
  text-align: center;
  opacity: 0;
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: end;
  justify-content: center;
  padding: 16px;
  background: rgba(29, 37, 32, 0.48);
}

.viewer.show {
  display: flex;
}

.viewer-panel {
  width: min(720px, 100%);
  max-height: min(90vh, 820px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(29, 37, 32, 0.28);
  overflow: hidden;
}

.viewer-head,
.viewer-actions {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.96);
}

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

.viewer-head h3,
.viewer-head p {
  margin: 0;
}

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

.viewer-head button {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: var(--ink);
  background: #ebe7dd;
  font-size: 20px;
  font-weight: 900;
}

.viewer-body {
  min-height: 260px;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow: auto;
  background: #e9e3d6;
}

.poster-output {
  position: relative;
  display: none;
  max-width: 100%;
  max-height: 70vh;
}

.poster-output.show {
  display: block;
}

.viewer-body img#viewer-image {
  display: none;
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(29, 37, 32, 0.24);
}

.viewer-body img.show,
.viewer-body img#viewer-image.show {
  display: block;
}

.viewer-empty {
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.viewer-empty.hide {
  display: none;
}

.viewer-actions {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  display: grid;
  gap: 10px;
}

.viewer-actions a,
.viewer-actions button {
  min-height: 44px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 900;
}

.viewer-actions .secondary-link {
  color: var(--ink);
  background: #ebe7dd;
}

.switch-account {
  width: 100%;
  min-height: 44px;
  margin: 0 0 78px;
  border-radius: 8px;
  color: var(--ink);
  background: #ebe7dd;
  font-weight: 900;
}

.admin-merchant-list {
  display: grid;
  gap: 12px;
}

.admin-merchant-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

.admin-merchant-card h4,
.admin-merchant-card p {
  margin: 0;
}

.admin-merchant-card h4 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.merchant-id {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
}

.admin-merchant-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.quota-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.quota-tools input {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.quota-tools button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
  font-weight: 900;
}

.metric-grid.compact {
  margin-top: 12px;
}

.metric-grid.compact .panel {
  min-height: 82px;
  padding: 14px;
}

.metric-grid.compact strong {
  font-size: 24px;
}

.admin-table-wrap {
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.admin-table th,
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.admin-table th {
  color: var(--muted);
  background: #f3efe6;
  font-size: 13px;
}

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

.download-row button {
  min-height: 42px;
  border-radius: 8px;
  color: var(--ink);
  background: #ebe7dd;
  font-weight: 900;
}

.download-row button:first-child {
  color: #fff;
  background: var(--brand);
}

.viewer-actions a.disabled,
.viewer-actions button.disabled {
  pointer-events: none;
  opacity: 0.45;
  background: #ebe7dd;
  color: var(--muted);
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (min-width: 760px) {
  .app {
    padding: 24px;
  }

  .draw-grid:not(.single) {
    grid-template-columns: minmax(340px, 0.92fr) minmax(360px, 1.08fr);
    align-items: start;
  }

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

  .wide,
  .upload,
  .hint-box {
    grid-column: span 2;
  }

  .plan-grid,
  .metric-grid,
  .quota-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .admin-hero {
    grid-template-columns: 1.25fr 0.75fr;
    align-items: center;
  }

  .admin-hero img {
    aspect-ratio: 16 / 7;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .mode-tabs button {
    flex: 1;
  }

  .list-item {
    grid-template-columns: 44px 1fr;
  }

  .progress-pill {
    grid-column: 2;
  }

  .done-pill {
    justify-self: start;
  }

  .work-side {
    grid-column: 2;
    justify-items: start;
  }
}
