:root {
  color-scheme: light;
  --bg: #eef3f2;
  --bg-panel: #f7faf9;
  --panel: #ffffff;
  --line: #d9e3e0;
  --line-strong: #adc4be;
  --text: #17211f;
  --muted: #64716d;
  --muted-strong: #465450;
  --accent: #0f766e;
  --accent-dark: #0a5f59;
  --accent-soft: #e0f3ef;
  --accent-soft-strong: #c7e8e2;
  --danger-soft: #fff4f0;
  --shadow: 0 12px 32px rgba(21, 45, 40, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(15, 118, 110, 0) 260px),
    var(--bg);
  font-family: Inter, "Avenir Next", "Helvetica Neue", "PingFang SC", "Noto Sans SC", sans-serif;
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(1440px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 16px 0 24px;
  transform-origin: center center;
  will-change: transform, opacity;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  margin-bottom: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--accent);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 0.98rem;
  line-height: 1.2;
}

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

.mode-switch {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 10px 24px rgba(21, 45, 40, 0.08);
}

.mode-option {
  appearance: none;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  color: var(--muted-strong);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.mode-option:hover {
  color: var(--text);
  background: var(--bg-panel);
}

.mode-option.is-active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.2);
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(460px, 1.08fr) minmax(290px, 0.62fr);
  grid-template-areas:
    "intro import stats"
    "results results results";
  gap: 12px;
  align-items: stretch;
}

.panel,
.intro-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  overflow: hidden;
  background: var(--panel);
}

.intro-panel {
  grid-area: intro;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  min-height: 268px;
  padding: 22px;
  color: #effffb;
  background:
    linear-gradient(180deg, rgba(16, 132, 123, 0.96), rgba(10, 95, 89, 0.98)),
    var(--accent);
}

.intro-panel > div:first-child {
  align-self: center;
  justify-self: center;
  width: min(100%, 28rem);
}

.eyebrow,
.section-kicker {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow {
  color: rgba(255, 255, 255, 0.7);
}

.section-kicker {
  margin-bottom: 6px;
  color: var(--accent);
}

.intro-panel h1 {
  margin: 12px 0 0;
  max-width: none;
  font-size: clamp(2rem, 2.55vw, 3.05rem);
  line-height: 1.06;
  letter-spacing: 0;
}

.hero-line {
  display: block;
}

.hero-copy {
  max-width: none;
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.65;
}

.hero-meta {
  align-self: end;
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.hero-tags,
.support-strip,
.source-list,
.dropzone-actions,
.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-tags span,
.support-item,
.source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.hero-tags span {
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.17);
  background: rgba(255, 255, 255, 0.11);
}

.support-strip {
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.support-label {
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.82rem;
  font-weight: 800;
}

.support-item {
  color: #f2fffd;
  background: rgba(255, 255, 255, 0.1);
}

.import-card {
  grid-area: import;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 22px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.16;
  letter-spacing: 0;
}

.section-head p:not(.section-kicker) {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.source-list {
  min-width: 0;
}

.source-pill {
  color: var(--accent-dark);
  border: 1px solid var(--accent-soft-strong);
  background: var(--accent-soft);
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.76rem;
}

.dropzone {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 232px;
  padding: 28px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(244, 250, 248, 0.96));
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.dropzone.is-dragover,
.dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.dropzone-title {
  max-width: 25rem;
  margin: 0;
  color: var(--text);
  font-size: clamp(1.55rem, 2vw, 2.25rem);
  font-weight: 900;
  line-height: 1.18;
  letter-spacing: 0;
}

.dropzone-copy {
  max-width: 25rem;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.55;
}

.dropzone-actions {
  justify-content: center;
  margin-top: 18px;
}

.import-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.button {
  appearance: none;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 850;
  transition: transform 150ms ease, opacity 150ms ease, background 150ms ease, border-color 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.button-primary {
  color: #fff;
  background: var(--accent);
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.button-secondary {
  color: var(--accent-dark);
  border-color: var(--accent-soft-strong);
  background: var(--accent-soft);
}

.button-ghost {
  color: var(--text);
  border-color: var(--line);
  background: var(--bg-panel);
}

.stats-column {
  grid-area: stats;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  display: grid;
  align-content: center;
  min-height: 106px;
  padding: 18px 20px;
}

.provider-card {
  grid-column: 1 / -1;
  align-content: start;
}

.stat-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
}

.stat-value {
  margin-top: 8px;
  color: var(--text);
  font-size: clamp(2.2rem, 3vw, 3.25rem);
  font-weight: 900;
  line-height: 1;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.provider-entry {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 72px;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-panel);
  text-align: center;
}

.provider-icon {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.provider-entry span {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.15;
  text-overflow: ellipsis;
}

.results-card {
  grid-area: results;
  padding: 20px 22px 22px;
}

.results-head {
  align-items: center;
  margin-bottom: 14px;
}

.results-actions {
  justify-content: flex-end;
}

.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.6fr) minmax(300px, 0.75fr);
  gap: 12px;
}

.result-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-panel);
}

.result-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.result-panel-head h3 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.2;
}

.result-panel-head span,
#summary-text,
#converted-hint,
#skipped-hint,
.issues-list li {
  color: var(--muted);
}

.table-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  table-layout: fixed;
}

.col-file {
  width: 36%;
}

.col-source {
  width: 16%;
}

.col-email {
  width: 24%;
}

.col-expiry {
  width: 15%;
}

.col-action {
  width: 9%;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted-strong);
  background: #f4f8f7;
  font-size: 0.8rem;
  font-weight: 900;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td code {
  font-size: 0.87rem;
}

.file-cell,
.source-cell,
.email-cell,
.expiry-cell {
  min-width: 0;
}

.file-meta,
.source-meta {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.file-name,
.file-path,
.file-entry,
.email-value,
.expiry-value {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name {
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86rem;
  font-weight: 850;
}

.file-path,
.cell-muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.file-entry {
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 750;
}

.source-meta {
  justify-items: start;
}

.source-chip,
.plan-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.76rem;
  font-weight: 850;
}

.source-chip {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.plan-chip {
  color: var(--muted-strong);
  background: #eef4f2;
}

.email-value,
.expiry-value {
  color: #26322f;
  font-size: 0.9rem;
}

.row-actions {
  display: flex;
}

.inline-button {
  min-height: 32px;
  border: 1px solid var(--accent-soft-strong);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  cursor: pointer;
  font-weight: 850;
  white-space: nowrap;
}

.empty-row td,
.issue-empty {
  color: var(--muted);
}

.issues-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.issues-list li {
  padding: 10px 11px;
  border: 1px solid #ffd9cf;
  border-radius: 6px;
  background: var(--danger-soft);
  line-height: 1.45;
  word-break: break-word;
}

.issues-list .issue-empty {
  border-color: var(--line);
  background: #fff;
}

.issue-file {
  display: block;
  color: var(--text);
  font-weight: 850;
}

.issue-reason {
  display: block;
  margin-top: 4px;
}

.page-shell.is-flip-out,
.page-shell.is-flip-in {
  pointer-events: none;
}

.page-shell.is-flip-out {
  animation: pageFlipOut 160ms cubic-bezier(0.55, 0.08, 0.62, 0.92) forwards;
}

.page-shell.is-flip-in {
  animation: pageFlipIn 200ms cubic-bezier(0.18, 0.82, 0.3, 1) forwards;
}

@keyframes pageFlipOut {
  from {
    transform: translateY(0);
    opacity: 1;
  }

  to {
    transform: translateY(6px);
    opacity: 0;
  }
}

@keyframes pageFlipIn {
  from {
    transform: translateY(-6px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 1180px) {
  .app-grid {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.74fr);
    grid-template-areas:
      "intro import"
      "stats stats"
      "results results";
  }

  .intro-panel {
    min-height: 270px;
  }

  .stats-column {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .provider-card {
    grid-column: auto;
  }
}

@media (max-width: 900px) {
  .app-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "intro"
      "import"
      "stats"
      "results";
  }

  .intro-panel {
    min-height: auto;
  }

  .stats-column {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .provider-card {
    grid-column: auto;
  }

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

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

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 20px, 1440px);
    padding-top: 10px;
  }

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

  .mode-switch,
  .mode-option,
  .results-actions,
  .dropzone-actions,
  .results-actions .button,
  .dropzone-actions .button {
    width: 100%;
  }

  .mode-option,
  .results-actions .button,
  .dropzone-actions .button {
    flex: 1 1 0;
  }

  .intro-panel,
  .import-card,
  .results-card,
  .stat-card,
  .result-panel {
    padding: 16px;
  }

  .intro-panel h1 {
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .stats-column {
    grid-template-columns: 1fr;
  }

  .provider-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .section-head,
  .results-head,
  .result-panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  table {
    min-width: 620px;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .page-shell,
  .dropzone,
  .button,
  .mode-option {
    transition: none;
  }

  .page-shell.is-flip-out,
  .page-shell.is-flip-in {
    animation: none;
  }
}
