:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1d2624;
  --muted: #68736f;
  --line: #dce3df;
  --accent: #1f6f68;
  --danger: #ad343e;
  --shadow: 0 14px 32px rgba(19, 34, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

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

.sidebar {
  background: #163532;
  color: #f5fbf8;
  padding: 24px 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #bed3ce;
  margin-top: 2px;
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  border-radius: 6px;
  padding: 12px 14px;
  color: #dbe8e4;
  text-decoration: none;
}

nav a.is-active,
nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar,
.table-head {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
}

.topbar {
  margin-bottom: 18px;
}

.topbar p {
  margin: 0 0 4px;
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
}

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

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

.metrics div {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.metrics span,
.tool-box p,
.selection-summary {
  color: var(--muted);
}

.metrics strong {
  font-size: 1.55rem;
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

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

.tool-box {
  display: grid;
  gap: 10px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 14px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 10px 11px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f2f4f1;
  padding: 10px;
}

.notice.is-ok {
  border-color: #9bc9bd;
  background: #effaf6;
  color: var(--accent);
}

.notice.is-error {
  border-color: #e7a6ab;
  background: #fff3f4;
  color: var(--danger);
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px;
  gap: 10px;
}

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

.mapping-actions {
  display: grid;
  grid-template-columns: 220px 140px;
  gap: 10px;
}

.mapping-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.mapping-box {
  min-width: 0;
}

.mapping-box h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.mapping-list {
  display: grid;
  gap: 8px;
}

.mapping-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(160px, 1fr);
  gap: 8px;
  align-items: center;
}

.mapping-row span {
  overflow: hidden;
  color: var(--muted);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mapping-row-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

.mapping-row-head span,
.mapping-row-head strong {
  color: var(--ink);
  font-size: 0.86rem;
}

.template-field {
  margin-top: 16px;
}

.selection-summary {
  margin: 12px 0;
  font-weight: 800;
}

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

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

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

th {
  color: var(--muted);
  font-size: 0.82rem;
}

.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  background: #eef5f2;
  padding: 4px 8px;
  color: var(--accent);
  font-weight: 800;
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
  }

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

  .topbar,
  .table-head {
    display: grid;
  }

  .filters,
  .mapping-actions,
  .mapping-grid {
    grid-template-columns: 1fr;
  }
}
