:root {
  --primary: #1E40AF;
  --primary-dark: #1E3A8A;
  --primary-light: #3B82F6;
  --accent: #F59E0B;
  --bg: #F8FAFC;
  --bg-card: #FFFFFF;
  --text: #1E293B;
  --text-light: #64748B;
  --border: #E2E8F0;
  --success: #059669;
  --danger: #DC2626;
  --warning: #D97706;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 24px rgba(0,0,0,.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* --- Navbar --- */
.navbar {
  background: var(--primary-dark);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.navbar .logo {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.navbar .logo span { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: .25rem; }
.nav-links a {
  color: rgba(255,255,255,.85);
  padding: .5rem .75rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-links a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-links .btn-nav {
  background: var(--accent);
  color: #000;
  padding: .5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
}
.nav-links .btn-nav:hover { background: #FBBF24; }
.menu-toggle { display: none; background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }

/* --- Container --- */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; flex: 1; }

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}
.card-header {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--primary-dark);
}

/* --- Hero --- */
.hero {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  color: #fff;
  padding: 5rem 2rem;
  text-align: center;
  margin: -2rem -1.5rem 2rem;
  border-radius: 0 0 24px 24px;
}
.hero h1 { font-size: 2.75rem; font-weight: 800; margin-bottom: 1rem; }
.hero p { font-size: 1.2rem; opacity: .9; max-width: 640px; margin: 0 auto 2rem; }
.hero .btn { font-size: 1.1rem; padding: .875rem 2.5rem; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .625rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: .9rem;
  border: none;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-accent { background: var(--accent); color: #000; }
.btn-accent:hover { background: #FBBF24; color: #000; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .375rem .875rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* --- Forms --- */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: .875rem;
  margin-bottom: .375rem;
  color: var(--text);
}
.form-control {
  width: 100%;
  padding: .625rem .875rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,64,175,.1);
}
textarea.form-control { min-height: 120px; resize: vertical; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.5rem; }

/* --- Grid --- */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* --- Features --- */
.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  transition: transform .2s, box-shadow .2s;
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.feature-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}
.feature-card h3 { font-size: 1.05rem; margin-bottom: .5rem; color: var(--primary-dark); }
.feature-card p { font-size: .875rem; color: var(--text-light); }

/* --- Stats --- */
.stats { display: flex; gap: 1.5rem; margin-bottom: 2rem; flex-wrap: wrap; }
.stat-card {
  flex: 1;
  min-width: 140px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: .8rem; color: var(--text-light); font-weight: 500; margin-top: .25rem; }

/* --- Doc list --- */
.doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.doc-item:last-child { border-bottom: none; }
.doc-meta { flex: 1; min-width: 0; }
.doc-meta h4 { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta span { font-size: .8rem; color: var(--text-light); }
.doc-type {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 6px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.doc-type-contract { background: #DBEAFE; color: #1E40AF; }
.doc-type-nda { background: #FEF3C7; color: #92400E; }
.doc-type-tos { background: #D1FAE5; color: #065F46; }
.doc-type-privacy { background: #EDE9FE; color: #5B21B6; }
.doc-type-review { background: #FFE4E6; color: #9F1239; }

.doc-actions { display: flex; gap: .5rem; flex-shrink: 0; }

/* --- Result page --- */
.doc-content {
  background: #FAFBFC;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  white-space: pre-wrap;
  font-size: .9rem;
  line-height: 1.75;
  max-height: 70vh;
  overflow-y: auto;
}

/* --- Pricing --- */
.pricing-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  transition: transform .2s, box-shadow .2s;
}
.pricing-card.featured { border-color: var(--primary); box-shadow: var(--shadow-lg); transform: scale(1.03); }
.pricing-card:hover { box-shadow: var(--shadow-lg); }
.pricing-name { font-size: 1.1rem; font-weight: 700; color: var(--primary-dark); margin-bottom: .5rem; }
.pricing-price { font-size: 2.5rem; font-weight: 800; color: var(--text); margin-bottom: .25rem; }
.pricing-price span { font-size: .9rem; font-weight: 400; color: var(--text-light); }
.pricing-features { list-style: none; margin: 1.5rem 0; text-align: left; }
.pricing-features li { padding: .4rem 0; font-size: .875rem; color: var(--text); display: flex; align-items: center; gap: .5rem; }
.pricing-features li::before { content: "\2713"; color: var(--success); font-weight: 700; }

/* --- Alerts --- */
.alert {
  padding: .875rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: .875rem;
  font-weight: 500;
}
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-danger { background: #FFE4E6; color: #9F1239; border: 1px solid #FECDD3; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

/* --- Disclaimer --- */
.disclaimer {
  background: #FFF7ED;
  border: 1px solid #FED7AA;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  font-size: .8rem;
  color: #9A3412;
  margin-top: 1.5rem;
}

/* --- Auth forms --- */
.auth-wrap { max-width: 440px; margin: 3rem auto; }
.auth-wrap .card { padding: 2.5rem; }
.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-header h2 { font-size: 1.5rem; color: var(--primary-dark); }
.auth-header p { color: var(--text-light); font-size: .9rem; }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: .875rem; color: var(--text-light); }

/* --- Page header --- */
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.75rem; font-weight: 800; color: var(--primary-dark); }
.page-header p { color: var(--text-light); margin-top: .25rem; }

/* --- Footer --- */
footer {
  background: var(--primary-dark);
  color: rgba(255,255,255,.7);
  text-align: center;
  padding: 1.5rem;
  font-size: .8rem;
  margin-top: auto;
}
footer a { color: rgba(255,255,255,.9); }

/* --- Spinner --- */
.spinner {
  display: none;
  text-align: center;
  padding: 2rem;
}
.spinner.active { display: block; }
.spinner::after {
  content: '';
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Responsive --- */
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .navbar { padding: 0 1rem; }
  .nav-links { display: none; position: absolute; top: 64px; left: 0; right: 0; background: var(--primary-dark); flex-direction: column; padding: 1rem; gap: .25rem; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
  .nav-links.open { display: flex; }
  .menu-toggle { display: block; }
  .hero { padding: 3rem 1.5rem; margin: -2rem -1.5rem 1.5rem; }
  .hero h1 { font-size: 1.75rem; }
  .hero p { font-size: 1rem; }
  .container { padding: 1.5rem 1rem; }
  .stats { flex-direction: column; }
  .pricing-card.featured { transform: none; }
  .doc-item { flex-direction: column; align-items: flex-start; }
  .doc-actions { width: 100%; }
}

/* --- Loading overlay for form submit --- */
.form-loading { position: relative; }
.form-loading::after {
  content: 'Generating document... This may take 15-30 seconds.';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.92);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--primary);
  border-radius: var(--radius);
  font-size: .95rem;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  gap: .5rem;
  margin-top: 1.5rem;
}
.pagination a, .pagination span {
  padding: .5rem .875rem;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
}
.pagination a { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); }
.pagination a:hover { background: var(--primary); color: #fff; }
.pagination .active { background: var(--primary); color: #fff; }
