:root {
  --bg-main: #0b0b0e;
  --bg-card: #141419;
  --bg-elev: #1b1b22;
  --bg-input: #101015;
  --border: rgba(212, 175, 55, 0.18);
  --border-soft: rgba(255, 255, 255, 0.08);
  --gold: #d4af37;
  --gold-light: #f3d778;
  --gold-dark: #9e7b1b;
  --text: #f5f3ee;
  --text-muted: #9f9a8e;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(circle at top, #191610 0%, var(--bg-main) 45%);
  color: var(--text);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

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

.login-card {
  width: 100%;
  max-width: 410px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  text-align: center;
}

.login-card img {
  width: 170px;
  height: auto;
  margin-bottom: 14px;
}

.login-badge {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold-light);
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 99px;
  margin-bottom: 18px;
  font-weight: 600;
}

/* Header & Nav */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(14, 14, 18, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
}

.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-box img {
  height: 38px;
  width: auto;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.3px;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

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

.sync-pill {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  padding: 6px 12px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}

.dot.syncing {
  background: var(--amber);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.25); }
}

.navtabs {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 24px 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-soft);
}

.navtab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s;
}

.navtab:hover {
  color: var(--text);
}

.navtab.active {
  color: var(--gold-light);
  border-bottom-color: var(--gold);
  background: rgba(212, 175, 55, 0.06);
  border-radius: 8px 8px 0 0;
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 24px 60px;
}

/* Cards & Grids */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.kpi-card.gold {
  border-color: var(--border);
  background: linear-gradient(145deg, #191610, #131318);
}

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

.kpi-val {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.kpi-card.gold .kpi-val {
  color: var(--gold-light);
}

.kpi-foot {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 6px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.card-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.segments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.segment-card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.segment-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.segment-count {
  font-size: 20px;
  font-weight: 800;
  color: var(--gold-light);
}

/* Forms & Buttons */
.form-group {
  margin-bottom: 14px;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #d8d3c8;
  margin-bottom: 6px;
}

.input, .select, .textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--gold);
}

.textarea {
  min-height: 82px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}

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

.btn-gold {
  background: linear-gradient(135deg, #d4af37, #b58d22);
  color: #101012;
  font-weight: 700;
}

.btn-gold:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-secondary {
  background: var(--bg-elev);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.14);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--gold);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

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

/* Campaign Builder Split Layout */
.builder-layout {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 20px;
  align-items: start;
}

.preview-sticky {
  position: sticky;
  top: 80px;
}

.preview-frame-wrap {
  background: #23232b;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  justify-content: center;
}

.preview-iframe {
  width: 100%;
  height: 680px;
  border: none;
  border-radius: 8px;
  background: #f4f1ea;
  transition: width 0.25s;
}

.preview-iframe.mobile {
  width: 375px;
}

/* Product Picker */
.catalog-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  max-height: 310px;
  overflow-y: auto;
  padding: 4px;
}

.prod-pick-card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}

.prod-pick-card img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 6px;
  background: #fff;
}

.prod-pick-name {
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.prod-pick-price {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gold-light);
}

.selected-prods-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.sel-prod-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.sel-prod-row img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 6px;
}

/* Tables & Badges */
.table-wrap {
  overflow-x: auto;
}

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

table.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-soft);
  font-weight: 600;
  font-size: 12px;
}

table.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}

.badge-green { background: rgba(16, 185, 129, 0.16); color: #6ee7b7; }
.badge-gold { background: rgba(212, 175, 55, 0.18); color: var(--gold-light); }
.badge-amber { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.badge-red { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }
.badge-gray { background: rgba(255, 255, 255, 0.09); color: #cbd5e1; }

.dns-pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dns-pill {
  padding: 8px 13px;
  border-radius: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  font-size: 12.5px;
  font-weight: 600;
}

.dns-pill.ok {
  border-color: rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.progress-bar {
  width: 100%;
  height: 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 5px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold-light));
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  margin-bottom: 14px;
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 999;
  background: #1b1b22;
  border: 1px solid var(--gold);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6);
  font-size: 13.5px;
  max-width: 380px;
}

@media (max-width: 980px) {
  .builder-layout, .grid-2 {
    grid-template-columns: 1fr;
  }
  .preview-sticky {
    position: static;
  }
}
