:root {
  --bg-a: #ecfeff;
  --bg-b: #fff7ed;
  --text: #10222e;
  --muted: #4b6473;
  --line: rgba(16, 34, 46, 0.16);
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.8);
  --teal-1: #0f766e;
  --teal-2: #2dd4bf;
  --orange-1: #ea580c;
  --orange-2: #fb923c;
  --error: #b91c1c;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Space Grotesk", Inter, Segoe UI, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background: radial-gradient(circle at 8% 10%, rgba(255, 255, 255, 0.8) 0, transparent 32%),
    linear-gradient(140deg, var(--bg-a), var(--bg-b));
  position: relative;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  width: 34rem;
  height: 34rem;
  border-radius: 999px;
  filter: blur(72px);
  opacity: 0.28;
  z-index: 0;
  pointer-events: none;
}

.bg-glow-teal {
  background: linear-gradient(120deg, var(--teal-1), var(--teal-2));
  top: -12rem;
  right: -7rem;
}

.bg-glow-orange {
  background: linear-gradient(120deg, var(--orange-1), var(--orange-2));
  bottom: -12rem;
  left: -9rem;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(100%, 1400px);
  margin: 0 auto;
  padding: 1rem 1.25rem 1.2rem;
  display: grid;
  gap: 0.9rem;
}

.glass {
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.08);
  border-radius: 20px;
}

.top-header {
  position: relative;
  z-index: 12;
  padding: 1rem 1.2rem;
  overflow: visible;
}

.brand-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.85rem;
  overflow: visible;
}

.header-side {
  display: flex;
  align-items: center;
  overflow: visible;
}

.header-side-left {
  justify-content: flex-start;
}

.header-side-right {
  justify-content: flex-end;
}

.top-header h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2.4vw, 1.8rem);
  text-align: center;
}

.header-tool {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  justify-content: center;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 999px;
  border: 1px solid rgba(16, 34, 46, 0.12);
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease, color 0.16s ease,
    background 0.16s ease, border-color 0.16s ease;
}

.header-tool:hover,
.header-tool:focus-visible,
.header-help:hover .header-tool,
.header-help:focus-within .header-tool {
  color: var(--teal-1);
  border-color: rgba(15, 118, 110, 0.22);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.12);
  transform: translateY(-1px);
  outline: none;
}

.header-tool-button {
  cursor: help;
}

.contact-icon {
  width: 0.92rem;
  height: 0.92rem;
}

.header-card {
  top: calc(100% + 0.6rem);
}

.top-header p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1.06fr 1.3fr;
  gap: 1rem;
  align-items: start;
}

.left-panel,
.right-panel {
  padding: 1rem;
  display: grid;
  align-content: start;
  gap: 0.95rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

h2,
h3 {
  margin: 0;
}

h2 {
  font-size: 1.02rem;
}

input,
select,
button {
  font: inherit;
}

.file-select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--glass-strong);
  border-radius: 12px;
  padding: 0.56rem 0.7rem;
}

.download-select {
  min-width: 210px;
}

.ghost-btn,
.secondary-btn,
.primary-btn,
.tab {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.56rem 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn {
  min-height: 40px;
  font-weight: 700;
}

.ghost-btn,
.secondary-btn {
  background: rgba(255, 255, 255, 0.75);
  border-color: var(--line);
}

.primary-btn {
  color: #fff;
  background: linear-gradient(120deg, var(--teal-1), var(--teal-2));
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.3);
}

.primary-btn[data-tone="active"] {
  background: linear-gradient(120deg, var(--orange-1), var(--orange-2));
  box-shadow: 0 8px 20px rgba(234, 88, 12, 0.24);
}

.primary-btn[data-tone="success"] {
  background: linear-gradient(120deg, #0f766e, #14b8a6);
}

.primary-btn[data-tone="error"] {
  background: linear-gradient(120deg, #b91c1c, #ef4444);
  box-shadow: 0 8px 20px rgba(185, 28, 28, 0.22);
}

.secondary-btn:disabled,
.file-select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.dropzone {
  position: relative;
  min-height: 108px;
  border: 1.5px dashed rgba(15, 118, 110, 0.45);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.58);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0.8rem 0.9rem;
  cursor: pointer;
}

.dropzone.drag-active {
  border-color: var(--orange-1);
  background: rgba(255, 237, 213, 0.64);
}

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

.dropzone-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.dropzone-subtitle {
  margin: 0.24rem 0 0;
  color: var(--muted);
  font-size: 0.77rem;
}

.file-meta {
  font-size: 0.84rem;
  color: var(--muted);
  min-height: 1rem;
  text-align: center;
}

.preview-shell {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.65rem;
  background: rgba(255, 255, 255, 0.62);
  min-height: clamp(460px, 56vh, 600px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0.55rem;
}

.preview-title,
.zoom-line {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

#pdfPreview {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 10px;
  background: #f8fafc;
}

.output-head {
  align-items: flex-start;
}

.tab-row {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.2rem;
}

.tab {
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  padding: 0.45rem 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.tab.active {
  color: #fff;
  background: linear-gradient(120deg, var(--orange-1), var(--orange-2));
}

.action-cluster {
  display: grid;
  grid-template-columns: minmax(160px, 190px) 1fr;
  gap: 0.8rem;
  align-items: stretch;
}

.download-stack {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.58);
  padding: 0.72rem 0.78rem;
  display: grid;
  gap: 0.7rem;
}

.download-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.download-head h3 {
  font-size: 0.92rem;
}

.help-pop {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  outline: none;
  z-index: 20;
}

.help-dot {
  width: 1.2rem;
  height: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(16, 34, 46, 0.08);
  border: 1px solid rgba(16, 34, 46, 0.12);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: help;
}

.help-card {
  position: absolute;
  top: calc(100% + 0.55rem);
  left: 50%;
  width: min(320px, 78vw);
  padding: 0.75rem 0.8rem;
  border-radius: 14px;
  border: 1px solid rgba(16, 34, 46, 0.12);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -4px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 40;
}

.help-pop:hover .help-card,
.help-pop:focus-within .help-card,
.help-pop.open .help-card {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.help-list {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.38rem;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.32;
}

.download-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.output-section {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.42);
  overflow: hidden;
}

.section-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.82rem 0.9rem;
  background: rgba(255, 255, 255, 0.58);
  font-size: 0.92rem;
  font-weight: 700;
}

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

.section-summary::after {
  content: "+";
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.output-section[open] > .section-summary::after {
  content: "−";
}

.table-shell {
  position: relative;
  background: rgba(255, 255, 255, 0.7);
  overflow: auto;
  min-height: clamp(340px, 42vh, 420px);
  max-height: 52vh;
  margin: 0 0.9rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.76rem;
  transform-origin: top left;
}

thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(255, 255, 255, 0.94);
}

th,
td {
  border-bottom: 1px solid rgba(16, 34, 46, 0.1);
  border-right: 1px solid rgba(16, 34, 46, 0.08);
  padding: 0.5rem 0.6rem;
  text-align: left;
  white-space: nowrap;
}

th:last-child,
td:last-child {
  border-right: none;
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.5);
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.totals-panel {
  margin: 0 0.9rem 0.9rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.67);
  border: 1px solid var(--line);
  border-radius: 14px;
  max-height: 300px;
  overflow: auto;
  display: grid;
  gap: 0.55rem;
}

.totals-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.metric-grid {
  display: grid;
  gap: 0.45rem;
  margin: 0.25rem 0 0.2rem;
}

.metric-record-list {
  display: grid;
  gap: 0.65rem;
  margin: 0.25rem 0 0.2rem;
}

.metric-record {
  border: 1px solid rgba(16, 34, 46, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  overflow: hidden;
}

.metric-record-title {
  padding: 0.52rem 0.62rem;
  background: rgba(16, 34, 46, 0.05);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-record-body {
  display: grid;
  gap: 0.35rem;
  padding: 0.5rem;
}

.summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.05rem 0 0.45rem;
}

.summary-stat {
  border-radius: 999px;
  padding: 0.24rem 0.54rem;
  border: 1px solid rgba(16, 34, 46, 0.1);
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.metric-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: baseline;
  padding: 0.45rem 0.55rem;
  border: 1px solid rgba(16, 34, 46, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
}

.metric-label {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
}

.metric-value {
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 700;
  text-align: right;
}

.totals-tree details {
  border: 1px solid rgba(16, 34, 46, 0.1);
  background: rgba(255, 255, 255, 0.56);
  border-radius: 10px;
  padding: 0.42rem 0.5rem;
  margin-bottom: 0.35rem;
}

.totals-tree summary {
  cursor: pointer;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

@media (max-width: 1024px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .action-cluster {
    grid-template-columns: 1fr;
  }

  .preview-shell {
    min-height: 420px;
  }

  .table-shell {
    min-height: 320px;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 0.75rem;
  }

  .left-panel,
  .right-panel {
    padding: 0.78rem;
    gap: 0.75rem;
  }

  .top-header p {
    font-size: 0.82rem;
  }

  .dropzone {
    min-height: 88px;
    border-style: solid;
    border-width: 1px;
  }

  .dropzone-title {
    font-size: 0.94rem;
  }

  .dropzone-subtitle {
    font-size: 0.76rem;
    margin-top: 0.22rem;
  }

  .download-actions {
    grid-template-columns: 1fr;
  }
  .preview-shell {
    min-height: 320px;
  }

  .table-shell {
    min-height: 260px;
    max-height: 42vh;
  }
}
