:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #34c759;
  --accent-2: #30d158;
  --danger: #bc2f32;
  --warning: #9a6700;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, Inter, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}

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

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  min-height: 40px;
  padding: 9px 14px;
  cursor: pointer;
  transition: border-color 200ms ease-out, box-shadow 200ms ease-out, background 200ms ease-out, transform 200ms ease-out;
}

button:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.07);
}

button:active {
  transform: scale(0.98);
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 44px;
  padding: 10px 12px;
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:hover,
textarea:hover,
select:hover,
input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 124, 102, 0.08);
  outline: none;
}

textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.5;
  font-size: 13px;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

button.small {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 12px;
}

.info-tip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  margin-left: 5px;
  border-radius: 50%;
  background: #f3f4f6;
  color: #8a94a3;
  font-size: 11px;
  font-weight: 500;
  cursor: help;
  vertical-align: middle;
}

.info-tip:hover::after,
.info-tip:focus::after {
  content: attr(data-tip);
  position: absolute;
  left: 24px;
  top: -8px;
  z-index: 120;
  width: 320px;
  max-width: min(320px, 70vw);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fcff;
  color: #6f96b6;
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.65;
  text-align: left;
  white-space: normal;
  word-break: break-word;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  padding: 20px;
  background: linear-gradient(180deg, #0f2f35 0%, #12242b 52%, #101820 100%);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #fff;
  font-weight: 800;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.brand span,
.sidebar-foot {
  color: #9fb3bf;
  font-size: 13px;
}

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

.nav-button {
  text-align: left;
  background: transparent;
  color: #c9d6df;
  border-color: transparent;
  border-radius: 10px;
}

.nav-button.active,
.nav-button:hover {
  background: rgba(54, 184, 156, 0.14);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(54, 184, 156, 0.22);
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.main {
  margin-left: 250px;
  padding: 24px 32px 32px;
}

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

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

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

.top-status {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  color: #64748b;
  font-size: 12px;
}

.top-status span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.top-actions {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
}

.top-actions button {
  height: 40px;
  min-width: 84px;
}

.top-actions button:not(.primary) {
  background: #fff;
  border-color: var(--line);
  color: #334155;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

.scan-health {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.scan-progress {
  display: none;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid #bdd7ee;
  border-radius: 8px;
  background: #f4f9fd;
  box-shadow: var(--shadow);
}

.scan-progress.active {
  display: block;
}

.progress-head,
.progress-foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.progress-head strong,
.progress-head span {
  display: block;
}

.progress-head span,
.progress-foot,
.progress-time {
  color: var(--muted);
  font-size: 13px;
}

.progress-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.progress-track {
  height: 10px;
  margin: 12px 0 8px;
  border-radius: 999px;
  background: #dceaf5;
  overflow: hidden;
}

.progress-alert {
  margin: 10px 0;
  padding: 8px 10px;
  border: 1px solid #f1c4c7;
  border-radius: 8px;
  background: #fff7f7;
  color: #9f1f28;
  font-size: 12px;
  line-height: 1.45;
}

.progress-track div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0d7c66, #1f9bb4);
  transition: width 0.4s ease;
}

.conclusion-panel {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.conclusion-panel span {
  color: var(--muted);
  font-size: 13px;
}

.conclusion-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.conclusion-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.conclusion-panel.hold {
  border-left-color: var(--warning);
}

.conclusion-panel.empty {
  border-left-color: #8aa0b5;
}

.conclusion-panel.hidden {
  display: none;
}

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

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric span,
.health-item span,
.panel-head span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.metric strong,
.health-item strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.health-item strong {
  font-size: 15px;
}

.health-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

.panel {
  overflow: hidden;
}

#settings .panel,
.settings-panel {
  overflow: visible;
}

.settings-panel-head {
  padding: 12px 16px 0;
  border-bottom: none;
}

.panel-subtitle,
.settings-panel-head span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.product-panel-head {
  align-items: flex-start;
}

.product-panel-head input {
  min-width: 220px;
}

.panel.wide {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-title-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover {
  background: #f8fafc;
}

.score {
  font-weight: 700;
}

.score.high {
  color: var(--accent);
}

.score.medium {
  color: var(--warning);
}

.score.low {
  color: var(--danger);
}

.stack {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.stack-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.stack-item strong {
  display: block;
  margin-bottom: 4px;
}

.alert-item {
  display: grid;
  gap: 6px;
}

.alert-item.resolved {
  opacity: 0.68;
}

.alert-item .small {
  justify-self: start;
  margin-top: 4px;
}

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

.product-list {
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.product-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.product-card-body {
  min-width: 0;
}

.product-select {
  margin-top: 4px;
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.detail-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.product-card:hover,
.product-card.active {
  border-color: var(--accent);
}

.product-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.product-card-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--muted);
  font-size: 12px;
}

.detail-panel {
  min-height: 520px;
}

.detail-empty {
  color: var(--muted);
  padding: 24px;
}

.detail {
  padding: 18px;
}

.detail h2 {
  margin: 0 0 4px;
}

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

.detail-card {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 12px;
}

.timeline {
  margin: 18px 0;
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.json-box {
  margin: 0;
  padding: 16px;
  overflow: auto;
  max-height: 70vh;
  background: #0f1720;
  color: #d8f3dc;
}

.settings-form {
  padding: 0 0 84px;
  background: var(--bg);
}

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

.settings-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.settings-section h3 {
  margin: 0;
  font-size: 16px;
}

.label-row,
.section-title-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.section-title-row {
  justify-content: space-between;
  width: 100%;
}

.button-row,
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.settings-section label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.settings-section label input,
.settings-section label textarea,
.settings-section label select {
  color: var(--text);
  font-size: 14px;
}

.data-source-section {
  align-content: start;
}

.source-master {
  display: grid !important;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid #b9d9ef;
  border-radius: 8px;
  background: #f8fcff;
  padding: 12px;
  color: var(--text) !important;
}

.source-master input {
  width: 16px;
  height: 16px;
}

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

.source-master small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.4;
}

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

.domestic-source-grid.hidden {
  display: none;
}

.country-grid {
  max-height: 230px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
}

.country-option {
  display: grid !important;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  border: 1px solid #eceef2;
  border-radius: 16px;
  background: #fff;
  min-height: 68px;
  padding: 12px 16px;
  color: var(--text) !important;
  font-size: 16px;
  transition: background 200ms ease-out, border-color 200ms ease-out, transform 200ms ease-out;
}

.country-option:has(input:checked) {
  border-color: rgba(52, 199, 89, 0.7);
  background: rgba(52, 199, 89, 0.06);
}

.country-option:hover {
  background: #f8fafc;
  transform: translateY(-1px);
}

.country-option[hidden] {
  display: none !important;
}

.option-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.option-copy > span {
  color: #111827;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.1;
}

.country-option small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

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

.wide-section {
  grid-column: 1 / -1;
}

.form-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.suggestion-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.suggestion-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.suggestion-head span {
  color: var(--muted);
  font-size: 12px;
  margin-right: auto;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.suggestion-chip {
  display: grid;
  gap: 2px;
  max-width: 190px;
  min-height: 38px;
  padding: 6px 8px;
  text-align: left;
}

.suggestion-chip strong,
.suggestion-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-chip span {
  color: var(--muted);
  font-size: 11px;
}

.suggestion-chip strong {
  font-size: 13px;
  line-height: 1.2;
}

.report-list {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.report-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

.report-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #475569;
  font-size: 13px;
}

.report-toolbar input,
.report-select {
  width: 16px;
  min-height: 16px;
}

.report-card {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
}

.report-open {
  min-height: auto;
  border: 0;
  box-shadow: none !important;
  padding: 0;
  display: grid;
  gap: 4px;
  text-align: left;
  background: transparent;
}

.report-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(13, 124, 102, 0.16);
}

.report-card span,
.report-card small {
  color: var(--muted);
}

.report-header {
  border-bottom: 1px solid var(--line);
}

.report-conclusion {
  margin: 16px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid #bdd7ee;
  background: #f5fbff;
  display: grid;
  gap: 5px;
}

.report-conclusion strong {
  color: var(--text);
}

.report-conclusion span {
  color: var(--muted);
  line-height: 1.55;
}

.metric-grid.compact {
  margin: 16px;
}

.report-products,
.report-alerts {
  display: grid;
  gap: 8px;
}

.report-product {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.report-product span {
  color: var(--muted);
}

button.danger {
  color: #b4232a;
  border-color: #f1c4c7;
}

.alert-filter.active {
  border-color: var(--accent);
  color: var(--accent);
  background: #eefaf6;
}

.alert-filter-row,
.alert-action-row {
  flex-wrap: nowrap;
}

.alert-guidance {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 4px 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.alert-guidance b {
  color: var(--text);
}

.settings-form {
  padding: 0 0 84px;
  background: var(--bg);
}

.settings-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-areas:
    "notice notice"
    "main side";
  gap: 16px;
  padding: 16px;
}

.settings-main {
  grid-area: main;
  display: grid;
  gap: 16px;
}

.settings-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 22px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.settings-card:hover {
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

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

.settings-card h3,
.settings-card-head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.settings-card p,
.settings-card-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.parameter-list,
.advanced-grid {
  display: grid;
  gap: 24px;
}

.config-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 8px 22px;
  align-items: center;
}

.config-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.config-item > small {
  grid-column: 1 / -1;
  color: #8b95a5;
  font-size: 12px;
}

.config-item p {
  margin: 4px 0 0;
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.4;
}

.stepper {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.stepper:hover,
.stepper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 124, 102, 0.08);
}

.stepper input {
  min-height: 42px;
  border: 0;
  border-radius: 0;
  text-align: center;
  box-shadow: none !important;
}

.stepper-btn {
  min-height: 42px;
  border: 0;
  border-radius: 0;
  background: #f9fafb;
  color: #475569;
  padding: 0;
  font-size: 16px;
}

.source-count-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: #ecfdf5;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.source-group {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid #f0f2f5;
}

.source-group:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.source-group h4 {
  margin: 0;
  font-size: 13px;
  color: #475569;
}

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

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

#domesticSourceGrid.hidden {
  display: none;
}

.source-card {
  min-height: 0;
  display: grid !important;
  grid-template-columns: 36px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #eceef2;
  border-radius: 14px;
  background: #fff;
  color: var(--text) !important;
  transition: box-shadow 200ms ease-out, border-color 200ms ease-out, transform 200ms ease-out;
}

.source-card-body {
  min-width: 0;
}

.source-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.source-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.source-hint {
  flex: 1 1 100%;
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-card:has(input:checked) {
  border-color: #eceef2;
  background: #fff;
  box-shadow: none;
}

.source-card:hover {
  border-color: #eceef2;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

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

.source-card strong {
  color: #111827;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}

.source-card small {
  margin-top: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.source-card b,
.source-card em,
.source-status,
.source-requirement,
.source-target,
.source-guide {
  min-height: 20px;
  display: inline-flex !important;
  align-items: center;
  width: fit-content;
  padding: 0 8px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 11px !important;
  font-weight: 500;
}

.source-icon-shell {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #eceef2;
}

.source-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: transparent !important;
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  overflow: hidden;
}

.source-icon svg {
  width: 22px;
  height: 22px;
}

.source-icon-fallback {
  color: #64748b;
  font-size: 11px;
}

.source-card:not(:has(input:checked)) .source-icon-shell {
  opacity: 0.82;
}

.source-check-btn {
  cursor: pointer;
  border: none;
  font: inherit;
}

.source-check-btn:hover {
  filter: brightness(0.97);
}

.checking-status {
  color: #2563eb !important;
  background: #eff6ff !important;
}

.suggestion-note {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.scan-progress.scan-anomaly-warning {
  border-color: #f59e0b;
}

.scan-progress.scan-anomaly-error {
  border-color: #ef4444;
}

.progress-alert.error {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.progress-alert.warning {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.switch-row {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 50px;
  height: 30px;
}

.switch-row input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-row i {
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: #e5e5ea;
  position: relative;
  transition: background 200ms ease-out, box-shadow 200ms ease-out, transform 200ms ease-out;
}

.switch-row i::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.22);
  transition: transform 200ms ease-out;
}

.switch-row input:checked + i,
.switch-row input:checked ~ i {
  background: #34c759;
  box-shadow: none;
}

.switch-row input:checked + i::after,
.switch-row input:checked ~ i::after {
  transform: translateX(20px);
}

.switch-row:hover i {
  filter: brightness(1.02);
}

.switch-row:active i {
  transform: scale(0.98);
}

.source-card.reserved {
  opacity: 0.72;
}

.muted-status {
  background: #f1f5f9;
  color: #6b7280 !important;
}

.pending-status,
.checking-status {
  background: #f3f4f6;
  color: #2563eb !important;
}

.ok-status {
  background: rgba(52, 199, 89, 0.12);
  color: #16a34a !important;
}

.bad-status {
  background: #f3f4f6;
  color: #f97316 !important;
}

.source-requirement {
  color: #6b7280 !important;
}

.source-target {
  color: #6b7280 !important;
}

.source-guide {
  color: #6b7280 !important;
}

.source-config {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 8px;
  max-width: 360px;
}

.source-config label {
  color: #64748b;
  font-size: 11px;
}

.source-config input {
  min-height: 34px;
  margin-top: 4px;
  padding: 7px 9px;
  font-size: 12px;
}

.source-card.reserved em {
  color: #94a3b8;
  font-size: 12px;
  font-style: normal;
}

.domestic-master {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 50px;
  align-items: center;
  gap: 16px;
  margin: 18px 0 12px;
  padding-top: 18px;
  border-top: 1px solid #f0f2f5;
  background: transparent;
}

.domestic-master strong,
.domestic-master small {
  display: block;
}

.domestic-master strong {
  font-size: 13px;
  color: #475569;
}

.domestic-master small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.language-panel {
  max-width: none;
}

.language-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-top: 18px;
  border-top: 1px solid #f0f2f5;
}

.language-head strong {
  display: block;
  font-size: 18px;
  line-height: 1.3;
}

.language-head span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.language-head span b {
  font-weight: 650;
  color: #475569;
}

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

.language-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 14px;
  border: 1px solid #eceef2;
  border-radius: 16px;
  min-height: 68px;
  padding: 12px 16px;
  background: #fff;
  color: var(--text);
  line-height: 1.1;
  transition: background 200ms ease-out, border-color 200ms ease-out, transform 200ms ease-out;
}

.language-option:hover {
  background: #f8fafc;
  transform: translateY(-1px);
}

.language-option:has(input:checked) {
  border-color: rgba(52, 199, 89, 0.7);
  background: rgba(52, 199, 89, 0.06);
}

.country-option input,
.language-option input {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-items: center;
  position: relative;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  margin: 0;
  padding: 0;
  width: 28px;
  height: 28px;
  min-height: 28px;
}

.country-option input::after,
.language-option input::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #34c759;
  opacity: 0;
  transform: scale(0.82);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
}

.country-option input::before,
.language-option input::before {
  content: "";
  position: absolute;
  z-index: 1;
  width: 7px;
  height: 13px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  opacity: 0;
  transform: rotate(45deg) translate(-1px, -2px);
  transition: opacity 180ms ease-out;
}

.country-option input:checked::after,
.language-option input:checked::after {
  opacity: 1;
  transform: scale(1);
}

.country-option input:checked::before,
.language-option input:checked::before {
  opacity: 1;
}

.language-option .option-copy > span {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.language-option small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.settings-secondary {
  background: #fff;
  color: #334155;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: none;
  place-items: center;
  padding: 32px;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(10px);
}

.settings-modal.active {
  display: grid;
}

.settings-modal-card {
  width: min(1060px, 100%);
  max-height: min(820px, 88vh);
  overflow: auto;
  padding: 32px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.18);
  animation: modalIn 200ms ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

.settings-modal-head h3,
.settings-modal-head p {
  margin: 0;
}

.settings-modal-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 15px;
}

.icon-button {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 14px;
  font-size: 24px;
  background: #fff;
  border: 1px solid #e5e7eb;
}

.country-search {
  min-height: 56px;
  margin-bottom: 18px;
  padding-left: 18px;
  border-radius: 16px;
  border-color: #e5e7eb;
  font-size: 16px;
}

.region-tabs {
  display: inline-flex;
  gap: 8px;
  min-height: 44px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #f8fafc;
}

.region-tab {
  min-height: 36px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #374151;
  transition: background 200ms ease-out, color 200ms ease-out, transform 200ms ease-out;
}

.region-tab.active {
  color: #fff;
  background: #34c759;
}

.settings-modal .country-grid {
  max-height: 520px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding-right: 4px;
}

.settings-modal .language-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

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

.connection-sections {
  display: grid;
  gap: 18px;
}

.connection-section h4 {
  margin: 0 0 10px;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.connection-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.connection-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.connection-field span {
  color: #475569;
  font-size: 12px;
  font-weight: 500;
}

.connection-field input {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.connection-field input:focus {
  outline: none;
  border-color: #86b7c8;
  box-shadow: 0 0 0 3px rgba(13, 124, 102, 0.08);
}

.connection-field.full {
  grid-column: 1 / -1;
}

.connection-inline {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) auto;
  gap: 12px 16px;
  align-items: end;
}

.connection-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  padding-bottom: 2px;
}

.connection-switch {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #475569;
  font-size: 12px;
  white-space: nowrap;
}

.connection-switch span {
  font-weight: 500;
}

.connection-grid label,
.textarea-grid label {
  font-size: 12px;
  color: #334155;
}

.connection-grid input,
.textarea-grid textarea {
  font-size: 12px;
}

.textarea-grid label:first-child {
  grid-column: 1 / -1;
}

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

.pool-field {
  display: grid;
  gap: 8px;
}

.pool-field:first-child {
  grid-column: 1 / -1;
}

.pool-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pool-field-head label {
  margin: 0;
  font-size: 12px;
  color: #334155;
}

.pool-field textarea {
  font-size: 12px;
}

.suggestion-list.compact {
  margin-top: 0;
}

.suggestion-list.compact .suggestion-chips {
  gap: 8px;
}

.settings-side {
  grid-area: side;
  min-width: 0;
}

.sticky-card {
  position: sticky;
  top: 16px;
}

.stats-list {
  display: grid;
  gap: 12px;
}

.stats-list div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}

.stats-list span {
  color: var(--muted);
  font-size: 12px;
}

.stats-list strong {
  font-size: 15px;
}

.advanced-card summary {
  cursor: pointer;
  list-style: none;
}

.advanced-card summary::-webkit-details-marker {
  display: none;
}

.advanced-card summary span,
.advanced-card summary strong,
.advanced-card summary small {
  display: block;
}

.advanced-card summary small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.advanced-card[open] summary {
  margin-bottom: 20px;
}

.reserved-control > span {
  justify-self: end;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #f8fafc;
  color: #64748b;
  font-size: 12px;
}

.settings-unsaved {
  grid-area: notice;
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid #f4d58d;
  border-radius: 8px;
  background: #fff8e6;
  color: #8a5a00;
  font-size: 12px;
  line-height: 1.35;
}

.settings-unsaved.active {
  display: flex;
}

.settings-unsaved-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #f59e0b;
  flex: 0 0 auto;
}

.settings-actionbar {
  position: sticky;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
}

#saveSettingsBtn.dirty {
  box-shadow: 0 10px 24px rgba(13, 124, 102, 0.2);
}

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

.validation-item {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
}

.validation-item strong,
.validation-item span {
  display: block;
}

.validation-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.validation-item.ok {
  border-color: #9ed7c6;
}

.validation-item.bad {
  border-color: #efb4b5;
}

.loading-row {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #c9d8e6;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(10, 18, 26, 0.58);
  backdrop-filter: blur(8px);
}

.auth-overlay.active {
  display: grid;
}

.auth-card {
  width: min(420px, 100%);
  padding: 24px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(10, 18, 26, 0.28);
  display: grid;
  gap: 14px;
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.auth-logo img {
  width: min(220px, 100%);
  height: auto;
  object-fit: contain;
}

.auth-card h2,
.auth-card p {
  margin: 0;
}

.auth-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.password-rules {
  color: var(--muted);
  font-size: 12px;
}

.toast-host {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  display: grid;
  place-items: center;
}

.toast-host.corner {
  place-items: start end;
  padding: 24px;
}

.toast {
  transform: translateY(8px) scale(0.98);
  opacity: 0;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid #b8dfd3;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  box-shadow: 0 18px 60px rgba(10, 18, 26, 0.18);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.toast.bad {
  border-color: #efb4b5;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(10, 18, 26, 0.38);
  backdrop-filter: blur(6px);
}

.modal-overlay.active {
  display: grid;
}

.modal-card {
  width: min(420px, 100%);
  padding: 20px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(10, 18, 26, 0.22);
  display: grid;
  gap: 12px;
}

.modal-card h3,
.modal-card p {
  margin: 0;
}

.modal-card p {
  color: var(--muted);
  line-height: 1.55;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 980px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .main {
    margin-left: 0;
    padding: 18px;
  }

  .topbar,
  .split {
    grid-template-columns: 1fr;
    display: grid;
  }

  .scan-health,
  .metric-grid,
  .content-grid,
  .detail-grid,
  .settings-grid,
  .inline-fields,
  .country-grid,
  .settings-shell,
  .connection-grid.cols-3,
  .connection-inline {
    grid-template-columns: 1fr;
  }

  .settings-shell {
    grid-template-areas:
      "notice"
      "main"
      "side";
  }
}
