:root {
  --green: #39e878;
  --green-dark: #28c05a;
  --bg: #ffffff;
  --bg-alt: #f3f3f1;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1a1a1a;
  --primary-hover: #333;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
  --sidebar-w: 240px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

img, svg { max-width: 100%; display: block; }

/* Navigation */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-links a { font-size: 0.9rem; }
.nav-links a:not(.btn):hover { color: var(--green-dark); }

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  font-family: var(--font);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover { background: var(--primary); color: #fff; }

.btn-green {
  background: var(--green);
  color: var(--text);
}

.btn-green:hover { background: var(--green-dark); }

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

.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.85rem;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: border-color 0.15s;
  background: var(--bg);
}

.form-input:focus { outline: none; border-color: var(--primary); }

textarea.form-input { resize: vertical; min-height: 80px; }

/* Dashboard Layout */
.dashboard-layout { display: flex; min-height: calc(100vh - 64px); }

.sidebar {
  width: var(--sidebar-w);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-alt);
  position: fixed;
  top: 64px;
  bottom: 0;
  left: 0;
  overflow-y: auto;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s;
}

.sidebar-link:hover, .sidebar-link.active {
  background: var(--bg);
  color: var(--text);
}

.sidebar-link svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 10px;
  word-break: break-all;
}

.dashboard-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px;
  max-width: calc(100vw - var(--sidebar-w));
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.page-header p { color: var(--text-muted); font-size: 0.95rem; }

/* Cards */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card-header {
  margin-bottom: 16px;
}

.card-header h2 { font-size: 1.1rem; font-weight: 600; }

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.kpi-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}

.kpi-change {
  font-size: 0.8rem;
  color: var(--green-dark);
  margin-top: 4px;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th, .data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.data-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 24px;
  transition: 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--green); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Color input */
input[type="color"] {
  width: 48px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 2px;
}

/* Profile preview */
.profile-preview {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
  padding: 48px 24px;
  border-radius: var(--radius);
}

.profile-preview .profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(0,0,0,0.1);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.profile-preview .profile-name {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.profile-preview .profile-bio {
  color: inherit;
  opacity: 0.7;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.profile-preview .profile-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.profile-preview .profile-link-btn {
  display: block;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-align: center;
}

.profile-preview .profile-link-btn:hover { opacity: 0.85; }

/* Link reorder */
.link-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--bg);
  cursor: grab;
  transition: box-shadow 0.15s;
}

.link-item:hover { box-shadow: var(--shadow); }
.link-item.dragging { opacity: 0.5; }

.link-item .drag-handle {
  color: var(--text-muted);
  cursor: grab;
  flex-shrink: 0;
}

.link-item .link-info { flex: 1; min-width: 0; }
.link-item .link-info .link-title { font-weight: 600; font-size: 0.9rem; }
.link-item .link-info .link-url { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-item .link-actions { display: flex; gap: 8px; flex-shrink: 0; }
.link-item .link-actions button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
}

.link-item .link-actions button:hover { color: var(--danger); }

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

.modal {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal h2 { font-size: 1.25rem; margin-bottom: 20px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease;
}

.toast-success { background: #065f46; color: #fff; }
.toast-error { background: #991b1b; color: #fff; }
.toast-info { background: #1e40af; color: #fff; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Charts placeholder */
.chart-bar {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 160px;
  padding-top: 24px;
}

.chart-bar .bar {
  flex: 1;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  position: relative;
  transition: height 0.3s;
}

.chart-bar .bar:hover { background: var(--green); }

.chart-labels {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.chart-labels span {
  flex: 1;
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Hero section */
.hero {
  text-align: center;
  padding: 80px 24px 64px;
  max-width: 720px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 20px;
}

.hero p {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-signup {
  display: flex;
  gap: 8px;
  max-width: 440px;
  margin: 0 auto;
}

.hero-signup input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font);
}

.hero-signup input:focus { outline: none; border-color: var(--primary); }
.hero-signup .btn { white-space: nowrap; }

/* Sections */
.section {
  padding: 80px 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.section-dark { background: var(--bg-alt); }

.section h2 {
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.section-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 48px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Feature grid */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.feature-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
}

.feature-card .feature-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.feature-card h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.feature-card p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }

/* Pricing cards */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.pricing-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  transition: border-color 0.15s;
}

.pricing-card.featured {
  border-color: var(--primary);
  position: relative;
}

.pricing-card.featured::before {
  content: 'Popular';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.pricing-card h3 { font-size: 1.2rem; margin-bottom: 8px; }
.pricing-card .price { font-size: 2.5rem; font-weight: 800; margin-bottom: 8px; }
.pricing-card .price span { font-size: 1rem; font-weight: 400; color: var(--text-muted); }
.pricing-card .price-sub { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 24px; }

.pricing-features {
  list-style: none;
  text-align: left;
  margin-bottom: 24px;
}

.pricing-features li {
  padding: 8px 0;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pricing-features li::before {
  content: '';
  width: 18px;
  height: 18px;
  background: var(--green);
  border-radius: 50%;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
}

/* Template grid */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.template-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.15s;
  cursor: pointer;
}

.template-card:hover { box-shadow: var(--shadow-lg); }

.template-preview {
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
}

.template-preview .mini-link {
  width: 70%;
  padding: 8px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.template-info {
  padding: 16px;
}

.template-info h3 { font-size: 0.95rem; font-weight: 600; }
.template-info p { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* Integration cards */
.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.integration-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.integration-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.integration-info { flex: 1; }
.integration-info h3 { font-size: 0.9rem; font-weight: 600; }
.integration-info p { font-size: 0.8rem; color: var(--text-muted); }

/* FAQ */
.faq-list { max-width: 720px; margin: 0 auto; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-q {
  padding: 20px 0;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-a {
  padding-bottom: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  display: none;
}

.faq-item.open .faq-a { display: block; }

/* CTA section */
.cta-section {
  text-align: center;
  padding: 80px 24px;
  background: var(--bg-alt);
}

.cta-section h2 { font-size: 2rem; font-weight: 700; margin-bottom: 16px; }
.cta-section p { color: var(--text-muted); margin-bottom: 24px; font-size: 1.1rem; }

/* Footer */
.footer {
  background: var(--text);
  color: #fff;
  padding: 64px 24px 32px;
}

.footer-grid {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 40px;
  margin-bottom: 40px;
}

.footer-col h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.footer-col a {
  display: block;
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  padding: 4px 0;
}

.footer-col a:hover { color: #fff; }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 24px;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}

.empty-state svg { margin-bottom: 16px; opacity: 0.3; }

.empty-state h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 8px; }

.empty-state p { font-size: 0.9rem; max-width: 400px; margin: 0 auto 20px; }

/* Spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 40px auto;
}

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

/* Settings sections */
.settings-section {
  margin-bottom: 32px;
}

.settings-section h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 16px;
}

.settings-row .setting-label {
  font-weight: 500;
  font-size: 0.9rem;
}

.settings-row .setting-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Team list */
.team-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.team-member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.team-member .member-info h4 { font-size: 0.9rem; font-weight: 600; }
.team-member .member-info p { font-size: 0.8rem; color: var(--text-muted); }

/* Two column layout */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

/* Admin specific */
.admin-section {
  margin-bottom: 40px;
}

.admin-section h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

/* Theme presets */
.theme-presets {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.theme-preset {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s;
}

.theme-preset:hover, .theme-preset.active { border-color: var(--primary); }

/* Responsive */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .mobile-menu-btn { display: block; }

  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    gap: 12px;
  }

  .hero h1 { font-size: 2rem; }
  .hero p { font-size: 1rem; }

  .sidebar {
    position: fixed;
    top: 64px;
    left: -100%;
    z-index: 150;
    height: calc(100vh - 64px);
    transition: left 0.2s;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open { left: 0; }

  .dashboard-main {
    margin-left: 0;
    max-width: 100vw;
    padding: 20px 16px;
  }

  .two-col { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .feature-grid, .pricing-grid { grid-template-columns: 1fr; }
  .template-grid { grid-template-columns: repeat(2, 1fr); }
  .integration-grid { grid-template-columns: 1fr; }

  .sidebar-toggle {
    display: flex !important;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 151;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
  }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.6rem; }
  .section { padding: 48px 16px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .template-grid { grid-template-columns: 1fr; }
}

/* Hidden elements */
.hidden { display: none !important; }
