/* Tema Escuro (Padrão) */
:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --border: #2d3a4a;
  --text: #e8eef5;
  --muted: #8b9bb0;
  --text-dim: #6b7c90;
  --input-bg: #1a222d;
  --hover: rgba(255, 255, 255, 0.06);
  --surface-hover: rgba(255, 255, 255, 0.09);
  --accent: #3d8bfd;
  --accent-dim: #2a5fad;
  --danger: #e85d6a;
  --success: #28a745;
  --warning: #ffc107;
  --primary: #007bff;
  --radius: 10px;
  --font: "DM Sans", system-ui, sans-serif;
}

/* Tema Claro */
[data-theme="light"] {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: #dee2e6;
  --text: #212529;
  --muted: #6c757d;
  --text-dim: #868e96;
  --input-bg: #ffffff;
  --hover: #f1f3f5;
  --surface-hover: #e9ecef;
  --accent: #0d6efd;
  --accent-dim: #0a58ca;
  --danger: #dc3545;
  --success: #198754;
  --warning: #fd7e14;
  --primary: #0d6efd;
}

@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,600;0,9..40,700;1,9..40,400&display=swap");

* {
  box-sizing: border-box;
}

/* Transições suaves para mudança de tema */
*, *::before, *::after {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Background gradients por tema */
body:not([data-theme="light"]) {
  background: linear-gradient(160deg, #0b0f14 0%, var(--bg) 40%, #121a24 100%);
}

[data-theme="light"] body {
  background: linear-gradient(160deg, #f1f3f4 0%, var(--bg) 40%, #e9ecef 100%);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
  transition: background-color 0.3s ease;
}

/* Tema escuro - topbar com transparência */
body:not([data-theme="light"]) .topbar {
  background: rgba(26, 34, 45, 0.85);
}

/* Tema claro - topbar sólida */
[data-theme="light"] .topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  color: var(--text);
}

.nav {
  display: flex;
  gap: 1.25rem;
}
.nav a {
  color: var(--muted);
  font-weight: 500;
}
.nav a:hover {
  color: var(--text);
}

/* Topbar Actions */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

/* User Menu */
.user-menu {
  position: relative;
}

.user-dropdown {
  position: relative;
}

.user-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.user-dropdown-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

[data-theme="light"] .user-dropdown-btn {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .user-dropdown-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

.user-avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-size: 0.85rem;
}

.user-name {
  font-weight: 600;
  color: var(--text);
}

.user-role {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dropdown-arrow {
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.user-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 180px;
  z-index: 1000;
  display: none;
}

.user-dropdown-menu.show {
  display: block;
}

[data-theme="light"] .user-dropdown-menu {
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: 0.9rem;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .dropdown-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

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

.logout-item {
  color: #dc3545;
}

.logout-item:hover {
  background: rgba(220, 53, 69, 0.1);
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
}

.theme-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.theme-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.05);
}

.theme-icon {
  font-size: 1.2rem;
  transition: transform 0.3s ease;
}

.theme-btn:hover .theme-icon {
  transform: rotate(20deg);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Tema claro - container com background mais definido */
[data-theme="light"] .container {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  margin-top: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.footer {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.lead {
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.grid.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Tema claro - cards com sombra sutil */
[data-theme="light"] .card {
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  border: 1px solid #e9ecef;
  background: #ffffff;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

/* Tema claro - botões com sombra */
[data-theme="light"] .btn {
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

[data-theme="light"] .btn:hover {
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  transform: translateY(-1px);
}
.btn:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.btn.primary,
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-color: transparent;
  color: #fff;
}

.btn.small {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

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

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover,
.dropzone:focus {
  border-color: var(--accent);
  outline: none;
}
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(61, 139, 253, 0.08);
}

.dropzone-text {
  margin: 0;
  color: var(--muted);
}

.file-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}
.file-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.progress {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 1rem;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.15s ease;
}

.message {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgba(61, 139, 253, 0.12);
  border: 1px solid var(--accent);
}
.message.error {
  background: rgba(232, 93, 106, 0.12);
  border-color: var(--danger);
}

.hidden {
  display: none !important;
}

/* ============================================================================
   Filters Layout - Improved Design
   ============================================================================ */

.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  position: relative;
}

.filters::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dim));
  border-radius: 12px 12px 0 0;
}

[data-theme="light"] .filters {
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  border-color: #e9ecef;
}

/* Filters Header */
.filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.filters-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filters-title::before {
  content: "🔍";
  font-size: 1.1rem;
}

/* Filters Grid */
.filters-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 1rem;
  align-items: end;
}

@media (max-width: 768px) {
  .filters-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .filters-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
}

/* Filter Groups */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.filter-group input,
.filter-group select {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: all 0.2s ease;
  min-height: 44px;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  transform: translateY(-1px);
}

[data-theme="light"] .filter-group input,
[data-theme="light"] .filter-group select {
  background: #ffffff;
  border-color: #d1d5db;
}

[data-theme="light"] .filter-group input:focus,
[data-theme="light"] .filter-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Filter Actions */
.filter-actions {
  display: flex;
  gap: 0.75rem;
  align-items: end;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  white-space: nowrap;
}

.filter-btn:hover {
  background: var(--hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.filter-btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-color: transparent;
  color: white;
}

.filter-btn.primary:hover {
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.filter-btn.secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}

.filter-btn.secondary:hover {
  background: var(--hover);
  color: var(--text);
}

[data-theme="light"] .filter-btn {
  background: #ffffff;
  border-color: #d1d5db;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .filter-btn:hover {
  background: #f9fafb;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Search Input Enhancement */
.search-input {
  position: relative;
}

.search-input::before {
  content: "🔍";
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
  z-index: 1;
}

.search-input input {
  padding-left: 2.5rem;
}

/* Select Enhancement */
.filter-group select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1rem;
  padding-right: 2.5rem;
  appearance: none;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .filters {
    padding: 1rem;
  }
  
  .filters-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .filter-actions {
    width: 100%;
    justify-content: stretch;
  }
  
  .filter-btn {
    flex: 1;
    justify-content: center;
  }
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: var(--surface);
  transition: background-color 0.3s ease;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface);
  transition: background-color 0.3s ease;
}

.data-table tbody tr:hover {
  background: var(--surface);
  transition: background-color 0.2s ease;
}

/* Tema escuro - backgrounds com transparência */
body:not([data-theme="light"]) .data-table th {
  background: rgba(26, 34, 45, 0.3);
}

body:not([data-theme="light"]) .data-table tbody tr:hover {
  background: rgba(26, 34, 45, 0.2);
}

/* Tema claro - backgrounds sólidos */
[data-theme="light"] .data-table {
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

[data-theme="light"] .data-table th {
  background: #f8f9fa;
  color: var(--text);
  border-bottom: 2px solid var(--border);
}

[data-theme="light"] .data-table tbody tr:hover {
  background: #f1f3f4;
}

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

.data-table .empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}

.pill {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #252f3d;
  color: var(--text);
  transition: background-color 0.3s ease;
}

/* Tema claro - pills com melhor contraste */
[data-theme="light"] .pill {
  background: #6c757d;
  color: #ffffff;
}

.status-upload {
  background: #4a5568;
  color: #e2e8f0;
}

.status-ocr {
  background: #3182ce;
  color: #ffffff;
}

.status-classified {
  background: #38a169;
  color: #ffffff;
}

.status-pending {
  background: #d69e2e;
  color: #ffffff;
}

.status-posted {
  background: #38a169;
  color: #ffffff;
}

.status-archived {
  background: #718096;
  color: #ffffff;
}

.edit-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.1fr);
  gap: 2rem;
  align-items: start;
}

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

.stacked-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.stacked-form input,
.stacked-form select,
.stacked-form textarea {
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
}

.stacked-form input::placeholder,
.stacked-form textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

.stacked-form input:focus,
.stacked-form select:focus,
.stacked-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

[data-theme="light"] .stacked-form input,
[data-theme="light"] .stacked-form select,
[data-theme="light"] .stacked-form textarea {
  color-scheme: light;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .stacked-form input:focus,
[data-theme="light"] .stacked-form select:focus,
[data-theme="light"] .stacked-form textarea:focus {
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2);
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
}

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

.preview-frame {
  width: 100%;
  min-height: 70vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #000;
}

.preview-img {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

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

.preview-section h2,
.sub-actions h2 {
  font-size: 1rem;
  margin: 0;
}

.sub-actions {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.sub-actions .row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.sub-actions select {
  padding: 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
}

[data-theme="light"] .sub-actions select {
  color-scheme: light;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.sub-actions select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.back {
  margin: 0 0 0.5rem;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.8rem;
}

.ocr-debug {
  margin-top: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(26, 34, 45, 0.5);
}

[data-theme="light"] .ocr-debug {
  background: #f8f9fa;
  border-color: var(--border);
}

.ocr-debug summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.85rem;
}

.ocr-text {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #0a0e13;
  color: var(--muted);
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 0.75rem;
  resize: vertical;
}

[data-theme="light"] .ocr-text {
  background: var(--input-bg);
  color: var(--text);
  color-scheme: light;
}

.amount-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.amount-field {
  flex: 2;
}

.currency-field {
  flex: 1;
  min-width: 120px;
}

/* Associations Page */
.associations-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  margin-top: 2rem;
}

.associations-main {
  min-width: 0;
}

.associations-sidebar {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 8px;
  height: fit-content;
  border: 1px solid var(--border);
  transition: background-color 0.3s ease;
}

.sidebar-section {
  margin-bottom: 2rem;
}

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

.sidebar-section h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  color: var(--text);
}

.association-group {
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  transition: background-color 0.3s ease;
}

.parent-doc {
  background: var(--surface);
  border-bottom: 2px solid var(--primary);
  padding: 1rem;
  transition: background-color 0.3s ease;
}

/* Tema escuro - backgrounds com transparência */
body:not([data-theme="light"]) .association-group {
  background: rgba(26, 34, 45, 0.2);
}

body:not([data-theme="light"]) .parent-doc {
  background: rgba(0, 123, 255, 0.1);
}

body:not([data-theme="light"]) .children-docs {
  background: rgba(26, 34, 45, 0.1);
}

/* Tema claro - backgrounds sólidos */
[data-theme="light"] .association-group {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

[data-theme="light"] .parent-doc {
  background: rgba(13, 110, 253, 0.05);
}

[data-theme="light"] .children-docs {
  background: var(--bg);
}

.child-doc {
  position: relative;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  margin-left: 2rem;
}

.child-doc:last-child {
  border-bottom: none;
}

.association-line {
  position: absolute;
  left: -2rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--primary);
}

.association-line::before {
  content: '';
  position: absolute;
  top: 50%;
  right: -6px;
  width: 12px;
  height: 2px;
  background: var(--primary);
  transform: translateY(-50%);
}

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

.doc-type {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
}

.parent-type {
  background: var(--primary);
  color: white;
}

.child-type {
  background: #6c757d;
  color: white;
}

.orphan-type {
  background: #ffc107;
  color: #000;
}

.doc-id {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--muted);
}

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

.doc-info {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.doc-info strong {
  color: var(--text);
}

.doc-number, .doc-amount {
  font-size: 0.9rem;
  color: var(--muted);
}

.primavera-number {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 500;
}

.posted-badge {
  background: var(--success);
  color: white;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 500;
}

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

.orphan-doc, .parent-available {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.75rem;
  background: rgba(26, 34, 45, 0.2);
}

.orphan-doc:last-child, .parent-available:last-child {
  margin-bottom: 0;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.empty-state p {
  margin-bottom: 0.5rem;
}

.text-warning {
  color: #ffc107 !important;
}

.alert.warning {
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid #ffc107;
  color: #ffc107;
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  transition: background-color 0.3s ease;
}

/* Tema claro - alertas com melhor contraste */
[data-theme="light"] .alert.warning {
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
}

@media (max-width: 768px) {
  .associations-layout {
    grid-template-columns: 1fr;
  }
  
  .child-doc {
    margin-left: 1rem;
  }
  
  .association-line {
    left: -1rem;
  }
}

/* Cost Distribution Page */
.cost-distribution-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  margin-top: 2rem;
}

.cost-distribution-main {
  min-width: 0;
}

.cost-distribution-sidebar {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 8px;
  height: fit-content;
  border: 1px solid var(--border);
  transition: background-color 0.3s ease;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  margin: 0;
}

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

.cost-distribution-table-wrapper {
  background: var(--surface);
  border-radius: 8px;
  overflow-x: auto; /* Scroll horizontal quando necessário */
  border: 1px solid var(--border);
  transition: background-color 0.3s ease;
}

/* Tema escuro - background com transparência */
body:not([data-theme="light"]) .cost-distribution-table-wrapper {
  background: rgba(26, 34, 45, 0.2);
}

/* Tema claro - background sólido com sombra */
[data-theme="light"] .cost-distribution-table-wrapper {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.cost-distribution-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1200px; /* Largura mínima para evitar truncamento */
}

.cost-distribution-table th,
.cost-distribution-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.cost-distribution-table th {
  white-space: nowrap; /* Headers não quebram */
}

.cost-distribution-table td {
  white-space: nowrap; /* Células também não quebram para manter alinhamento */
  padding: 0.75rem 0.5rem; /* Padding horizontal menor para dar mais espaço */
  font-size: 0.9rem;
}

/* Larguras específicas para colunas */
.cost-distribution-table th:nth-child(1) { width: 40px; }   /* Checkbox */
.cost-distribution-table th:nth-child(2) { width: 80px; }   /* Tipo */
.cost-distribution-table th:nth-child(3) { width: 200px; }  /* Fornecedor */
.cost-distribution-table th:nth-child(4) { width: 120px; }  /* Nº Documento */
.cost-distribution-table th:nth-child(5) { width: 100px; }  /* Valor */
.cost-distribution-table th:nth-child(6) { width: 90px; }   /* Nº Primavera */
.cost-distribution-table th:nth-child(7) { width: 120px; }  /* Data Lançamento */
.cost-distribution-table th:nth-child(8) { width: 150px; }  /* Associações */
.cost-distribution-table th:nth-child(9) { width: 140px; }  /* Status Distribuição */
.cost-distribution-table th:nth-child(10) { width: 130px; } /* Data Distribuição */
.cost-distribution-table th:nth-child(11) { width: 120px; } /* Ações */

/* Estilos para associações na distribuição de custos */
.associations-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.association-badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  background: var(--accent-dim);
  color: white;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: help;
}

.association-more {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  background: var(--muted);
  color: var(--text);
  border-radius: 12px;
  font-size: 0.7rem;
  cursor: help;
}

.cost-distribution-table th {
  background: var(--surface);
  font-weight: 600;
  color: var(--text);
  font-size: 0.85rem; /* Fonte ligeiramente menor para caber melhor */
  transition: background-color 0.3s ease;
  padding: 0.75rem 0.5rem; /* Padding horizontal menor para dar mais espaço */
}

.cost-distribution-table tbody tr:hover {
  background: var(--surface);
  transition: background-color 0.2s ease;
}

/* Tema escuro - backgrounds com transparência */
body:not([data-theme="light"]) .cost-distribution-table th {
  background: rgba(26, 34, 45, 0.5);
}

body:not([data-theme="light"]) .cost-distribution-table tbody tr:hover {
  background: rgba(26, 34, 45, 0.3);
}

/* Tema claro - backgrounds sólidos */
[data-theme="light"] .cost-distribution-table th {
  background: #f8f9fa;
}

[data-theme="light"] .cost-distribution-table tbody tr:hover {
  background: #f8f9fa;
}

.cost-distribution-table tbody tr.pending-distribution {
  background: rgba(255, 193, 7, 0.05);
  border-left: 3px solid #ffc107;
}

.doc-type-badge {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.doc-type-badge.vfad {
  background: #dc3545;
  color: white;
}

.doc-type-badge.vdac {
  background: #fd7e14;
  color: white;
}

.doc-type-badge.desp {
  background: #6f42c1;
  color: white;
}

.status-badge {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
}

.status-badge.distributed {
  background: rgba(40, 167, 69, 0.2);
  color: #28a745;
  border: 1px solid #28a745;
}

.status-badge.pending {
  background: rgba(255, 193, 7, 0.2);
  color: #ffc107;
  border: 1px solid #ffc107;
}

.primavera-number {
  font-family: monospace;
  font-weight: 600;
  color: var(--primary);
}

.amount {
  font-weight: 600;
  color: var(--text);
}

.date {
  font-size: 0.9rem;
  color: var(--muted);
}

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

.doc-checkbox {
  transform: scale(1.2);
}

.type-stats {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: rgba(26, 34, 45, 0.2);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.type-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.type-total {
  font-weight: 600;
  color: var(--text);
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(26, 34, 45, 0.5);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

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

.progress-text {
  font-size: 0.8rem;
  color: var(--muted);
}

.type-pending {
  font-size: 0.8rem;
  color: #ffc107;
  margin-top: 0.25rem;
}

.pending-doc, .distributed-doc {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.75rem;
  background: rgba(26, 34, 45, 0.2);
}

.pending-doc:last-child, .distributed-doc:last-child {
  margin-bottom: 0;
}

.pending-doc {
  border-left: 3px solid #ffc107;
}

.distributed-doc {
  border-left: 3px solid #28a745;
}

.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.doc-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.doc-info strong {
  color: var(--text);
  font-size: 0.9rem;
}

.doc-info .amount {
  font-size: 0.85rem;
}

.doc-info .date.small {
  font-size: 0.8rem;
}

@media (max-width: 768px) {
  .cost-distribution-layout {
    grid-template-columns: 1fr;
  }
  
  .section-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  .bulk-actions {
    justify-content: center;
  }
  
  .cost-distribution-table-wrapper {
    overflow-x: auto;
  }
  
  .cost-distribution-table {
    min-width: 1200px; /* Mantém largura mínima em mobile */
  }
  
  /* Headers mais compactos em mobile */
  @media (max-width: 768px) {
    .cost-distribution-table th:nth-child(8) { 
      width: 100px; /* Status Distribuição mais compacto */
    }
    .cost-distribution-table th:nth-child(9) { 
      width: 100px; /* Data Distribuição mais compacta */
    }
  }
}


/* ============================================================================
   User Management Styles
   ============================================================================ */

/* Page Header - Enhanced */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(168, 85, 247, 0.05));
  border-radius: 12px;
  padding: 1.5rem;
}

[data-theme="light"] .page-header {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.03), rgba(168, 85, 247, 0.03));
  border-color: #e9ecef;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

.header-info h1 {
  margin: 0 0 0.5rem 0;
  color: var(--text);
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-description {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.95rem;
  opacity: 0.8;
}

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

/* Enhanced Create Button */
.btn-create-type {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  position: relative;
  overflow: hidden;
}

.btn-create-type:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
}

.btn-create-type:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-create-type::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.btn-create-type:hover::before {
  left: 100%;
}

.btn-icon {
  font-size: 1.2rem;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.btn-text {
  font-weight: 600;
  letter-spacing: 0.025em;
}

.btn-shortcut {
  font-size: 0.8rem;
  opacity: 0.7;
  background: rgba(255, 255, 255, 0.15);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
}

/* Responsive Header */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .header-info h1 {
    font-size: 1.5rem;
  }
  
  .header-actions {
    width: 100%;
    justify-content: center;
  }
  
  .btn-create-type {
    width: 100%;
    justify-content: center;
    padding: 1.25rem 1.5rem;
  }
  
  .btn-shortcut {
    display: none;
  }
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

[data-theme="light"] .stat-card {
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  font-size: 2rem;
  opacity: 0.8;
}

.stat-content {
  flex: 1;
}

.stat-number {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* Users Table */
.users-table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 2rem;
}

[data-theme="light"] .users-table-wrapper {
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.users-table th,
.users-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.users-table th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
}

[data-theme="light"] .users-table th {
  background: rgba(0, 0, 0, 0.02);
}

.users-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .users-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

/* Profile Styles */
.profile-container {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  max-width: 1200px;
}

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

[data-theme="light"] .profile-card {
  background: #ffffff;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.profile-header {
  padding: 2rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-dim) 100%);
  color: white;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 2rem;
  border: 3px solid rgba(255, 255, 255, 0.3);
}

.profile-info h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
}

.profile-username {
  margin: 0 0 1rem 0;
  opacity: 0.9;
  font-size: 1rem;
}

.profile-badges {
  display: flex;
  gap: 0.75rem;
}

.profile-details {
  padding: 2rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

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

.detail-row label {
  font-weight: 600;
  color: var(--text);
}

.detail-row span {
  color: var(--muted);
}

/* Profile Actions */
.profile-actions {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  height: fit-content;
}

[data-theme="light"] .profile-actions {
  background: #ffffff;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.action-section h3 {
  margin: 0 0 1.5rem 0;
  color: var(--text);
  font-size: 1.1rem;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary);
}

[data-theme="light"] .action-btn:hover {
  background: rgba(0, 0, 0, 0.02);
}

.action-btn:last-child {
  margin-bottom: 0;
}

.action-danger {
  border-color: #dc3545;
  color: #dc3545;
}

.action-danger:hover {
  background: rgba(220, 53, 69, 0.1);
  border-color: #dc3545;
}

.action-icon {
  font-size: 1.2rem;
  opacity: 0.8;
}

.action-content {
  flex: 1;
}

.action-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.action-description {
  font-size: 0.85rem;
  color: var(--muted);
}

.action-danger .action-title,
.action-danger .action-description {
  color: #dc3545;
}

/* ============================================================================
   Modal Styles
   ============================================================================ */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

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

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

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-dim);
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--hover);
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
}

/* Form Styles */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text);
  font-weight: 500;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

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

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

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

/* ============================================================================
   Document Types Management Styles
   ============================================================================ */

/* Types Table */
.types-table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 2rem;
}

[data-theme="light"] .types-table-wrapper {
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.types-table th,
.types-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.types-table th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
}

[data-theme="light"] .types-table th {
  background: rgba(0, 0, 0, 0.02);
}

.types-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .types-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

/* Type Badges */
.code-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: white;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  font-size: 0.85rem;
}

.category-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.category-badge.parent {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.category-badge.child {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.category-badge.standalone {
  background: rgba(156, 163, 175, 0.1);
  color: #9ca3af;
  border: 1px solid rgba(156, 163, 175, 0.2);
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-badge.active {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-badge.inactive {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.origin-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.origin-badge.predefined {
  background: rgba(168, 85, 247, 0.1);
  color: #a855f7;
  border: 1px solid rgba(168, 85, 247, 0.2);
}

.origin-badge.custom {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Behavior Badges */
.behaviors {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.behavior-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
}

.behavior-badge.associations {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.behavior-badge.cost-dist {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.behavior-badge.none {
  background: rgba(156, 163, 175, 0.1);
  color: #9ca3af;
  border: 1px solid rgba(156, 163, 175, 0.2);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.action-btn:hover {
  background: var(--hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.action-btn.view-btn:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
  color: #3b82f6;
}

.action-btn.edit-btn:hover {
  background: rgba(245, 158, 11, 0.1);
  border-color: #f59e0b;
  color: #f59e0b;
}

.action-btn.toggle-btn:hover {
  background: rgba(34, 197, 94, 0.1);
  border-color: #22c55e;
  color: #22c55e;
}

.action-btn.delete-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
}

/* Type Details Modal */
.type-details {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.detail-group label {
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
}

.detail-group span {
  color: var(--text-dim);
}

/* Form Enhancements for Document Types */
.form-group small {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.form-group input[type="checkbox"] {
  width: auto;
  margin-right: 0.5rem;
}

.form-group label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  cursor: pointer;
}

/* ============================================================================
   Multiple Associations Styles
   ============================================================================ */

.associations-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 0.5rem;
}

[data-theme="light"] .associations-container {
  background: #f8f9fa;
  border-color: #dee2e6;
}

.associations-container h4 {
  margin: 0 0 0.75rem 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

#current-associations {
  margin-bottom: 1.5rem;
}

.association-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  transition: all 0.2s ease;
}

.association-item:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.association-item.new-association {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.05);
}

.new-badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  background: var(--success);
  color: white;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 500;
  margin-left: 0.5rem;
  margin-bottom: 0.5rem;
}

[data-theme="light"] .association-item {
  background: #ffffff;
  border-color: #e9ecef;
}

.association-info {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text);
  font-family: 'Courier New', monospace;
}

.remove-association {
  background: var(--danger);
  color: white;
  border: none;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

.remove-association:hover {
  background: #dc2626;
  transform: scale(1.05);
}

.no-associations {
  color: var(--text-dim);
  font-style: italic;
  margin: 0;
  padding: 0.5rem;
  text-align: center;
}

.add-association {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.association-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.association-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  pointer-events: auto;
  position: relative;
}

.association-buttons .btn {
  white-space: nowrap;
  min-width: auto;
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  pointer-events: auto;
  position: relative;
  z-index: 10;
}

.association-buttons .btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.association-buttons .btn.btn-secondary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.association-buttons .btn.btn-warning {
  background: #f59e0b;
  color: white;
  border-color: #f59e0b;
}

.association-select {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
}

[data-theme="light"] .association-select {
  color-scheme: light;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.association-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

[data-theme="light"] .association-select:focus {
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .types-table-wrapper {
    overflow-x: auto;
  }
  
  .types-table {
    min-width: 800px;
  }
  
  .action-buttons {
    flex-direction: column;
  }
  
  .behaviors {
    flex-direction: column;
  }
  
  .association-form {
    flex-direction: column;
    align-items: stretch;
  }
  
  .association-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

