.v1-detect-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.v1-detect-row button {
  width: fit-content;
  white-space: nowrap;
  flex-shrink: 0;
}

.v1-detect-btn {
  width: 120px !important;
  display: inline-flex;
  align-items: center;
  gap: 0;
  text-align: start;
}

.v1-detect-icon {
  display: inline-block;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.v1-detect-result {
  width: 108px;
  font-size: 11px;
  color: var(--brand);
  font-family: var(--font-mono, monospace);
  opacity: 0.9;
  min-width: 108px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v1-detect-result.is-loading {
  color: #c7c7c7;
}

.v1-detect-loader {
  display: inline-grid;
  grid-template-columns: repeat(3, 5px);
  grid-template-rows: repeat(2, 5px);
  gap: 2px;
  align-items: center;
  justify-items: center;
}

.v1-detect-loader-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #7a7a7a;
}

.v1-detect-loader-dot.is-active {
  background: #ffffff;
}

.v1-use-btn {
  flex-shrink: 0;
  border: 1px solid #3f3f46;
  border-radius: 5px;
  background: transparent;
  color: var(--txt);
  font-size: 10px;
  font-family: var(--font-ui);
  padding: 2px 6px;
  cursor: pointer;
  opacity: 0.7;
}

.v1-use-btn:hover {
  border-color: var(--brand);
  opacity: 1;
}

.v1-port-preset-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  min-width: 0;
}

/* "Profile" is longer than the other short labels (From/To/Ports) sharing
   .v1-ip-label's fixed 32px column - give this row's label an auto-width
   column instead of squeezing/overflowing the fixed one. */
.v1-port-preset-row--profile {
  grid-template-columns: auto minmax(0, 1fr);
}

.v1-port-preset-row--profile .v1-ip-label {
  width: auto;
  white-space: nowrap;
}

.v1-port-preset-select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  background: #1f1f23;
  border: 1px solid #3f3f46;
  border-radius: 6px;
  color: var(--txt);
  font-size: 11px;
  font-family: var(--font-ui);
  padding: 4px 6px;
  cursor: pointer;
  outline: none;
}

.v1-port-preset-select:focus {
  border-color: var(--brand);
}

.v1-iplib-actions {
  margin-top: 0;
  flex-wrap: wrap;
}

.v1-iplib-grid {
  margin-top: 8px;
  display: grid;
  gap: 10px;
}

.v1-iplib-field {
  display: grid;
  gap: 6px;
}

.v1-iplib-field label {
  color: var(--txt-dim);
  font-size: 12px;
}

.v1-iplib-countries {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 64px;
  background: #1b1c20;
  border: 1px solid #3f3f46;
  border-radius: 8px;
  color: var(--txt);
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  padding: 7px 8px;
  outline: none;
}

.v1-iplib-countries:focus {
  border-color: var(--brand);
}

.v1-iplib-topranges {
  width: 104px;
  max-width: 100%;
  box-sizing: border-box;
  background: #1b1c20;
  border: 1px solid #3f3f46;
  border-radius: 8px;
  color: var(--txt);
  font-size: 11px;
  font-family: var(--font-ui);
  padding: 6px 8px;
  outline: none;
}

.v1-iplib-topranges:focus {
  border-color: var(--brand);
}

.v1-ip-extractor-input,
.v1-ip-extractor-output {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin-top: 8px;
  resize: none;
  min-height: 58px;
  background: #1f1f23;
  border: 1px solid #3f3f46;
  border-radius: 8px;
  color: var(--txt);
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  padding: 6px 8px;
  outline: none;
}

.v1-ip-extractor-input:focus {
  border-color: var(--brand);
}

.v1-ip-extractor-output {
  margin-top: 6px;
  opacity: 0.95;
}

.v1-range-history {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 176px;
  overflow: auto;
}

.v1-range-history-empty {
  color: var(--txt-dim);
  font-size: 11px;
}

.v1-range-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  border: 1px solid #3f3f46;
  border-radius: 8px;
  background: #22252a;
  padding: 5px 6px;
}

.v1-range-history-text {
  width: auto;
  min-width: 0;
  font-size: 11px;
  color: var(--txt);
  font-family: var(--font-mono, monospace);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v1-range-history-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 2px;
  width: 44px;
  justify-content: flex-end;
}

html[dir="rtl"] .v1-range-history-actions {
  margin-left: 0;
  margin-right: 2px;
}

.v1-range-history-btn {
  border: 1px solid #3f3f46;
  border-radius: 5px;
  background: transparent;
  color: var(--txt);
  font-size: 10px;
  font-family: var(--font-ui);
  padding: 2px 6px;
  cursor: pointer;
}

.v1-range-history-btn:hover {
  border-color: var(--brand);
}

.v1-range-history-btn[data-history-action="delete"]:hover {
  border-color: #c94b4b;
  color: #ffd2d2;
}

.v1-ip-row {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.v1-ip-label {
  width: 32px;
  color: var(--txt-dim);
  font-size: 12px;
}

.v1-ip-box {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #3f3f46;
  border-radius: 8px;
  background: #1f1f23;
  padding: 4px 6px;
}

.v1-octet {
  width: 34px;
  border: 0;
  background: transparent;
  color: var(--txt);
  text-align: center;
  font-size: 12px;
  font-family: var(--font-ui);
  padding: 2px 0;
}

.v1-octet:focus {
  outline: none;
  box-shadow: inset 0 -2px 0 var(--brand);
}

.v1-octet-dot {
  color: var(--txt-dim);
  line-height: 1;
  user-select: none;
}

.v1-range-mode-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.v1-range-mode-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--txt-dim);
  font-size: 12px;
  cursor: pointer;
}

.v1-range-mode-option input[type="radio"] {
  accent-color: var(--brand);
  cursor: pointer;
}

.v1-cidr-input {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid #3f3f46;
  border-radius: 8px;
  background: #1f1f23;
  color: var(--txt);
  font-size: 12px;
  font-family: var(--font-ui);
  padding: 5px 8px;
  outline: none;
}

.v1-cidr-input:focus {
  border-color: var(--brand);
}

/* .v1-ip-row's own "display: flex" ties in specificity with the browser's
   default "[hidden] { display: none }" UA rule, and author CSS wins ties
   over UA styles - so the CIDR row (which is both .v1-ip-row and a
   [data-range-mode-panel]) stayed visible despite the [hidden] attribute
   toggled by initRangeModeToggle(). Higher-specificity override forces it
   to actually hide. */
[data-range-mode-panel][hidden] {
  display: none;
}

.v1-cidr-input.is-invalid {
  border-color: #c94b4b;
}
