body {
  font-family: -apple-system, system-ui, Segoe UI, Roboto, Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

:root {
  --brand: #226c4f;
  --bg: #f9f9f9;
  --text: #333;
  --muted: #666;
  --card: #fff;
  --border: #e6e6e6;
  --primary: #1F2933;
  --secondary: #6c757d;
}

* {
  box-sizing: border-box;
}

/* Header */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #fff;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  z-index: 1000;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary);
}

.header-nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-left: 2rem;
  flex: 1;
}

.nav-item {
  position: relative;
  display: inline-block;
}

.nav-badge {
  position: absolute;
  top: -2px;
  right: -6px;
  background: #dc3545;
  color: white;
  border-radius: 50%;
  width: 10px;
  height: 10px;
  display: inline-block;
  box-shadow: 0 0 0 2px white;
  z-index: 10;
}

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

.user-profile-menu {
  position: relative;
}

.profile-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}

.profile-icon:hover {
  border-color: var(--primary);
  background: #f5f5f5;
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  z-index: 1001;
  overflow: hidden;
}

.profile-dropdown-header {
  padding: 1rem;
  background: #f9f9f9;
}

.profile-name {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
  font-size: 0.95em;
}

.profile-email {
  font-size: 0.85em;
  color: var(--muted);
}

.profile-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

.profile-dropdown-item {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 0.95em;
  cursor: pointer;
}

.profile-dropdown-item:hover {
  background: #f5f5f5;
}

.profile-dropdown-item-logout {
  color: #dc3545;
}

.profile-dropdown-item-logout:hover {
  background: #fff5f5;
  color: #c82333;
}

/* Header Navigation */
.nav-item {
  padding: 0.5rem 1rem;
  color: var(--text);
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.2s;
  font-size: 0.95em;
  white-space: nowrap;
}

.nav-item:hover {
  background: #f5f5f5;
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary);
  color: white;
}

/* Main Content */
#mainContent {
  margin-top: 60px;
  padding: 2rem;
  min-height: calc(100vh - 60px);
}

/* Home Page */
.home-section {
  margin-bottom: 2rem;
}

.home-section h2 {
  margin-bottom: 0.5rem;
}

.home-section p {
  color: #666;
  margin-bottom: 1rem;
}

#homeNewProjectBtn {
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-box {
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stat-box h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9em;
  color: #666;
  font-weight: normal;
}

.stat-value {
  font-size: 2rem;
  font-weight: bold;
  color: var(--primary);
}

.stat-value-small {
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--primary);
}

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

.data-table thead tr {
  background: #f8f9fa;
}

.data-table th {
  padding: 1rem;
  text-align: left;
  border-bottom: 2px solid #ddd;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.data-table th.sortable:hover {
  background-color: #e9ecef;
}

.data-table th.sortable::after {
  content: ' ↕';
  opacity: 0.3;
  font-size: 0.9em;
}

.data-table th.sortable:hover::after {
  opacity: 0.6;
}

.data-table td {
  padding: 1rem;
}

.data-table tbody tr {
  border-bottom: 1px solid #eee;
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: #f8f9fa;
}

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

.table-loading {
  padding: 1rem;
  text-align: center;
  color: #666;
}

.table-empty {
  padding: 1rem;
  text-align: center;
  color: #666;
}

/* Projects Page */
#projectsView h2 {
  margin-bottom: 1.5rem;
}

#newProjectForm {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  align-items: baseline;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1em;
  font-family: inherit;
}

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

.form-group.full-width {
  grid-column: 1 / -1;
}

#projectsListContainer {
  margin-top: 1rem;
}

/* Project Details */
.project-info-section {
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.project-info-section h3 {
  margin-top: 0;
  margin-bottom: 1rem;
}

.project-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.info-item {
  padding: 0.5rem 0;
}

.info-item strong {
  display: inline-block;
  min-width: 120px;
  color: #666;
}

.project-details-section {
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.project-details-section h3 {
  margin-top: 0;
  margin-bottom: 1.5rem;
}

.project-details-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.btn-save-project {
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
  align-self: flex-start;
  margin-top: 0.5rem;
}

.btn-save-project:hover {
  filter: brightness(0.95);
}

/* Documents Table */
.documents-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.documents-table thead {
  background: #f8f9fa;
}

.documents-table th {
  padding: 1rem;
  text-align: left;
  border-bottom: 2px solid #ddd;
  font-weight: 600;
}

.documents-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

.documents-table tbody tr:hover {
  background: #f8f9fa;
}

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

.doc-name-cell {
  min-width: 200px;
}

.doc-name-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.doc-name-link {
  color: var(--primary);
  text-decoration: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-name-link:hover {
  text-decoration: underline;
}

.doc-filename-input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  flex: 1;
  border: 1px solid var(--primary);
  background: #fff;
  padding: 0.25rem;
  border-radius: 4px;
}

.doc-filename-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.btn-edit-name {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1em;
  opacity: 0.6;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.btn-edit-name:hover {
  opacity: 1;
}

.btn-view-doc,
.btn-delete-doc {
  padding: 0.4rem 0.8rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  margin-right: 0.5rem;
  transition: all 0.2s;
}

.btn-view-doc {
  background: var(--primary);
  color: white;
  text-decoration: none;
  display: inline-block;
}

.btn-view-doc:hover {
  filter: brightness(0.95);
}

.btn-delete-doc {
  background: #dc3545;
  color: white;
}

.btn-delete-doc:hover {
  background: #c82333;
}

/* Documents Page */
#documentsView h2 {
  margin-bottom: 1.5rem;
}

/* Settings Page */
#settingsView h2 {
  margin-bottom: 1.5rem;
}

#settingsView p {
  color: #666;
}

/* Project Detail View */
#backToList {
  margin: 1rem 2rem 1rem 2rem;
  padding: 0.5rem 1rem;
  background: var(--secondary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  align-self: flex-start;
}

#projectView {
  margin-top: -2rem;
  margin-left: -2rem;
  margin-right: -2rem;
  margin-bottom: -2rem;
  padding: 0;
  height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
}

.project-view-wrapper {
  display: flex;
  gap: 0;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.project-view-container {
  flex: 0 0 70%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-width: 0;
  transition: flex-basis 0.3s ease;
}

/* Adjust project view container width based on chat width */
body.chat-minimized .project-view-container {
  flex: 0 0 100%;
}

body.chat-standard .project-view-container {
  flex: 0 0 70%;
}

body.chat-full .project-view-container {
  flex: 0 0 0%;
  display: none;
}

/* Minimized chat icon */
.chat-minimized-icon {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  transition: all 0.3s ease;
}

.chat-minimized-icon:hover {
  background: #1d5f47;
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chat-minimized-icon svg {
  width: 24px;
  height: 24px;
}

.project-view-left {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 0 2rem;
}

.project-header {
  margin-bottom: 0.5rem;
}

.project-header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 2rem;
  color: var(--primary);
}

.project-meta {
  color: var(--muted);
  font-size: 0.95em;
}

.project-id {
  font-weight: 500;
}

.meta-separator {
  margin: 0 0.5rem;
  color: var(--border);
}

.project-customer {
  font-weight: 500;
}

.project-content-box {
  display: flex;
  flex-direction: column;
  /* Remove border and background */
}

/* Tabs - separated from content */
.project-tabs {
  display: flex;
  gap: 0;
  background: #f0f2f4;
  border-radius: 0.625rem;
  padding: 0.25rem;
  margin-bottom: 1rem;
}

.project-tab {
  flex: 0 0 auto;
  padding: 0.625rem 1.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  transition: all 0.2s ease;
  font-weight: 500;
  border-radius: 0.625rem;
}

.project-tab:hover {
  background: rgba(255, 255, 255, 0.5);
  color: var(--primary);
}

.project-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.project-tab {
  position: relative;
}

.project-tab-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  background: #dc3545;
  color: white;
  border-radius: 50%;
  width: 8px;
  height: 8px;
  display: inline-block;
  box-shadow: 0 0 0 2px white;
  z-index: 10;
}

/* Tab Content - separated from tabs */
.project-tab-content {
  min-height: 300px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.project-content-left {
  flex: 5;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.project-content-right {
  flex: 5;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.status-boxes-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.status-box {
  border-radius: 0.625rem;
  padding: 1.5rem;
  background: #fff;
}

.status-boxes-row .status-box {
  flex: 1;
}

.status-box-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.status-box-header svg {
  flex-shrink: 0;
  color: var(--primary);
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  background: #f0f2f4;
  border-radius: 0.625rem;
  padding: 0.5rem;
}

.status-box h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-badge {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--secondary);
  color: white;
  border-radius: 4px;
  font-size: 0.9em;
  font-weight: 500;
}

.status-badge.status-none {
  background: #ccc;
  color: #666;
}

.status-badge.status-generating {
  background: #1481b8;
  color: white;
  animation: pulse 2s infinite;
}

.status-badge.status-draft {
  background: #ffa500;
  color: white;
}

.status-badge.status-approved {
  background: #28a745;
  color: white;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.btn-approve {
  background: #28a745;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-approve:hover {
  background: #218838;
}

.btn-approve:active {
  background: #1e7e34;
}

/* Process Steps Table */
.processteg-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  margin-bottom: 1.5rem;
}

.processteg-add-row-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.processteg-approve-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.btn-approve-process {
  background: #28a745;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.75rem 2rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background 0.2s;
  min-width: 200px;
}

.btn-approve-process:hover:not(:disabled) {
  background: #218838;
}

.btn-approve-process:disabled {
  background: #6c757d;
  cursor: not-allowed;
  opacity: 0.6;
}

.process-status-message {
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
  text-align: center;
}

.process-status-message.approved {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.process-status-message.draft {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

.process-approval-info {
  padding: 0.75rem 1rem;
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
  border-radius: 4px;
  font-size: 0.9rem;
  text-align: center;
}

.processteg-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.processteg-table thead {
  background: #f0f2f4;
  border-bottom: 2px solid var(--border);
}

.processteg-table th {
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  border-right: 1px solid var(--border);
}

.processteg-table th:last-child {
  border-right: none;
}

.processteg-table tbody tr {
  border-bottom: 1px solid #e0e0e0;
}

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

.processteg-table td {
  padding: 0.75rem;
  vertical-align: top;
  border-right: 1px solid #e0e0e0;
}

.processteg-table td:last-child {
  border-right: none;
}

.processteg-table td.processteg-nr {
  text-align: center;
  font-weight: 500;
  color: #666;
  background: #f9f9f9;
}

.processteg-table td.processteg-editable {
  cursor: pointer;
  position: relative;
  min-height: 2rem;
}

.processteg-table td.processteg-editable:hover {
  background: #f0f7ff;
}

.processteg-table td.processteg-editable.editing {
  background: #fff;
  padding: 0;
}

.processteg-cell-content {
  min-height: 1.5rem;
  padding: 0.25rem 0;
  word-wrap: break-word;
}

.processteg-cell-content.empty {
  color: #999;
  font-style: italic;
}

.processteg-table input.processteg-input,
.processteg-table textarea.processteg-input {
  width: 100%;
  padding: 0.5rem;
  border: 2px solid var(--primary);
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
  background: white;
  box-sizing: border-box;
}

.processteg-table input.processteg-input {
  min-height: 2rem;
}

.processteg-table textarea.processteg-input {
  min-height: 3rem;
  resize: vertical;
}

.processteg-table input.processteg-input:focus,
.processteg-table textarea.processteg-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 129, 184, 0.1);
}

.processteg-actions {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
  align-items: center;
}

.processteg-action-btn {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 0.375rem;
  cursor: pointer;
  color: var(--text);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  opacity: 0.7;
}

.processteg-action-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  opacity: 1;
}

.processteg-action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.processteg-action-btn:disabled:hover {
  background: transparent;
  opacity: 0.3;
}

.processteg-action-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.btn-add-row {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.75rem 2rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background 0.2s;
  min-width: 200px;
}

.btn-add-row:hover {
  background: #0f6b9a;
}

.btn-generate-process {
  background: #226c4f;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.75rem 2rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background 0.2s;
  min-width: 200px;
}

.btn-generate-process:hover:not(:disabled) {
  background: #1a5a3f;
}

.btn-generate-process:disabled {
  background: #6c757d;
  cursor: not-allowed;
  opacity: 0.6;
}

.processteg-list {
  margin: 0;
  padding-left: 1.5rem;
  list-style-type: decimal;
}

.processteg-list li {
  margin: 0.5rem 0;
  line-height: 1.5;
}

.documents-box {
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  padding: 1rem;
  background: #fff;
  min-height: 200px;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.documents-box-full {
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
  min-height: 300px;
  margin-top: 1rem;
}

/* Documents Progress Bar */
.documents-progress-bar {
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

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

.documents-progress-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.documents-progress-count {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
}

.documents-progress-bar-track {
  width: 100%;
  height: 12px;
  background: #e9ecef;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.documents-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #1a9fd8 100%);
  border-radius: 6px;
  transition: width 0.3s ease;
  min-width: 2px;
}

.project-info-box {
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
  margin-top: 1rem;
}

.logs-box-content {
  margin-top: 1rem;
}

.project-info-item {
  display: flex;
  padding: 0.75rem 0;
  border-bottom: 1px solid #e0e0e0;
}

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

.project-info-label {
  font-weight: 600;
  min-width: 150px;
  color: var(--text);
}

.project-info-value {
  flex: 1;
  color: #666;
}

.documents-box h3,
/* Removed - now using .status-box h3 styling */

#docListContainer {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

#docList {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.document-item {
  padding: 0.75rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.document-item .doc-name-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.document-item .doc-name-link:hover {
  text-decoration: underline;
}

.document-item .doc-meta {
  font-size: 0.85em;
  color: var(--muted);
}

/* Documents sections */
.documents-section {
  margin-bottom: 2rem;
}

.documents-section:last-child {
  margin-bottom: 0;
}

.documents-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.doc-empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-style: italic;
}

.document-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  gap: 1rem;
}

.document-item .doc-name-link {
  flex: 1;
  min-width: 0;
}

.document-item-required {
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.doc-required-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.doc-required-name {
  font-weight: 500;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.doc-type-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: #e3f2fd;
  color: #1976d2;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: 500;
}

.doc-required-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}

.doc-required-status {
  font-size: 0.9em;
  color: #f57c00;
  font-weight: 500;
}

.document-item-not-needed {
  opacity: 0.7;
}

.document-item-not-needed .doc-required-status {
  color: #666;
  font-style: italic;
}

.btn-mark-not-needed {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.2s;
}

/* Document category sections */
.doc-category-section {
  margin-bottom: 2rem;
}

.doc-category-section:last-child {
  margin-bottom: 0;
}

.doc-category-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 0.75rem 0;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-mark-not-needed:hover {
  background: #f5f5f5;
  border-color: var(--muted);
}

.btn-restore-required {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.2s;
}

.btn-restore-required:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-delete-doc-small {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  font-size: 1.2em;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.2s, color 0.2s;
  flex-shrink: 0;
}

.btn-delete-doc-small:hover {
  opacity: 1;
  color: #d32f2f;
}

/* Uploader */
#dropZone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  margin: 1rem 0;
  background-color: #fafafa;
  transition: all 0.3s ease;
  cursor: pointer;
}

#dropZone:hover {
  border-color: var(--primary);
  background-color: #e3f2fd;
}

#dropZone.drag-over {
  border-color: var(--primary);
  background-color: #e3f2fd;
}

#dropZone p {
  margin: 0.5rem 0;
  color: #666;
}

#dropZone p.small {
  font-size: 0.9em;
  color: #999;
}

#projectFile {
  display: none;
}

#uploadBtn {
  margin-top: 1rem;
  padding: 0.5rem 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
}

#selectedFiles {
  margin: 1rem 0;
}

#selectedFiles h4 {
  margin: 0.5rem 0;
  font-size: 1em;
}

#fileList {
  list-style: none;
  padding: 0;
  margin: 0;
}

.file-item {
  padding: 0.5rem;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.file-remove {
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  cursor: pointer;
}

.btn-success {
  background: #28a745;
  border-color: #28a745;
  margin-top: 1rem;
  padding: 0.75rem 1.5rem;
}

#uploadProgress {
  margin-top: 0.5rem;
}

.progress-bar-container {
  width: 100%;
  background-color: #e0e0e0;
  border-radius: 4px;
  height: 20px;
  position: relative;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
}

.progress-text {
  margin-top: 0.25rem;
  font-size: 0.9em;
  color: #666;
}

/* Chat */
#chatSection {
  position: fixed;
  right: 0;
  top: 60px;
  height: calc(100vh - 60px);
  width: 30%;
  max-width: 30%;
  border: 1px solid var(--border);
  border-radius: 0;
  background: #f9f9f9;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, max-width 0.3s ease, left 0.3s ease, right 0.3s ease, background 0.2s ease, border-color 0.2s ease, border-left 0.3s ease;
  border-top: none;
  border-right: none;
  border-bottom: none;
  border-left: 1px solid var(--border);
  overflow: hidden;
  min-width: 0;
}

.chat-header {
  background: white;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.chat-resize-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.chat-resize-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: all 0.2s;
}

.chat-resize-btn:hover {
  background: #f0f2f4;
  border-color: var(--brand);
  color: var(--brand);
}

.chat-resize-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.chat-resize-btn svg {
  display: block;
}

/* Chat width states */
#chatSection.chat-width-minimized {
  width: 0;
  max-width: 0;
  overflow: hidden;
  border-left: none;
}

#chatSection.chat-width-standard {
  width: 30%;
  max-width: 30%;
}

#chatSection.chat-width-full {
  width: 100%;
  max-width: 100%;
  left: 0;
  right: 0;
}

.chat-header h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  color: var(--text);
  font-weight: 600;
}

.chat-header h4 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: normal;
}

.chat-footer {
  background: white;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#chatSection.chat-drag-over {
  border-color: var(--primary);
  background: rgba(34, 108, 79, 0.08);
}

.chat-drop-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--primary);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--primary);
  font-weight: 600;
  font-size: 1rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 2;
  margin: 1.5rem;
}

.chat-drop-overlay.visible {
  opacity: 1;
}

.chat-drop-text {
  padding: 1rem 1.5rem;
  background: rgba(34, 108, 79, 0.1);
  border-radius: 999px;
  border: 1px solid rgba(34, 108, 79, 0.3);
}

#chatMessages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 1.5rem;
  background: #f9f9f9;
}

.chat-upload-status {
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.95rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chat-upload-status-info {
  background: #eef2ff;
  color: #3730a3;
}

.chat-upload-status-warning {
  background: #fff8e1;
  color: #b45309;
}

.chat-upload-status-error {
  background: #fee2e2;
  color: #b91c1c;
}

.chat-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

#chatInput {
  width: 100%;
  padding: 0.75rem 3rem 0.75rem 1rem;
  border: 1px solid #ddd;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  font-family: inherit;
  box-sizing: border-box;
  resize: none;
  overflow-y: auto;
  min-height: 2.5rem;
  max-height: calc(1.5rem * 6 + 1.5rem); /* 6 rows max */
  line-height: 1.5rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

#chatInput:focus {
  outline: none;
  border-color: var(--primary);
}

.chat-send-icon {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  transition: color 0.2s;
}

.chat-send-icon:hover:not(:disabled) {
  color: #226c4f;
}

.chat-send-icon:disabled {
  color: #ccc;
  cursor: not-allowed;
}

.chat-send-icon svg {
  width: 20px;
  height: 20px;
}

.chat-message {
  margin-bottom: 1rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.5;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.chat-message.user {
  flex-direction: row;
}

.chat-message.assistant {
  flex-direction: row;
}

.chat-message-timestamp {
  text-align: right;
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 0.25rem;
  padding-right: 45px;
  width: 100%;
  box-sizing: border-box;
}

.chat-message-content {
  flex: 0 1 auto;
  min-width: 0;
  padding: 0.75rem;
  border-radius: 0.75rem;
  max-width: 75%;
}

.chat-message.user .chat-message-content {
  background: #1481b8;
  color: white;
  text-align: right;
  margin-left: auto;
}

.chat-message.assistant .chat-message-content {
  background: #fff;
  color: var(--text);
  text-align: left;
}

.chat-message-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.75rem;
  overflow: hidden;
  position: relative;
  cursor: default;
}

.chat-message.user .chat-message-avatar {
  background: rgba(20, 129, 184, 0.1);
  color: #1481b8;
  border: 2px solid #1481b8;
}

.chat-message.user .chat-message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  background: transparent;
  border: none;
}

/* When avatar contains an image, remove border and background */
.chat-message.user .chat-message-avatar-with-image {
  background: transparent;
  border: 2px solid transparent;
  padding: 0;
}

.chat-message.user .chat-message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.chat-message.assistant .chat-message-avatar {
  background: #e0e0e0;
  color: var(--primary);
}

.chat-message-avatar svg {
  width: 20px;
  height: 20px;
}

/* Buttons */
button {
  padding: .6rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--primary);
  color: white;
  cursor: pointer;
}

button:hover:not([disabled]) {
  filter: brightness(.95);
}

button[disabled] {
  opacity: .55;
  cursor: not-allowed;
}

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

/* Utility Classes */
.text-muted {
  color: #666;
}

.text-center {
  text-align: center;
}

.text-error {
  color: #dc3545;
}

.hidden {
  display: none;
}

/* Chat Messages */
.chat-placeholder {
  color: #666;
  font-style: italic;
}

.chat-message-content p {
  margin: 0.5em 0;
}

.chat-message-content p.list-item {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

/* Chat Tables */
.chat-table-wrapper {
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid #ddd;
  border-radius: 4px;
  max-width: 100%;
  box-sizing: border-box;
}

.chat-table-wrapper::-webkit-scrollbar {
  height: 8px;
}

.chat-table-wrapper::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.chat-table-wrapper::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.chat-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.chat-table-download {
  margin-bottom: 0.5rem;
}

.chat-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 0.85em;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  table-layout: auto;
  min-width: 100%;
}

.chat-table thead {
  background: #f8f9fa;
}

.chat-table th {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 2px solid #ddd;
  font-weight: 600;
  white-space: nowrap;
}

.chat-table td {
  padding: 0.75rem;
  border-bottom: 1px solid #eee;
  vertical-align: top;
}

.chat-table tbody tr:hover {
  background: #f8f9fa;
}

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

.btn-download-excel {
  padding: 0.5rem 1rem;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background 0.2s;
}

.btn-download-excel:hover:not(:disabled) {
  background: #218838;
}

.btn-download-excel:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Thinking Indicator */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #666;
  font-style: italic;
  margin: 0;
}

.thinking-dots {
  display: inline-flex;
  gap: 0.25rem;
}

.thinking-dot {
  animation: thinking 1.4s infinite;
}

.thinking-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes thinking {
  0%, 20% { opacity: 0.3; }
  50% { opacity: 1; }
  80%, 100% { opacity: 0.3; }
}

/* Settings Styles */
.settings-header {
  margin-bottom: 2rem;
}

.settings-header h2 {
  font-size: 2rem;
  color: #1F2933;
  margin-bottom: 0.5rem;
}

.settings-header p {
  color: #616E7C;
  font-size: 1rem;
}

.settings-card {
  background: #FFFFFF;
  border: 1px solid #E4E7EB;
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.settings-card h3 {
  font-size: 1.5rem;
  color: #1F2933;
  margin-bottom: 0.5rem;
}

.settings-card .card-description {
  color: #616E7C;
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: #323F4B;
  font-weight: 500;
  font-size: 0.95rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #CBD2D9;
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #333333;
}

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

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

.btn-secondary {
  background: #FFFFFF;
  color: #323F4B;
  border: 1px solid #CBD2D9;
  padding: 0.875rem 1.5rem;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #F7FAFC;
  border-color: #9AA5B1;
}

#settingsAlert .alert {
  padding: 0.875rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

#settingsAlert .alert-success {
  background: #F0FFF4;
  color: #22863A;
  border: 1px solid #C6F6D5;
}

#settingsAlert .alert-error {
  background: #FFF0F0;
  color: #D64545;
  border: 1px solid #FFCFCF;
}

/* Responsive */
@media (max-width: 768px) {
  .header-nav {
    gap: 0.25rem;
    margin-left: 1rem;
  }

  .nav-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.85em;
  }

  .project-view-container {
    flex-direction: column;
  }

  .project-view-left,
  .project-view-right {
    flex: 1 1 auto;
  }

  .project-content-box {
    flex-direction: column;
  }

  .project-tabs {
    flex-wrap: wrap;
  }

  .project-tab {
    flex: 1 1 auto;
    min-width: 80px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  .project-tab-content {
    padding: 1rem;
  }

  .project-content-left,
  .project-content-right {
    flex: 1 1 auto;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .settings-card {
    padding: 1.5rem;
  }
}

/* Profile Image Section */
.profile-image-section {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}

.profile-image-container {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border);
  background: #f9f9f9;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.profile-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.profile-image-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn-danger {
  background: #dc3545;
  color: white;
  border-color: #dc3545;
}

.btn-danger:hover {
  background: #c82333;
  border-color: #bd2130;
}

.profile-image-info {
  margin-top: 0.5rem;
}

/* Fullscreen Modal Styles */
.fullscreen-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.fullscreen-modal-content {
  background: #fff;
  width: 100%;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  border-radius: 0.625rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

.fullscreen-modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.fullscreen-modal-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.edit-link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

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

.btn-save, .btn-cancel {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.375rem;
  font-weight: 500;
  cursor: pointer;
  font-size: 0.875rem;
}

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

.btn-save:hover {
  background: #1a5a3f;
}

.btn-cancel {
  background: #e0e0e0;
  color: var(--text);
}

.btn-cancel:hover {
  background: #d0d0d0;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.25rem;
}

.btn-close:hover {
  background: #f0f0f0;
}

.fullscreen-modal-body {
  flex: 1;
  overflow: auto;
  padding: 1.5rem;
}

/* Editable Table Styles */
.fullscreen-table-wrapper {
  width: 100%;
  overflow-x: auto;
}

.fullscreen-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.fullscreen-table th,
.fullscreen-table td {
  padding: 0.75rem;
  text-align: left;
  border: 1px solid var(--border);
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.fullscreen-table th {
  background: #f0f2f4;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
  vertical-align: middle;
}

/* Editable header cells */
.fullscreen-table.edit-mode th.editable-header-cell {
  padding: 0.25rem;
  position: relative;
}

.fullscreen-table.edit-mode th.editable-header-cell .header-cell-content {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.fullscreen-table.edit-mode th .header-input {
  flex: 1;
  padding: 0.5rem;
  border: 2px solid transparent;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  background: white;
  min-width: 100px;
}

.fullscreen-table.edit-mode th .header-input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
}

.fullscreen-table.edit-mode th.add-column-cell {
  padding: 0.5rem;
  text-align: center;
  min-width: 40px;
  background: #e8f5e9;
}

.fullscreen-table.edit-mode th.add-column-cell:hover {
  background: #c8e6c9;
}

.column-action-btn {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  opacity: 0.7;
  flex-shrink: 0;
}

.column-action-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  opacity: 1;
}

.column-action-btn.delete-column-btn {
  color: #dc3545;
}

.column-action-btn.delete-column-btn:hover {
  background: rgba(220, 53, 69, 0.1);
}

.column-action-btn.add-column-btn {
  color: var(--brand);
}

.column-action-btn svg {
  display: block;
}

.fullscreen-table tbody tr:hover {
  background: #f9f9f9;
}

/* Edit Mode Styles - Excel-like */
.fullscreen-table.edit-mode td {
  padding: 0;
  vertical-align: top;
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  overflow: hidden;
  box-sizing: border-box;
}

.fullscreen-table.edit-mode td.row-actions {
  padding: 0.25rem;
  vertical-align: middle;
  text-align: center;
  box-sizing: border-box;
}

.fullscreen-table.edit-mode td textarea {
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  border: none;
  padding: 0.25rem;
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: 1.4;
  background: transparent;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: pre-wrap;
  resize: none;
  min-height: 1.5rem;
  height: 100%;
  overflow: hidden;
}

.fullscreen-table.edit-mode td textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  background: #fff;
  z-index: 1;
  position: relative;
}

.fullscreen-table.edit-mode td:has(textarea:focus) {
  background: #fff;
}

/* RPN cell - read-only, calculated field */
.fullscreen-table.edit-mode td textarea.rpn-cell {
  background: #f5f5f5;
  cursor: not-allowed;
  color: #666;
  pointer-events: none; /* Prevent interaction entirely */
}

.fullscreen-table.edit-mode td textarea.rpn-cell:focus {
  outline: none;
  background: #f5f5f5;
}

/* Numeric cells - for Occurrence, Severity, Detection */
.fullscreen-table.edit-mode td textarea.numeric-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Row Actions */
.row-actions {
  display: none;
  gap: 0.25rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.fullscreen-table.edit-mode .row-actions {
  display: flex;
  height: 100%;
}

.row-action-btn {
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
}

.row-action-btn:hover {
  background: #f0f0f0;
  border-color: #999;
}

.row-action-btn.delete-btn:hover {
  background: #fee;
  border-color: #f00;
  color: #c00;
}

.row-action-btn svg {
  width: 16px;
  height: 16px;
}

/* Status box clickable */
.status-box.clickable {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.status-box.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Unsaved changes indicator */
.unsaved-indicator {
  color: #f59e0b;
  font-size: 0.875rem;
  margin-left: 1rem;
}

/* File Upload Area */

.file-upload-dropzone {
  border: 2px dashed var(--border);
  border-radius: 0.625rem;
  padding: 2rem;
  background: #fff;
  transition: all 0.2s ease;
  cursor: pointer;
}

.file-upload-dropzone:hover {
  border-color: var(--primary);
  background-color: #f8f9fa;
}

.file-upload-dropzone.drag-over {
  border-color: var(--primary);
  background-color: #e3f2fd;
  border-style: solid;
}

.file-upload-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.file-upload-text {
  margin: 0.5rem 0;
  color: var(--text);
  font-size: 1rem;
}

.file-upload-hint {
  margin: 0.5rem 0 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.file-upload-browse-btn {
  background: none;
  border: none;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  padding: 0;
  margin: 0;
}

.file-upload-browse-btn:hover {
  color: var(--brand);
}

.file-upload-selected {
  margin-top: 1rem;
}

.file-upload-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.file-upload-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
}

.file-upload-list li:last-child {
  margin-bottom: 0;
}

.file-upload-list .file-name {
  flex: 1;
  color: var(--text);
  font-size: 0.9rem;
}

.file-upload-list .file-size {
  color: var(--muted);
  font-size: 0.85rem;
  margin-left: 1rem;
}

.file-upload-list .file-remove {
  background: transparent;
  border: none;
  color: #dc3545;
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0 0.5rem;
  margin-left: 0.5rem;
  line-height: 1;
}

.file-upload-list .file-remove:hover {
  color: #c82333;
}

.btn-upload-files {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 0.375rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}

.btn-upload-files:hover {
  background: var(--brand);
}

.btn-upload-files:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.file-upload-progress {
  margin-top: 1rem;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 0.375rem;
}

.file-upload-progress-bar {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.file-upload-progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
  width: 0%;
}

.file-upload-progress-text {
  font-size: 0.875rem;
  color: var(--muted);
  text-align: center;
}

.file-upload-status {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
  min-height: 1.25rem;
}

/* Collapsible Modules */
.collapsible-modules {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.collapsible-module {
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  background: #fff;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.collapsible-module:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.collapsible-module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}

.collapsible-module-header:hover {
  background-color: #f8f9fa;
}

.collapsible-module-header-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.collapsible-module-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #f0f2f4;
  border-radius: 0.625rem;
  color: var(--primary);
  flex-shrink: 0;
}

.collapsible-module-icon svg {
  width: 24px;
  height: 24px;
}

.collapsible-module-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.collapsible-module-summary {
  color: var(--muted);
  font-size: 0.95rem;
  margin-right: 1rem;
  flex-shrink: 0;
}

.collapsible-module-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--muted);
  transition: transform 0.3s ease, color 0.2s ease;
  flex-shrink: 0;
}

.collapsible-module-toggle svg {
  width: 20px;
  height: 20px;
}

.collapsible-module.open .collapsible-module-toggle {
  transform: rotate(180deg);
  color: var(--primary);
}

.collapsible-module-content {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0;
  display: none;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.collapsible-module.open .collapsible-module-content {
  display: block;
}

.collapsible-module.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

.collapsible-module.disabled .collapsible-module-header {
  cursor: not-allowed;
}

.collapsible-module.disabled .collapsible-module-summary::after {
  content: " (Kräver godkända processteg)";
  font-size: 0.85em;
  color: #dc3545;
  font-weight: normal;
}

.static-module.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

.static-module.disabled .static-module-header {
  cursor: not-allowed;
}

.static-module.disabled .static-module-summary::after {
  content: " (Kräver godkända processteg)";
  font-size: 0.85em;
  color: #dc3545;
  font-weight: normal;
}

/* Static Modules (FMEA and Kontrollplan side by side) */
.fmea-kontrollplan-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.static-module {
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  background: #fff;
  overflow: hidden;
}

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

.static-module-header-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.static-module-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #f0f2f4;
  border-radius: 0.625rem;
  color: var(--primary);
  flex-shrink: 0;
}

.static-module-icon svg {
  width: 24px;
  height: 24px;
}

.static-module-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.static-module-summary {
  color: var(--muted);
  font-size: 0.95rem;
  margin-right: 1rem;
  flex-shrink: 0;
}

.static-module-content {
  padding: 1.5rem;
}

.help-link-container {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.help-link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.help-link:hover {
  color: #1a5a3f;
  text-decoration: underline;
}

/* Extraction Badge */
.extraction-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.extraction-badge-pdfjs {
  background: #e3f2fd;
  color: #1976d2;
}

.extraction-badge-ocr {
  background: #fff3e0;
  color: #f57c00;
}

.extraction-badge-hybrid {
  background: #e8f5e9;
  color: #388e3c;
}

/* Text Extraction Test Page */
.text-extraction-section {
  max-width: 1400px;
  margin: 0 auto;
}

.text-extraction-section h2 {
  margin-bottom: 2rem;
  color: var(--primary);
}

.text-extraction-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  height: calc(100vh - 180px);
}

.text-extraction-left,
.text-extraction-right {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  overflow-y: auto;
}

.text-extraction-left h3,
.text-extraction-right h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--primary);
  font-size: 1.2rem;
}

/* File Upload Area */
.file-upload-area {
  margin-bottom: 1.5rem;
}

.file-upload-dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafafa;
}

.file-upload-dropzone:hover {
  border-color: var(--primary);
  background: #f5f5f5;
}

.file-upload-dropzone p {
  margin: 0.5rem 0;
  color: var(--text);
}

.file-upload-hint {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Uploaded Files List */
.uploaded-files-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.uploaded-file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: #f9f9f9;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.file-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.file-name {
  font-weight: 500;
  color: var(--text);
  font-size: 0.95rem;
}

.file-status {
  font-size: 0.85rem;
  color: var(--muted);
}

.file-status.completed {
  color: #28a745;
}

.file-status.error {
  color: #dc3545;
}

.file-status.processing {
  color: #ffc107;
}

.file-view-btn {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.file-view-btn:hover {
  background: #1a1f26;
}

/* Text Output Area */
.text-extraction-output {
  height: calc(100% - 3rem);
  display: flex;
  flex-direction: column;
}

.extracted-text-content {
  flex: 1;
  overflow-y: auto;
}

.placeholder-text {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 2rem;
}

.extracted-text-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.extracted-text-header h4 {
  margin: 0;
  color: var(--primary);
  font-size: 1rem;
}

.copy-text-btn {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.copy-text-btn:hover {
  background: #1a1f26;
}

.extracted-text-body {
  flex: 1;
  overflow-y: auto;
}

.extracted-text-body pre {
  margin: 0;
  padding: 1rem;
  background: #f9f9f9;
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}
