:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-muted: #eef3f4;
  --border: #d8e1e3;
  --text: #172126;
  --muted: #627178;
  --teal: #087d76;
  --teal-dark: #05645f;
  --teal-soft: #e0f2ef;
  --amber: #b7791f;
  --danger: #b42318;
  --shadow: 0 20px 50px rgba(14, 42, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

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

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 34px);
}

h2 {
  font-size: 20px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.button:hover:not(:disabled) {
  border-color: #9eb5b8;
  transform: translateY(-1px);
}

.button:disabled {
  color: #9aa7ac;
  cursor: not-allowed;
}

.button.primary {
  border-color: var(--teal);
  color: #ffffff;
  background: var(--teal);
}

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

.button.primary:disabled {
  border-color: var(--border);
  color: #9aa7ac;
  background: #f2f5f6;
}

.button.subtle {
  background: transparent;
}

.button svg,
.search-field svg,
.drop-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.upload-panel,
.results-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.upload-panel {
  padding: 16px;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 190px;
  padding: 24px;
  border: 1px dashed #9eb5b8;
  border-radius: 8px;
  text-align: center;
  background: var(--surface-muted);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.dropzone.drag-over {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 12px;
  border-radius: 8px;
  color: var(--teal);
  background: #ffffff;
  border: 1px solid var(--border);
}

.drop-title {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

.drop-copy {
  display: block;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

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

.stats-grid div {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfc;
}

.stats-grid span {
  display: block;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.stats-grid small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.25;
}

.status-panel {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.panel-title {
  margin-bottom: 8px;
  font-weight: 700;
}

.status-list {
  display: grid;
  gap: 8px;
  max-height: 310px;
  padding: 0;
  margin: 0;
  overflow: auto;
  list-style: none;
}

.status-list li {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfc;
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
}

.status-list li.ok {
  color: #155e50;
  border-color: #b9dfd8;
  background: #eefaf7;
}

.status-list li.skip {
  color: #77520c;
  border-color: #efd3a0;
  background: #fff8e8;
}

.status-list li.error {
  color: var(--danger);
  border-color: #f1b8b2;
  background: #fff1f0;
}

.status-list li.saved-file {
  display: grid;
  gap: 4px;
}

.status-list li.saved-file strong {
  color: #14353a;
  font-size: 13px;
}

.status-list li.saved-file small {
  color: var(--muted);
}

.results-panel {
  min-width: 0;
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.visible-total {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  color: var(--muted);
}

.visible-total[hidden] {
  display: none;
}

.visible-total > span {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.visible-total-item {
  min-width: 130px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfc;
}

.visible-total-item small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.visible-total-item strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(320px, 100%);
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: #ffffff;
}

.search-field input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #324147;
  background: #edf4f4;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td.number,
tfoot td {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tbody tr:hover {
  background: #fbfefe;
}

.subtotal-row td {
  border-top: 2px solid #b9cacc;
  color: #14353a;
  font-weight: 800;
  background: #eef6f5;
}

.subtotal-row td:first-child {
  color: var(--muted);
}

tfoot td {
  font-weight: 800;
  background: #f8fbfb;
}

.no-data-row td {
  height: 220px;
  color: var(--muted);
  text-align: left;
  vertical-align: middle;
  white-space: normal;
}

.pdf-cell {
  min-width: 170px;
  vertical-align: middle;
}

.pdf-upload {
  display: grid;
  gap: 8px;
  align-content: center;
}

.pdf-empty {
  color: var(--muted);
  font-size: 13px;
}

.pdf-link {
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  word-break: break-word;
}

.pdf-link:hover {
  text-decoration: underline;
}

.pdf-upload-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--teal);
  border-radius: 8px;
  color: var(--teal);
  background: #ffffff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.pdf-upload-control:hover {
  background: var(--teal-soft);
}

.pdf-upload-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding: 14px 0;
  }

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

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions .button {
    flex: 1 1 120px;
  }

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

  .search-field {
    min-width: 0;
    width: 100%;
  }

  .visible-total {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .visible-total-item {
    flex: 1 1 150px;
  }
}
