:root {
  color-scheme: light;
  --content-gutter: clamp(20px, 4vw, 64px);
  --ink: #171a18;
  --muted: #687068;
  --paper: #f2f4ef;
  --surface: #ffffff;
  --surface-2: #e9ede7;
  --line: #c7cec6;
  --line-strong: #8e978f;
  --accent: #b7ef45;
  --blue: #2457d6;
  --blue-soft: #e9efff;
  --danger: #c7362f;
  --danger-soft: #fff0ed;
  --warning: #b76508;
  --warning-soft: #fff3d9;
  --success: #28713a;
  --success-soft: #e9f7e6;
  font-family: "Avenir Next", "Noto Sans SC", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
input, select, textarea { color: var(--ink); }

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px var(--content-gutter);
  border-bottom: 1px solid var(--ink);
  background: var(--surface);
}

.brand-block, .target-block { min-width: 0; display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  background: var(--ink);
  color: var(--accent);
  font: 800 16px/1 ui-monospace, "SFMono-Regular", monospace;
}
.kicker, .step, .meta-label { margin: 0; font: 700 11px/1.2 ui-monospace, "SFMono-Regular", monospace; color: var(--muted); }
h1, h2 { margin: 3px 0 0; font-weight: 700; letter-spacing: 0; }
h1 { font-size: 22px; }
h2 { font-size: 20px; }
.signal { width: 10px; height: 10px; flex: 0 0 10px; background: var(--line); border: 1px solid var(--ink); }
.signal.connected { background: var(--accent); }
.signal.error { background: var(--danger); }
.target-block > div { min-width: 0; }
.target-block strong { display: block; margin-top: 4px; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; font-size: 13px; white-space: nowrap; }

.connection-band {
  width: min(1600px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(220px, 3fr) minmax(360px, 5fr) 132px minmax(150px, 2fr);
  gap: 18px;
  align-items: end;
  padding: 18px var(--content-gutter);
  border-bottom: 1px solid var(--line);
}

.field { display: grid; gap: 7px; min-width: 0; }
.field > span:first-child { font: 700 11px/1 ui-monospace, "SFMono-Regular", monospace; color: var(--muted); }
.field input, .field select, .monitor-refresh-controls select, .more-action-control select, .table-pagination select {
  width: 100%;
  height: 40px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface);
  padding: 0 11px;
  outline: none;
}
.field input:focus, .field select:focus, textarea:focus, select:focus {
  border-color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}
.field input:invalid { border-color: var(--danger); box-shadow: inset 3px 0 0 var(--danger); }
.admin-token-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.admin-token-control input { border-right: 0; border-radius: 2px 0 0 2px; }
.admin-token-control output {
  display: grid;
  place-items: center;
  min-width: 142px;
  min-height: 40px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--accent);
  padding: 0 10px;
  font: 700 11px/1 ui-monospace, "SFMono-Regular", monospace;
}
.primary-command {
  height: 40px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--ink);
  color: white;
  padding: 0 16px;
  font-weight: 700;
  white-space: nowrap;
}
.primary-command:not(:disabled):hover { background: var(--blue); border-color: var(--blue); }
.connection-status {
  min-height: 40px;
  display: flex;
  align-items: center;
  border-left: 3px solid var(--line-strong);
  padding: 0 11px;
  color: var(--muted);
  font-size: 12px;
}
.connection-status.connected { border-color: var(--success); color: var(--success); }
.connection-status.error { border-color: var(--danger); color: var(--danger); }

.workspace-tabs {
  width: min(1600px, 100%);
  height: 58px;
  margin: 0 auto;
  display: flex;
  padding: 0 var(--content-gutter);
  border-bottom: 1px solid var(--ink);
  background: var(--surface);
}
.workspace-tab {
  width: min(240px, 50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 0 18px;
  color: var(--muted);
  font-weight: 700;
}
.workspace-tab:first-child { border-left: 1px solid var(--line); }
.workspace-tab small { font: 700 10px/1 ui-monospace, "SFMono-Regular", monospace; }
.workspace-tab:hover { background: var(--surface-2); color: var(--ink); }
.workspace-tab.active { background: var(--ink); color: white; }
.workspace-tab.active small { color: var(--accent); }

main { width: min(1600px, 100%); margin: 0 auto; }
.view { min-height: calc(100vh - 218px); }
.import-config-band {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(380px, .85fr);
  gap: 0;
  border-bottom: 1px solid var(--line);
}
.import-config-fields,
.import-defaults-pane {
  min-width: 0;
  padding: 20px var(--content-gutter);
}
.import-config-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: end;
}
.import-defaults-pane {
  display: flex;
  align-items: end;
  border-left: 1px solid var(--ink);
}
.defaults { display: flex; flex-wrap: wrap; gap: 5px; padding-bottom: 1px; }
.defaults span { padding: 9px 10px; border: 1px solid var(--ink); background: var(--surface); font: 700 10px/1 ui-monospace, "SFMono-Regular", monospace; }
.defaults span:last-child { background: var(--accent); }

.import-workspace { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(380px, .85fr); }
.input-pane, .review-pane { min-width: 0; padding: 30px var(--content-gutter) 36px; }
.input-pane { border-right: 1px solid var(--ink); }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 22px; }
.quiet-button { border: 0; border-bottom: 1px solid var(--ink); background: transparent; padding: 5px 0; color: var(--ink); font-size: 12px; }
.quiet-button:hover { color: var(--blue); border-color: var(--blue); }
.paste-field { display: block; }
textarea {
  width: 100%;
  height: 320px;
  resize: vertical;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--surface);
  padding: 18px;
  outline: none;
  font: 13px/1.7 ui-monospace, "SFMono-Regular", monospace;
}
.mapping-list { display: grid; gap: 6px; margin-top: 14px; }
.mapping-line { display: grid; grid-template-columns: 120px auto minmax(0, 1fr); align-items: start; gap: 12px; font: 12px/1.2 ui-monospace, "SFMono-Regular", monospace; }
.mapping-line span:nth-child(2) { color: var(--blue); }
.mapping-line strong { overflow-wrap: anywhere; }
.counter { display: flex; align-items: baseline; gap: 6px; }
.counter strong { font: 800 34px/1 ui-monospace, "SFMono-Regular", monospace; }
.counter span { color: var(--muted); font-size: 12px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); background: var(--surface); }
.summary-grid > div { padding: 13px; border-right: 1px solid var(--line); }
.summary-grid > div:last-child { border-right: 0; }
.summary-grid span, .summary-grid strong { display: block; }
.summary-grid span { color: var(--muted); font-size: 11px; }
.summary-grid strong { margin-top: 6px; font: 700 17px/1 ui-monospace, "SFMono-Regular", monospace; }
.preview-list { height: 280px; margin: 14px 0; overflow: auto; border-top: 1px solid var(--line); }
.preview-row, .result-row { display: grid; align-items: center; gap: 12px; min-height: 46px; border-bottom: 1px solid var(--line); }
.preview-row { grid-template-columns: 32px minmax(0, 1fr) auto; }
.preview-row .index { color: var(--muted); font: 11px/1 ui-monospace, "SFMono-Regular", monospace; }
.preview-row .identity { min-width: 0; }
.preview-row strong, .preview-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-row strong { font-size: 13px; }
.preview-row small { margin-top: 3px; color: var(--muted); }
.badge, .channel-tag, .state-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 4px 7px;
  border: 1px solid currentColor;
  border-radius: 2px;
  font: 700 10px/1 ui-monospace, "SFMono-Regular", monospace;
  white-space: nowrap;
}
.badge.valid, .state-tag.good { color: var(--success); background: var(--success-soft); }
.badge.invalid, .state-tag.bad { color: var(--danger); background: var(--danger-soft); }
.badge.duplicate, .state-tag.warn { color: var(--warning); background: var(--warning-soft); }
.state-tag.neutral { color: #59615b; background: var(--surface-2); }
.submit-button {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--ink);
  color: white;
  padding: 0 18px;
  font-weight: 700;
}
.submit-button:not(:disabled):hover { background: var(--blue); }
.results-band { padding: 30px var(--content-gutter) 50px; border-top: 1px solid var(--ink); background: var(--surface); }
.result-summary { margin: 0; color: var(--muted); font: 12px/1.5 ui-monospace, "SFMono-Regular", monospace; }
.results-list { border-top: 1px solid var(--ink); }
.result-row { grid-template-columns: 110px minmax(0, 1fr) 90px; }
.result-row .result-type { font: 700 11px/1 ui-monospace, "SFMono-Regular", monospace; }
.result-row.created .result-type { color: var(--success); }
.result-row.existing .result-type { color: var(--warning); }
.result-row.failed .result-type { color: var(--danger); }
.result-row span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; }
.result-row code { text-align: right; color: var(--muted); }

.monitor-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px var(--content-gutter) 20px;
  background: var(--surface);
}
.monitor-refresh-controls { display: flex; align-items: center; gap: 8px; }
.monitor-refresh-controls select { width: 100px; }
.switch-control { min-height: 40px; display: inline-flex; align-items: center; gap: 9px; padding: 0 10px; border: 1px solid var(--line); background: var(--surface); }
.switch-control input { position: absolute; opacity: 0; pointer-events: none; }
.switch-control > span { width: 31px; height: 18px; border: 1px solid var(--line-strong); background: var(--surface-2); padding: 2px; }
.switch-control > span::after { content: ""; display: block; width: 12px; height: 12px; background: var(--line-strong); transition: transform .16s ease; }
.switch-control input:checked + span { border-color: var(--ink); background: var(--accent); }
.switch-control input:checked + span::after { transform: translateX(13px); background: var(--ink); }
.switch-control b { font-size: 12px; white-space: nowrap; }

.metric-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); background: var(--surface); }
.metric-strip button { min-width: 0; min-height: 116px; display: grid; align-content: space-between; gap: 8px; border: 0; border-right: 1px solid var(--line); background: transparent; padding: 16px 18px; text-align: left; }
.metric-strip button:last-child { border-right: 0; }
.metric-strip button:hover { background: var(--surface-2); }
.metric-strip span { color: var(--muted); font-size: 12px; }
.metric-strip strong { font: 800 30px/1 ui-monospace, "SFMono-Regular", monospace; }
.metric-strip small { min-height: 14px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.filter-band { padding: 22px var(--content-gutter); border-bottom: 1px solid var(--line); }
.filter-primary-grid { display: grid; grid-template-columns: minmax(260px, 2fr) repeat(5, minmax(118px, 1fr)); gap: 12px; }
.advanced-filters { margin-top: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.advanced-filters summary { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 20px; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 700; list-style: none; }
.advanced-filters summary::-webkit-details-marker { display: none; }
.advanced-filters summary::before { content: "+"; display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 8px; border: 1px solid var(--line-strong); color: var(--ink); }
.advanced-filters[open] summary::before { content: "−"; }
.advanced-filters summary span { margin-right: auto; }
.advanced-filters summary small { color: var(--blue); font: 700 10px/1 ui-monospace, "SFMono-Regular", monospace; }
.filter-advanced-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; padding: 4px 0 16px; }
.range-control { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 5px; }
.range-control i, .suffix-input i { color: var(--muted); font-size: 11px; font-style: normal; }
.range-control input { min-width: 0; padding: 0 7px; }
.filter-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 14px; }
.filter-preset-row { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-preset-row button { min-height: 30px; border: 1px solid var(--line-strong); border-radius: 2px; background: var(--surface); padding: 0 10px; color: var(--muted); font-size: 11px; }
.filter-preset-row button:hover { border-color: var(--blue); color: var(--blue); }

.batch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px var(--content-gutter);
  border-bottom: 1px solid var(--ink);
  background: var(--ink);
  color: white;
}
.selection-summary { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.selection-summary strong { color: var(--accent); font: 800 20px/1 ui-monospace, "SFMono-Regular", monospace; }
.selection-summary span { margin-right: 6px; color: #c9cec9; font-size: 11px; }
.selection-summary button { border: 0; border-bottom: 1px solid #8e9790; background: transparent; padding: 4px 0; color: #e7eae7; font-size: 10px; }
.batch-commands { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.batch-commands > button, .more-action-control button { min-height: 34px; border: 1px solid #727a73; border-radius: 2px; background: #292e2a; color: white; padding: 0 11px; font-size: 11px; font-weight: 700; }
.batch-commands > button:not(:disabled):hover, .more-action-control button:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.more-action-control { display: grid; grid-template-columns: 126px 48px; }
.more-action-control select { height: 34px; border-color: #727a73; border-radius: 2px 0 0 2px; background: #292e2a; color: white; padding: 0 7px; font-size: 11px; }
.more-action-control button { border-left: 0; border-radius: 0 2px 2px 0; }
.operation-result { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; padding: 14px var(--content-gutter); border-bottom: 1px solid var(--line); background: var(--blue-soft); }
.operation-result > div { display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline; }
.operation-result strong { color: var(--blue); font-size: 12px; }
.operation-result span { color: var(--muted); font-size: 12px; }
.operation-result > button { width: 26px; height: 26px; border: 0; background: transparent; font-size: 20px; }
.operation-result ol { grid-column: 1 / -1; max-height: 120px; margin: 0; overflow: auto; padding-left: 22px; color: var(--danger); font: 11px/1.6 ui-monospace, "SFMono-Regular", monospace; }

.account-table-section { padding: 0 var(--content-gutter) 42px; }
.table-meta { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); font: 11px/1.3 ui-monospace, "SFMono-Regular", monospace; }
.account-table-wrap { position: relative; max-height: min(66vh, 760px); overflow: auto; border: 1px solid var(--ink); background: var(--surface); }
.account-table { width: 100%; min-width: 1240px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.account-table th { position: sticky; top: 0; z-index: 2; height: 42px; border-bottom: 1px solid var(--ink); border-right: 1px solid var(--line); background: var(--surface-2); padding: 0 10px; color: var(--muted); text-align: left; font-size: 10px; }
.account-table th:last-child { border-right: 0; }
.account-table th button { width: 100%; height: 100%; border: 0; background: transparent; padding: 0; color: inherit; text-align: left; font-weight: 700; }
.account-table th button:hover, .account-table th button.sorted { color: var(--blue); }
.account-table th:nth-child(1) { width: 42px; text-align: center; }
.account-table th:nth-child(2) { width: 250px; }
.account-table th:nth-child(3) { width: 150px; }
.account-table th:nth-child(4) { width: 180px; }
.account-table th:nth-child(5) { width: 190px; }
.account-table th:nth-child(6) { width: 150px; }
.account-table th:nth-child(7) { width: 130px; }
.account-table th:nth-child(8) { width: 170px; }
.account-table td { height: 70px; border-bottom: 1px solid var(--line); border-right: 1px solid #e1e5df; padding: 9px 10px; vertical-align: middle; font-size: 12px; }
.account-table tr:last-child td { border-bottom: 0; }
.account-table td:last-child { border-right: 0; }
.account-table tbody tr:hover td { background: #f8faf6; }
.account-table tbody tr.selected td { background: #f0f6dc; }
.select-column, .account-table td:first-child { text-align: center; }
.account-table input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--blue); }
.account-identity { min-width: 0; }
.account-identity strong, .account-identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-identity strong { font-size: 12px; }
.account-identity small { margin-top: 4px; color: var(--muted); font: 10px/1.2 ui-monospace, "SFMono-Regular", monospace; }
.account-identity em { display: block; margin-top: 3px; overflow: hidden; color: var(--danger); font-size: 10px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.channel-cell, .state-cell { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.channel-tag { color: var(--blue); background: var(--blue-soft); }
.group-list { width: 100%; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.usage-cell { display: grid; gap: 7px; }
.usage-line { display: grid; grid-template-columns: 20px minmax(0, 1fr) 36px; align-items: center; gap: 6px; }
.usage-line > span { color: var(--muted); font: 9px/1 ui-monospace, "SFMono-Regular", monospace; }
.usage-line > strong { text-align: right; font: 700 10px/1 ui-monospace, "SFMono-Regular", monospace; }
.usage-track { height: 7px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.usage-fill { height: 100%; width: var(--usage-width, 0%); background: var(--success); }
.usage-fill.warning { background: var(--warning); }
.usage-fill.danger { background: var(--danger); }
.today-cell strong, .today-cell span, .load-cell strong, .load-cell span, .activity-cell strong, .activity-cell span { display: block; }
.today-cell strong, .load-cell strong { font: 700 12px/1.25 ui-monospace, "SFMono-Regular", monospace; }
.today-cell span, .load-cell span, .activity-cell span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.activity-cell strong { font-size: 11px; }
.table-empty { min-height: 240px; display: grid; place-items: center; color: var(--muted); font: 12px/1 ui-monospace, "SFMono-Regular", monospace; }
.table-pagination { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.table-pagination label, .table-pagination div { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.table-pagination select { width: 72px; height: 32px; }
.table-pagination button { min-width: 62px; height: 32px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 11px; }
.table-pagination output { min-width: 70px; text-align: center; font: 11px/1 ui-monospace, "SFMono-Regular", monospace; }

.bulk-dialog { width: min(640px, calc(100vw - 28px)); max-height: calc(100vh - 28px); border: 1px solid var(--ink); border-radius: 3px; background: var(--surface); padding: 0; color: var(--ink); }
.bulk-dialog::backdrop { background: rgba(23, 26, 24, .62); }
.bulk-dialog form { display: grid; }
.bulk-dialog header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--ink); }
.bulk-dialog header > button { width: 32px; height: 32px; border: 0; background: transparent; font-size: 22px; }
.bulk-field-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 14px 20px; }
.bulk-field { min-height: 66px; display: grid; grid-template-columns: 20px 108px minmax(0, 1fr); align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 8px 10px 8px 0; font-size: 12px; }
.bulk-field:nth-child(odd) { margin-right: 12px; }
.bulk-field > input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--blue); }
.bulk-field > input[type="number"], .bulk-field select, .suffix-input { width: 100%; height: 36px; border: 1px solid var(--line); background: var(--surface); padding: 0 8px; }
.bulk-field > input:disabled, .bulk-field select:disabled, .suffix-input:has(input:disabled) { background: var(--surface-2); color: var(--muted); }
.suffix-input { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding-right: 9px; }
.suffix-input input { width: 100%; min-width: 0; height: 32px; border: 0; background: transparent; outline: none; }
.confirm-risk { display: flex; align-items: center; gap: 8px; padding: 8px 20px 18px; color: var(--warning); font-size: 11px; }
.bulk-dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
.bulk-dialog footer button { min-height: 38px; border: 1px solid var(--line-strong); background: var(--surface); padding: 0 16px; font-weight: 700; }
.bulk-dialog footer button:last-child { border-color: var(--ink); background: var(--ink); color: white; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(440px, calc(100vw - 44px)); padding: 13px 16px; border: 1px solid var(--ink); background: var(--ink); color: white; transform: translateY(30px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.visible { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }
.empty-state { display: grid; place-items: center; height: 100%; color: var(--muted); font: 12px/1 ui-monospace, "SFMono-Regular", monospace; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

@media (max-width: 1220px) {
  .connection-band { grid-template-columns: minmax(210px, 1fr) minmax(340px, 1.5fr) 120px; }
  .connection-status { grid-column: 1 / -1; min-height: 30px; }
  .metric-strip { grid-template-columns: repeat(3, 1fr); }
  .metric-strip button:nth-child(3) { border-right: 0; }
  .metric-strip button:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .filter-primary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .search-field { grid-column: span 2; }
  .filter-advanced-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .batch-bar { align-items: flex-start; flex-direction: column; }
  .batch-commands { justify-content: flex-start; }
}

@media (max-width: 900px) {
  .connection-band { grid-template-columns: 1fr 1fr; }
  .primary-command { min-width: 0; }
  .connection-status { grid-column: auto; }
  .import-config-band { grid-template-columns: 1fr; }
  .import-defaults-pane { border-top: 1px solid var(--line); border-left: 0; }
  .import-workspace { grid-template-columns: 1fr; }
  .input-pane { border-right: 0; border-bottom: 1px solid var(--ink); }
  .filter-advanced-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bulk-field-list { grid-template-columns: 1fr; }
  .bulk-field:nth-child(odd) { margin-right: 0; }
}

@media (max-width: 680px) {
  .topbar { min-height: 78px; align-items: flex-start; gap: 12px; padding: 14px 18px; }
  .brand-block { gap: 10px; }
  .brand-mark { width: 44px; height: 44px; flex-basis: 44px; }
  .brand-block h1 { font-size: 18px; white-space: nowrap; }
  .target-block { max-width: 43%; flex: 0 1 43%; padding-top: 6px; }
  .target-block strong { max-width: 100%; }
  .connection-band { grid-template-columns: 1fr; padding: 16px 18px; }
  .connection-status { min-height: 34px; }
  .admin-token-control { grid-template-columns: 1fr; }
  .admin-token-control input { border-right: 1px solid var(--line); border-radius: 2px 2px 0 0; }
  .admin-token-control output { min-height: 32px; }
  .workspace-tabs { height: 52px; padding: 0 18px; }
  .workspace-tab { width: 50%; padding: 0 10px; }
  .import-config-fields { grid-template-columns: 1fr; }
  .import-config-fields, .import-defaults-pane { padding: 18px; }
  .import-defaults-pane { border-top: 1px solid var(--line); }
  .input-pane, .review-pane, .results-band { padding-left: 18px; padding-right: 18px; }
  textarea { height: 280px; }
  .result-row { grid-template-columns: 78px minmax(0, 1fr); padding: 9px 0; }
  .result-row code { grid-column: 2; text-align: left; }
  .monitor-head { align-items: flex-start; flex-direction: column; padding: 20px 18px 16px; }
  .monitor-refresh-controls { width: 100%; display: grid; grid-template-columns: 1fr 90px; }
  .monitor-refresh-controls .primary-command { grid-column: 1 / -1; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .metric-strip button { min-height: 104px; }
  .metric-strip button:nth-child(2n) { border-right: 0; }
  .metric-strip button:nth-child(3) { border-right: 1px solid var(--line); }
  .metric-strip button:nth-child(4) { border-bottom: 1px solid var(--line); }
  .filter-band { padding: 18px; }
  .filter-primary-grid, .filter-advanced-grid { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .filter-footer { align-items: flex-start; flex-direction: column; }
  .batch-bar { padding: 12px 18px; }
  .selection-summary { width: 100%; flex-wrap: wrap; }
  .batch-commands { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .batch-commands > button { min-width: 0; }
  .more-action-control { grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr) 52px; }
  .operation-result { padding: 14px 18px; }
  .account-table-section { padding: 0 18px 30px; }
  .table-meta { align-items: flex-start; flex-direction: column; justify-content: center; padding: 8px 0; }
  .account-table-wrap { max-height: 68vh; }
  .table-pagination { align-items: flex-start; flex-direction: column; padding: 12px 0; }
  .table-pagination div { width: 100%; justify-content: space-between; }
  .bulk-field { grid-template-columns: 20px 100px minmax(0, 1fr); }
  .bulk-dialog footer button { flex: 1; padding: 0 8px; }
}

html[data-ui-mode="embedded"] {
  --content-gutter: clamp(18px, 2vw, 40px);
}

/* Keep full-width layout geometry, but confine visible bands to the shared rail. */
html[data-ui-mode="embedded"] .topbar,
html[data-ui-mode="embedded"] .connection-band,
html[data-ui-mode="embedded"] .workspace-tabs,
html[data-ui-mode="embedded"] .import-config-band,
html[data-ui-mode="embedded"] .results-band,
html[data-ui-mode="embedded"] .monitor-head,
html[data-ui-mode="embedded"] .metric-strip,
html[data-ui-mode="embedded"] .filter-band,
html[data-ui-mode="embedded"] .batch-bar,
html[data-ui-mode="embedded"] .operation-result,
html[data-ui-mode="embedded"] .account-table-section {
  clip-path: inset(0 var(--content-gutter));
}

html[data-ui-mode="embedded"] .connection-band,
html[data-ui-mode="embedded"] .workspace-tabs,
html[data-ui-mode="embedded"] main {
  width: 100%;
}

html[data-ui-mode="embedded"] .topbar {
  min-height: 72px;
  padding-top: 12px;
  padding-bottom: 12px;
}

html[data-ui-mode="embedded"] .brand-mark {
  width: 44px;
  height: 44px;
  flex-basis: 44px;
}

html[data-ui-mode="embedded"] .connection-band {
  padding-top: 12px;
  padding-bottom: 12px;
}

html[data-ui-mode="embedded"] .workspace-tabs {
  height: 52px;
}

html[data-ui-mode="embedded"] .monitor-head {
  padding-top: 14px;
  padding-bottom: 14px;
}

html[data-ui-mode="embedded"] .metric-strip button {
  min-height: 88px;
  padding: 12px 16px;
}

html[data-ui-mode="embedded"] .metric-strip strong {
  font-size: 26px;
}

html[data-ui-mode="embedded"] .metric-strip > button:first-child {
  padding-left: var(--content-gutter);
}

html[data-ui-mode="embedded"] .metric-strip > button:last-child {
  padding-right: var(--content-gutter);
}

html[data-ui-mode="embedded"] .filter-band {
  padding-top: 14px;
  padding-bottom: 14px;
}

html[data-ui-mode="embedded"] .advanced-filters {
  margin-top: 10px;
}

html[data-ui-mode="embedded"] .advanced-filters summary {
  min-height: 36px;
}

html[data-ui-mode="embedded"] .filter-footer {
  margin-top: 10px;
}

html[data-ui-mode="embedded"] .batch-bar {
  padding-top: 9px;
  padding-bottom: 9px;
}

html[data-ui-mode="embedded"] .account-table-section {
  padding-bottom: 10px;
}

html[data-ui-mode="embedded"] .table-meta {
  min-height: 38px;
}

html[data-ui-mode="embedded"] .table-pagination {
  min-height: 46px;
}

html[data-ui-mode="embedded"] .account-table-wrap {
  max-height: none;
}

@media (max-width: 1220px) {
  html[data-ui-mode="embedded"] .metric-strip > button:nth-child(3n + 1) {
    padding-left: var(--content-gutter);
  }

  html[data-ui-mode="embedded"] .metric-strip > button:nth-child(3n) {
    padding-right: var(--content-gutter);
  }
}

@media (max-width: 680px) {
  html[data-ui-mode="embedded"] .metric-strip > button {
    padding-left: 16px;
    padding-right: 16px;
  }

  html[data-ui-mode="embedded"] .metric-strip > button:nth-child(odd) {
    padding-left: var(--content-gutter);
  }

  html[data-ui-mode="embedded"] .metric-strip > button:nth-child(even) {
    padding-right: var(--content-gutter);
  }
}

@media (min-width: 1221px) and (min-height: 860px) {
  html[data-ui-mode="embedded"],
  html[data-ui-mode="embedded"] body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
  }

  html[data-ui-mode="embedded"] body {
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
  }

  html[data-ui-mode="embedded"] main {
    min-height: 0;
    overflow: hidden;
  }

  html[data-ui-mode="embedded"] .view {
    height: 100%;
    min-height: 0;
  }

  html[data-ui-mode="embedded"] #import-view:not([hidden]) {
    overflow: auto;
  }

  html[data-ui-mode="embedded"] #monitor-view:not([hidden]) {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: auto;
  }

  html[data-ui-mode="embedded"] #monitor-view > :not(.account-table-section) {
    flex: 0 0 auto;
  }

  html[data-ui-mode="embedded"] .account-table-section {
    min-height: 0;
    flex: 1 1 auto;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  html[data-ui-mode="embedded"] .account-table-wrap {
    min-height: 0;
    height: auto;
    overflow: auto;
    scrollbar-gutter: stable;
  }
}
