:root {
  /* Apple-inspired color system */
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --bg-elevated-2: #2c2c2e;
  --surface: #1c1c1e;
  --border: rgba(255,255,255,0.08);
  
  --text: rgba(255,255,255,0.95);
  --text-2: rgba(255,255,255,0.65);
  --text-3: rgba(255,255,255,0.45);
  
  --brand: #0a84ff;
  --brand-hover: #409cff;
  --success: #30d158;
  --warning: #ff9f0a;
  --danger: #ff453a;
  --purple: #bf5af2;
  
  /* Precise spacing (Apple's 8px grid) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  
  /* Apple-precise radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  
  /* Typography - SF Pro inspired */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--brand); }

/* Layout */
.container {
  width: min(1200px, calc(100% - 48px));
  margin: 0 auto;
}

.app-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  padding: var(--s-6) 0 var(--s-7);
}

/* Top bar - Apple style */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(28,28,30,0.72);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  gap: var(--s-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-mark svg {
  width: 18px;
  height: 18px;
  fill: white;
}

.brand-name {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.nav {
  display: flex;
  gap: var(--s-2);
  align-items: center;
}

.nav a {
  color: var(--text-2);
  font-weight: 500;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.2s;
}

.nav a.active,
.nav a:hover {
  color: var(--text);
  background: rgba(255,255,255,0.08);
}

/* Bottom nav (mobile) */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: rgba(28,28,30,0.80);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px;
}

.bottom-nav a {
  color: var(--text-2);
  font-weight: 600;
  font-size: 11px;
  padding: 8px;
  border-radius: 10px;
  text-align: center;
  transition: all 0.2s;
}

.bottom-nav a.active {
  color: var(--text);
  background: rgba(255,255,255,0.08);
}

/* Page header */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-4);
  margin-bottom: var(--s-6);
}

.title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.subtitle {
  margin-top: var(--s-2);
  color: var(--text-2);
  font-size: 15px;
  line-height: 1.4;
  max-width: 60ch;
}

/* Cards - Perfect Apple style */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: all 0.2s;
}

.card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.section-title {
  font-size: 13px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* Stats grid - Equal height cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--s-4);
  margin-bottom: var(--s-6);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-card-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.stat-card-link:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: 0 4px 12px rgba(10,132,255,0.2);
}

.stat-card-link:active {
  transform: translateY(0);
}

.stat-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: var(--s-2);
}

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

.stat-help {
  color: var(--text-3);
  font-size: 13px;
  margin-top: var(--s-2);
}

.stat-accent { color: var(--brand); }
.stat-accent2 { color: var(--purple); }
.stat-success { color: var(--success); }
.stat-warn { color: var(--warning); }

/* Buttons - Apple precision */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  border-radius: 10px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 14px;
  border: none;
  color: var(--text);
  background: var(--bg-elevated-2);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(255,255,255,0.12);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--brand);
  color: white;
}

.btn-primary:hover {
  background: var(--brand-hover);
}

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

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-remove {
  background: transparent;
  border: 1px solid rgba(255,69,58,0.3);
  color: var(--danger);
}

/* Forms */
.form {
  display: grid;
  gap: var(--s-5);
}

.field {
  display: grid;
  gap: var(--s-2);
}

.label {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

.input,
.select {
  width: 100%;
  border-radius: var(--r-md);
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
  font-family: var(--font);
}

.input:focus,
.select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(10,132,255,0.15);
}

.help {
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.4;
}

/* Grids */
.grid {
  display: grid;
  gap: var(--s-4);
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
}

/* Product cards */
.product-name {
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
  margin-bottom: var(--s-1);
}

.source-list {
  display: grid;
  gap: var(--s-2);
  margin: var(--s-4) 0;
  padding: var(--s-4);
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  min-height: 60px;
}

.source-item {
  display: flex;
  gap: var(--s-2);
  align-items: center;
}

.source-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.source-name {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.btn-group {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-top: var(--s-4);
}

.empty-title {
  font-size: 20px;
  font-weight: 700;
  margin: var(--s-3) 0 var(--s-2) 0;
}

/* Link items */
.link-item {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border);
}

.link-item:last-child {
  border-bottom: none;
}

.link-info {
  min-width: 0;
  flex: 1;
}

.link-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.link-url {
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Notices */
.notice {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  padding: var(--s-4);
  font-size: 14px;
}

.notice-info {
  border-left: 3px solid var(--brand);
}

.notice-success {
  border-left: 3px solid var(--success);
}

.notice-warning {
  border-left: 3px solid var(--warning);
}

.notice-danger {
  border-left: 3px solid var(--danger);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-google {
  background: rgba(10,132,255,0.15);
  color: var(--brand);
}

.badge-direct {
  background: rgba(48,209,88,0.15);
  color: var(--success);
}

.badge-blocked {
  background: rgba(255,159,10,0.15);
  color: var(--warning);
}

.badge-success {
  background: rgba(48,209,88,0.15);
  color: var(--success);
}

.badge-warn {
  background: rgba(255,159,10,0.15);
  color: var(--warning);
}

.badge-muted {
  background: rgba(255,255,255,0.08);
  color: var(--text-3);
}

/* Empty state */
.empty-state {
  padding: var(--s-6);
  text-align: center;
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: var(--s-2);
}

/* Offer grid (discovery) */
.offer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-4);
  margin-top: var(--s-4);
}

.offer-card {
  position: relative;
  padding: var(--s-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all 0.2s;
  cursor: pointer;
}

.offer-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transform: translateY(-2px);
}

.offer-check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
}

.offer-media {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: var(--s-3);
}

.offer-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.offer-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  margin-bottom: var(--s-2);
}

.offer-price {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: var(--s-2);
}

.offer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2);
  font-size: 12px;
  color: var(--text-3);
}

/* Manual URL input */
.manual-url-input {
  display: flex;
  gap: var(--s-2);
}

.manual-url-input .input {
  flex: 1;
}

/* Sticky CTA */
.sticky-cta {
  position: sticky;
  bottom: var(--s-4);
  display: flex;
  justify-content: center;
  margin-top: var(--s-6);
  z-index: 50;
}

.sticky-cta .btn {
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  padding: 12px 24px;
  font-size: 15px;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: var(--s-3) var(--s-4);
  text-align: left;
}

thead tr {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

tbody tr {
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child {
  border-bottom: none;
}

th {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Loading */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--brand);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s;
}

body.is-loading .progress-bar {
  opacity: 1;
}

/* Danger zone */
.danger-zone {
  margin-top: var(--s-6);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    width: calc(100% - 32px);
  }
  
  .nav {
    display: none;
  }
  
  .bottom-nav {
    display: block;
  }
  
  .main {
    padding-bottom: calc(var(--s-7) + 60px);
  }
  
  .title {
    font-size: 28px;
  }
  
  .subtitle {
    font-size: 14px;
  }
  
  .page-head {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .grid-2 {
    grid-template-columns: 1fr;
  }
  
  .offer-grid {
    grid-template-columns: 1fr;
  }
  
  .card {
    padding: var(--s-4);
  }
  
  .manual-url-input {
    flex-direction: column;
  }
}

