/* ─── Reset & base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sp-bg:        #f0f2f5;
  --sp-surface:   #ffffff;
  --sp-border:    #dde1e8;
  --sp-accent:    #2563eb;
  --sp-accent-h:  #1d4ed8;
  --sp-text:      #111827;
  --sp-muted:     #6b7280;
  --sp-success:   #16a34a;
  --sp-error:     #dc2626;
  --sp-warning:   #d97706;
  --sp-radius:    10px;
  --sp-shadow:    0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --sp-header-h:  52px;
}

html { font-size: 15px; }

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

a { color: var(--sp-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: ui-monospace, 'SF Mono', 'Fira Code', monospace;
  font-size: .88em;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
}

/* ─── Header ──────────────────────────────────────────────── */
.sp-header {
  height: var(--sp-header-h);
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,.06);
}

.sp-logo {
  font-size: 15px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: .02em;
}
.sp-logo:hover { color: #fff; text-decoration: none; }

.sp-operator-info {
  display: flex;
  align-items: center;
  gap: 18px;
}

.sp-operator-name {
  font-size: 13px;
  color: #64748b;
}

.sp-logout-btn {
  font-size: 13px;
  color: #64748b;
  transition: color .15s;
}
.sp-logout-btn:hover { color: #cbd5e1; text-decoration: none; }

/* ─── Container ───────────────────────────────────────────── */
.sp-container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 56px;
}

/* ─── Login page ──────────────────────────────────────────── */
.sp-login-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 32px 16px;
}

.sp-login-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--sp-shadow);
}

.sp-login-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--sp-text);
}

.sp-login-subtitle {
  font-size: 13px;
  color: var(--sp-muted);
  margin-bottom: 28px;
}

/* ─── Forms ───────────────────────────────────────────────── */
.sp-form { display: flex; flex-direction: column; gap: 16px; }
.sp-form-group { display: flex; flex-direction: column; gap: 4px; }

.sp-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--sp-text);
}

.sp-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--sp-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--sp-text);
  background: var(--sp-surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.sp-input:focus {
  border-color: var(--sp-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ─── Buttons ─────────────────────────────────────────────── */
.sp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
  text-decoration: none;
}

.sp-btn-primary {
  background: var(--sp-accent);
  color: #fff;
}
.sp-btn-primary:hover { background: var(--sp-accent-h); text-decoration: none; color: #fff; }

.sp-btn-success {
  background: var(--sp-success);
  color: #fff;
}
.sp-btn-success:hover { background: #15803d; text-decoration: none; color: #fff; }

.sp-btn-danger {
  background: var(--sp-error);
  color: #fff;
}
.sp-btn-danger:hover { background: #b91c1c; text-decoration: none; color: #fff; }

.sp-btn-full { width: 100%; margin-top: 4px; }

/* ─── Copy button ─────────────────────────────────────────── */
.sp-btn-copy {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid var(--sp-border);
  background: #f8fafc;
  color: var(--sp-text);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.sp-btn-copy:hover { background: #eff6ff; border-color: var(--sp-accent); }
.sp-btn-copy--done { background: #f0fdf4; border-color: #86efac; color: var(--sp-success); }

/* ─── Bonus forms ─────────────────────────────────────────── */
.sp-bonus-forms {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sp-bonus-form {
  background: #f8fafc;
  border: 1px solid var(--sp-border);
  border-radius: 8px;
  padding: 14px 16px;
}

.sp-bonus-form-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}
.sp-bonus-plus-title  { color: var(--sp-success); }
.sp-bonus-minus-title { color: var(--sp-error); }

.sp-bonus-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.sp-input-sm  { width: 100px; flex-shrink: 0; }
.sp-input-grow { flex: 1; min-width: 140px; }

/* ─── Alerts ──────────────────────────────────────────────── */
.sp-alert {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.sp-alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}
.sp-alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
}
.sp-alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

/* ─── Search ──────────────────────────────────────────────── */
.sp-page-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--sp-text);
}

.sp-search-form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.sp-search-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--sp-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--sp-text);
  background: var(--sp-surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.sp-search-input:focus {
  border-color: var(--sp-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ─── Search results ──────────────────────────────────────── */
.sp-section { margin-bottom: 20px; }

.sp-section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--sp-muted);
  margin-bottom: 10px;
}

.sp-result-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sp-result-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color .15s, background .15s;
}
.sp-result-link:hover {
  border-color: var(--sp-accent);
  background: #eff6ff;
  text-decoration: none;
}

.sp-result-name { flex: 1; }
.sp-result-arrow { color: var(--sp-muted); font-size: 13px; }

/* ─── Hints ───────────────────────────────────────────────── */
.sp-hints-card {
  margin-top: 24px;
  padding: 16px 20px;
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
}

.sp-hints-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--sp-muted);
  margin-bottom: 10px;
}

.sp-hints-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sp-hints-list li { font-size: 13px; color: var(--sp-muted); }

/* ─── Card ────────────────────────────────────────────────── */
.sp-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 20px 24px;
  box-shadow: var(--sp-shadow);
  margin-bottom: 16px;
}

.sp-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.sp-card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--sp-text);
}

.sp-card-subtitle {
  font-size: 14px;
  font-weight: 600;
  color: var(--sp-text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sp-count {
  font-size: 12px;
  font-weight: 400;
  color: var(--sp-muted);
}

/* ─── Info grid ───────────────────────────────────────────── */
.sp-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px 24px;
}

.sp-info-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sp-info-item--full { grid-column: 1 / -1; }

.sp-info-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--sp-muted);
}

.sp-info-value {
  font-size: 14px;
  color: var(--sp-text);
}

.sp-bonus {
  font-weight: 600;
  color: var(--sp-success);
}

/* ─── Badges ──────────────────────────────────────────────── */
.sp-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.sp-badge-active   { background: #dcfce7; color: #166534; }
.sp-badge-deleted  { background: #f3f4f6; color: #6b7280; }
.sp-badge-blocked  { background: #fef3c7; color: #92400e; }
.sp-badge-error    { background: #fee2e2; color: #991b1b; }
.sp-badge-unknown  { background: #f3f4f6; color: #6b7280; }

/* ─── Table ───────────────────────────────────────────────── */
.sp-table-wrap { overflow-x: auto; margin: 0 -4px; }

.sp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.sp-table th {
  text-align: left;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--sp-muted);
  border-bottom: 1.5px solid var(--sp-border);
  white-space: nowrap;
}

.sp-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #f1f3f5;
  vertical-align: top;
  color: var(--sp-text);
}

.sp-table tr:last-child td { border-bottom: none; }
.sp-table tbody tr:hover td { background: #f8fafc; }

.sp-td-id {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--sp-muted);
  white-space: nowrap;
}

.sp-td-mono {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--sp-muted);
  white-space: nowrap;
}

.sp-td-date-active { color: var(--sp-success) !important; font-weight: 500; }

.sp-td-key {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--sp-muted);
}

.sp-td-note {
  font-size: 12px;
  color: var(--sp-muted);
  max-width: 200px;
}

.sp-td-days {
  font-size: 13px;
  white-space: nowrap;
  color: var(--sp-muted);
}
.sp-td-active-days { color: var(--sp-success); font-weight: 500; }
.sp-td-expired     { color: var(--sp-error); }

.sp-td-traffic {
  font-size: 12px;
  white-space: nowrap;
  color: var(--sp-muted);
}
.sp-td-traffic--warning { color: var(--sp-warning); font-weight: 600; }
.sp-td-traffic--danger  { color: var(--sp-error);   font-weight: 700; }

.sp-referrals {
  font-weight: 600;
  color: var(--sp-accent);
}

.sp-partner-link {
  font-size: 13px;
  word-break: break-all;
}

.sp-empty {
  font-size: 13px;
  color: var(--sp-muted);
  padding: 2px 0;
}

/* ─── Breadcrumb ──────────────────────────────────────────── */
.sp-breadcrumb {
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--sp-muted);
}
.sp-breadcrumb a { color: var(--sp-muted); }
.sp-breadcrumb a:hover { color: var(--sp-accent); text-decoration: none; }

/* ─── Icon buttons (+ −) ──────────────────────────────────── */
.sp-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border: 1.5px solid;
  cursor: pointer;
  line-height: 1;
  vertical-align: middle;
  margin-left: 5px;
  transition: background .15s, border-color .15s, color .15s;
  padding: 0;
}
.sp-btn-icon-plus  { border-color: var(--sp-success); color: var(--sp-success); background: transparent; }
.sp-btn-icon-plus:hover  { background: #f0fdf4; }
.sp-btn-icon-minus { border-color: var(--sp-error);   color: var(--sp-error);   background: transparent; }
.sp-btn-icon-minus:hover { background: #fef2f2; }
.sp-btn-date-edit {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  vertical-align: middle;
}
.sp-btn-delete {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  vertical-align: middle;
  opacity: 0.45;
}
.sp-btn-delete:hover { opacity: 1; }
.sp-td-actions { white-space: nowrap; }

/* ─── Modal ───────────────────────────────────────────────── */
.sp-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.sp-modal-overlay--open { display: flex; }

.sp-modal {
  background: var(--sp-surface);
  border-radius: var(--sp-radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 380px;
}

.sp-modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--sp-text);
}

.sp-modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.sp-btn-secondary {
  background: var(--sp-surface);
  color: var(--sp-text);
  border: 1.5px solid var(--sp-border);
}
.sp-btn-secondary:hover { background: #f1f5f9; text-decoration: none; }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .sp-container  { padding: 16px 14px 40px; }
  .sp-card       { padding: 16px 14px; }
  .sp-info-grid  { grid-template-columns: repeat(2, 1fr); }
  .sp-search-form { flex-direction: column; }
  .sp-search-input { width: 100%; }
}


/* ─── X8 / Source badges ──────────────────────────────────── */
.sp-badge-axo {
  background: #dbeafe;
  color: #1d4ed8;
}
.sp-badge-x8 {
  background: #fef3c7;
  color: #92400e;
}

/* ─── X8 deactivate button ────────────────────────────────── */
.sp-btn-deactivate {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  background: #fff7ed;
  color: #c2410c;
  transition: background .15s;
}
.sp-btn-deactivate:hover { background: #fed7aa; }

/* ─── Warning button ──────────────────────────────────────── */
.sp-btn-warning {
  background: #f97316;
  color: #fff;
  border: none;
}
.sp-btn-warning:hover { background: #ea580c; text-decoration: none; }
