/* TraceLink — Sleek, minimal dashboard */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

:root {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-muted: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --accent: #0ea5e9;
  --accent-hover: #0284c7;
  --accent-muted: #e0f2fe;
  --success: #10b981;
  --success-muted: #d1fae5;
  --danger: #ef4444;
  --danger-muted: #fee2e2;
  --warning: #f59e0b;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.04);
  --shadow: 0 4px 6px -1px rgb(15 23 42 / 0.06), 0 2px 4px -2px rgb(15 23 42 / 0.04);
  --shadow-md: 0 10px 15px -3px rgb(15 23 42 / 0.06), 0 4px 6px -4px rgb(15 23 42 / 0.04);
}

body {
  font-family: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  padding: 1rem 0;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-top: 0.125rem;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
}

/* Main */
.main-content {
  flex: 1;
  padding: 1.25rem 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

@media (min-width: 1600px) {
  .container {
    max-width: 1280px;
    padding: 0 2rem;
  }
}

/* Stats strip — compact, horizontal scroll on mobile */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.875rem;
  margin-bottom: 1rem;
}

.stats-strip {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 -1.5rem;
  padding: 0 1.5rem 0.5rem;
}
.stats-strip::-webkit-scrollbar { display: none; }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border);
}

.stat-icon {
  width: 40px;
  height: 40px;
  background: var(--accent-muted);
  color: var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.stat-icon .icon-svg { width: 1.25rem; height: 1.25rem; }
.security-icon .icon-svg { width: 1.25rem; height: 1.25rem; }
.nav-icon.icon-svg { width: 1.25rem; height: 1.25rem; }
.btn-primary .icon-svg, .btn-secondary .icon-svg, .btn-outline .icon-svg { width: 1rem; height: 1rem; }
.copy-btn .icon-svg { width: 1rem; height: 1rem; }
.action-btn .icon-svg { width: 0.875rem; height: 0.875rem; }

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* Sections */
.create-section,
.links-section,
.events-section {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

/* Create form — collapsible on mobile only */
.create-toggle {
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.create-toggle .toggle-icon {
  display: none;
}
@media (max-width: 767px) {
  .create-toggle {
    cursor: pointer;
  }
  .create-toggle .toggle-icon {
    display: block;
    font-size: 1.25rem;
    font-weight: 300;
    color: var(--accent);
    margin-left: auto;
  }
  .create-form-wrap.collapsed {
    display: none !important;
  }
}

/* Analytics tab panels */
.analytics-tab-panel {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Analytics tabs */
.analytics-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}
.analytics-tab {
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.analytics-tab:hover {
  color: var(--text-secondary);
  background: var(--bg-elevated);
}
.analytics-tab.active {
  color: var(--accent);
  background: var(--accent-muted);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.section-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.section-description {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-top: 0.25rem;
}

.section-actions {
  display: flex;
  gap: 0.5rem;
}

/* Form */
.create-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-group label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group select {
  padding: 0.6875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-page);
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 44px;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

/* Buttons */
.btn-primary {
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.2s, transform 0.1s;
}

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

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.btn-secondary {
  padding: 0.5625rem 1rem;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s, border-color 0.2s;
}

.btn-secondary:hover {
  background: var(--bg-muted);
  border-color: var(--text-muted);
}

.btn-secondary:focus-visible,
.btn-outline:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.btn-outline {
  padding: 0.5rem 0.875rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s, border-color 0.2s;
}

.btn-outline:hover {
  background: var(--bg-elevated);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-close {
  width: 36px;
  height: 36px;
  background: var(--bg-elevated);
  border: none;
  border-radius: var(--radius);
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.btn-close:hover {
  background: var(--danger-muted);
  color: var(--danger);
}

.btn-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--danger-muted);
}

/* Link result */
.link-result {
  margin-top: 1.25rem;
  padding: 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.result-header h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.copy-btn {
  padding: 0.5rem 1rem;
  background: var(--success);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s, transform 0.1s;
}

.copy-btn:hover {
  background: #059669;
}

.copy-btn:active {
  transform: scale(0.98);
}

.link-display input {
  width: 100%;
  padding: 0.6875rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: ui-monospace, 'SF Mono', Monaco, monospace;
  font-size: 0.8125rem;
  color: var(--text-primary);
}

/* Link cards */
.links-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 1rem;
}

.link-card {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.link-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

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

.link-card-field {
  margin-bottom: 0.5rem;
}

.link-card-field:last-of-type {
  margin-bottom: 0;
}

.link-card-field .link-card-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.link-card-id,
.link-card-url {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-muted);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  word-break: break-all;
  display: block;
}

.link-card-url {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  background: var(--bg-muted);
  word-break: break-all;
  overflow-wrap: break-word;
}

.link-card-destination {
  display: block;
  font-size: 0.8125rem;
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-card-destination:hover {
  text-decoration: underline;
}

.link-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.link-card-clicks {
  color: var(--text-primary);
  font-weight: 600;
}

.link-card-domains {
  margin-top: 0.5rem;
  font-size: 0.6875rem;
}

.link-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.action-btn {
  padding: 0.4375rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.action-btn:hover {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent);
}

.action-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.action-btn.delete {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}

.action-btn.delete:hover {
  background: var(--danger-muted);
  color: var(--danger);
  border-color: var(--danger);
}

/* Events / Analytics section */
.events-section {
  display: none;
}

.events-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.events-header-left h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
}

.events-header-left code {
  background: var(--bg-elevated);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem;
  color: var(--accent);
}

/* Analytics grid */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.analytics-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.card-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.375rem;
}

.card-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Security strip */
.security-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.625rem;
  margin-bottom: 1rem;
}

.security-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-left: 3px solid;
}

.security-card.vpn { border-color: #f59e0b; }
.security-card.vpn .security-icon { color: #f59e0b; }
.security-card.proxy { border-color: #8b5cf6; }
.security-card.proxy .security-icon { color: #8b5cf6; }
.security-card.tor { border-color: #ec4899; }
.security-card.tor .security-icon { color: #ec4899; }
.security-card.hosting { border-color: #06b6d4; }
.security-card.hosting .security-icon { color: #06b6d4; }
.security-card.webrtc { border-color: #f97316; }
.security-card.webrtc .security-icon { color: #f97316; }

.security-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.security-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.security-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.security-badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-right: 0.25rem;
}

.security-badge.vpn { background: #fef3c7; color: #92400e; }
.security-badge.proxy { background: #ede9fe; color: #5b21b6; }
.security-badge.tor { background: #fce7f3; color: #9d174d; }
.security-badge.hosting { background: #cffafe; color: #155e75; }
.security-badge.mobile { background: #d1fae5; color: #065f46; }
.security-badge.bot { background: #f3e8ff; color: #6b21a8; }
.security-badge.webrtc { background: #ffedd5; color: #c2410c; }

/* Charts */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.875rem;
  margin-bottom: 1rem;
}

.chart-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.chart-card h3,
.chart-card h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.chart-container {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.chart-bar {
  display: grid;
  grid-template-columns: 100px 1fr 40px;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
}

.chart-bar-label {
  color: var(--text-secondary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-bar-track {
  height: 6px;
  background: var(--bg-muted);
  border-radius: 3px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #38bdf8);
  border-radius: 3px;
  transition: width 0.25s ease;
}

.chart-bar-value {
  text-align: right;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.75rem;
}

.timeline-chart-card {
  grid-column: span 3;
}

.timeline-container {
  display: flex;
  align-items: flex-end;
  gap: 0.375rem;
  height: 80px;
  padding-top: 0.5rem;
}

.timeline-bar {
  flex: 1;
  background: linear-gradient(180deg, var(--accent), #38bdf8);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.25s ease;
}

.timeline-bar:hover {
  opacity: 0.9;
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.75rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* Details */
.details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.875rem;
  margin-bottom: 1rem;
}

.detail-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.detail-card h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4375rem 0;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--border-subtle);
}

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

.stat-list-item-label {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 65%;
}

.stat-list-item-value {
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

/* UTM */
.utm-section {
  margin-bottom: 1rem;
}

.utm-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.utm-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.utm-grid .chart-card h4 {
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.375rem;
}

/* Table / Events grid */
.events-table-section {
  margin-top: 1rem;
}

.events-table-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.events-table-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-style: italic;
}

.events-table-actions {
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.events-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* Events card grid - no scroll, compact */
.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 0.75rem;
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.events-grid::-webkit-scrollbar {
  width: 6px;
}

.events-grid::-webkit-scrollbar-track {
  background: var(--bg-muted);
  border-radius: 3px;
}

.events-grid::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

.event-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.8125rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.event-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.event-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.event-card-time {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.75rem;
}

.event-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.event-card-row {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
  margin-bottom: 0.25rem;
  min-height: 1.25rem;
}

.event-card-label {
  color: var(--text-muted);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 4.5rem;
  flex-shrink: 0;
}

.event-card-value {
  color: var(--text-secondary);
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}

.event-card-value code {
  background: var(--bg-muted);
  padding: 0.125rem 0.25rem;
  border-radius: 4px;
  font-size: 0.6875rem;
  color: var(--accent);
  word-break: break-all;
}

/* Responsive event cards */
@media (max-width: 640px) {
  .event-card {
    padding: 0.875rem;
    font-size: 0.75rem;
  }
  .event-card-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.125rem;
    margin-bottom: 0.375rem;
  }
  .event-card-label {
    min-width: 0;
  }
  .event-card-value {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .events-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

/* Legacy table - hidden, used for export only */
.table-wrapper {
  display: none;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table tr:hover td {
  background: var(--bg-page);
}

.data-table td code {
  background: var(--bg-elevated);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--accent);
}

.domain-badge {
  display: inline-block;
  padding: 0.125rem 0.4375rem;
  background: var(--bg-muted);
  border-radius: 4px;
  font-size: 0.6875rem;
  margin-right: 0.25rem;
  color: var(--text-secondary);
}

.domain-badge.primary {
  background: var(--accent);
  color: white;
}

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

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / 0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 520px;
  max-height: min(88vh, 560px);
  overflow: auto;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-subtle);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-body {
  padding: 1.25rem 1.5rem;
}

.domain-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.domain-form .checkbox {
  flex-direction: row;
  align-items: center;
}

.domain-form .checkbox label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.domains-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.domain-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1rem;
  background: var(--bg-elevated);
  border-radius: var(--radius);
}

.domain-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.domain-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9375rem;
}

.domain-name.primary {
  color: var(--accent);
}

.domain-link {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.domain-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ssl-badge {
  padding: 0.2rem 0.4375rem;
  background: var(--success);
  color: white;
  border-radius: 4px;
  font-size: 0.5625rem;
  font-weight: 600;
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  margin-bottom: 0.75rem;
  opacity: 0.5;
  display: flex;
  justify-content: center;
}

.empty-state-icon .icon-svg {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--text-muted);
}

.empty-state-text {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--text-secondary);
}

.empty-state-description {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.links-cards .empty-state {
  grid-column: 1 / -1;
  padding: 2rem 1rem;
}

.loading-state {
  padding: 2rem !important;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 0.75rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-cell {
  text-align: center;
  padding: 2rem !important;
  color: var(--text-muted);
}

.loading-cell .loading-spinner {
  margin-bottom: 0.5rem;
}

/* Footer */
.app-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  padding: 0.75rem 1rem;
  margin-top: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.6875rem;
}

.app-footer p {
  margin: 0;
}

/* Bottom nav — mobile only */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  padding: 0.5rem 0;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  z-index: 100;
  box-shadow: 0 -4px 6px -1px rgb(15 23 42 / 0.04);
}
.bottom-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
}
.bottom-nav button:hover,
.bottom-nav button:focus {
  color: var(--accent);
  outline: none;
}
.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Responsive */
@media (max-width: 1024px) {
  .quick-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .analytics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .charts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .timeline-chart-card {
    grid-column: span 2;
  }
  .details-grid {
    grid-template-columns: 1fr;
  }
  .security-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .header-content {
    padding: 0 1rem;
    flex-direction: row;
    align-items: center;
  }
  .header-actions {
    display: none;
  }
  .tagline {
    display: none;
  }
  .container {
    padding: 0 1rem;
  }
  .main-content {
    padding: 1rem 0 5.5rem;
  }
  .quick-stats {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.25rem;
  }
  .stat-card {
    flex: 0 0 140px;
    min-width: 140px;
    padding: 0.875rem 1rem;
  }
  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 0.9375rem;
  }
  .stat-value {
    font-size: 1.25rem;
  }
  .stat-label {
    font-size: 0.6875rem;
  }
  .create-section,
  .links-section,
  .events-section {
    padding: 1rem;
    margin-bottom: 0.75rem;
  }
  .section-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
  }
  .section-header h2 {
    font-size: 1rem;
  }
  .bottom-nav {
    display: flex;
    justify-content: space-around;
  }
  .events-section {
    position: fixed;
    inset: 0;
    z-index: 200;
    margin: 0;
    border-radius: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .events-section .events-header {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
    padding: 1rem;
    margin-bottom: 0.75rem;
  }
  .analytics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
  }
  .analytics-card {
    padding: 0.75rem;
  }
  .card-value {
    font-size: 1.125rem;
  }
  .security-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
  }
  .security-card {
    padding: 0.75rem;
  }
  .charts-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }
  .timeline-chart-card {
    grid-column: span 1;
  }
  .chart-bar {
    grid-template-columns: 70px 1fr 32px;
    gap: 0.5rem;
    font-size: 0.75rem;
  }
  .details-grid.charts-details {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .utm-grid {
    grid-template-columns: 1fr;
  }
  .events-tab-content {
    margin-top: 0;
  }
  .events-table-note {
    margin-bottom: 0.5rem;
    font-size: 0.6875rem;
  }
  .events-grid {
    max-height: 55vh;
    grid-template-columns: 1fr;
  }
  .events-header {
    flex-direction: row;
    align-items: center;
  }
  .modal-content {
    width: 95%;
    max-height: 90vh;
  }
  .modal-body {
    padding: 1rem;
  }
  .utm-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .logo h1 {
    font-size: 1.25rem;
  }
  .tagline {
    font-size: 0.75rem;
  }
  .analytics-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  .analytics-card {
    padding: 1rem;
  }
  .card-value {
    font-size: 1.125rem;
  }
  .section-header {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }
  .section-header h2 {
    font-size: 1rem;
  }
  .link-display {
    flex-direction: column;
  }
  .link-display input {
    font-size: 0.75rem;
  }
  .btn-primary,
  .btn-secondary {
    min-height: 44px;
    width: 100%;
    justify-content: center;
  }
  .create-form .btn-primary {
    width: 100%;
  }
  .result-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .copy-btn {
    width: 100%;
    justify-content: center;
  }
  .data-table {
    min-width: 800px;
  }
  .events-header-left code {
    word-break: break-all;
    font-size: 0.6875rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html {
    scroll-behavior: auto;
  }
}
