:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7f8;
  color: #172528;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f5f7f8;
}

button,
input,
select {
  font: inherit;
}

button {
  height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: #16776b;
  color: #ffffff;
  font-weight: 650;
  cursor: pointer;
}

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

button.warn {
  background: #b55318;
}

input,
select,
textarea {
  height: 40px;
  border: 1px solid #cbd7d5;
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
  color: #172528;
}

textarea {
  width: 100%;
  height: 138px;
  padding: 10px 12px;
  line-height: 1.45;
  resize: vertical;
}

.shell {
  width: min(1240px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.topbar p {
  margin: 7px 0 0;
  color: #68737a;
  font-size: 14px;
}

.icon-btn {
  width: 42px;
  padding: 0;
  font-size: 20px;
}

.panel {
  background: #ffffff;
  border: 1px solid #dde5e4;
  border-radius: 8px;
  padding: 18px;
}

.token-panel {
  max-width: 560px;
}

.token-panel label {
  display: block;
  margin-bottom: 10px;
  color: #506067;
  font-size: 14px;
}

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

.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 18px;
  align-items: start;
}

.sidebar {
  display: grid;
  gap: 18px;
}

.content {
  display: grid;
  gap: 18px;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 8px;
  padding: 0 10px;
  background: #e7f5ef;
  color: #19704d;
  font-size: 13px;
  font-weight: 650;
}

.badge.muted {
  background: #eef3f5;
  color: #506067;
}

.list {
  display: grid;
  gap: 10px;
}

.card {
  border: 1px solid #dde5e4;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
}

.card:hover,
.card.active {
  border-color: #16776b;
  background: #f1f8f7;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}

.meta {
  margin-top: 6px;
  color: #68737a;
  font-size: 13px;
  line-height: 1.5;
}

.detail-empty {
  min-height: 110px;
  display: grid;
  place-items: center;
  color: #68737a;
  border: 1px dashed #cbd7d5;
  border-radius: 8px;
}

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

.kv {
  min-height: 64px;
  border: 1px solid #edf1f1;
  border-radius: 8px;
  padding: 10px 12px;
}

.kv-label {
  color: #68737a;
  font-size: 12px;
}

.kv-value {
  margin-top: 6px;
  color: #172528;
  font-weight: 650;
  word-break: break-all;
}

.actions {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  margin-top: 14px;
}

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

.wide-btn {
  width: 100%;
  margin-top: 10px;
}

.phone-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 14px;
}

.auto-match {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #edf1f1;
  border-radius: 8px;
  background: #f8fbfb;
}

.diagnostic {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #d4e5e2;
  border-radius: 8px;
  background: #fbfdfd;
}

.auto-match-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.auto-match h3 {
  margin: 0;
  font-size: 15px;
}

.auto-match p {
  margin: 5px 0 0;
  color: #68737a;
  font-size: 12px;
}

.auto-match-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.stat-pill {
  min-height: 58px;
  border: 1px solid #dde5e4;
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
}

.stat-pill span {
  display: block;
  color: #68737a;
  font-size: 12px;
}

.stat-pill strong {
  display: block;
  margin-top: 4px;
  color: #172528;
  font-size: 20px;
}

.sample-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.sample-row {
  display: grid;
  grid-template-columns: 90px 1fr 130px 100px;
  gap: 10px;
  align-items: center;
  border-top: 1px solid #edf1f1;
  padding-top: 8px;
  color: #506067;
  font-size: 13px;
}

.diagnostic-stats {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.issue-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.issue {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid #edf1f1;
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
  color: #506067;
  font-size: 13px;
}

.issue strong {
  color: #172528;
}

.issue.error {
  border-color: #ffd6c2;
  background: #fff8f4;
}

.issue.warn {
  border-color: #ffe5b8;
  background: #fffaf0;
}

.issue.ok {
  border-color: #cfecdf;
  background: #f5fbf8;
}

.diagnostic-section {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #edf1f1;
}

.diagnostic-row {
  grid-template-columns: 120px 130px 120px 150px 1fr;
}

.diagnostic-link-row {
  grid-template-columns: 120px 130px 1fr 130px;
}

.map-form {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 10px;
  margin-bottom: 14px;
}

.map-list {
  display: grid;
  gap: 10px;
}

.batch-form {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid #edf1f1;
  border-radius: 8px;
  background: #f8fbfb;
}

.batch-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.batch-head h3 {
  margin: 0;
  font-size: 15px;
}

.batch-head span {
  color: #68737a;
  font-size: 12px;
}

.batch-form button {
  justify-self: end;
}

.map-row {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid #edf1f1;
  border-radius: 8px;
  padding: 10px;
}

.map-row button {
  background: #eef3f5;
  color: #506067;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 40px));
  padding: 12px 16px;
  border-radius: 8px;
  background: #172528;
  color: #ffffff;
  box-shadow: 0 12px 40px rgba(23, 37, 40, 0.24);
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .detail-grid,
  .actions,
    .import-form,
    .map-form,
    .map-row,
    .auto-match-head,
    .auto-match-stats,
    .sample-row,
    .diagnostic-stats,
    .diagnostic-row,
    .diagnostic-link-row {
    grid-template-columns: 1fr;
  }

  .phone-form {
    grid-template-columns: 1fr;
  }
}
