:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef3f7;
  --line: #d7dee8;
  --ink: #1f2933;
  --muted: #647084;
  --brand: #1769e0;
  --brand-2: #0f9f7a;
  --danger: #c93552;
  --shadow: 0 16px 40px rgba(22, 34, 51, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button,
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
}

button {
  min-height: 40px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

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

button.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

textarea,
input,
select {
  width: 100%;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
  padding: 12px;
}

input {
  min-height: 42px;
  padding: 0 12px;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-card {
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #f0b7c2;
  border-radius: 8px;
  background: #fff1f4;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

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

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

.status-pill {
  min-width: 120px;
  padding: 8px 12px;
  border: 1px solid #bed6f8;
  border-radius: 999px;
  background: #eaf3ff;
  color: #1458bd;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.tenant-pill {
  max-width: 220px;
  overflow: hidden;
  padding: 8px 12px;
  border: 1px solid #b9dfd0;
  border-radius: 999px;
  background: #ebfaf4;
  color: #0f6b52;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

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

.metric {
  min-height: 96px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 32px;
}

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

.admin-shell {
  width: min(980px, 100%);
}

.admin-grid {
  display: grid;
  gap: 16px;
}

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

.control-panel {
  padding: 16px;
}

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

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

.results-panel .panel-heading {
  padding: 16px 16px 0;
}

.selection-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.selection-bar button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pagination-bar div {
  display: flex;
  gap: 8px;
}

.pagination-bar button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.source-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.source-card {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 70px;
  padding: 10px;
  text-align: left;
}

.source-card.is-selected {
  border-color: var(--brand);
  background: #eef5ff;
}

.source-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}

.source-copy strong,
.source-copy small {
  display: block;
}

.source-copy small {
  margin-top: 2px;
  color: var(--muted);
}

.source-phase {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.query-box {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.batch-controls {
  display: grid;
  grid-template-columns: 72px 72px minmax(0, 1fr);
  gap: 8px;
}

.batch-controls input {
  min-height: 40px;
  padding: 0 8px;
}

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

.transfer-actions button {
  border-color: #b9dfd0;
  background: #ebfaf4;
  color: #0f6b52;
  font-weight: 700;
}

.job-list {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.job-list h3 {
  margin: 0;
  font-size: 14px;
}

.job-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.small-danger {
  min-height: 30px;
  padding: 0 10px;
  border-color: #f0b7c2;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}

.small-action {
  min-height: 30px;
  width: fit-content;
  padding: 0 10px;
  border-color: #bed6f8;
  color: #1458bd;
  font-size: 12px;
  font-weight: 700;
}

.job-rows {
  display: grid;
  gap: 8px;
}

.job-row,
.job-empty {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: 12px;
}

.job-row {
  display: grid;
  gap: 3px;
}

.job-row strong {
  color: var(--brand);
}

.job-row span,
.job-row small,
.job-empty {
  color: var(--muted);
}

.job-message {
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.credential-panel {
  display: grid;
  gap: 10px;
}

.credential-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.credential-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.credential-heading h3 {
  margin: 0;
}

.credential-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.credential-rows {
  display: grid;
  gap: 8px;
}

.credential-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.credential-row strong,
.credential-row small {
  display: block;
}

.credential-row small {
  margin-top: 3px;
  color: var(--muted);
}

.audit-row {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: 12px;
}

.audit-row strong,
.audit-row small {
  display: block;
}

.audit-row small {
  color: var(--muted);
}

.audit-row code {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credential-row-actions,
.credential-actions {
  display: flex;
  gap: 6px;
}

.credential-row-actions span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #b9dfd0;
  border-radius: 999px;
  background: #ebfaf4;
  color: #0f6b52;
  font-size: 12px;
  font-weight: 700;
}

.credential-row-actions button {
  min-width: 38px;
  min-height: 34px;
  padding: 0 8px;
  font-size: 12px;
}

.credential-actions {
  display: grid;
  grid-template-columns: auto 1fr;
}

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

.provider-tabs button.is-selected {
  border-color: var(--brand);
  background: #eef5ff;
  color: #1458bd;
  font-weight: 800;
}

.provider-panel {
  display: grid;
  gap: 10px;
}

.filters {
  display: grid;
  grid-template-columns: 150px 170px minmax(180px, 240px);
  gap: 8px;
  align-items: center;
  width: min(100%, 580px);
}

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

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

.select-col {
  width: 54px;
}

.row-select {
  width: auto;
}

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

th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.empty-row {
  height: 220px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 920px) {
  .app-shell {
    padding: 14px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .topbar,
  .topbar-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-wrap {
    max-height: none;
  }

  .filters {
    grid-template-columns: 1fr;
    width: 100%;
  }
}
