:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-soft: #1c2128;
  --border: #30363d;
  --border-soft: #252b33;
  --text: #d8dee4;
  --muted: #8b949e;
  --accent: #58a6ff;
  --danger: #ff7b72;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }

.muted { color: var(--muted); }

main { max-width: 1680px; margin: 0 auto; padding: 20px; }
.eyebrow { margin: 0 0 12px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .18em; }
h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }

.button { border: 1px solid transparent; border-radius: 6px; min-height: 36px; padding: 0 13px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-size: 12px; font-weight: 600; white-space: nowrap; }
.button-secondary { background: #21262d; border-color: #373e47; color: var(--text); }
.button-secondary:hover { background: #292f37; border-color: #505966; }
.button-primary { background: #2f81f7; border-color: #2f81f7; color: #fff; }
.button-primary:hover { background: #388bfd; }
.button:disabled { opacity: .55; cursor: default; }
.button-small { min-height: 28px; padding: 0 9px; font-size: 10px; }
.button-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.button-quiet:hover { color: var(--text); background: #21262d; }

.panel { border: 1px solid var(--border); border-radius: 8px; background: var(--panel); overflow: hidden; box-shadow: 0 1px 0 rgba(255,255,255,.02); }
.panel-head { padding: 18px 18px 16px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.panel-meta { display: flex; gap: 7px; align-items: center; margin-top: 7px; font-size: 12px; }
.meta-divider { color: #505960; }
.panel-actions { display: flex; align-items: center; gap: 8px; }
.base-switch { display: flex; gap: 2px; padding: 0 18px 14px; }
.base-switch button { min-width: 112px; height: 44px; padding: 0 12px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); text-align: left; }
.base-switch button:first-child { border-radius: 6px 0 0 6px; }
.base-switch button:last-child { border-radius: 0 6px 6px 0; }
.base-switch button + button { margin-left: -3px; }
.base-switch button.active { position: relative; z-index: 1; border-color: #4b647e; background: #25313e; color: #e6edf3; }
.base-switch span { display: block; font-size: 11px; font-weight: 600; }
.base-switch small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }
.filters { display: flex; align-items: center; gap: 7px; padding: 0 18px 14px; flex-wrap: wrap; }
.filters input, .filters select, .pagination select { height: 36px; border: 1px solid var(--border); border-radius: 6px; background-color: #0d1117; color: var(--text); outline: none; font-size: 12px; }
.filters input:focus, .filters select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(88,166,255,.12); }
.filters select, .pagination select {
  appearance: none;
  -webkit-appearance: none;
  padding: 0 42px 0 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m1 1.5 5 5 5-5' fill='none' stroke='%2389939d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
}
.search-field { position: relative; min-width: 300px; flex: 1; }
.search-field input { width: 100%; padding: 0 12px 0 38px; }
.search-icon { position: absolute; left: 13px; top: 6px; color: var(--muted); font-size: 19px; }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 9px; }
.text-button:hover { color: var(--text); }
.dataset-toggle { display: inline-flex; align-items: center; gap: 2px; height: 36px; padding: 3px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.dataset-toggle label { cursor: pointer; }
.dataset-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dataset-toggle span { display: inline-flex; align-items: center; height: 28px; padding: 0 9px; border-radius: 4px; color: var(--muted); font-size: 11px; font-weight: 600; }
.dataset-toggle input:checked + span { background: #25313e; color: #d9e6f2; }
.dataset-toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.table-wrap { overflow: auto; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 1320px; }
.portfolio-table { min-width: 720px; }
.portfolio-table th.portfolio-column:nth-child(10), .portfolio-table td:nth-child(1) { width: 28%; }
.portfolio-table th.portfolio-column:nth-child(11), .portfolio-table td:nth-child(2) { width: 36%; }
.portfolio-table th.portfolio-column:nth-child(12), .portfolio-table td:nth-child(3) { width: 36%; }
.semrush-table { min-width: 1120px; }
.semrush-table th, .semrush-table td { width: auto; }
.semrush-table th:nth-child(14), .semrush-table td:nth-child(1) { width: 17%; }
.semrush-table th:nth-child(15), .semrush-table td:nth-child(2) { width: 9%; }
.semrush-table th:nth-child(16), .semrush-table td:nth-child(3) { width: 8%; }
.semrush-table th:nth-child(17), .semrush-table td:nth-child(4) { width: 12%; }
.semrush-table th:nth-child(18), .semrush-table td:nth-child(5) { width: 11%; }
.semrush-table th:nth-child(19), .semrush-table td:nth-child(6) { width: 11%; }
.semrush-table th:nth-child(20), .semrush-table td:nth-child(7) { width: 12%; }
.semrush-table th:nth-child(21), .semrush-table td:nth-child(8) { width: 10%; }
.semrush-table th:nth-child(22), .semrush-table td:nth-child(9) { width: 10%; }
th:nth-child(1), td:nth-child(1) { width: 17%; }
th:nth-child(2), td:nth-child(2) { width: 19%; }
th:nth-child(3), td:nth-child(3) { width: 10%; }
th:nth-child(4), td:nth-child(4) { width: 16%; }
th:nth-child(5), td:nth-child(5) { width: 7%; }
th:nth-child(6), td:nth-child(6) { width: 8.5%; }
th:nth-child(7), td:nth-child(7) { width: 8.5%; }
th:nth-child(8), td:nth-child(8) { width: 7.5%; }
th:nth-child(9), td:nth-child(9) { width: 6.5%; }
th { position: sticky; top: 0; z-index: 2; padding: 0 13px; height: 38px; background: #11161d; text-align: left; color: #7d8792; font-size: 10px; text-transform: uppercase; letter-spacing: .055em; border-right: 1px solid rgba(48,54,61,.35); }
th:last-child { border-right: 0; }
th button { border: 0; background: transparent; color: inherit; padding: 0; text-transform: inherit; letter-spacing: inherit; font-size: inherit; }
th button:hover { color: #c9d1d9; }
th button span { margin-left: 3px; color: #58616b; }
td { height: 56px; padding: 10px 13px; border-top: 1px solid var(--border-soft); vertical-align: middle; max-width: 300px; overflow: hidden; font-size: 12.5px; line-height: 1.35; }
tbody tr { transition: background .1s; }
tbody tr:nth-child(even) { background: rgba(255,255,255,.009); }
tbody tr:hover { background: #1b2129; }
.domain-button { color: #e6edf3; font-weight: 600; background: transparent; border: 0; padding: 0; text-align: left; font-size: 12.5px; }
.domain-button:hover { color: var(--accent); }
.cell-secondary { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; }
.cell-tags { margin-top: 5px; }
.tag-list { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; max-width: 100%; }
.badge { display: inline-flex; align-items: center; min-height: 20px; border: 0; border-radius: 5px; padding: 2px 7px; color: #c7cdd4; background: #2b3139; font-size: 10px; font-weight: 600; line-height: 1; white-space: nowrap; }
.badge-neutral { color: #c4cbd3; background: #2b3139; }
.badge-muted { color: #929ba5; background: #252a31; }
.badge-type { color: #b7c6d6; background: #25313e; }
.badge-success { color: #b6f2c1; background: #214b30; }
.badge-danger { color: #ffc0ba; background: #542b2d; }
.badge-warning { color: #f6d889; background: #554519; }
.badge-source-anjouan { color: #c8eea1; background: #355020; }
.badge-source-kahnawake { color: #d6c4ff; background: #423466; }
.badge-source-mga { color: #b9dcff; background: #244c72; }
.badge-source-forum_gambling_com_uk { color: #b9dcff; background: #244c72; }
.badge[class*="badge-source-forum_"] { color: #c8d9eb; background: #293c50; }
.empty-state { min-height: 260px; display: grid; place-content: center; gap: 8px; text-align: center; color: var(--muted); }
.empty-state[hidden] { display: none; }
.empty-state strong { color: var(--text); }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 11px 16px; color: var(--muted); font-size: 12px; }
.pagination select { height: 34px; }
.icon-button { width: 32px; height: 32px; border: 1px solid var(--border); background: #11161d; color: var(--text); border-radius: 6px; }
.icon-button:disabled { opacity: .35; cursor: default; }

.toast { position: fixed; right: 22px; bottom: 22px; max-width: 420px; padding: 14px 18px; border: 1px solid #385014; background: #17200d; color: #d8ff9b; border-radius: 10px; box-shadow: 0 18px 50px rgba(0,0,0,.35); z-index: 30; }
.toast.error { border-color: #633128; background: #261411; color: #ffb1a5; }
dialog { width: min(720px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 14px; background: var(--panel); color: var(--text); padding: 0; box-shadow: 0 24px 80px rgba(0,0,0,.65); }
dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(3px); }
.semrush-details-dialog { width: min(1180px, calc(100vw - 32px)); }
.dialog-head { padding: 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-head h3 { margin: 0; font-size: 23px; }
.observation { padding: 18px 22px; border-bottom: 1px solid var(--border); }
.observation:last-child { border-bottom: 0; }
.observation-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 13px 22px; }
.detail-grid dt { color: var(--muted); font-size: 11px; text-transform: uppercase; margin-bottom: 4px; }
.detail-grid dd { margin: 0; word-break: break-word; }
.detail-grid a { color: var(--accent); }
.enrich-dialog { width: min(620px, calc(100vw - 32px)); }
.enrich-form { display: grid; gap: 16px; padding: 20px 22px 22px; }
.semrush-key-field { display: grid; gap: 7px; color: var(--text); font-size: 11px; }
.semrush-key-field input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 6px; outline: none; background: var(--bg); color: var(--text); }
.semrush-key-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(88,166,255,.12); }
.semrush-key-field small { color: var(--muted); font-size: 10px; }
.semrush-access-row { display: flex; align-items: center; gap: 10px; }
.profile-options { display: grid; gap: 8px; }
.profile-option { display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; align-items: start; padding: 13px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); cursor: pointer; }
.profile-option:has(input:checked) { border-color: #4b647e; background: #1d2834; }
.profile-option input { margin-top: 2px; }
.profile-option strong { display: block; font-size: 12px; }
.profile-option span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.profile-option small { color: #d8b85f; font-size: 10px; white-space: nowrap; }
.semrush-balance { flex: 1; min-height: 34px; padding: 10px 12px; border-radius: 6px; background: var(--bg); color: var(--muted); font-size: 11px; line-height: 1.5; }
.semrush-data { padding: 18px 22px; border-bottom: 1px solid var(--border); }
.semrush-data h4 { margin: 0 0 12px; font-size: 12px; }
.semrush-raw-links { display: flex; gap: 8px; margin-top: 14px; }
.raw-table-wrap { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.raw-table { min-width: 900px; table-layout: auto; }
.raw-table th, .raw-table td { width: auto; height: auto; padding: 8px 10px; white-space: nowrap; }

.login-page { min-height: 100vh; display: grid; place-items: center; }
.login-shell { width: 100%; max-width: 340px; padding: 20px; }
.login-card { width: 100%; }
.login-card input[type="password"] { width: 100%; height: 44px; padding: 0 13px; border: 1px solid var(--border); border-radius: 6px; outline: none; background: var(--panel); color: var(--text); }
.login-card input[type="password"]:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(88,166,255,.12); }
.login-card input[aria-invalid="true"] { border-color: #d65b55; }

.upload-layout { min-height: 100vh; display: grid; place-items: center; }
.upload-panel { width: min(680px, 100%); padding: 24px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.upload-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.upload-head p { max-width: 480px; margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.upload-form { display: grid; gap: 10px; margin-top: 28px; }
.file-drop { display: grid; place-items: center; min-height: 150px; padding: 24px; border: 1px dashed #46505c; border-radius: 7px; background: var(--bg); text-align: center; cursor: pointer; }
.file-drop:hover { border-color: #637080; background: #11161d; }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-drop strong { max-width: 100%; overflow: hidden; color: #e6edf3; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.file-drop span { margin-top: 7px; color: var(--muted); font-size: 11px; }
.upload-message { margin-top: 14px; padding: 11px 13px; border-radius: 6px; background: #1d3526; color: #b6f2c1; font-size: 12px; }
.upload-message.error { background: #3b2225; color: #ffc0ba; }
.upload-status { display: grid; gap: 5px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.upload-status span { color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.upload-status strong { font-size: 16px; }
.upload-status small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
  .panel-head { align-items: flex-start; }
}
@media (max-width: 620px) {
  main { padding: 12px; }
  .panel-head { align-items: stretch; flex-direction: column; }
  .panel-actions { width: 100%; }
  .panel-actions .button { flex: 1; }
  .filters, .panel-head { padding-left: 14px; padding-right: 14px; }
  .base-switch { padding-left: 14px; padding-right: 14px; overflow-x: auto; }
  .search-field { min-width: 100%; }
  .filters select { flex: 1; }
  .detail-grid { grid-template-columns: 1fr; }
  .upload-head { flex-direction: column; }
}
