:root {
  color: #17202f;
  background: #eef2f6;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #f8fafc;
  border-right: 1px solid #d8e0ea;
  padding: 24px;
  overflow-y: auto;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #153e6f;
  color: #fff;
  font-weight: 800;
  border-radius: 8px;
}

h1,
h2,
p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.2;
}

.brand p,
.field span,
.hint,
.account-option small,
.status-line,
.topbar p,
.metric span {
  color: #667085;
  font-size: 12px;
}

.panel {
  padding: 16px 0;
  border-top: 1px solid #e2e8f0;
}

.panel h2 {
  font-size: 13px;
  margin-bottom: 12px;
}

.hint {
  line-height: 1.5;
  margin-top: -4px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

input[type="file"],
input[type="date"],
input[type="text"],
input[type="search"],
select,
textarea {
  width: 100%;
  border: 1px solid #cfd8e3;
  background: #fff;
  border-radius: 6px;
  padding: 9px 10px;
  color: #17202f;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 74px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #2f6fab;
  box-shadow: 0 0 0 3px rgba(47, 111, 171, 0.14);
}

.check-row,
.account-option,
.staff-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.inline-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: -2px 0 12px;
}

.inline-actions.single-action {
  grid-template-columns: 1fr;
}

.secondary-button {
  border: 1px solid #b8c9d9;
  border-radius: 6px;
  background: #fff;
  color: #1f5f98;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 10px;
}

.secondary-button:disabled {
  color: #98a2b3;
  cursor: not-allowed;
}

a.secondary-button {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  text-decoration: none;
}

a.secondary-button.disabled {
  color: #98a2b3;
  cursor: not-allowed;
  pointer-events: none;
}

.preset-list,
.account-list,
.staff-list {
  display: grid;
  gap: 8px;
}

.account-list {
  max-height: 260px;
  overflow: auto;
  margin-bottom: 12px;
  padding-right: 2px;
}

.preset,
.account-option {
  width: 100%;
  text-align: left;
  border: 1px solid #d8e0ea;
  border-radius: 6px;
  background: #fff;
  padding: 10px;
}

.preset {
  cursor: pointer;
  color: #1c4975;
}

.account-option strong {
  display: block;
  font-size: 13px;
}

.account-option.selected {
  border-color: #9ec2df;
  background: #f0f7fc;
}

.account-option.candidate {
  border-style: dashed;
  background: #fffaf1;
}

.account-option small {
  display: block;
  margin-top: 2px;
}

.account-search-hint {
  min-height: 36px;
}

.account-discovery {
  border: 1px solid #dce5ee;
  border-radius: 8px;
  background: #fbfcfe;
  margin: 12px 0;
  padding: 10px;
}

.account-discovery summary {
  color: #344054;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.account-discovery[open] summary {
  margin-bottom: 10px;
}

.candidate-list {
  max-height: 190px;
  margin: 10px 0;
}

.temporary-account-form {
  border-top: 1px solid #e2e8f0;
  margin-top: 12px;
  padding-top: 12px;
}

.temporary-account-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.temporary-account {
  align-items: center;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 8px 9px;
}

.temporary-account strong,
.temporary-account small {
  display: block;
}

.temporary-account strong {
  color: #7c2d12;
  font-size: 12px;
}

.temporary-account small {
  color: #9a3412;
  font-size: 11px;
  margin-top: 2px;
}

.remove-temporary {
  background: transparent;
  border: 0;
  color: #9a3412;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 4px;
}

.advanced-section {
  border-top: 1px solid #dce5ee;
  margin: 12px 0;
  padding-top: 12px;
}

.advanced-section summary {
  color: #344054;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
}

.staff-list {
  max-height: 245px;
  overflow: auto;
  margin-bottom: 12px;
  padding-right: 2px;
}

.staff-option {
  border: 1px solid #d8e0ea;
  border-radius: 6px;
  background: #fff;
  padding: 9px;
}

.staff-option.selected {
  border-color: #9ec2df;
  background: #f0f7fc;
}

.staff-option strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}

.staff-option small {
  display: block;
  color: #667085;
  font-size: 11px;
  line-height: 1.35;
  margin-top: 2px;
}

.primary-button {
  width: 100%;
  border: 0;
  border-radius: 7px;
  background: #1f5f98;
  color: #fff;
  font-weight: 700;
  padding: 12px 16px;
  cursor: pointer;
  margin-top: 14px;
}

.primary-button:disabled {
  opacity: 0.58;
  cursor: wait;
}

.run-panel {
  background: #f8fafc;
  border-top: 1px solid #d8e0ea;
  bottom: 0;
  margin: 14px -24px -24px;
  padding: 14px 24px 18px;
  position: sticky;
}

.run-panel .primary-button {
  margin-top: 0;
}

.run-panel .hint {
  margin-top: 8px;
}

.status-line {
  margin-top: 10px;
  min-height: 18px;
}

.status-line[data-tone="error"] {
  color: #b42318;
}

.status-line[data-tone="success"] {
  color: #027a48;
}

.status-line[data-tone="loading"] {
  color: #1f5f98;
}

.workspace {
  padding: 24px;
  overflow: hidden;
}

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

.topbar h2 {
  font-size: 22px;
  line-height: 1.25;
}

.result-quality {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 750;
  margin-top: 8px;
  padding: 4px 9px;
}

.result-quality.official {
  background: #ecfdf3;
  color: #027a48;
}

.result-quality.diagnostic,
.result-quality.fallback {
  background: #fff7ed;
  color: #b54708;
}

.result-quality.neutral {
  background: #f2f4f7;
  color: #667085;
}

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

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  height: 36px;
  color: #1f5f98;
  border: 1px solid #b8c9d9;
  border-radius: 6px;
  text-decoration: none;
  background: #fff;
  font-size: 13px;
  font-weight: 650;
}

.ghost-button.disabled {
  color: #98a2b3;
  pointer-events: none;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-grid.compact {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
}

.metric {
  background: #fff;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  padding: 14px;
}

.metric strong {
  display: block;
  font-size: 24px;
  line-height: 1.2;
  margin-top: 6px;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.method-card {
  background: #fff;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  padding: 13px 14px;
}

.method-card span {
  display: block;
  color: #667085;
  font-size: 12px;
  margin-bottom: 6px;
}

.method-card strong {
  display: block;
  font-size: 15px;
  line-height: 1.35;
  color: #17202f;
}

.method-card p {
  color: #667085;
  font-size: 12px;
  line-height: 1.5;
  margin-top: 6px;
}

.method-card[data-tone="warning"] {
  border-color: #f4c790;
  background: #fff8ed;
}

.interaction-panel {
  background: #fff;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.section-kicker,
.freshness {
  color: #667085;
  font-size: 12px;
}

.section-head h3,
.mini-table h4 {
  margin: 0;
}

.section-head h3 {
  font-size: 17px;
  line-height: 1.3;
  margin-top: 4px;
}

.scope-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}

.scope-button {
  border: 1px solid #cfd8e3;
  border-radius: 6px;
  background: #fff;
  color: #475467;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 11px;
}

.scope-button.active {
  background: #e8f1f8;
  border-color: #9ec2df;
  color: #153e6f;
}

.split-tables {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 12px;
}

.mini-table {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.mini-table h4 {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  color: #344054;
  font-size: 13px;
  padding: 10px 12px;
}

.mini-table table {
  font-size: 12px;
}

.results-panel {
  background: #fff;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  overflow: hidden;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #e2e8f0;
  padding: 10px;
}

.tab {
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  background: transparent;
  color: #475467;
  cursor: pointer;
}

.tab.active {
  background: #e8f1f8;
  color: #153e6f;
  font-weight: 700;
}

.tabs input {
  margin-left: auto;
  max-width: 280px;
}

.table-wrap {
  max-height: calc(100vh - 245px);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid #edf1f5;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475467;
  font-size: 12px;
  font-weight: 750;
  z-index: 1;
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.matched {
  background: #ecfdf3;
  color: #027a48;
}

.status-pill.unmatched {
  background: #fff7ed;
  color: #b54708;
}

.status-pill.internal {
  background: #f2f4f7;
  color: #475467;
}

.empty {
  color: #98a2b3;
  text-align: center;
  padding: 40px;
}

.empty.slim {
  border: 1px dashed #d8e0ea;
  border-radius: 6px;
  padding: 18px 10px;
  font-size: 12px;
}

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid #d8e0ea;
    overflow: visible;
  }

  .run-panel {
    margin: 14px -24px -24px;
    position: static;
  }

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

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

  .metric-grid.compact,
  .split-tables {
    grid-template-columns: 1fr;
  }

  .tabs input {
    max-width: none;
  }
}
