/* DoanProxy — primary white, secondary black, accent orange */

:root {
  --primary: #ffffff;
  --secondary: #0a0a0a;
  --accent: #ea580c;
  --accent-hover: #c2410c;
  --accent-muted: rgba(234, 88, 12, 0.12);
  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f0f0f0;
  --border: #e4e4e7;
  --border-hover: #d4d4d8;
  --text: #0a0a0a;
  --text-dim: #52525b;
  --text-muted: #a1a1aa;
  --green: #16a34a;
  --green-bg: rgba(22, 163, 74, 0.1);
  --green-glow: rgba(22, 163, 74, 0.2);
  --red: #dc2626;
  --red-bg: rgba(220, 38, 38, 0.08);
  --yellow: #ca8a04;
  --yellow-bg: rgba(202, 138, 4, 0.1);
  --blue: #2563eb;
  --blue-bg: rgba(37, 99, 235, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* ---- Global shell (Tester | Dedupe) ---- */
.shell {
  flex-shrink: 0;
  background: var(--primary);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}

.shell-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.shell-brand {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--secondary);
  text-decoration: none;
}

.shell-brand span {
  color: var(--accent);
}

.shell-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.shell-nav-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--radius-xs);
  transition: color 0.15s, background 0.15s;
}

.shell-nav-link:hover {
  color: var(--secondary);
  background: var(--surface-3);
}

.shell-nav-link.active {
  color: var(--accent);
  background: var(--accent-muted);
}

.app {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ---- Sidebar (secondary black) ---- */
.sidebar {
  width: 280px;
  background: var(--secondary);
  color: #fafafa;
  border-right: 1px solid #27272a;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-module-label {
  padding: 12px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #71717a;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid #27272a;
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  color: #fff;
}

.sidebar .logo h1 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fafafa;
}

.sidebar .logo h1 span {
  color: var(--accent);
}

.sidebar-actions {
  padding: 12px 14px;
  border-bottom: 1px solid #27272a;
  display: flex;
  gap: 8px;
}

.groups-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.group-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 2px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.group-item:hover {
  background: #18181b;
}

.group-item.active {
  background: rgba(234, 88, 12, 0.15);
  border-color: rgba(234, 88, 12, 0.35);
}

.group-item-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
  color: #f4f4f5;
}

.group-item-meta {
  font-size: 11px;
  color: #a1a1aa;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid #27272a;
}

/* ---- Main ---- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.topbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  background: var(--primary);
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
  letter-spacing: -0.01em;
}

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

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

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--border);
}

.btn-danger:hover {
  background: var(--red-bg);
  border-color: var(--red);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--surface-2);
}

.btn-success {
  background: var(--secondary);
  color: #fff;
}

.btn-success:hover {
  background: #27272a;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 11px;
}

.btn-lg {
  padding: 11px 20px;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-sm);
}

/* ---- Empty ---- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  color: var(--text-dim);
  text-align: center;
  gap: 12px;
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.empty-icon svg {
  width: 26px;
  height: 26px;
}

.empty p {
  font-size: 14px;
  max-width: 320px;
  line-height: 1.6;
}

/* ---- Editor / fields ---- */
.editor {
  max-width: 860px;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.input::placeholder {
  color: var(--text-muted);
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2371717a' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

select.input option {
  background: var(--primary);
  color: var(--text);
}

textarea.input {
  min-height: 220px;
  resize: vertical;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 12px;
  line-height: 1.7;
}

.field-help {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.proxy-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-muted);
  color: var(--accent);
  margin-left: 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.settings-grid .field {
  margin-bottom: 0;
}

/* ---- Results ---- */
.result-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s;
}

.stat-card:hover {
  border-color: var(--border-hover);
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat-label {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.grade-a .stat-value {
  color: var(--green);
}
.grade-b .stat-value {
  color: var(--blue);
}
.grade-c .stat-value {
  color: var(--yellow);
}
.grade-d .stat-value,
.grade-f .stat-value {
  color: var(--red);
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---- Compare ---- */
.compare-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.compare-label {
  width: 120px;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-dim);
}

.compare-track {
  flex: 1;
  height: 30px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
  position: relative;
}

.compare-fill {
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  transition: width 0.5s ease;
  white-space: nowrap;
}

.colors-0 {
  background: linear-gradient(90deg, var(--green), #15803d);
}
.colors-1 {
  background: linear-gradient(90deg, var(--blue), #1d4ed8);
}
.colors-2 {
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
}
.colors-3 {
  background: linear-gradient(90deg, var(--yellow), #a16207);
}
.colors-4 {
  background: linear-gradient(90deg, var(--red), #b91c1c);
}

/* ---- Tables ---- */
.asn-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 20px;
  font-size: 12px;
}

.asn-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.asn-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.asn-table tr:hover td {
  background: var(--surface-2);
}

.asn-table .rank {
  font-weight: 800;
  color: var(--text-muted);
  width: 28px;
}

.asn-table .rank-1 {
  color: var(--green);
}

.asn-table .asn-name {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-dim);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pass-bar {
  height: 5px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
  width: 72px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

.pass-bar-fill {
  height: 100%;
  border-radius: 2px;
}

/* ---- Score pills ---- */
.proxy-url {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-dim);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.score-pill.s-green {
  background: var(--green-bg);
  color: var(--green);
}
.score-pill.s-blue {
  background: var(--blue-bg);
  color: var(--blue);
}
.score-pill.s-yellow {
  background: var(--yellow-bg);
  color: var(--yellow);
}
.score-pill.s-red {
  background: var(--red-bg);
  color: var(--red);
}

/* ---- Test dots ---- */
.test-dots {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.test-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: relative;
  cursor: default;
  transition: transform 0.12s;
}

.test-dot:hover {
  transform: scale(1.4);
}

.test-dot.pass {
  background: var(--green);
}
.test-dot.fail {
  background: var(--red);
}

.test-dot-tip {
  display: none;
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--secondary);
  border: 1px solid #3f3f46;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 10px;
  white-space: nowrap;
  z-index: 10;
  color: #fafafa;
  pointer-events: none;
  box-shadow: var(--shadow);
}

.test-dot:hover .test-dot-tip {
  display: block;
}

/* ---- Proxy detail ---- */
.proxy-detail {
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.proxy-detail:hover {
  border-color: var(--border-hover);
}

.proxy-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}

.proxy-detail-header:hover {
  background: var(--surface-2);
}

.proxy-detail-body {
  display: none;
  padding: 0 16px 16px;
  animation: slideDown 0.2s ease;
}

.proxy-detail.open .proxy-detail-body {
  display: block;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}

.detail-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.detail-cell-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-cell .tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.tag.pass {
  background: var(--green-bg);
  color: var(--green);
}

.tag.fail {
  background: var(--red-bg);
  color: var(--red);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 2px 0;
}

.detail-row .dk {
  color: var(--text-dim);
}

.detail-row .dv {
  font-family: monospace;
  font-weight: 500;
}

/* ---- Progress ---- */
.progress-container {
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 400px;
}

.progress-ring {
  width: 132px;
  height: 132px;
  position: relative;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring circle {
  fill: none;
  stroke-width: 5;
}

.progress-ring .track {
  stroke: var(--surface-3);
}

.progress-ring .fill {
  stroke: url(#prog-gradient);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease;
}

.progress-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}

.progress-label {
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
  font-weight: 500;
}

.progress-log {
  width: 100%;
  max-width: 520px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 11px;
  font-family: "SF Mono", "Fira Code", monospace;
  color: var(--text-dim);
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.progress-log .done {
  color: var(--green);
}

.progress-log .running {
  color: var(--accent);
}

/* ---- Filter / pass rate ---- */
.filter-bar {
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.pass-rate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.pass-rate-card {
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color 0.15s;
}

.pass-rate-card:hover {
  border-color: var(--border-hover);
}

.speed-entry {
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.15s;
}

.speed-entry:hover {
  border-color: var(--accent);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  display: inline-block;
}

.fade-in {
  animation: fadeIn 0.25s ease forwards;
}

::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ---- Modal (dedupe from group) ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.45);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow);
}

.modal-card h3 {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text);
}

.modal-card p {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 16px;
}

.modal-card code {
  font-size: 11px;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.dedupe-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.dedupe-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 12px;
  text-align: center;
}

.dedupe-stat .v {
  font-size: 20px;
  font-weight: 800;
}

.dedupe-stat .l {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 4px;
  letter-spacing: 0.04em;
}

.dedupe-log {
  font-size: 11px;
  font-family: monospace;
  color: var(--text-dim);
  max-height: 100px;
  overflow-y: auto;
  margin: 8px 0;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

/* ---- Dedupe full page module ---- */
.dedupe-page {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 48px;
  max-width: 920px;
  margin: 0 auto;
  width: 100%;
}

.dedupe-page h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.dedupe-page .lead {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.65;
  margin-bottom: 24px;
  max-width: 640px;
}

.dedupe-card {
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.dedupe-page .row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

.dedupe-page .status {
  font-size: 12px;
  color: var(--text-dim);
}

.dedupe-page .grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 560px) {
  .dedupe-page .grid2 {
    grid-template-columns: 1fr;
  }
  .dedupe-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .shell-inner {
    padding: 0 16px;
  }
}
