:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --line: #d9e2ef;
  --text: #182333;
  --muted: #66758a;
  --blue: #1f75ff;
  --blue-dark: #155bd1;
  --green: #16a36a;
  --red: #d64545;
  --amber: #9b6a00;
  --shadow: 0 10px 28px rgba(27, 42, 71, 0.08);
}

* { box-sizing: border-box; }

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

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

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 18px 0 14px;
}

h1, h2, p { margin: 0; }

h1 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.provider {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 9px 11px;
  color: var(--muted);
  font-size: 13px;
}

.notice {
  margin-bottom: 12px;
  border: 1px solid #f0d48b;
  border-radius: 6px;
  background: #fff8e5;
  color: var(--amber);
  padding: 10px 12px;
  line-height: 1.55;
}

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

.input-panel {
  padding: 14px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

textarea {
  width: 100%;
  min-height: 230px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
  color: var(--text);
  outline: none;
  padding: 12px;
  line-height: 1.55;
}

textarea:focus {
  border-color: rgba(31, 117, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(31, 117, 255, 0.12);
}

.locations {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.locations select,
.output-format select,
.row-location {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbff;
  color: var(--text);
  padding: 0 12px;
}

.row-location {
  min-width: 86px;
}

.locations label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbff;
  padding: 0 12px;
  color: var(--text);
}

.locations input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 0.8fr 0.65fr minmax(260px, 1.35fr) minmax(150px, 0.8fr) repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.output-format {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbff;
  padding: 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.output-format select {
  width: 100%;
  min-width: 0;
  border-color: transparent;
  background: transparent;
  padding: 0;
  color: var(--text);
}

.http-prefix {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbff;
  padding: 0 10px;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

.http-prefix input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: #b8c8dd;
  background: #f8fbff;
}

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

.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
  font-weight: 700;
}

.primary:hover {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
}

.progress-panel {
  margin-top: 12px;
  padding: 12px;
}

.progress-text {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

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

.progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef6;
  margin-top: 10px;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), #20b486);
  transition: width 0.2s ease;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
}

.filter {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}

.filter.active {
  border-color: var(--blue);
  color: var(--blue);
  background: #edf5ff;
  font-weight: 700;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-top: 12px;
  background: var(--line);
}

.stats div {
  background: #fff;
  padding: 13px;
}

.stats b {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.stats span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.table-panel {
  overflow: hidden;
  margin-top: 12px;
}

.table-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.table-title h2 {
  font-size: 17px;
}

.table-title span {
  color: var(--amber);
  font-size: 13px;
}

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

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

th, td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid #edf1f6;
  vertical-align: middle;
  font-size: 14px;
}

th {
  background: #f7f9fc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.target {
  font-weight: 700;
}

.ip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #334155;
}

.error {
  max-width: 260px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 26px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}

.badge.ok {
  color: var(--green);
  background: #eaf8f1;
  border: 1px solid #bde8d2;
}

.badge.bad {
  color: var(--red);
  background: #fff0f0;
  border: 1px solid #f2c2c2;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(80px);
  max-width: min(92vw, 420px);
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #182333;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 760px) {
  .app { padding: 10px; }
  .topbar { flex-direction: column; }
  .provider { width: 100%; }
  h1 { font-size: 24px; }
  textarea { min-height: 260px; }
  .actions, .stats { grid-template-columns: 1fr; }
  .progress-text, .table-title { flex-direction: column; align-items: flex-start; }
  .locations label { flex: 1 1 120px; justify-content: center; }
}
