:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1c2530;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #156c74;
  --accent-2: #b94733;
  --accent-3: #5b6f1d;
  --danger: #a7343a;
  --sidebar: #18212b;
  --sidebar-muted: #aab4c0;
  --shadow: 0 12px 28px rgba(28, 37, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.96);
}

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

.small-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.danger-button {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar);
  color: white;
  padding: 22px 16px;
}

.brand {
  display: grid;
  gap: 4px;
  margin-bottom: 26px;
  padding: 0 8px;
}

.brand span {
  color: var(--sidebar-muted);
  font-size: 13px;
}

.brand strong {
  font-size: 20px;
  letter-spacing: 0;
}

.module-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  justify-content: flex-start;
  width: 100%;
  min-height: 44px;
  border-color: transparent;
  background: transparent;
  color: var(--sidebar-muted);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.content-shell {
  min-width: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(16px, 4vw, 42px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.app-header h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: 0;
}

.app-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.layout,
.tab-panel {
  display: grid;
  gap: 18px;
}

.layout {
  padding: 22px clamp(16px, 4vw, 42px) 42px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
}

.panel,
.toolbar,
.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-title h2,
.mapping-area h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.section-title span {
  color: var(--muted);
  font-size: 14px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 126px;
  padding: 20px;
  border: 1px dashed #98a2b3;
  border-radius: 8px;
  background: #fbfcfd;
  text-align: center;
  cursor: pointer;
}

.drop-zone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.drop-zone strong {
  font-size: 18px;
}

.drop-zone span {
  max-width: 560px;
  color: var(--muted);
  margin-top: 6px;
}

.mapping-area {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.hidden {
  display: none;
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label,
.toolbar label {
  color: var(--muted);
  font-size: 13px;
}

select,
input[type="date"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 0 10px;
}

.status-select {
  min-width: 160px;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  resize: vertical;
}

.mapping-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 14px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  padding: 14px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.metric-card {
  padding: 16px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  letter-spacing: 0;
}

.chart-wrap {
  height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fbfcfd;
}

#trendChart {
  display: block;
  width: 100%;
  height: 100%;
}

.table-wrap {
  overflow: auto;
  max-height: 420px;
}

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

.transaction-table {
  min-width: 1800px;
}

.eligible-table {
  min-width: 1620px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

.transaction-table th,
.transaction-table td,
.eligible-table th,
.eligible-table td {
  text-align: left;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.quality-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.quality-list li {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--muted);
  background: #fbfcfd;
}

.notes-cell {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.notes-cell span {
  max-width: 280px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(24, 33, 43, 0.42);
  z-index: 20;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 24px 60px rgba(24, 33, 43, 0.24);
  padding: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .app-header,
  .mapping-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    height: 280px;
  }
}
