/*
 * Visual refinement layer for the current production front end.
 * Structure and element IDs stay unchanged.
 * Component proportions and form treatment reference Tabler (MIT).
 */

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #dfe3e8;
  --border-focus: #206bc4;
  --text: #182433;
  --text-muted: #667382;
  --accent: #206bc4;
  --accent-hover: #1a569d;
  --accent-glow: rgba(32, 107, 196, 0.11);
  --success: #1a7f37;
  --success-bg: #dafbe1;
  --danger: #d63939;
  --danger-bg: #fceded;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(24, 36, 51, 0.04);
  --shadow-md: 0 4px 18px rgba(24, 36, 51, 0.07);
}

[data-theme="dark"] {
  --bg: #151922;
  --surface: #1d232f;
  --surface-2: #252c3a;
  --border: #30394a;
  --border-focus: #4299e1;
  --text: #edf0f5;
  --text-muted: #9ba7b5;
  --accent: #4299e1;
  --accent-hover: #65abe7;
  --accent-glow: rgba(66, 153, 225, 0.14);
  --success: #5eba6d;
  --success-bg: rgba(47, 179, 68, 0.12);
  --danger: #e66b6b;
  --danger-bg: rgba(214, 57, 57, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 5px 20px rgba(0, 0, 0, 0.2);
}

body.by-refined {
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI",
    sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

.by-site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: 58px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: 0 1px 1px rgba(24, 36, 51, 0.02);
  backdrop-filter: blur(10px);
}

.by-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1240px, calc(100% - 48px));
  height: 100%;
  margin: 0 auto;
  padding-right: 92px;
}

.by-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
}

.by-ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(640px, 62vw);
  height: 36px;
  border: 1px dashed color-mix(in srgb, var(--text-muted) 45%, var(--border));
  border-radius: 6px;
  color: var(--text-muted);
  background:
    repeating-linear-gradient(
      -45deg,
      transparent 0,
      transparent 8px,
      color-mix(in srgb, var(--text-muted) 3%, transparent) 8px,
      color-mix(in srgb, var(--text-muted) 3%, transparent) 16px
    ),
    var(--surface-2);
}

.by-ad-slot span {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.by-ad-slot strong {
  color: var(--text-soft, var(--text-muted));
  font-size: 11px;
  font-weight: 600;
}

.by-ad-slot small {
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.by-brand:hover {
  color: var(--text);
  text-decoration: none;
}

.by-brand-mark {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 7px;
  color: #ffffff;
  background: var(--accent);
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 2px 5px rgba(32, 107, 196, 0.2);
}

.by-brand strong,
.by-brand small {
  display: block;
  line-height: 1.15;
}

.by-brand strong {
  font-size: 14px;
  font-weight: 700;
}

.by-brand small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
}

.by-header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.by-environment,
.by-online {
  display: inline-flex;
  align-items: center;
  height: 27px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 600;
}

.by-online {
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 20%, var(--border));
  background: var(--success-bg);
}

.by-online i {
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--success);
}

body.by-refined > .top-bar {
  position: fixed;
  top: 11px;
  z-index: 1200;
  padding: 0;
}

body.by-refined > .top-bar[style*="left:0"] {
  right: 62px !important;
  left: auto !important;
}

body.by-refined > .top-bar[style*="right:0"] {
  right: 22px !important;
  left: auto !important;
}

.theme-toggle {
  width: 34px;
  height: 34px;
  border-color: var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: none;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--surface-2);
}

body.by-refined main {
  max-width: 1240px;
  padding: 26px 24px 48px;
}

.by-page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  padding-left: 9px;
  border-left: 2px solid var(--accent);
}

.by-page-heading span {
  display: block;
  margin: 0;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.13em;
}

.by-page-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.by-page-heading p {
  margin: 0 0 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.by-server-key-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.by-server-key-button:hover {
  border-color: rgba(36, 107, 254, 0.52);
  color: var(--accent);
  background: #f8fbff;
}

.by-server-key-button i {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #94a3b8;
}

.by-server-key-button.is-configured {
  border-color: rgba(22, 163, 74, 0.30);
  color: #166534;
  background: #f6fff8;
}

.by-server-key-button.is-configured i {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.11);
}

.extract-stats-panel {
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

[data-theme="dark"] .extract-stats-panel {
  background: var(--surface);
  border-color: var(--border);
}

.extract-stats-eyebrow {
  color: var(--accent);
  font-size: 10px;
}

.extract-stats-eyebrow span {
  width: 6px;
  height: 6px;
  background: var(--success);
  box-shadow: none;
}

.extract-stats-header h2 {
  font-size: 15px;
  font-weight: 650;
}

.extract-stats-grid {
  gap: 3px;
  margin-top: 9px;
  padding: 7px;
  border-color: var(--border);
  border-radius: 6px;
  background: var(--surface-2);
}

.extract-stats-cell {
  border-color: color-mix(in srgb, var(--text-muted) 20%, var(--border));
  border-radius: 2px;
  background: color-mix(in srgb, var(--text-muted) 18%, var(--surface));
  box-shadow: none;
}

.extract-stats-cell.is-success {
  border-color: color-mix(in srgb, var(--success) 60%, var(--border));
  background: var(--success);
  box-shadow: none;
}

.main-layout {
  grid-template-columns: minmax(0, 1fr) 410px;
  gap: 16px;
}

.main-layout.jp-hidden {
  grid-template-columns: minmax(0, 960px);
}

.card {
  padding: 22px;
  border-color: var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pp-panel.card {
  position: relative;
  overflow: hidden;
  padding: 22px !important;
}

.pp-panel.card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
}

.header {
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header .badge {
  height: 24px;
  padding: 0 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
  border-radius: 5px;
  background: var(--accent-glow);
  font-size: 10px;
}

.field {
  margin-bottom: 15px;
}

.by-cdk-shell {
  position: relative;
  margin: 4px 0 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  background: var(--surface-2);
}

.by-cdk-shell > label {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#shortCdkAuthType {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.by-auth-segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: color-mix(in srgb, var(--border) 36%, var(--surface));
}

.by-auth-option {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 45px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  background: transparent;
  text-align: left;
  box-shadow: none;
}

.by-auth-option:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}

.by-auth-option.is-active {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.by-auth-dot {
  width: 13px;
  height: 13px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
}

.by-auth-option.is-active .by-auth-dot {
  border: 4px solid var(--accent);
}

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

.by-auth-copy strong {
  font-size: 11px;
  font-weight: 650;
}

.by-auth-copy small {
  margin-top: 1px;
  color: var(--text-muted);
  font-size: 9px;
}

.by-auth-code {
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  background: var(--surface-2);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 8px;
}

#shortAccountCdkPanel,
#shortBrowserCdkPanel {
  margin-top: 12px !important;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

#shortAccountCdkPanel .input-label-row,
#shortBrowserCdkPanel .input-label-row {
  margin-bottom: 6px;
}

#shortAccountCdkPanel .input-label-row label,
#shortBrowserCdkPanel .input-label-row label {
  margin-bottom: 0;
}

#shortCdk,
#shortBrowserCdk {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.03em;
}

#shortCdkBind,
#shortBrowserCdkBind {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 11px;
}

.field label {
  margin-bottom: 6px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.input-label-row {
  align-items: center;
}

.mode-hint,
.field-help,
.token-meta,
.cdk-status {
  color: var(--text-muted);
  font-size: 11px;
}

input,
textarea,
select {
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: inset 0 1px 1px rgba(24, 36, 51, 0.02);
}

input,
select {
  min-height: 38px;
  padding: 7px 10px;
  font-size: 13px;
}

textarea {
  min-height: 106px;
  padding: 10px 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
}

input:hover,
textarea:hover,
select:hover {
  border-color: color-mix(in srgb, var(--text-muted) 45%, var(--border));
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.grid-2,
.grid-3,
.grid-4 {
  gap: 10px;
}

.by-config-grid {
  grid-template-columns:
    minmax(190px, 1.35fr)
    repeat(5, minmax(105px, 1fr)) !important;
  gap: 8px !important;
  margin: 2px 0 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
}

.by-config-grid .field {
  margin-bottom: 0;
}

.by-config-grid .field label {
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.by-config-grid input,
.by-config-grid select {
  min-height: 40px;
  border-color: var(--border);
  background-color: var(--surface);
  font-size: 12px;
}

.by-config-grid select:disabled,
.by-config-grid input:disabled {
  color: var(--text);
  background-color: color-mix(in srgb, var(--surface) 82%, var(--surface-2));
  opacity: 1;
}

#extractMode {
  color: var(--accent);
  border-left: 2px solid var(--accent);
  font-weight: 650;
}

.proxy-pools {
  gap: 10px;
}

.proxy-pool-card,
.proxy-card {
  border-color: var(--border);
  border-radius: 7px;
  background: var(--surface-2);
}

.divider {
  margin: 18px 0 14px;
  border-color: var(--border);
}

.toggle-advanced {
  min-height: 32px;
  padding: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.advanced-panel {
  margin-top: 9px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
}

.actions {
  align-items: center;
  gap: 9px;
  margin-top: 18px;
}

.actions #generate {
  min-width: 150px;
}

.btn,
.btn-primary,
.btn-secondary,
.btn-danger-outline,
a.btn {
  min-height: 39px;
  padding: 8px 15px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
}

.btn-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.btn-secondary,
.btn.btn-secondary {
  color: var(--text);
  border: 1px solid var(--border);
  background: var(--surface);
}

.btn-secondary:hover:not(:disabled),
.btn.btn-secondary:hover:not(:disabled) {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
  background: var(--surface-2);
}

.progress-bar {
  height: 5px;
  margin-top: 15px;
  border-radius: 2px;
  background: var(--surface-2);
}

.progress-bar-fill {
  border-radius: 2px;
  background: var(--accent);
}

.progress-text,
.status-bar {
  font-size: 12px;
}

.status-bar {
  min-height: 20px;
  margin-top: 8px;
}

.result-card {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
}

.result-card.show {
  display: block;
}

.result-header {
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}

#openLink.btn-success {
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid #166b31;
  border-radius: 7px;
  background: #1a7f37;
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 1px 2px rgba(18, 86, 43, 0.18);
  font-weight: 680;
  letter-spacing: 0.01em;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.08s ease;
}

#openLink.btn-success:hover {
  border-color: #125a29;
  background: #15652c;
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    0 3px 8px rgba(18, 86, 43, 0.18);
}

#openLink.btn-success:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 2px rgba(6, 52, 23, 0.20);
}

#copy.btn-secondary {
  min-height: 40px;
  padding: 9px 16px;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(24, 36, 51, 0.05);
}

#copy.btn-secondary:hover:not(:disabled) {
  border-color: #b8c2cf;
  background: #f8fafc;
}

.result-row {
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  margin-bottom: 8px;
}

.result-label {
  padding-top: 8px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.result-value {
  min-height: 37px;
  padding: 8px 10px;
  border-color: var(--border);
  border-radius: 5px;
  background: var(--surface);
  font-size: 11px;
  line-height: 1.55;
}

.result-value.success-value {
  color: #15652c;
  border-color: #b8ddc1;
  background: #f1faf3;
  box-shadow: inset 3px 0 0 #1a7f37;
}

.error-detail pre {
  border-radius: 6px;
  font-size: 11px;
}

.jp-panel {
  padding: 19px;
}

.jp-gen-header {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.jp-gen-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.jp-country-badge {
  border: 1px solid color-mix(in srgb, var(--danger) 20%, var(--border));
  border-radius: 5px;
  font-size: 10px;
}

.jp-country-tabs {
  gap: 3px;
  padding: 3px;
  border-color: var(--border);
  border-radius: 6px;
  background: var(--surface-2);
}

.jp-country-tab {
  height: 31px;
  border-radius: 4px;
  font-size: 12px;
}

.jp-country-tab.active {
  color: var(--accent);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.jp-gen-btn {
  height: 37px;
  border-radius: 6px;
  background: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.jp-fields {
  border-radius: 6px;
}

.jp-fields .jp-cell {
  padding: 8px 10px;
  background: var(--surface);
}

.jp-field-label {
  font-size: 11px;
}

.jp-field-value {
  font-size: 13px;
}

.jp-copy-btn {
  min-width: 42px;
  height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--accent);
  font-size: 10px;
}

.jp-copy-all-btn {
  height: 35px;
  border-radius: 6px;
  font-size: 12px;
}

.otp-modal-card {
  border-color: var(--border);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: 0 16px 48px rgba(24, 36, 51, 0.18);
}

@media (max-width: 1100px) {
  .main-layout {
    grid-template-columns: minmax(0, 1fr) 370px;
  }

  .by-config-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 900px) {
  .by-header-inner {
    width: calc(100% - 32px);
  }

  .main-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body.by-refined main {
    padding: 20px 16px 36px;
  }

  .by-page-heading {
    align-items: flex-start;
  }

  .by-page-heading p {
    margin-top: 5px;
  }

  .by-server-key-button {
    flex: 0 0 auto;
  }

  .by-header-meta {
    display: none;
  }

  .result-row {
    display: block;
  }

  .result-label {
    padding-top: 0;
  }
}

@media (max-width: 560px) {
  .by-site-header {
    height: 54px;
  }

  .by-header-inner {
    width: calc(100% - 24px);
    padding-right: 82px;
  }

  .by-ad-slot {
    justify-content: flex-start;
    width: calc(100% - 8px);
    padding: 0 8px;
  }

  .by-ad-slot small {
    display: none;
  }

  body.by-refined > .top-bar {
    top: 9px;
  }

  body.by-refined > .top-bar[style*="left:0"] {
    right: 54px !important;
  }

  body.by-refined > .top-bar[style*="right:0"] {
    right: 12px !important;
  }

  .pp-panel.card {
    padding: 16px !important;
  }

  .by-auth-segmented,
  .by-config-grid {
    grid-template-columns: 1fr !important;
  }
}


/* HF header cleanup: centered ad slot, no status or utility controls. */
.by-header-inner {
  justify-content: center !important;
  padding-right: 0 !important;
}
.by-ad-slot {
  width: min(728px, 78vw) !important;
}
body.by-refined > .top-bar {
  display: none !important;
}

/* The public extractor no longer exposes the auxiliary address generator. */
.main-layout,
.main-layout.jp-hidden {
  grid-template-columns: minmax(0, 960px) !important;
  justify-content: center;
}

#jpPanel {
  display: none !important;
}
