:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: #111827;
  --panel-soft: #1f2937;
  --line: rgba(148, 163, 184, 0.22);
  --text: #e5edf8;
  --muted: #94a3b8;
  --brand: #38bdf8;
  --brand-strong: #0ea5e9;
  --success: #34d399;
  --danger: #fb7185;
  --shadow: 0 24px 80px rgba(2, 6, 23, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(14, 165, 233, 0.18), transparent 34rem),
    linear-gradient(135deg, #0f172a 0%, #111827 52%, #0b1120 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.site-header,
.site-footer,
.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  padding: 24px 0 18px;
}

.ad-slot {
  display: grid;
  min-height: 90px;
  place-items: center;
  border: 1px dashed rgba(148, 163, 184, 0.45);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.66);
  color: var(--muted);
  letter-spacing: 0.02em;
}

.ad-slot-top {
  margin-bottom: 40px;
}

.ad-slot-bottom {
  margin: 28px 0 32px;
}

.hero {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 4.75rem);
  line-height: 1.02;
}

.hero p:not(.eyebrow) {
  max-width: 620px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 20px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.86);
  box-shadow: var(--shadow);
}

.upload-panel {
  padding: 22px;
}

.drop-zone {
  display: grid;
  min-height: 270px;
  place-items: center;
  padding: 28px;
  border: 2px dashed rgba(56, 189, 248, 0.45);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
  text-align: center;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging,
.drop-zone:focus-visible {
  border-color: var(--brand);
  background: rgba(14, 165, 233, 0.12);
  outline: none;
  transform: translateY(-1px);
}

.drop-icon {
  display: grid;
  width: 56px;
  height: 56px;
  margin-bottom: 12px;
  place-items: center;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.14);
  color: var(--brand);
  font-size: 2.1rem;
  font-weight: 300;
}

.drop-zone h2 {
  margin: 0;
  font-size: 1.28rem;
}

.drop-zone p {
  margin: 8px 0 12px;
  color: var(--muted);
}

#selectedFileName {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #bae6fd;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 9px;
  color: var(--muted);
  font-size: 0.92rem;
}

.field span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.field b {
  color: var(--text);
}

input[type="range"] {
  accent-color: var(--brand);
}

input[type="number"],
select {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1220;
  color: var(--text);
  padding: 0 12px;
}

input[type="number"]:focus,
select:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(56, 189, 248, 0.14);
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: white;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 150ms ease,
    opacity 150ms ease,
    background 150ms ease;
}

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

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

.primary-button {
  flex: 1;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
}

.secondary-button {
  background: #334155;
}

.status {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  color: var(--muted);
}

.status.is-error {
  color: var(--danger);
}

.status.is-success {
  color: var(--success);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(148, 163, 184, 0.28);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.result-panel {
  min-width: 0;
  padding: 22px;
}

.section-heading h2 {
  margin: 0 0 18px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

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

th {
  color: #cbd5e1;
  font-size: 0.82rem;
  text-transform: uppercase;
}

td {
  color: var(--text);
}

td:nth-child(2) {
  max-width: 220px;
  overflow-wrap: anywhere;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
}

.reduction {
  color: var(--success);
  font-weight: 800;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .site-header,
  .site-footer,
  .app-shell {
    width: min(100% - 20px, 1120px);
  }

  .site-header {
    padding-top: 14px;
  }

  .ad-slot-top {
    margin-bottom: 28px;
  }

  .hero h1 {
    font-size: 2.15rem;
  }

  .upload-panel,
  .result-panel {
    padding: 16px;
  }

  .drop-zone {
    min-height: 230px;
    padding: 22px 16px;
  }

  .actions {
    flex-direction: column;
  }
}
