:root {
  color-scheme: light;
  --ink: #1d252b;
  --muted: #5c6872;
  --line: #d8dee4;
  --panel: #ffffff;
  --surface: #f4f7f8;
  --accent: #0f766e;
  --accent-dark: #134e4a;
  --warn-bg: #fff7ed;
  --warn-line: #fdba74;
  --warn-ink: #9a3412;
  --error-bg: #fef2f2;
  --error-line: #fca5a5;
  --error-ink: #991b1b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.08), rgba(15, 23, 42, 0) 38%),
    var(--surface);
  color: var(--ink);
}

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workspace {
  display: grid;
  gap: 20px;
}

.lock-screen {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
}

.lock-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
}

.unlock-form {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

.unlock-form label,
.sheet-panel label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.unlock-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input[type="password"],
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 42px;
  padding: 0 12px;
  font: inherit;
  color: var(--ink);
  background: white;
}

.password-error {
  color: var(--error-ink);
  font-weight: 650;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

.privacy-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 700;
  padding: 8px 12px;
  white-space: nowrap;
}

.upload-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 16px;
}

.dropzone {
  display: grid;
  min-height: 230px;
  align-content: center;
  justify-items: center;
  gap: 12px;
  border: 2px dashed #9fb0b8;
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  padding: 28px;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--accent);
  background: #eefdfa;
  transform: translateY(-1px);
}

.dropzone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.upload-icon {
  display: inline-grid;
  place-items: center;
  width: 62px;
  height: 76px;
  border: 2px solid var(--accent);
  border-radius: 6px;
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 800;
}

.drop-title {
  color: var(--ink);
  font-size: 19px;
  font-weight: 750;
}

.drop-subtitle {
  max-width: 520px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.status-grid {
  display: grid;
  gap: 12px;
}

.status-item,
.metric,
.rules > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status-item {
  display: grid;
  gap: 7px;
  padding: 18px;
  min-width: 0;
}

.status-label,
.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 17px;
}

.notice,
.error-box,
.sheet-status {
  border-radius: 8px;
  padding: 14px 16px;
  line-height: 1.45;
}

.notice {
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.error-box {
  border: 1px solid var(--error-line);
  background: var(--error-bg);
  color: var(--error-ink);
  font-weight: 650;
}

.sheet-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.sheet-panel > div {
  display: grid;
  gap: 8px;
}

.sheet-status {
  border: 1px solid #99f6e4;
  background: #f0fdfa;
  color: var(--accent-dark);
  font-weight: 650;
}

.sheet-status-error {
  border-color: var(--error-line);
  background: var(--error-bg);
  color: var(--error-ink);
}

.hidden {
  display: none;
}

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

.metric {
  padding: 18px;
}

.metric strong {
  display: block;
  margin-top: 9px;
  font-size: 32px;
  line-height: 1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 42px;
  padding: 0 15px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

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

#downloadCsvBtn,
#downloadXlsxBtn,
#pushSheetBtn,
#unlockBtn {
  background: var(--accent);
  color: white;
}

#resetBtn {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

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

.rules > div {
  padding: 18px;
}

.rules p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

code {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f8fafc;
  padding: 1px 5px;
  font-size: 0.92em;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 22px, 1120px);
    padding: 18px 0;
  }

  .masthead,
  .upload-panel,
  .sheet-panel,
  .rules {
    grid-template-columns: 1fr;
  }

  .masthead {
    display: grid;
    align-items: start;
  }

  .privacy-badge {
    justify-self: start;
  }

  h1 {
    font-size: 30px;
    line-height: 1.08;
  }

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

  .dropzone {
    min-height: 210px;
    padding: 22px;
  }
}

@media (max-width: 420px) {
  h1 {
    font-size: 28px;
  }

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

  .actions button {
    flex: 1 1 100%;
  }

  .unlock-row {
    grid-template-columns: 1fr;
  }
}
