/* ── BASE ─────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

.admin-body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #0d1117;
  color: #e2e8f0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ───────────────────────────────────────────────────── */
.admin-header {
  background: #161b22;
  border-bottom: 1px solid #21262d;
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-header .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 24px;
}

.admin-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .95rem;
  font-weight: 700;
  color: #f0f6fc;
  text-decoration: none;
  flex-shrink: 0;
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.admin-logo svg {
  color: #3b82f6;
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: .825rem;
  font-weight: 500;
  color: #8b949e;
  text-decoration: none;
  transition: all .15s;
}

.admin-nav a:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, .06);
}

.admin-nav a.active {
  color: #58a6ff;
  background: rgba(56, 139, 253, .1);
}

.admin-nav a svg {
  opacity: .7;
}

.admin-view-site {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .8rem;
  font-weight: 500;
  color: #8b949e;
  text-decoration: none;
  padding: 5px 10px;
  border: 1px solid #30363d;
  border-radius: 6px;
  transition: all .15s;
}

.admin-view-site:hover {
  color: #e2e8f0;
  border-color: #58a6ff;
}

.admin-header .header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── MAIN ─────────────────────────────────────────────────────── */
.admin-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── ALERT ────────────────────────────────────────────────────── */
.alert {
  background: rgba(56, 139, 253, .1);
  border: 1px solid rgba(56, 139, 253, .3);
  color: #79c0ff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: .875rem;
}

.alert-error {
  background: rgba(248, 81, 73, .1);
  border-color: rgba(248, 81, 73, .3);
  color: #ff7b72;
}

/* ── STATS ────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 10px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .15s;
}

.stat-card--active {
  border-color: #3b82f6;
}

.stat-icon {
  color: #3b82f6;
  opacity: .7;
}

.stat-number {
  font-size: 1.75rem;
  font-weight: 800;
  color: #f0f6fc;
  line-height: 1;
}

.stat-label {
  font-size: .775rem;
  color: #6e7681;
  font-weight: 500;
}

/* ── AUTO WRITER CARD ─────────────────────────────────────────── */
.auto-writer-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 12px;
  padding: 24px;
}

.auto-writer-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.auto-writer-top h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #f0f6fc;
  margin-bottom: 4px;
}

.auto-desc {
  font-size: .825rem;
  color: #6e7681;
}

/* Toggle */
.toggle-switch {
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input {
  display: none;
}

.toggle-track {
  display: block;
  width: 48px;
  height: 26px;
  background: #30363d;
  border-radius: 26px;
  position: relative;
  transition: background .25s;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #8b949e;
  transition: transform .25s, background .25s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

.toggle-switch input:checked+.toggle-track {
  background: #1f6feb;
}

.toggle-switch input:checked+.toggle-track .toggle-thumb {
  transform: translateX(22px);
  background: #fff;
}

/* Settings row */
.settings-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid #21262d;
}

.settings-row .form-group {
  flex: 1;
  min-width: 120px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: .72rem;
  font-weight: 600;
  color: #6e7681;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.form-group input,
.form-group select {
  background: #0d1117;
  border: 1px solid #30363d;
  color: #e2e8f0;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: .875rem;
  outline: none;
  font-family: inherit;
  transition: border-color .15s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: #58a6ff;
  box-shadow: 0 0 0 3px rgba(56, 139, 253, .12);
}

.form-group input::placeholder {
  color: #484f58;
}

.form-group select option {
  background: #161b22;
}

.align-end {
  justify-content: flex-end;
}

/* Language selector */
.lang-selector {
  padding-top: 18px;
}

.lang-selector>label {
  font-size: .72rem;
  font-weight: 600;
  color: #6e7681;
  text-transform: uppercase;
  letter-spacing: .06em;
  display: block;
  margin-bottom: 10px;
}

.lang-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lang-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid #30363d;
  color: #6e7681;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}

.lang-chip:hover {
  border-color: #58a6ff;
  color: #c9d1d9;
}

.lang-chip.active {
  background: rgba(56, 139, 253, .1);
  border-color: #1f6feb;
  color: #58a6ff;
}

.lang-code {
  font-size: .68rem;
  font-weight: 700;
  font-family: monospace;
  background: #21262d;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: .04em;
}

.lang-chip.active .lang-code {
  background: rgba(56, 139, 253, .2);
}

/* Live log */
.live-log {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #21262d;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}

.live-log::-webkit-scrollbar {
  width: 4px;
}

.live-log::-webkit-scrollbar-track {
  background: transparent;
}

.live-log::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 4px;
}

.log-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: .8rem;
  transition: background .1s;
}

.log-entry:hover {
  background: rgba(255, 255, 255, .03);
}

.log-time {
  font-family: monospace;
  font-size: .73rem;
  color: #484f58;
  flex-shrink: 0;
  width: 38px;
}

.log-status {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
}

.log-success .log-status {
  background: rgba(46, 160, 67, .2);
  color: #56d364;
}

.log-generating .log-status {
  background: rgba(56, 139, 253, .2);
  color: #58a6ff;
}

.log-error .log-status {
  background: rgba(248, 81, 73, .2);
  color: #ff7b72;
}

.log-info .log-status {
  background: rgba(187, 128, 9, .15);
  color: #e3b341;
}

.log-title {
  color: #c9d1d9;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-msg {
  color: #484f58;
  font-size: .72rem;
  flex-shrink: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-empty {
  color: #484f58;
  text-align: center;
  padding: 16px;
  font-size: .825rem;
}

/* Manual section */
.manual-section {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 12px;
  padding: 16px 20px;
}

.manual-section summary {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #8b949e;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  user-select: none;
  list-style: none;
}

.manual-section summary::-webkit-details-marker {
  display: none;
}

.manual-section summary:hover {
  color: #e2e8f0;
}

.manual-section[open] summary {
  color: #e2e8f0;
  margin-bottom: 18px;
}

.manual-form .settings-row {
  border-bottom: none;
  padding-bottom: 0;
}

/* Admin card */
.admin-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 12px;
  padding: 20px 24px;
}

.admin-card h2 {
  font-size: .925rem;
  font-weight: 700;
  color: #f0f6fc;
  margin-bottom: 16px;
}

/* Table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .825rem;
}

.admin-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: .7rem;
  font-weight: 600;
  color: #6e7681;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid #21262d;
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #0d1117;
  color: #c9d1d9;
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: rgba(255, 255, 255, .02);
}

.admin-table a {
  color: #58a6ff;
  text-decoration: none;
  font-weight: 500;
}

.admin-table a:hover {
  text-decoration: underline;
}

.text-muted {
  color: #6e7681 !important;
  font-size: .8rem;
}

/* Lang tag */
.lang-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: .68rem;
  font-weight: 700;
  font-family: monospace;
  background: #21262d;
  color: #8b949e;
  letter-spacing: .04em;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
  background: rgba(56, 139, 253, .12);
  color: #58a6ff;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: .825rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}

.btn-primary {
  background: #1f6feb;
  color: #fff;
}

.btn-primary:hover {
  background: #388bfd;
}

.btn-success {
  background: #238636;
  color: #fff;
}

.btn-success:hover {
  background: #2ea043;
}

.btn-sm {
  padding: 5px 10px;
  font-size: .775rem;
  border-radius: 5px;
}

.btn-outline {
  background: transparent;
  border: 1px solid #30363d;
  color: #8b949e;
}

.btn-outline:hover {
  border-color: #8b949e;
  color: #e2e8f0;
}

.btn-danger {
  background: #da3633;
  color: white;
}

.btn-danger:hover {
  background: #f85149;
}

/* Icon button */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 1px solid #30363d;
  background: transparent;
  cursor: pointer;
  color: #6e7681;
  transition: all .15s;
}

.btn-icon:hover {
  border-color: #6e7681;
  color: #e2e8f0;
}

.btn-icon-danger:hover {
  border-color: #da3633;
  color: #ff7b72;
  background: rgba(218, 54, 51, .1);
}

.empty {
  color: #484f58;
  text-align: center;
  padding: 24px;
  font-size: .875rem;
}

/* ── LOGIN ────────────────────────────────────────────────────── */
.login-body {
  background: #0d1117;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 12px;
  padding: 36px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-card h1 {
  color: #58a6ff;
  font-size: 1.4rem;
  margin-bottom: 6px;
}

.login-card>p {
  color: #6e7681;
  margin-bottom: 24px;
  font-size: .875rem;
}

.login-card .form-group {
  text-align: left;
  margin-bottom: 12px;
}

.login-card .btn {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

/* ── AFFILIATES ───────────────────────────────────────────────── */
.affiliate-search-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 12px;
  padding: 24px;
}

.affiliate-search-top {
  margin-bottom: 16px;
}

.affiliate-search-top h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #f0f6fc;
  margin-bottom: 4px;
}

.affiliate-search-top p {
  font-size: .825rem;
  color: #6e7681;
}

.affiliate-search-top strong {
  color: #58a6ff;
}

.search-row {
  display: flex;
  gap: 10px;
}

.search-row input {
  flex: 1;
  background: #0d1117;
  border: 1px solid #30363d;
  color: #e2e8f0;
  padding: 9px 14px;
  border-radius: 6px;
  font-size: .875rem;
  outline: none;
  font-family: inherit;
  transition: border-color .15s;
}

.search-row input:focus {
  border-color: #58a6ff;
  box-shadow: 0 0 0 3px rgba(56, 139, 253, .12);
}

.search-row input::placeholder {
  color: #484f58;
}

.search-suggestions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.search-suggestions span {
  color: #484f58;
  font-size: .775rem;
}

.suggestion-chip {
  background: rgba(56, 139, 253, .08);
  border: 1px solid rgba(56, 139, 253, .2);
  color: #58a6ff;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: .75rem;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}

.suggestion-chip:hover {
  background: rgba(56, 139, 253, .15);
  border-color: #58a6ff;
}

.affiliate-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.affiliate-result-card {
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 10px;
  padding: 18px;
  transition: border-color .15s;
}

.affiliate-result-card:hover {
  border-color: #30363d;
}

.affiliate-result-card.lifetime {
  border-color: rgba(56, 139, 253, .3);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}

.result-header h3 {
  font-size: .925rem;
  font-weight: 700;
  color: #f0f6fc;
}

.result-category {
  font-size: .7rem;
  color: #6e7681;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 2px;
}

.lifetime-badge {
  background: rgba(56, 139, 253, .15);
  border: 1px solid rgba(56, 139, 253, .3);
  color: #58a6ff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.result-desc {
  color: #8b949e;
  font-size: .8rem;
  line-height: 1.5;
  margin-bottom: 12px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.result-stat {
  background: #161b22;
  border-radius: 6px;
  padding: 7px 9px;
}

.stat-key {
  display: block;
  font-size: .65rem;
  color: #484f58;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 2px;
}

.stat-val {
  font-size: .78rem;
  color: #c9d1d9;
  font-weight: 600;
}

.stat-val.commission {
  color: #56d364;
}

.result-why,
.result-angles {
  font-size: .775rem;
  color: #8b949e;
  margin-bottom: 8px;
  line-height: 1.4;
}

.result-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 4, 9, .8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 460px;
}

.modal-card h3 {
  color: #f0f6fc;
  font-size: 1rem;
  font-weight: 700;
}