:root {
  --ink: #11231f;
  --muted: #71827d;
  --line: #dde8e3;
  --page: #f3f7f5;
  --surface: #ffffff;
  --surface-soft: #f8fbfa;
  --green: #103f35;
  --green-2: #1f6a5a;
  --mint: #e7f3ee;
  --cream: #f8f0e1;
  --orange: #a26310;
  --danger: #b94732;
  --shadow: 0 18px 50px rgba(14, 45, 37, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(232, 245, 238, 0.95), transparent 28rem),
    radial-gradient(circle at 90% 18%, rgba(248, 240, 225, 0.95), transparent 28rem),
    var(--page);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 18px;
  border-right: 1px solid rgba(16, 63, 53, 0.1);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 16px;
  color: white;
  background: var(--green);
  font-size: 22px;
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
}

.brand p,
.section-label,
.card-head p,
.sidebar-foot {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.menu-nav {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.bulk-line {
  display: flex;
  gap: 8px;
}

.menu-card {
  display: grid;
  grid-template-columns: 22px 42px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 13px;
  color: var(--ink);
  background: var(--item-color, #f6faf7);
  text-align: left;
}

.menu-card.active {
  color: white;
  background: var(--green);
  box-shadow: 0 12px 30px rgba(16, 63, 53, 0.22);
}

.menu-card .switch {
  transform: scale(0.82);
  transform-origin: left center;
}

.menu-card .select-box {
  transform: scale(0.9);
  transform-origin: left center;
}

.menu-content {
  min-width: 0;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.menu-main {
  min-width: 0;
}

.menu-title {
  display: block;
  overflow: hidden;
  font-size: 17px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-subtitle {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: inherit;
  font-size: 12px;
  opacity: 0.72;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-tools {
  display: flex;
  gap: 4px;
}

.tool-mini {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 0;
  border-radius: 10px;
  color: var(--green);
  background: rgba(255, 255, 255, 0.72);
}

.tool-mini:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.sidebar-add,
.primary-button,
.ghost-button,
.small-button,
.danger-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
}

.sidebar-add {
  width: 100%;
  color: var(--green);
  background: var(--mint);
  font-weight: 800;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px 6px 4px;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 999px;
  background: #d8a02f;
}

.status-dot.saved {
  background: #2fa66a;
}

.status-dot.dirty {
  background: #d88e2f;
}

.status-dot.error {
  background: #c64b3a;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-label {
  margin: 0 0 6px;
  color: var(--orange);
  font-weight: 900;
  letter-spacing: 0.08em;
}

h2,
h3 {
  margin: 0;
  letter-spacing: -0.04em;
}

h2 {
  font-size: clamp(30px, 4vw, 46px);
}

h3 {
  font-size: 23px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

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

.ghost-button {
  color: var(--green);
  background: var(--mint);
}

.ghost-button.compact {
  padding: 10px 14px;
}

.small-button {
  color: white;
  background: var(--green-2);
  font-weight: 800;
}

.danger-button {
  color: white;
  background: var(--danger);
}

.compact {
  padding: 10px 14px;
  font-size: 14px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.88fr) minmax(460px, 1.12fr);
  gap: 18px;
}

.work-card,
.package-card,
.preview-card {
  min-width: 0;
  border: 1px solid rgba(16, 63, 53, 0.09);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.work-card {
  padding: 20px;
}

.package-card {
  margin-top: 18px;
  padding: 20px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.category-list,
.item-list,
.package-list {
  display: grid;
  gap: 10px;
}

.package-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 22px;
  padding: 14px;
  background: var(--row-color, #f6faf7);
}

.package-main {
  min-width: 0;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.package-count {
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.package-steps {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.admin-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 22px;
  padding: 12px;
  background: var(--row-color, #f6faf7);
}

.admin-row.active {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
}

.switch {
  position: relative;
  width: 48px;
  height: 28px;
}

.select-box {
  position: relative;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
}

.select-box input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.select-box span {
  display: block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(16, 63, 53, 0.5);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.select-box input:checked + span {
  border-color: var(--green);
  background: var(--green);
}

.select-box input:checked + span::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 8px;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.switch span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #d6dedb;
  transition: background 0.18s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  transition: transform 0.18s ease;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.row-content {
  min-width: 0;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.row-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.row-title {
  overflow: hidden;
  font-size: 17px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-subtitle {
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  flex: none;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--green);
  background: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  font-weight: 900;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 12px;
}

.import-note {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 13px;
  line-height: 1.7;
}

.import-note a {
  color: var(--green-2);
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--ink);
  background: #fbfdfc;
}

textarea {
  resize: vertical;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 20px;
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
}

.preview-card {
  margin-top: 18px;
  padding: 20px;
}

.keyboard-preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: #f9fcfb;
}

.keyboard-tabs,
.preview-crumbs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  background: #f3f7f5;
}

.preview-crumbs {
  padding-top: 0;
}

.keyboard-tab,
.crumb-button {
  border: 0;
  border-radius: 18px;
  padding: 13px 10px;
  color: #2a6659;
  background: #eaf4ef;
  font-size: 18px;
}

.keyboard-tab.normal,
.crumb-button.back {
  color: var(--orange);
  background: var(--cream);
}

.crumb-button.current {
  color: white;
  background: var(--green);
}

.preview-grid {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.preview-grid.root,
.preview-grid.categories {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.preview-tile {
  display: flex;
  min-height: 116px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  border: 0;
  border-radius: 22px;
  padding: 12px;
  color: var(--ink);
  background: var(--tile-color);
  text-align: center;
}

.preview-tile h4 {
  margin: 0;
  font-size: 28px;
  font-weight: 500;
}

.preview-tile p {
  overflow: hidden;
  max-width: 92%;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#editDialog {
  width: min(720px, calc(100vw - 36px));
  border: 0;
  border-radius: 28px;
  padding: 0;
  box-shadow: var(--shadow);
}

#packageDialog {
  width: min(980px, calc(100vw - 36px));
  border: 0;
  border-radius: 28px;
  padding: 0;
  box-shadow: var(--shadow);
}

#editDialog::backdrop,
#packageDialog::backdrop {
  background: rgba(12, 35, 30, 0.32);
  backdrop-filter: blur(8px);
}

.dialog-card {
  padding: 24px;
}

.dialog-head,
.dialog-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: var(--mint);
  font-size: 26px;
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.field-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.package-dialog-card {
  max-height: 90vh;
  overflow: auto;
}

.package-builder {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-soft);
}

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

.builder-box {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 14px;
  border-radius: 18px;
  background: white;
}

.builder-box h3,
.sequence-head h3 {
  margin: 0;
  font-size: 18px;
}

.builder-box p,
.sequence-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.sequence-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.package-step-list {
  display: grid;
  gap: 10px;
}

.package-step-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 18px;
  background: var(--row-color, #f6faf7);
}

.step-index {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: var(--green);
  font-weight: 900;
}

.step-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.step-main strong,
.step-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-main span {
  color: var(--muted);
  font-size: 13px;
}

.full-field {
  grid-column: 1 / -1;
}

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

.check-row input {
  width: auto;
}

.dialog-actions {
  grid-template-columns: auto 1fr auto auto;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

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

@media (max-width: 720px) {
  .main {
    padding: 18px 12px;
  }

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

  .menu-nav,
  .keyboard-tabs,
  .preview-crumbs,
  .preview-grid.root,
  .preview-grid.categories,
  .preview-grid.items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid,
  .search-wrap,
  .package-builder-grid {
    grid-template-columns: 1fr;
  }
}
