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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: #f5f5f5;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navbar */
.navbar {
  background-color: #2c3e50;
  color: white;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand {
  font-size: 1.25rem;
  font-weight: bold;
  color: white;
  text-decoration: none;
}

.nav-brand:hover {
  color: #ecf0f1;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-links a {
  color: white;
  text-decoration: none;
}

.nav-links a:hover {
  text-decoration: underline;
}

a.nav-user {
  color: #bdc3c7;
  text-decoration: none;
}

a.nav-user:hover {
  color: white;
  text-decoration: underline;
}

.btn-link {
  background: none;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  font-size: 1rem;
}

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

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

/* Login */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
}

.login-box {
  background: white;
  padding: 2.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
}

.login-box h1 {
  text-align: center;
  margin-bottom: 0.5rem;
  color: #2c3e50;
}

.login-subtitle {
  text-align: center;
  color: #7f8c8d;
  margin-bottom: 2rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-weight: 500;
  color: #34495e;
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary {
  background-color: #3498db;
  color: white;
}

.btn-primary:hover {
  background-color: #2980b9;
}

.btn-block {
  width: 100%;
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.alert-error {
  background-color: #fee2e2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.alert-success {
  background-color: #d1fae5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-header h1 {
  color: #2c3e50;
}

/* Tables */
.table {
  width: 100%;
  background: white;
  border-collapse: collapse;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.table th,
.table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.table th {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #34495e;
}

.table tr:last-child td {
  border-bottom: none;
}

.clickable-row {
  cursor: pointer;
  transition: background-color 0.2s;
}

.clickable-row:hover {
  background-color: #f8f9fa;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
}

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

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

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.empty-state h2 {
  color: #2c3e50;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: #7f8c8d;
  margin-bottom: 1.5rem;
}

/* Form Container */
.form-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 2rem;
  max-width: 800px;
}

.form-section {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid #eee;
}

.form-section:last-of-type {
  border-bottom: none;
  margin-bottom: 1rem;
  padding-bottom: 0;
}

.form-section h2 {
  color: #2c3e50;
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
}

.budget-form textarea {
  resize: vertical;
  min-height: 150px;
}

.char-count {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #7f8c8d;
}

.field-error {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #dc2626;
}

/* Loading Overlay */
.loading-overlay[hidden] {
  display: none;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(245, 245, 245, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-card {
  background: white;
  border-radius: 8px;
  padding: 2rem 2.5rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  text-align: center;
  max-width: 420px;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e2e8f0;
  border-top-color: #3498db;
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.9s linear infinite;
}

.loading-text {
  color: #2c3e50;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.loading-subtext {
  color: #7f8c8d;
  font-size: 0.95rem;
}

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

button:disabled,
.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Checkbox Group */
.checkbox-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: #34495e;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.checkbox-label:hover {
  color: #2c3e50;
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.btn-secondary {
  background-color: #6c757d;
  color: white;
  text-decoration: none;
  display: inline-block;
}

.btn-secondary:hover {
  background-color: #5a6268;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.1rem;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

/* Admin */
.admin-layout {
  display: grid;
  gap: 1.5rem;
}

.admin-card h2,
.admin-users h2 {
  margin-bottom: 1rem;
  color: #2c3e50;
}

.admin-users {
  width: 100%;
}

.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.inline-input {
  padding: 0.5rem 0.6rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  min-width: 160px;
}

@media (min-width: 1000px) {
  .admin-layout {
    grid-template-columns: 360px 1fr;
    align-items: start;
  }
}

/* Budget View */
.budget-details {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 2rem;
}

.budget-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #eee;
  margin-bottom: 1.5rem;
}

.meta-item {
  color: #34495e;
}

.meta-item strong {
  color: #2c3e50;
}

.internal-notes {
  background: #fef3c7;
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
}

.internal-notes h3 {
  color: #92400e;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.internal-notes p {
  color: #92400e;
  margin: 0;
}

.budget-content {
  margin-bottom: 1.5rem;
}

.budget-content h3,
.requirements-section h3 {
  color: #2c3e50;
  margin-bottom: 1rem;
}

.markdown-content {
  line-height: 1.6;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: #2c3e50;
}

.markdown-content p {
  margin-bottom: 1rem;
}

.markdown-content ul,
.markdown-content ol {
  margin-bottom: 1rem;
  padding-left: 2rem;
}

.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid #ddd;
  padding: 0.5rem;
  text-align: left;
}

.markdown-content th {
  background: #f8f9fa;
}

.requirements-section {
  border-top: 1px solid #eee;
  padding-top: 1.5rem;
}

.requirements-text {
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 4px;
  white-space: pre-wrap;
  font-family: inherit;
  color: #34495e;
}

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

/* Pricing */
.pricing-meta {
  margin-bottom: 1.5rem;
  color: #7f8c8d;
  font-size: 0.9rem;
}

.pricing-meta .meta-label {
  font-weight: 500;
}

.pricing-content {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 2rem;
}

.pricing-editor {
  max-width: 100%;
}

.markdown-editor {
  width: 100%;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  resize: vertical;
  min-height: 500px;
}

.markdown-editor:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-hint {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #7f8c8d;
}

/* PDF Upload Section */
.upload-section {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 2rem;
  margin-bottom: 2rem;
}

.upload-section h2 {
  color: #2c3e50;
  margin-bottom: 0.5rem;
}

.upload-section > p {
  color: #7f8c8d;
  margin-bottom: 1.5rem;
}

.upload-area {
  border: 2px dashed #ddd;
  border-radius: 8px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 1rem;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: #3498db;
  background-color: #f8f9fa;
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.upload-text {
  color: #34495e;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.upload-hint {
  color: #7f8c8d;
  font-size: 0.9rem;
}

.selected-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #e8f4fd;
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.file-name {
  color: #2980b9;
  font-weight: 500;
}

.btn-remove {
  background: none;
  border: none;
  color: #e74c3c;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 0.5rem;
}

.btn-remove:hover {
  color: #c0392b;
}

.section-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 2rem 0;
}

.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #ddd;
}

.section-divider span {
  padding: 0 1rem;
  color: #7f8c8d;
  font-size: 0.9rem;
}

/* Extracted Preview */
.extracted-preview {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 2rem;
}

.extracted-preview h2 {
  color: #2c3e50;
  margin-bottom: 0.5rem;
}

.preview-notice {
  color: #7f8c8d;
  margin-bottom: 1.5rem;
}

.preview-content {
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  max-height: 500px;
  overflow-y: auto;
}

.preview-content pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
}

.preview-actions {
  display: flex;
  gap: 1rem;
}

/* Footer */
.footer {
  background-color: #2c3e50;
  color: #bdc3c7;
  text-align: center;
  padding: 1rem;
  margin-top: auto;
}

/* Status Badges - Extended */
.badge-sent {
  background-color: #dbeafe;
  color: #1e40af;
}

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

.badge-rejected {
  background-color: #fee2e2;
  color: #dc2626;
}

.badge-archived {
  background-color: #e5e7eb;
  color: #4b5563;
}

/* Status Dropdown */
.status-dropdown {
  padding: 0.35rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  background-color: white;
  transition: all 0.2s;
}

.status-dropdown:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.status-dropdown.status-updated {
  background-color: #d1fae5;
  border-color: #059669;
}

/* Budget Edit Page */
.budget-edit-form {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.edit-container {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 600px;
}

.edit-sidebar {
  background: #f8f9fa;
  padding: 1.5rem;
  border-right: 1px solid #eee;
  border-radius: 8px 0 0 0;
}

.sidebar-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #ddd;
}

.sidebar-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.sidebar-section h3 {
  color: #2c3e50;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}

.info-item {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #34495e;
}

.info-item strong {
  display: block;
  font-size: 0.8rem;
  color: #7f8c8d;
  margin-bottom: 0.1rem;
}

.status-select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
}

.edit-sidebar textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  resize: vertical;
}

.btn-block {
  display: block;
  width: 100%;
  text-align: center;
}

.action-hint {
  font-size: 0.8rem;
  color: #7f8c8d;
  margin-top: 0.5rem;
  text-align: center;
}

.edit-main {
  padding: 1.5rem;
}

.edit-main .markdown-editor {
  min-height: 500px;
}

.budget-edit-form .form-actions {
  padding: 1.5rem;
  border-top: 1px solid #eee;
  background: #f8f9fa;
  border-radius: 0 0 8px 8px;
}

/* Responsive Edit Page */
@media (max-width: 900px) {
  .edit-container {
    grid-template-columns: 1fr;
  }

  .edit-sidebar {
    border-right: none;
    border-bottom: 1px solid #eee;
    border-radius: 8px 8px 0 0;
  }
}

/* Filters Section */
.filters-section {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
}

.filters-form {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.filter-group {
  flex: 1;
  min-width: 150px;
  max-width: 250px;
}

.filter-input,
.filter-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
}

.filter-input:focus,
.filter-select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.results-info {
  color: #7f8c8d;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding: 1rem;
}

.pagination-link {
  padding: 0.5rem 1rem;
  background: #3498db;
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

.pagination-link:hover {
  background: #2980b9;
}

.pagination-info {
  color: #7f8c8d;
  font-size: 0.9rem;
}

/* Profile */
.profile-layout {
  display: grid;
  gap: 1.5rem;
}

.profile-card h2 {
  margin-bottom: 1rem;
  color: #2c3e50;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
}

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

.info-label {
  color: #7f8c8d;
  font-weight: 500;
}

.info-value {
  color: #2c3e50;
}

.profile-forms {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 1000px) {
  .profile-layout {
    grid-template-columns: 300px 1fr;
    align-items: start;
  }
}

/* Responsive Filters */
@media (max-width: 768px) {
  .filters-form {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    max-width: none;
  }
}

/* AI Pre-fill Section */
.ai-prefill-section {
  background: #f0f7ff;
  border: 2px dashed #3498db;
  border-radius: 8px;
}

.ai-prefill-section h2 {
  color: #2980b9;
}

.section-hint {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.ai-prefill-section textarea {
  min-height: 120px;
  resize: vertical;
}

.ai-prefill-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.ai-result {
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 1rem;
  margin-top: 0.75rem;
}

.ai-result-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
