:root {
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-soft: #f5faff;
  --text: #102d50;
  --muted: #7085a2;
  --accent: #11a6a1;
  --accent-dark: #057b78;
  --accent-soft: #e7f8f7;
  --blue: #2278d4;
  --line: #d1e7fb;
  --line-strong: #aed4f5;
  --success: #079455;
  --warning: #b54708;
  --error: #d92d20;
  --shadow: 0 16px 44px rgba(57, 130, 194, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  isolation: isolate;
  font-family: "Avenir Next", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -8%, rgba(17, 166, 161, 0.16), transparent 30%),
    radial-gradient(circle at 92% 0%, rgba(34, 120, 212, 0.13), transparent 28%),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 46%, #eef5f8 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image:
    linear-gradient(rgba(34, 120, 212, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 120, 212, 0.035) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.95), transparent 74%);
}

.page-shell {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 36px 56px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding: 20px 26px;
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 22px;
  background: linear-gradient(110deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.72));
  box-shadow: 0 12px 36px rgba(57, 130, 194, 0.06);
  backdrop-filter: blur(16px);
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  place-items: center;
  border-radius: 17px;
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, var(--accent) 0%, var(--blue) 100%);
  box-shadow: 0 7px 18px rgba(17, 166, 161, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand-ai {
  display: block;
  width: 46px;
  height: 46px;
}

.brand-decoration {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.brand-decoration span {
  width: 56px;
  height: 9px;
  border-radius: 20px;
  background: #e0f0fe;
}

.brand-decoration i {
  width: 35px;
  height: 35px;
  margin-left: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #def1ff, #badcff);
}

.brand-name,
.brand-subtitle {
  margin: 0;
}

.brand-name {
  font-size: 1.35rem;
  font-weight: 850;
  letter-spacing: 0.01em;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.9rem;
}

.hero-card,
.panel {
  background: linear-gradient(130deg, rgba(255, 255, 255, 0.97), rgba(248, 252, 255, 0.9));
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 32px 34px 34px;
  min-height: 224px;
  margin-bottom: 20px;
  background:
    linear-gradient(132deg, transparent 71%, rgba(216, 244, 255, 0.42) 71.1% 76%, transparent 76.1%),
    linear-gradient(110deg, #ffffff 30%, #f3faff 100%);
}

.hero-card::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 15px;
  width: 80px;
  height: 54px;
  background: radial-gradient(circle, #b8e0ff 2.5px, transparent 3px) 0 0 / 14px 14px;
  opacity: 0.45;
}

.hero-illustration {
  position: absolute;
  right: 24px;
  top: 4px;
  width: 286px;
  height: 220px;
  object-fit: contain;
  pointer-events: none;
}

.panel {
  padding: 28px 30px;
  margin-bottom: 20px;
}

.eyebrow {
  position: relative;
  z-index: 1;
  width: fit-content;
  margin: 0 0 18px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  position: relative;
  z-index: 1;
  margin: 0;
}

h1 {
  max-width: none;
  font-size: clamp(1.3rem, 1.83vw, 1.75rem);
  line-height: 1.5;
  letter-spacing: -0.035em;
  width: fit-content;
  max-width: calc(100% - 235px);
  white-space: nowrap;
}

h2 {
  font-size: 1.12rem;
  letter-spacing: -0.02em;
}

.lead {
  position: relative;
  z-index: 1;
  max-width: none;
  margin: 22px 0 0;
  line-height: 1.9;
  color: var(--muted);
  font-size: clamp(0.68rem, 0.93vw, 0.86rem);
  white-space: nowrap;
}

form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.04fr) 205px;
  gap: 24px;
  align-items: end;
}

.field {
  display: grid;
  gap: 12px;
  min-width: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 750;
}

input[type="file"],
select {
  width: 100%;
  min-height: 58px;
  padding: 14px 18px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
  font: inherit;
  color: inherit;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

input[type="file"] {
  border-style: dashed;
  padding: 12px;
  font-size: 0.84rem;
  font-weight: 500;
  text-overflow: ellipsis;
  color: transparent;
}

input[type="file"]:valid {
  color: var(--text);
}

input[type="file"]::file-selector-button {
  padding: 6px 10px;
  margin-right: 10px;
  border: 1px solid #d0e0ef;
  border-radius: 6px;
  color: #345273;
  background: linear-gradient(#ffffff, #eef6fe);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

select {
  appearance: none;
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%237085a2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
}

.file-control {
  position: relative;
  display: flex;
  min-width: 0;
}

input[type="file"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(17, 166, 161, 0.12);
}

.hint-box {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 58px;
  justify-self: stretch;
  border: none;
  border-radius: 13px;
  padding: 14px 22px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 850;
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, var(--blue) 100%);
  box-shadow: 0 10px 22px rgba(17, 166, 161, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    opacity 0.16s ease;
}

button:focus-visible,
.download-link:focus-visible {
  outline: 3px solid var(--accent-dark);
  outline-offset: 4px;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(17, 166, 161, 0.28);
}

button:disabled {
  opacity: 0.62;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

#status-text {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

#status-text::before {
  content: "";
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #79bfe7;
  box-shadow: 0 0 0 4px #eaf6fe;
}

.results-panel {
  position: relative;
  min-height: 208px;
}

.results-empty {
  position: relative;
  display: grid;
  place-items: center;
  height: 132px;
  margin: -10px -30px -28px;
  overflow: hidden;
  border-radius: 0 0 21px 21px;
  background:
    radial-gradient(ellipse at 28% 115%, #e8f5ff 0 42%, transparent 42.5%),
    radial-gradient(ellipse at 82% 115%, #eef8ff 0 43%, transparent 43.5%);
}

.results-empty img {
  position: relative;
  width: 152px;
  height: 124px;
  opacity: 0.88;
}

.result-list:not(:empty) + .results-empty {
  display: none;
}

.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.result-item {
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.result-item p {
  margin: 8px 0 0;
  line-height: 1.5;
}

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

.result-head strong,
.result-item p,
.download-link {
  overflow-wrap: anywhere;
  min-width: 0;
}

.badge {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 850;
}

.badge-success {
  color: var(--success);
  background: rgba(7, 148, 85, 0.12);
}

.badge-unsupported {
  color: var(--warning);
  background: rgba(181, 71, 8, 0.12);
}

.badge-error {
  color: var(--error);
  background: rgba(217, 45, 32, 0.12);
}

.warning {
  color: var(--warning);
}

.message {
  color: var(--muted);
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 850;
  text-decoration: none;
}

.download-link:hover {
  background: #d8f3f1;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 16px;
  margin-top: 18px;
}

.review-pane {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  overflow: hidden;
}

.preview-title,
.excel-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: #1f3d5a;
  font-weight: 850;
  background: #f1f8ff;
}

.pdf-pane iframe {
  display: block;
  width: 100%;
  height: 680px;
  border: 0;
  background: white;
}

.preview-note {
  margin: 10px 14px 0;
  color: var(--warning);
  font-size: 0.9rem;
}

.excel-table-wrap {
  max-height: 680px;
  overflow: auto;
}

.excel-formula-bar {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #f1f8ff;
  font-size: 0.86rem;
}

.excel-formula-value {
  overflow-wrap: anywhere;
  min-width: 0;
}

.excel-formula-cell {
  cursor: pointer;
}

.excel-preview-table td.excel-selected-cell,
.excel-preview-table td.excel-formula-cell:focus-visible {
  outline: 2px solid var(--primary, #078b8b);
  outline-offset: -2px;
  background: #e7f7f7;
}

.excel-preview-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.86rem;
  background: white;
}

.excel-preview-table th,
.excel-preview-table td {
  min-width: 120px;
  max-width: 280px;
  padding: 8px 10px;
  border-right: 1px solid #e2ebf1;
  border-bottom: 1px solid #e2ebf1;
  text-align: center;
  vertical-align: middle;
  white-space: pre-wrap;
}

.excel-preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef7fb;
  color: #1f3d5a;
  font-weight: 850;
}

.excel-preview-table tr:nth-child(even) td {
  background: #f9fcfe;
}

@media (max-width: 1180px) {
  .page-shell {
    padding: 28px 24px 48px;
  }

  .hero-illustration {
    width: 225px;
    right: 8px;
  }

  h1 {
    font-size: 1.35rem;
    max-width: calc(100% - 180px);
    white-space: normal;
  }

  .lead {
    font-size: 0.8rem;
    white-space: normal;
    max-width: calc(100% - 165px);
  }

  form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 178px;
    gap: 16px;
  }
}

@media (max-width: 900px) {
  .hero-card {
    padding: 28px;
  }

  h1 {
    font-size: 1.3rem;
  }

  .hero-illustration {
    width: 190px;
    top: 12px;
    opacity: 0.8;
  }

  .lead {
    max-width: none;
  }

  form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  #submit-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .page-shell {
    padding: 18px 14px 48px;
  }

  .topbar,
  .hero-card,
  .panel {
    border-radius: 18px;
  }

  .hero-card,
  .panel {
    padding: 20px;
  }

  .topbar {
    padding: 17px 20px;
  }

  .brand-decoration span {
    display: none;
  }

  .brand-decoration i {
    width: 28px;
    height: 28px;
    margin-left: 0;
  }

  .hero-card {
    min-height: 0;
  }

  .hero-illustration {
    top: 4px;
    right: 4px;
    width: 96px;
    height: 68px;
  }

  .eyebrow {
    font-size: 0.59rem;
    letter-spacing: 0.1em;
    padding: 7px 9px;
    margin: 0 0 24px;
  }

  h1 {
    font-size: clamp(1.2rem, 4vw, 1.45rem);
    max-width: none;
    line-height: 1.6;
    white-space: normal;
  }

  .lead {
    margin-top: 15px;
    font-size: 0.78rem;
    white-space: normal;
  }

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

  .status-row,
  .result-head {
    flex-direction: column;
    align-items: flex-start;
  }

  #status-text {
    font-size: 0.78rem;
  }

  .results-empty {
    margin: 0 -20px -20px;
  }

  button {
    width: 100%;
  }

  .review-layout {
    grid-template-columns: 1fr;
  }

  .pdf-pane iframe,
  .excel-table-wrap {
    max-height: 520px;
  }

  .pdf-pane iframe {
    height: 520px;
  }
}

@media (max-width: 390px) {
  .hero-illustration {
    width: 88px;
    right: -4px;
    opacity: 0.65;
  }

  .eyebrow {
    font-size: 0.52rem;
  }
}
