:root {
  --ui-green: #16a34a;
  --ui-green-dark: #15803d;
  --ui-green-soft: #ecfdf3;
  --ui-bg: #f4f6f8;
  --ui-panel: #ffffff;
  --ui-line: #e5e7eb;
  --ui-text: #111827;
  --ui-muted: #6b7280;
  --ui-danger: #dc2626;
  --content-max: 1600px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ui-bg);
  color: var(--ui-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

.nav-glass {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  z-index: 10;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--ui-line);
  backdrop-filter: blur(14px);
}

.nav-container {
  position: relative;
  max-width: var(--content-max);
  height: 100%;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-menu {
  position: relative;
}

.nav-menu summary {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid #dfe3ea;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  font-weight: 850;
  list-style: none;
  cursor: pointer;
}

.nav-menu summary::-webkit-details-marker {
  display: none;
}

.nav-popover {
  position: absolute;
  top: 46px;
  right: 0;
  z-index: 20;
  width: min(420px, calc(100vw - 28px));
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .16);
}

.nav-popover h2 {
  font-size: 16px;
}

.nav-popover p {
  margin-top: 3px;
  font-size: 13px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 900;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ui-green);
  color: #fff;
  font-weight: 950;
}

.brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-link,
.primary-btn,
.secondary-btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 850;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.nav-link,
.secondary-btn {
  color: #374151;
  background: #fff;
  border-color: #dfe3ea;
}

.primary-btn {
  color: #fff;
  background: var(--ui-green);
  border-color: var(--ui-green);
}

.primary-btn:hover { background: var(--ui-green-dark); }

.danger-btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 8px;
  color: #991b1b;
  background: #fff7f7;
  border: 1px solid #fecaca;
  font-weight: 850;
  cursor: pointer;
}

.main-wrapper {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 92px 16px 40px;
}

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

.import-hero {
  min-height: calc(100vh - 130px);
  display: grid;
  place-items: start stretch;
  padding-top: 18px;
}

.import-card {
  width: 100%;
  display: grid;
  gap: 22px;
  padding: 46px;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 55px rgba(15, 23, 42, .08);
  text-align: center;
}

.import-card h1 {
  margin-top: 8px;
  font-size: 36px;
}

.import-card p {
  font-size: 16px;
}

.drop-zone {
  position: relative;
  min-height: 260px;
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 34px;
  border: 1px dashed #cfd6df;
  border-radius: 8px;
  background: #fff;
}

.drop-zone span {
  color: #14532d;
  font-size: 18px;
  font-weight: 950;
}

.upload-icon {
  width: 122px;
  height: auto;
  pointer-events: none;
  user-select: none;
}

.drop-zone small {
  max-width: 100%;
  color: #64748b;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drop-zone input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.hero-submit {
  width: min(280px, 100%);
  min-height: 48px;
  justify-self: center;
  font-size: 16px;
}

.eyebrow {
  color: var(--ui-green-dark);
  font-size: 13px;
  font-weight: 900;
}

h1, h2, p { margin: 0; }

h1 {
  margin-top: 6px;
  font-size: 28px;
  line-height: 1.2;
}

p {
  margin-top: 8px;
  color: var(--ui-muted);
  line-height: 1.55;
}

.template-status {
  min-width: 240px;
  padding: 14px;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: #fff;
}

.template-status.ready {
  background: var(--ui-green-soft);
  border-color: #bbf7d0;
}

.template-status strong,
.template-status span {
  display: block;
}

.template-status span {
  margin-top: 4px;
  color: var(--ui-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.entry-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(330px, .75fr);
  gap: 12px;
}

.entry-grid,
.upload-choice-grid,
.template-row {
  display: none;
}

.main-import-panel {
  display: flex;
  flex-direction: column;
  min-height: 308px;
}

.main-import-panel .file-box {
  flex: 1;
}

.side-tools {
  display: grid;
  gap: 12px;
}

.side-panel {
  min-height: 0;
}

.side-panel .panel-head {
  margin-bottom: 10px;
}

.template-panel .file-box {
  margin-top: 0;
}

.hero-file-box {
  min-height: 176px;
  border-color: #9bd8ad;
  background: #f3fbf6;
}

.result-stack {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  background: var(--ui-panel);
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  padding: 22px;
}

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

.panel-head.compact { margin-bottom: 14px; }

h2 {
  font-size: 20px;
  line-height: 1.25;
}

.file-box {
  min-height: 112px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
  margin-top: 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f9fafb;
}

.file-box.slim { min-height: 96px; }

.file-box span {
  font-weight: 900;
}

.file-box small {
  color: var(--ui-muted);
}

input[type="file"] {
  width: 100%;
  min-height: 36px;
}

input[type="file"]::file-selector-button {
  min-height: 32px;
  margin-right: 10px;
  padding: 0 12px;
  border: 1px solid #dfe3ea;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  font-weight: 850;
  cursor: pointer;
}

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

.template-form .secondary-btn {
  width: 100%;
}

.alert {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 850;
}

.alert.danger {
  color: var(--ui-danger);
  background: #fff7f7;
  border: 1px solid #fecaca;
}

.alert.success {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.result-panel {
  margin-top: 0;
  border-color: #bbf7d0;
  background: #fbfffd;
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
}

.metrics div {
  padding: 16px;
  border-right: 1px solid var(--ui-line);
  background: #f9fafb;
}

.metrics div:last-child { border-right: 0; }

.metrics b {
  display: block;
  font-size: 24px;
}

.metrics span {
  display: block;
  margin-top: 4px;
  color: var(--ui-muted);
  font-size: 13px;
  font-weight: 850;
}

.log-view {
  max-height: 520px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: #0f172a;
  color: #e5e7eb;
  line-height: 1.6;
  white-space: pre-wrap;
}

.issue-panel,
.sheet-panel {
  margin-top: 12px;
}

.review-panel {
  border-color: #f2d3d3;
  background: #fff;
}

.review-head,
.review-titlebar,
.result-hero,
.section-titleline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.review-head {
  align-items: center;
}

.danger-text {
  color: #b91c1c;
}

.review-count {
  min-width: 64px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #991b1b;
  background: #fee2e2;
  text-align: center;
  font-weight: 950;
}

.review-titlebar {
  margin-bottom: 12px;
}

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

.review-card {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #f1dddd;
  border-radius: 8px;
  background: #fff;
  box-shadow: none;
}

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

.review-card-top strong,
.review-card-top span {
  display: block;
}

.review-card-top strong {
  font-size: 15px;
  overflow-wrap: anywhere;
}

.review-card-top div > span {
  margin-top: 4px;
  color: var(--ui-muted);
  font-size: 13px;
}

.raw-strip {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f9fafb;
  color: #4b5563;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.raw-details {
  border-radius: 8px;
  background: #f9fafb;
}

.raw-details summary {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: #374151;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.raw-details div {
  padding: 0 12px 12px;
  color: #4b5563;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

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

.fix-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.fix-grid label span {
  color: #374151;
  font-size: 13px;
  font-weight: 850;
}

.fix-grid input {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid #d7dde6;
  border-radius: 8px;
  background: #fff;
  font: inherit;
}

.fix-grid .wide {
  grid-column: span 2;
}

.review-actions {
  display: flex;
  align-items: end;
}

.review-actions .primary-btn,
.ignore-form .danger-btn {
  width: 100%;
}

.ignore-form {
  display: flex;
  justify-content: flex-end;
  margin-top: -4px;
}

.ignore-form .danger-btn {
  width: auto;
}

.issue-table-wrap {
  overflow: auto;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: #fff;
}

.issue-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 14px;
}

.issue-table th,
.issue-table td {
  padding: 12px;
  border-bottom: 1px solid var(--ui-line);
  text-align: left;
  vertical-align: top;
}

.issue-table th {
  background: #f8fafc;
  font-weight: 900;
  color: #374151;
}

.sheet-panel .issue-table-wrap {
  border-color: #d8efe1;
}

.sheet-panel .issue-table th {
  background: #f0fdf4;
  color: #14532d;
}

.sheet-panel .issue-table td:nth-child(2) {
  font-weight: 900;
  color: #14532d;
}

.sheet-summary {
  padding: 0;
  overflow: hidden;
}

.sheet-summary-head {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
}

.sheet-summary-head strong,
.sheet-summary-head small {
  display: block;
}

.sheet-summary-head strong {
  font-size: 20px;
}

.sheet-summary-head small {
  margin-top: 4px;
  color: var(--ui-muted);
  font-size: 13px;
}

.sheet-summary-head b {
  padding: 8px 10px;
  border-radius: 8px;
  background: #ecfdf3;
  color: #14532d;
}

.sheet-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 18px 18px;
}

.sheet-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #d8efe1;
  border-radius: 8px;
  background: #fbfefc;
}

.sheet-card-main {
  min-width: 0;
}

.sheet-card-main strong,
.sheet-card-main span,
.sheet-card-side b,
.sheet-card-side span {
  display: block;
}

.sheet-card-main strong {
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.sheet-card-main span {
  margin-top: 4px;
  color: var(--ui-muted);
  font-size: 13px;
}

.sheet-card-side {
  padding: 10px;
  border-radius: 8px;
  background: #ecfdf3;
  text-align: center;
}

.sheet-card-side b {
  color: #14532d;
  overflow-wrap: anywhere;
}

.sheet-card-side span {
  margin-top: 4px;
  color: #166534;
  font-size: 12px;
  font-weight: 850;
}

.issue-table tr:last-child td {
  border-bottom: 0;
}

.reason-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border-radius: 8px;
  color: #991b1b;
  background: #fee2e2;
  font-weight: 850;
  white-space: nowrap;
}

.raw-data {
  max-width: 520px;
  color: #4b5563;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .sheet-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .nav-container { padding: 0 14px; }
  .nav-link { display: none; }
  .nav-actions {
    gap: 6px;
  }
  .nav-menu summary {
    padding: 0 9px;
    font-size: 13px;
  }
  .nav-popover {
    position: fixed;
    top: 70px;
    left: 12px;
    right: 12px;
    width: auto;
  }
  .brand { max-width: 100%; font-size: 16px; }
  .main-wrapper { padding: 82px 12px 28px; }
  .page-head,
  .panel-head {
    display: grid;
  }
  .panel-head .primary-btn,
  .result-actions,
  .result-actions a {
    width: 100%;
  }
  .result-actions {
    justify-content: stretch;
  }
  .template-status { min-width: 0; }
  .import-hero { min-height: auto; padding-top: 8px; }
  .import-card { padding: 20px 14px; gap: 14px; }
  .import-card h1 { font-size: 28px; }
  .drop-zone { min-height: 160px; padding: 18px 12px; }
  .drop-zone span { font-size: 16px; }
  .upload-icon { width: 84px; }
  .entry-grid { grid-template-columns: 1fr; }
  .main-import-panel { min-height: 0; }
  .review-titlebar,
  .result-hero,
  .section-titleline { display: grid; }
  h1 { font-size: 24px; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metrics div { border-bottom: 1px solid var(--ui-line); }
  .file-box { min-height: 104px; padding: 14px; }
  .panel { padding: 14px; }
  .issue-table { min-width: 720px; font-size: 13px; }
  .review-card-top { display: grid; }
  .fix-grid { grid-template-columns: 1fr; }
  .fix-grid .wide { grid-column: auto; }
  .review-actions { display: block; }
  .ignore-form .danger-btn { width: 100%; }
  .sheet-card-grid { grid-template-columns: 1fr; }
  .sheet-card { grid-template-columns: 1fr; }
  .sheet-card-side { text-align: left; }
}

@media (max-width: 420px) {
  .brand { font-size: 15px; }
  h1 { font-size: 22px; }
  .metrics { grid-template-columns: 1fr; }
  .nav-menu summary {
    padding: 0 8px;
    font-size: 12px;
  }
}
