:root {
  color-scheme: light;
  --red: #a71913;
  --red-deep: #791510;
  --cream: #f6efe5;
  --paper: #fffaf3;
  --ink: #342923;
  --muted: #8b7b72;
  --line: #e8ddd2;
  --green: #3e6a5b;
  --amber: #a66a21;
  --shadow: 0 18px 48px rgba(72, 42, 28, .09);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--cream); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 20% 12%, rgba(190,49,36,.12), transparent 28%),
    linear-gradient(145deg, #f8f1e7, #f3e7d8);
}
.login-card {
  width: min(460px, 100%);
  padding: 42px;
  border: 1px solid rgba(125,35,28,.12);
  border-radius: 28px;
  background: rgba(255,252,246,.96);
  box-shadow: 0 24px 80px rgba(83,38,27,.14);
}
.login-card h1 { margin: 12px 0; font-size: 30px; }
.login-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.7; }
.login-seal { margin-bottom: 22px; color: var(--red); }
.login-form { display: grid; gap: 18px; margin-top: 26px; }
.login-mode-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; gap: 4px; background: #f2e9df; border-radius: 10px; }
.login-mode-tab { min-height: 38px; color: var(--muted); background: transparent; border: 0; border-radius: 8px; font-weight: 700; }
.login-mode-tab.active { color: var(--red); background: var(--paper); box-shadow: 0 2px 8px rgba(83,38,27,.08); }
.login-method { display: grid; gap: 8px; }
.login-method small { color: var(--muted); font-size: 12px; line-height: 1.55; }
.verification-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.verification-row button { height: 44px; white-space: nowrap; }
.text-button { width: fit-content; padding: 0; color: var(--red); background: transparent; border: 0; font-size: 12px; }
.danger-text { margin-right: auto; color: #8b423d; }
.login-submit { width: 100%; min-height: 46px; }
.login-status { min-height: 24px; margin: 16px 0 0; font-size: 13px; }
.login-status.error { color: var(--red); }
.login-status.success { color: #347a55; }

.app-shell { display: grid; min-height: 100vh; grid-template-columns: 248px 1fr; }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; padding: 24px 16px; flex-direction: column; color: #fff7ea; background: linear-gradient(180deg, #831611, #a71913 52%, #6e130f); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; border-bottom: 1px solid rgba(255,255,255,.13); }
.brand-seal { display: grid; width: 42px; height: 48px; place-items: center; border: 3px double #f6cf8b; border-radius: 9px; font-family: STKaiti, KaiTi, serif; font-size: 25px; }
.brand strong, .brand span, .sidebar-footer strong, .sidebar-footer span { display: block; }
.brand span, .sidebar-footer span { margin-top: 4px; color: rgba(255,247,234,.62); font-size: 12px; }
#main-nav { flex: 1; padding: 18px 0; overflow-y: auto; }
.nav-group { margin: 16px 10px 7px; color: rgba(255,247,234,.45); font-size: 10px; letter-spacing: .15em; }
.nav-item { display: flex; width: 100%; margin: 3px 0; padding: 10px 12px; align-items: center; gap: 10px; color: rgba(255,247,234,.78); background: transparent; border: 0; border-radius: 9px; text-align: left; }
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.13); }
.nav-item b { width: 22px; font-weight: 500; text-align: center; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; padding: 14px 10px 2px; border-top: 1px solid rgba(255,255,255,.13); font-size: 12px; }
.status-dot { width: 8px; height: 8px; background: #9dd5b7; border-radius: 50%; box-shadow: 0 0 0 5px rgba(157,213,183,.12); }

.main { min-width: 0; }
.topbar { display: flex; min-height: 92px; padding: 19px 32px; align-items: center; justify-content: space-between; background: rgba(255,250,243,.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.eyebrow { margin: 0 0 5px; color: var(--red); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: STKaiti, KaiTi, serif; font-size: 30px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.account { margin-left: 7px; padding-left: 16px; color: inherit; background: transparent; border: 0; border-left: 1px solid var(--line); font-size: 12px; text-align: left; }
.account span, .account strong { display: block; }
.account span { color: var(--muted); }
.page-content { padding: 28px 32px 48px; }

.primary-button, .review-button, .ghost-button { min-height: 38px; padding: 0 16px; border-radius: 9px; font-weight: 650; }
.primary-button { color: white; background: var(--red); border: 1px solid var(--red); }
.review-button { color: white; background: var(--green); border: 1px solid var(--green); }
.ghost-button { color: var(--ink); background: var(--paper); border: 1px solid var(--line); }
.primary-button:disabled, .review-button:disabled, .ghost-button:disabled, .page-button:disabled {
  cursor: not-allowed;
  opacity: .5;
}
.icon-button { width: 36px; height: 36px; color: var(--muted); background: transparent; border: 0; font-size: 25px; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.metric-card, .panel { background: var(--paper); border: 1px solid rgba(125,91,72,.1); border-radius: 16px; box-shadow: var(--shadow); }
.metric-card { padding: 20px; }
.metric-card span { color: var(--muted); font-size: 13px; }
.metric-card strong { display: block; margin-top: 10px; font-family: Georgia, serif; font-size: 34px; }
.metric-card em { display: block; margin-top: 8px; color: var(--green); font-size: 12px; font-style: normal; }
.dashboard-grid { display: grid; margin-top: 18px; grid-template-columns: 1.6fr 1fr; gap: 18px; }
.panel { padding: 22px; }
.panel-header, .list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.panel h3 { margin-bottom: 4px; font-size: 17px; }
.panel-subtitle { color: var(--muted); font-size: 12px; }

.workflow-list, .activity-list { margin-top: 16px; }
.workflow-row, .activity-row { display: grid; padding: 13px 0; align-items: center; border-top: 1px solid var(--line); }
.workflow-row { grid-template-columns: 1fr 100px 90px; }
.activity-row { grid-template-columns: 32px minmax(220px,1.4fr) 120px 100px 112px minmax(230px,1fr); gap: 10px; }
.activity-row.header { padding: 10px 0; color: var(--muted); border-top: 0; font-size: 11px; font-weight: 700; }
.activity-select { display: grid; width: 28px; height: 28px; place-items: center; cursor: pointer; }
.activity-select input { width: 16px; height: 16px; margin: 0; accent-color: var(--red); cursor: pointer; }
.activity-name strong, .activity-name span { display: block; }
.activity-name span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.status { display: inline-flex; width: fit-content; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.status.draft { color: #655b55; background: #eee7e1; }
.status.pending { color: #8c591a; background: #f5e4c6; }
.status.published { color: #2f6252; background: #dcebe5; }
.status.offline, .status.archived { color: #7d6156; background: #eadfd8; }
.status.deleted { color: #8b423d; background: #f2d9d5; }
.row-actions { display: flex; align-items: center; gap: 3px 7px; flex-wrap: wrap; }
.row-action { color: var(--red); background: transparent; border: 0; font-weight: 700; }
.row-action.danger { color: #8b423d; }
.row-action:disabled { cursor: wait; opacity: .52; }
.search-input { min-width: 260px; height: 38px; padding: 0 12px; background: white; border: 1px solid var(--line); border-radius: 9px; }
.filter-tabs { display: flex; margin: 18px 0 4px; gap: 8px; }
.filter-tab { padding: 7px 12px; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 999px; }
.filter-tab.active { color: var(--red); background: #f3dfcd; border-color: #e8c9ae; }
.bulk-toolbar {
  display: flex;
  min-height: 56px;
  margin-top: 14px;
  padding: 10px 12px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f8efe4;
  border: 1px solid #ead7c2;
  border-radius: 12px;
}
.selection-summary, .bulk-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.selection-summary strong { color: var(--red-deep); font-size: 13px; }
.compact-button { min-height: 34px; padding: 0 12px; font-size: 12px; }
.danger-button { color: #8b423d; border-color: #d9b5ae; }
.bulk-hint { color: var(--muted); font-size: 12px; }
.empty-module { padding: 70px 20px; color: var(--muted); text-align: center; }
.empty-module.compact { padding: 42px 20px; }
.empty-module strong { display: block; margin-bottom: 8px; color: var(--ink); font-size: 18px; }
.file-button { display: inline-flex; align-items: center; cursor: pointer; }
.pagination {
  display: flex;
  margin-top: 20px;
  padding-top: 18px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.pagination-actions { display: flex; align-items: center; gap: 6px; }
.pagination .ghost-button, .page-button { min-height: 34px; padding: 0 11px; }
.page-button {
  min-width: 34px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.page-button.active { color: #fff; background: var(--red); border-color: var(--red); }
.import-panel { display: grid; gap: 20px; }
.import-header-actions { display: flex; align-items: center; gap: 10px; }
.import-guidance, .import-complete {
  display: flex;
  padding: 18px;
  flex-direction: column;
  gap: 6px;
  background: #f8efe4;
  border: 1px solid #ead7c2;
  border-radius: 12px;
  line-height: 1.6;
}
.import-guidance span, .import-complete span { color: var(--muted); font-size: 13px; }
.import-guidance.success, .import-complete { color: var(--green); background: #edf4f1; border-color: #d7e8e1; }
.import-complete.warning { color: #7d5018; background: #f8ead0; border-color: #ecd6aa; }
.import-complete .review-button { width: fit-content; margin-top: 8px; }
.import-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.import-metrics .metric-card { padding: 16px; box-shadow: none; }
.import-metrics .metric-card strong { font-size: 28px; }
.import-progress { display: grid; gap: 10px; padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.progress-copy { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.progress-copy span { color: var(--muted); }
.progress-track { height: 10px; overflow: hidden; background: #eee5db; border-radius: 999px; }
.progress-track i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), #d05a3d); border-radius: inherit; transition: width .2s ease; }
.conflict-section { display: grid; gap: 12px; }
.conflict-list { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.conflict-row {
  display: grid;
  min-width: 780px;
  padding: 13px 16px;
  grid-template-columns: minmax(200px, 1.3fr) minmax(170px, 1fr) minmax(190px, 1fr) 170px;
  gap: 16px;
  align-items: center;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.conflict-row:first-child { border-top: 0; }
.conflict-row.header { color: var(--muted); background: #f7f0e8; font-size: 11px; font-weight: 700; }
.conflict-action { width: 100%; padding: 9px 10px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.entity-list { margin-top: 18px; }
.entity-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px 130px;
  gap: 18px;
  align-items: center;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.drawer-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(36,22,17,.4); }
.drawer { position: fixed; top: 0; right: 0; z-index: 90; width: min(720px, 94vw); height: 100vh; padding: 0 28px; overflow: hidden; background: #fffdf9; box-shadow: -18px 0 50px rgba(44,25,16,.2); transform: translateX(102%); transition: transform .24s ease; }
.drawer.open { transform: translateX(0); }
.drawer form { display: flex; height: 100%; min-height: 0; flex-direction: column; }
.drawer-header { z-index: 3; display: flex; flex: 0 0 auto; padding: 24px 0 16px; align-items: center; justify-content: space-between; background: #fffdf9; border-bottom: 1px solid var(--line); }
.drawer-header h2 { margin-bottom: 0; font-size: 24px; }
.workflow-steps { display: flex; flex: 0 0 auto; margin: 16px 0; gap: 8px; }
.workflow-steps button { flex: 1; min-height: 40px; padding: 8px; color: var(--muted); background: #f2ebe3; border: 0; border-radius: 8px; font-size: 12px; text-align: center; }
.workflow-steps .active { color: white; background: var(--red); }
.workflow-content { flex: 1 1 auto; min-height: 0; padding: 2px 4px 28px 0; overflow-y: auto; }
.workflow-pane { min-height: 100%; }
.step-intro { display: flex; margin-bottom: 18px; padding: 14px 16px; flex-direction: column; gap: 5px; color: var(--ink); background: #f8efe4; border: 1px solid #ead7c2; border-radius: 10px; }
.step-intro strong { color: var(--red); font-size: 14px; }
.step-intro span { color: var(--muted); font-size: 12px; line-height: 1.55; }
.review-step-intro { background: #f5eee6; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 7px; color: #65574f; font-size: 12px; font-weight: 700; }
.field-wide { grid-column: 1 / -1; }
.field input, .field select, .field textarea { width: 100%; padding: 11px 12px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 9px; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(167,25,19,.08); }
.field textarea { min-height: 78px; resize: vertical; }
.field small { color: var(--muted); font-weight: 400; }
.map-field-note { margin-top: -8px; }
.form-section-heading {
  display: flex;
  grid-column: 1 / -1;
  margin-top: 4px;
  padding: 14px 16px;
  flex-direction: column;
  gap: 4px;
  color: var(--ink);
  background: #f8efe4;
  border: 1px solid #ead7c2;
  border-radius: 10px;
}
.form-section-heading strong { color: var(--red); font-size: 14px; }
.form-section-heading span { color: var(--muted); font-size: 12px; }
.quality-panel { margin: 16px 0; padding: 14px; color: var(--green); background: #e8f1ed; border-radius: 10px; font-size: 12px; line-height: 1.6; }
.quality-panel.warning { color: #7d5018; background: #f8ead0; }
.review-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.review-summary-card { padding: 15px; background: white; border: 1px solid var(--line); border-radius: 10px; }
.review-summary-card span, .review-summary-card strong { display: block; }
.review-summary-card span { margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.review-summary-card strong { font-size: 14px; line-height: 1.5; }
.publish-note { display: flex; padding: 15px; flex-direction: column; gap: 5px; color: var(--green); background: #edf4f1; border-radius: 10px; font-size: 12px; line-height: 1.6; }
.drawer-footer { display: flex; flex: 0 0 auto; width: auto; margin: 0 -28px; padding: 15px 28px; justify-content: flex-end; gap: 10px; background: rgba(255,253,249,.98); border-top: 1px solid var(--line); }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 120; width: max-content; min-width: 220px; max-width: min(480px, calc(100vw - 48px)); padding: 12px 16px; color: white; background: #332722; border-radius: 9px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; line-height: 1.5; overflow-wrap: anywhere; }
.toast.show { opacity: 1; transform: translateY(0); }

.compliance-footer {
  position: fixed;
  right: 18px;
  bottom: 12px;
  z-index: 20;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}
.compliance-footer a { color: inherit; text-decoration: none; }
.compliance-footer a:hover { color: var(--red); text-decoration: underline; }

.module-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  color: var(--ink);
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 28px 90px rgba(44,25,16,.28);
}
.module-dialog::backdrop { background: rgba(36,22,17,.48); }
.module-dialog form { padding: 0 28px 26px; }
.module-dialog-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  padding: 24px 0 16px;
  align-items: center;
  justify-content: space-between;
  background: #fffdf9;
  border-bottom: 1px solid var(--line);
}
.module-dialog-header h2 { margin-bottom: 0; }
.module-dialog-fields { padding-top: 20px; }
.module-dialog-footer { display: flex; margin-top: 24px; justify-content: flex-end; gap: 10px; }
.account-dialog { width: min(620px, calc(100vw - 32px)); }
.account-dialog-copy { padding-top: 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.account-dialog-copy p { margin-bottom: 0; }
.account-dialog-footer { align-items: center; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 82px 1fr; }
  .brand div:last-child, .nav-item span, .nav-group, .sidebar-footer div { display: none; }
  .brand { justify-content: center; }
  .nav-item { justify-content: center; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .import-metrics { grid-template-columns: repeat(2, 1fr); }
  .activity-row { grid-template-columns: 32px 1fr 110px minmax(210px, auto); }
  .activity-row > :nth-child(4), .activity-row > :nth-child(5) { display: none; }
  .entity-row { grid-template-columns: 1fr 120px; }
  .entity-row > :nth-child(2) { display: none; }
}

@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px; }
  .brand { justify-content: flex-start; padding-bottom: 10px; }
  .brand div:last-child { display: block; }
  #main-nav { display: flex; padding: 8px 0 0; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; width: auto; }
  .nav-item span { display: inline; }
  .sidebar-footer, .nav-group { display: none; }
  .topbar { padding: 16px; align-items: flex-start; }
  .top-actions .ghost-button { display: none; }
  .account { margin-left: 0; padding-left: 10px; }
  .account span { display: none; }
  .page-content { padding: 18px 16px 36px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .review-summary { grid-template-columns: 1fr; }
  .list-toolbar, .panel-header, .pagination, .progress-copy { align-items: stretch; flex-direction: column; }
  .search-input { width: 100%; min-width: 0; }
  .filter-tabs, .pagination-actions, .import-header-actions { overflow-x: auto; }
  .bulk-toolbar { align-items: stretch; flex-direction: column; }
  .activity-row { grid-template-columns: 28px minmax(150px, 1fr) minmax(190px, auto); }
  .activity-row > :nth-child(3) { display: none; }
  .pagination-actions button, .import-header-actions > * { flex: 0 0 auto; }
  .import-metrics { grid-template-columns: 1fr 1fr; }
  .drawer-footer { flex-wrap: wrap; }
  .entity-row { grid-template-columns: 1fr; }
  .compliance-footer { position: static; padding: 12px 16px; justify-content: center; background: #fffdf9; }
}
