:root {
  --background: #fafafa;
  --foreground: #0f172a;
  --card: #ffffff;
  --card-foreground: #0f172a;
  --primary: #1e3a5f;
  --primary-foreground: #ffffff;
  --secondary: #f1f5f9;
  --secondary-foreground: #0f172a;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --border: #e2e8f0;
  --accent: #c9a962;
  --destructive: #ef4444;
  --radius: 6px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: 'Crimson Pro', Georgia, serif;
  font-weight: 600;
}

.container {
  min-height: 100vh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--primary);
}

.logo-icon {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

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

.nav-link {
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--foreground);
}

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

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

.page-header h1 {
  font-size: 28px;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--muted-foreground);
  font-size: 14px;
}

.usage-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, #2d4a6f 100%);
  border-radius: var(--radius);
  margin-bottom: 24px;
  color: #fff;
}

.usage-info {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.usage-text {
  font-size: 14px;
}

.usage-text strong {
  font-weight: 600;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  font-family: 'Crimson Pro', Georgia, serif;
}

.stat-label {
  font-size: 12px;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.card-header h2 {
  font-size: 16px;
}

.card-content {
  padding: 20px;
}

.table-wrapper {
  overflow-x: auto;
}

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

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted-foreground);
}

tbody tr:hover {
  background: var(--secondary);
}

.client-cell {
  display: flex;
  flex-direction: column;
}

.client-name {
  font-weight: 500;
}

.client-email {
  font-size: 12px;
  color: var(--muted-foreground);
}

.date-cell {
  color: var(--muted-foreground);
  font-size: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
}

.badge-type {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.badge-status {
  text-transform: capitalize;
}

.badge-open {
  background: #dbeafe;
  color: #1e40af;
}

.badge-in-progress {
  background: #fef3c7;
  color: #92400e;
}

.badge-closed {
  background: #d1fae5;
  color: #065f46;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

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

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

.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

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

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

.btn-outline:hover:not(:disabled) {
  background: var(--secondary);
}

.btn-link {
  background: transparent;
  color: var(--primary);
  padding: 4px 8px;
}

.btn-link:hover {
  text-decoration: underline;
}

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

.user-email {
  font-size: 14px;
  color: var(--muted-foreground);
  padding: 0 8px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 24px;
}

.back-link:hover {
  color: var(--foreground);
}

.back-icon {
  width: 16px;
  height: 16px;
}

.case-header {
  margin-bottom: 24px;
}

.case-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.case-title-row h1 {
  font-size: 28px;
}

.case-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}

@media (max-width: 900px) {
  .case-grid {
    grid-template-columns: 1fr;
  }
}

.case-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.case-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.summary-text {
  white-space: pre-wrap;
  color: var(--muted-foreground);
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 14px;
  color: var(--muted-foreground);
}

.info-value {
  font-size: 14px;
  font-weight: 500;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-buttons .btn {
  width: 100%;
}

.document-list {
  list-style: none;
}

.document-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.doc-icon {
  width: 20px;
  height: 20px;
  color: var(--muted-foreground);
}

.doc-name {
  font-size: 14px;
}

.empty-state {
  color: var(--muted-foreground);
  font-size: 14px;
  text-align: center;
  padding: 24px;
}

/* Auth Pages */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--primary) 0%, #2d5a8c 100%);
}

.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-header .logo {
  justify-content: center;
  margin-bottom: 24px;
}

.auth-header h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
}

.form-group input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color 0.2s;
}

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

.btn-block {
  width: 100%;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--muted-foreground);
}

.auth-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Pricing Page */
.pricing-container {
  min-height: 100vh;
}

.pricing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.pricing-header .nav {
  display: flex;
  gap: 12px;
}

.pricing-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 64px 24px;
}

.pricing-hero {
  text-align: center;
  margin-bottom: 48px;
}

.pricing-hero h1 {
  font-size: 40px;
  margin-bottom: 16px;
}

.pricing-hero .subtitle {
  font-size: 18px;
  color: var(--muted-foreground);
  max-width: 600px;
  margin: 0 auto;
}

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

.pricing-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  position: relative;
}

.pricing-card-featured {
  border-color: var(--primary);
  box-shadow: 0 10px 40px -10px rgba(30, 58, 95, 0.2);
}

.pricing-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 4px 16px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
}

.pricing-card-header {
  text-align: center;
  margin-bottom: 24px;
}

.pricing-card-header h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.price {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}

.price .amount {
  font-size: 40px;
  font-weight: 700;
  font-family: 'Crimson Pro', Georgia, serif;
  color: var(--primary);
}

.price .period {
  color: var(--muted-foreground);
  font-size: 14px;
}

.pricing-features {
  list-style: none;
  margin-bottom: 32px;
}

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

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

/* Success Page */
.success-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.success-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 48px;
  width: 100%;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.success-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  background: #d1fae5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-icon svg {
  width: 40px;
  height: 40px;
  color: #059669;
}

.success-card h1 {
  font-size: 28px;
  margin-bottom: 12px;
}

.success-card .subtitle {
  color: var(--muted-foreground);
  margin-bottom: 32px;
}

.success-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
  text-align: left;
}

.success-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--secondary);
  border-radius: var(--radius);
}

.success-feature svg {
  width: 20px;
  height: 20px;
  color: #059669;
}

/* Form Enhancements */
.form-group select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--card);
  width: 100%;
  cursor: pointer;
}

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

.form-group textarea {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  width: 100%;
  resize: vertical;
  min-height: 200px;
  font-family: inherit;
}

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

.form-hint {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 4px;
}

.btn-icon {
  width: 18px;
  height: 18px;
  margin-right: 8px;
}

.info-text {
  color: var(--muted-foreground);
  font-size: 14px;
  margin-bottom: 16px;
}

.feature-list {
  list-style: none;
}

.feature-list li {
  padding: 8px 0;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.feature-list li:last-child {
  border-bottom: none;
}

.feature-list li::before {
  content: "";
  width: 14px;
  height: 14px;
  background: var(--accent);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") no-repeat center;
  flex-shrink: 0;
}

.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--primary-foreground);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

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

.raw-text-preview {
  font-family: 'Inter', monospace;
  font-size: 13px;
  white-space: pre-wrap;
  background: var(--secondary);
  padding: 16px;
  border-radius: var(--radius);
  max-height: 300px;
  overflow-y: auto;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header-row h1 {
  margin-bottom: 0;
}

.btn-block {
  width: 100%;
}

.file-input {
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  width: 100%;
  cursor: pointer;
  background: var(--secondary);
}

.file-input:hover {
  border-color: var(--primary);
}
