/* CSS Variables for Premium Design System */
:root {
  /* Common variables */
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  /* Dark Theme Colors (Default) */
  --bg-app: #0b0f19;
  --bg-card: rgba(23, 31, 50, 0.7);
  --bg-card-hover: rgba(30, 41, 67, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #06b6d4;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-cell-ref: #06b6d4;
  
  /* Accents */
  --accent-teal: #06b6d4;
  --accent-teal-glow: rgba(6, 182, 212, 0.35);
  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.3);
  --accent-orange: #f97316;
  --accent-orange-glow: rgba(249, 115, 22, 0.4);
  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.3);
  --accent-yellow: #eab308;
}

/* Light Theme overrides */
body.light-theme {
  --bg-app: #f4f6fa;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: #0891b2;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --text-cell-ref: #0891b2;
  
  --accent-teal: #0891b2;
  --accent-teal-glow: rgba(8, 145, 178, 0.2);
  --accent-green: #059669;
  --accent-green-glow: rgba(5, 150, 105, 0.2);
  --accent-orange: #ea580c;
  --accent-orange-glow: rgba(234, 88, 12, 0.25);
  --accent-red: #dc2626;
  --accent-red-glow: rgba(220, 38, 38, 0.2);
  --accent-yellow: #ca8a04;
}

/* Base resets and defaults */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  padding: 24px;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  line-height: 1.5;
}

/* App Layout */
.app-container {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Brand Logo */
.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  user-select: none;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
  line-height: 1;
}

.brand-tag {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--accent-teal);
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.25);
  padding: 3px 7px;
  border-radius: 4px;
  line-height: 1;
}

/* Top Utility Bar */
.top-utility-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 0;
  padding: 12px 20px;
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  z-index: 10;
}

/* Theme Toggle */
.btn-icon {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background-color: var(--border-color);
  border-color: var(--text-muted);
}

/* Badges */
.status-badge {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  transition: all var(--transition-normal);
}

.status-badge.loading {
  background: rgba(234, 179, 8, 0.1);
  color: var(--accent-yellow);
  border-color: rgba(234, 179, 8, 0.2);
}

.status-badge.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
  border-color: rgba(16, 185, 129, 0.2);
}

.status-badge.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
  border-color: rgba(239, 68, 68, 0.2);
}

/* Drag & Drop File Upload Alert Card */
.upload-card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border: 2px dashed var(--accent-yellow);
  border-radius: var(--radius-md);
  padding: 30px;
  text-align: center;
  transition: all var(--transition-normal);
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.upload-icon {
  font-size: 3rem;
  color: var(--accent-yellow);
  margin-bottom: 8px;
}

.upload-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.upload-card p {
  color: var(--text-muted);
  max-width: 500px;
  font-size: 0.95rem;
}

.hidden-input {
  display: none;
}

/* Layout Grid */
.grid-layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
}

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

/* Panels */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.panel:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  border-color: rgba(255, 255, 255, 0.12);
}

body.light-theme .panel:hover {
  border-color: rgba(0, 0, 0, 0.12);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.panel-header i {
  font-size: 1.2rem;
  color: var(--accent-teal);
}

.panel-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  width: 100%;
}

.section-divider {
  margin-top: 24px;
}

.cell-ref {
  font-size: 0.75rem;
  font-weight: 700;
  background-color: var(--border-color);
  color: var(--text-cell-ref);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
  font-family: monospace;
}

/* Inputs and Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

input[type="text"], input[type="number"], select, textarea {
  font-family: var(--font-family);
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  outline: none;
}

body.light-theme input[type="text"], body.light-theme input[type="number"], body.light-theme select, body.light-theme textarea {
  background-color: rgba(255, 255, 255, 0.6);
}

input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.25);
  background-color: rgba(0, 0, 0, 0.3);
}

body.light-theme input[type="text"]:focus, body.light-theme input[type="number"]:focus, body.light-theme select:focus, body.light-theme textarea:focus {
  background-color: rgba(255, 255, 255, 1);
  box-shadow: 0 0 8px rgba(8, 145, 178, 0.15);
}

/* Buttons */
.btn {
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
  border: none;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--accent-teal);
  color: #0b0f19;
}

.btn-primary:hover {
  background-color: #22d3ee;
  box-shadow: 0 0 15px var(--accent-teal-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.15);
  border-color: var(--text-muted);
}

body.light-theme .btn-secondary {
  background-color: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--text-main);
}

body.light-theme .btn-secondary:hover {
  background-color: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.15);
}

.btn-success {
  background-color: var(--accent-green);
  color: #0b0f19;
}

.btn-success:hover:not(:disabled) {
  background-color: #34d399;
  box-shadow: 0 0 15px var(--accent-green-glow);
  transform: translateY(-1px);
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.btn-danger:hover {
  background-color: var(--accent-red);
  color: white;
  box-shadow: 0 0 15px var(--accent-red-glow);
}

.btn-large {
  width: 100%;
  padding: 16px 24px;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-glow {
  box-shadow: 0 4px 14px var(--accent-green-glow);
}

/* Summary Dashboard Card */
.summary-dashboard {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

body.light-theme .summary-card {
  background: rgba(255, 255, 255, 0.5);
}

.summary-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.summary-value {
  font-size: 1.35rem;
  font-weight: 700;
}

/* Specific Summary Card styles */
.total-card {
  grid-column: span 2;
  background: linear-gradient(135deg, var(--accent-orange-glow), rgba(0, 0, 0, 0.2));
  border-color: rgba(249, 115, 22, 0.3);
  border-left-width: 4px;
}

.total-card .summary-value {
  color: var(--accent-orange);
  font-size: 1.65rem;
}

.cost-card {
  border-left-width: 4px;
  border-left-color: var(--accent-red);
}

.margin-card {
  grid-column: span 2;
  border-left-width: 4px;
  border-left-color: var(--accent-teal);
  background: linear-gradient(135deg, var(--accent-teal-glow), rgba(0, 0, 0, 0.2));
}

.margin-card .summary-value {
  color: var(--accent-teal);
}

/* Tables Styling */
.table-panel-header {
  justify-content: space-between;
  align-items: center;
}

.title-with-icon {
  display: flex;
  align-items: center;
  gap: 12px;
}

.table-actions {
  display: flex;
  gap: 12px;
}

.table-responsive {
  overflow-x: auto;
  max-height: 480px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background-color: rgba(0, 0, 0, 0.3);
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 8px;
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

body.light-theme th {
  background-color: rgba(0, 0, 0, 0.04);
}

td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

/* Inline Edit Cells */
table input[type="text"], table input[type="number"] {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.85rem;
  border-radius: 4px;
}

/* Dynamic row animation */
tbody tr {
  transition: background-color var(--transition-fast);
}

tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

body.light-theme tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.btn-table-del {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-table-del:hover {
  background: var(--accent-red);
  color: white;
  transform: scale(1.1);
}

.row-index {
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

.calculated-cell {
  font-weight: 600;
  font-family: monospace;
  color: var(--accent-teal);
  padding: 6px 10px;
  font-size: 0.9rem;
}

.calculated-cell.total {
  color: var(--accent-orange);
  font-weight: 700;
}

/* Estimates Table overrides */
.estimates-table th, .estimates-table td {
  padding: 6px 4px;
}

.estimates-table input[type="number"], .estimates-table input[type="text"] {
  padding: 5px 8px;
}

/* Alert transitions and details */
.hidden {
  display: none !important;
}

/* Button focus & subtle elevation helpers */
.btn-glow {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Theme fade transition helper */
.theme-transition * {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease !important;
}

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

body.light-theme ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Export Panel at bottom */
.panel-export {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px 20px;
  border-color: rgba(16, 185, 129, 0.2);
  background: linear-gradient(180deg, var(--bg-card) 0%, rgba(16, 185, 129, 0.03) 100%);
  transition: all var(--transition-normal);
}

.panel-export:hover {
  border-color: rgba(16, 185, 129, 0.45);
  box-shadow: 0 12px 40px rgba(16, 185, 129, 0.08);
}

/* Floating Category Filter Drawer */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.drawer-overlay.hidden {
  display: none !important;
  opacity: 0;
}

.filter-drawer {
  position: fixed;
  top: 0;
  left: -380px;
  width: 380px;
  height: 100vh;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-color);
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.filter-drawer.open {
  left: 0;
}

/* Floating Middle-Left Drawer Trigger Button */
.filter-drawer-trigger {
  position: absolute;
  top: 50%;
  right: -44px;
  transform: translateY(-50%);
  width: 44px;
  height: 80px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  box-shadow: 6px 0 16px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1001;
  transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
  color: var(--accent-teal);
}

.filter-drawer-trigger:hover {
  background-color: var(--bg-card-hover);
  color: #22d3ee;
  box-shadow: 6px 0 20px rgba(6, 182, 212, 0.25);
}

.trigger-arrow {
  font-size: 1.1rem;
}

.filter-badge {
  background-color: var(--accent-teal);
  color: #0b0f19;
  font-size: 0.7rem;
  font-weight: 800;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
  box-shadow: 0 0 6px var(--accent-teal-glow);
  transition: all var(--transition-fast);
}

.filter-badge.empty {
  background-color: var(--text-muted);
  box-shadow: none;
  opacity: 0.6;
}



.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
  margin-bottom: 14px;
}

.drawer-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-close {
  background: transparent;
  border: none;
  font-size: 2rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition-fast);
}

.drawer-close:hover {
  color: var(--accent-red);
}

.drawer-actions {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--accent-teal);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  font-family: var(--font-family);
  transition: color var(--transition-fast);
}

.btn-link:hover {
  color: #22d3ee;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

/* Hierarchical Tree Connectors */
.category-tree, .category-tree ul {
  list-style: none;
  padding-left: 24px;
  position: relative;
}

.category-tree {
  padding-left: 0;
}

/* Collapsible child trees with smooth height/opacity transitions */
.child-tree-list {
  max-height: 500px;
  opacity: 1;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

.child-tree-list.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Hide vertical connector lines when children list is collapsed */
.child-tree-list.collapsed::before {
  display: none !important;
}

/* Vertical dotted line */
.category-tree ul::before {
  content: "";
  position: absolute;
  top: 0;
  left: 6px;
  border-left: 1px dotted var(--text-muted);
  height: calc(100% - 10px);
}

.category-tree li {
  margin: 10px 0;
  position: relative;
  padding-left: 16px;
}

/* Horizontal dotted line */
.category-tree li::before {
  content: "";
  position: absolute;
  top: 10px;
  left: -18px;
  border-top: 1px dotted var(--text-muted);
  width: 18px;
  height: 0;
}

/* Container for checkbox and label */
.tree-node {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 0.95rem;
}

.tree-node input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent-teal);
}

.tree-node label {
  cursor: pointer;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.tree-node:hover label {
  color: var(--accent-teal);
}

/* Parent Node specific styles */
.parent-node {
  font-weight: 700 !important;
  color: var(--text-main);
}


/* Database Catalog Search Panel Styles */
.catalog-filters {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
  margin-bottom: 16px;
}

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

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-input-wrapper input {
  width: 100%;
  padding-left: 38px !important;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.catalog-results-container {
  max-height: 500px;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: rgba(0, 0, 0, 0.2);
}

body.light-theme .catalog-results-container {
  background-color: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

.catalog-status-msg {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.catalog-status-msg.error {
  color: var(--accent-red);
}

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

.catalog-table th {
  background-color: rgba(0, 0, 0, 0.35);
  font-size: 0.8rem;
  padding: 10px 8px;
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1;
}

body.light-theme .catalog-table th {
  background-color: rgba(0, 0, 0, 0.04);
}

.catalog-table td {
  padding: 8px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.btn-catalog-add {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  margin: 0 auto;
}

.btn-catalog-add:hover {
  background-color: var(--accent-green);
  color: #0b0f19;
  transform: scale(1.15);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

/* Settings Dropdown Container */
.settings-dropdown-container {
  position: relative;
}

.settings-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 250px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.settings-dropdown.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.settings-dropdown h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 0;
  transition: color var(--transition-fast);
}

.settings-label:hover {
  color: var(--text-main);
}

.settings-label input[type="checkbox"] {
  accent-color: var(--accent-teal);
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.settings-label input[type="checkbox"]:disabled + span {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Hide Table Columns dynamically */
#catalog-table.hide-col-name .col-name { display: none; }
#catalog-table.hide-col-unit .col-unit { display: none; }
#catalog-table.hide-col-buy_price .col-buy_price { display: none; }
#catalog-table.hide-col-markup .col-markup { display: none; }
#catalog-table.hide-col-work_coefficient .col-work_coefficient { display: none; }
#catalog-table.hide-col-work_price .col-work_price { display: none; }
#catalog-table.hide-col-supplier .col-supplier { display: none; }
#catalog-table.hide-col-link .col-link { display: none; }
#catalog-table.hide-col-action .col-action { display: none; }

/* Settings Modal Overlay and Popup Window */
.settings-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.settings-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.settings-modal {
  width: 720px;
  height: 520px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalSlideUp var(--transition-normal);
  color: var(--text-main);
}

@keyframes modalSlideUp {
  from { transform: translateY(25px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.settings-modal-header {
  padding: 14px 20px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-modal-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.window-controls {
  display: flex;
  gap: 14px;
  align-items: center;
}

.window-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: color var(--transition-fast);
  padding: 4px;
}

.window-btn:hover {
  color: var(--text-main);
}

.window-btn.close:hover {
  color: var(--accent-red);
}

.settings-modal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.settings-sidebar {
  width: 210px;
  background: rgba(0, 0, 0, 0.12);
  border-right: 1px solid var(--border-color);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-item {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
}

.sidebar-item.active {
  background: var(--accent-teal-glow);
  color: var(--accent-teal);
  border-left: 3px solid var(--accent-teal);
  padding-left: 11px;
}

.settings-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.05);
}

body.light-theme .settings-content {
  background: rgba(255, 255, 255, 0.3);
}

.settings-pane {
  display: none;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}

.settings-pane.active {
  display: flex;
}

.fieldset-container {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 20px;
  position: relative;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
}

.fieldset-legend {
  position: absolute;
  top: -10px;
  left: 14px;
  background: var(--bg-app);
  padding: 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: background-color var(--transition-normal);
}

.settings-checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  overflow-y: auto;
  max-height: 350px;
  padding-right: 4px;
}

@media (max-width: 600px) {
  .settings-checkbox-grid {
    grid-template-columns: 1fr;
  }
}

.feedback-rating i {
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.feedback-rating i:hover {
  transform: scale(1.2);
}

/* Hide Basket Table Columns dynamically */
#items-table.hide-col-b-id .col-b-id { display: none; }
#items-table.hide-col-b-produkt .col-b-produkt { display: none; }
#items-table.hide-col-b-jednotky .col-b-jednotky { display: none; }
#items-table.hide-col-b-quantity .col-b-quantity { display: none; }
#items-table.hide-col-b-nakup_materialu .col-b-nakup_materialu { display: none; }
#items-table.hide-col-b-koeficient_material .col-b-koeficient_material { display: none; }
#items-table.hide-col-b-material_spolu .col-b-material_spolu { display: none; }
#items-table.hide-col-b-koeficient_prace .col-b-koeficient_prace { display: none; }
#items-table.hide-col-b-work_qty .col-b-work_qty { display: none; }
#items-table.hide-col-b-cena_prace .col-b-cena_prace { display: none; }
#items-table.hide-col-b-work_spolu .col-b-work_spolu { display: none; }
#items-table.hide-col-b-spolu .col-b-spolu { display: none; }
#items-table.hide-col-b-dodavatel .col-b-dodavatel { display: none; }
#items-table.hide-col-b-odkaz .col-b-odkaz { display: none; }
#items-table.hide-col-b-product_type_id .col-b-product_type_id { display: none; }
#items-table.hide-col-b-hlavna_kategoria .col-b-hlavna_kategoria { display: none; }
#items-table.hide-col-b-nazov_tabulky .col-b-nazov_tabulky { display: none; }

/* Toast Notification System */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 320px;
  max-width: 450px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  color: var(--text-main);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 14px;
  transform: translateX(120%);
  opacity: 0;
  transition: all var(--transition-normal);
  border-left: 4px solid var(--accent-teal);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.success {
  border-left-color: var(--accent-green);
}
.toast.success i {
  color: var(--accent-green);
}

.toast.error {
  border-left-color: var(--accent-red);
}
.toast.error i {
  color: var(--accent-red);
}

.toast.warning {
  border-left-color: var(--accent-orange);
}
.toast.warning i {
  color: var(--accent-orange);
}

.toast.info {
  border-left-color: var(--accent-teal);
}
.toast.info i {
  color: var(--accent-teal);
}

.toast-message {
  font-size: 0.9rem;
  font-weight: 500;
  flex: 1;
  line-height: 1.4;
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  transition: color var(--transition-fast);
  line-height: 1;
  padding: 0 4px;
}

.toast-close:hover {
  color: var(--text-main);
}

/* Generic Modal Popups (Save Version Dialog) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalSlideUp var(--transition-normal);
  color: var(--text-main);
}

.modal-header {
  padding: 14px 20px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition-fast);
}

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

/* Work Management Table specific styling */
.work-management-table {
  width: 100%;
  border-collapse: collapse;
}

.work-management-table th {
  padding: 10px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
  font-size: 0.85rem;
}

.work-management-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.work-management-table tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

body.light-theme .work-management-table tr:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.work-management-table input[type="number"] {
  width: 100%;
  padding: 6px 8px;
  background-color: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  text-align: center;
}

body.light-theme .work-management-table input[type="number"] {
  background-color: rgba(255, 255, 255, 0.5);
}

.work-management-table input[type="number"]:focus {
  border-color: var(--border-focus);
}

.work-management-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent-teal);
  vertical-align: middle;
}

/* Styling to distinguish labor and transport in the budget table */
.work-item-row {
  background-color: rgba(6, 182, 212, 0.04) !important;
  border-left: 4px solid var(--accent-teal) !important;
}

.work-item-row:hover {
  background-color: rgba(6, 182, 212, 0.08) !important;
}

.transport-item-row {
  background-color: rgba(249, 115, 22, 0.04) !important;
  border-left: 4px solid var(--accent-orange) !important;
}

.transport-item-row:hover {
  background-color: rgba(249, 115, 22, 0.08) !important;
}

/* Light theme adjustments */
body.light-theme .work-item-row {
  background-color: rgba(8, 145, 178, 0.06) !important;
}
body.light-theme .work-item-row:hover {
  background-color: rgba(8, 145, 178, 0.1) !important;
}
body.light-theme .transport-item-row {
  background-color: rgba(234, 88, 12, 0.06) !important;
}
body.light-theme .transport-item-row:hover {
  background-color: rgba(234, 88, 12, 0.1) !important;
}

/* Section divider row styles in tables */
.section-divider-row {
  background-color: rgba(6, 182, 212, 0.08) !important; /* light blue tint in dark theme */
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border-color);
}

.section-divider-row td {
  padding: 10px 14px !important;
  color: var(--accent-teal) !important;
  font-size: 0.9rem;
}

.section-divider-row:hover {
  background-color: rgba(6, 182, 212, 0.15) !important;
}

body.light-theme .section-divider-row {
  background-color: #d8f5ff !important; /* exact light blue from APPKA */
}

body.light-theme .section-divider-row td {
  color: #0284c7 !important; /* nice sky blue/teal */
}

.catalog-section-divider {
  background-color: rgba(6, 182, 212, 0.05) !important;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border-color);
}

.catalog-section-divider td {
  padding: 8px 12px !important;
  color: var(--accent-teal) !important;
  font-size: 0.85rem;
}

.catalog-section-divider:hover {
  background-color: rgba(6, 182, 212, 0.12) !important;
}

body.light-theme .catalog-section-divider {
  background-color: #e6f7ff !important;
}

body.light-theme .catalog-section-divider td {
  color: #0284c7 !important;
}

/* Reordering buttons hover styling */
.category-actions button:hover {
  background-color: var(--accent-teal) !important;
  color: #ffffff !important;
  border-color: var(--accent-teal) !important;
}

.btn-row-up:hover, .btn-row-down:hover {
  color: var(--accent-teal) !important;
}

.btn-table-del:hover {
  color: var(--accent-red) !important;
}

/* Drag and Drop Visual Feedback Styles */
tr.dragging {
  opacity: 0.45;
  outline: 2px dashed var(--accent-teal, #06b6d4) !important;
  outline-offset: -2px;
  background-color: rgba(6, 182, 212, 0.12) !important;
}

tr.dragging td {
  background-color: rgba(6, 182, 212, 0.12) !important;
}

tr.drag-over {
  outline: 2px dashed var(--accent-teal, #06b6d4) !important;
  outline-offset: -2px;
  background-color: rgba(6, 182, 212, 0.18) !important;
}

tr.drag-over td {
  background-color: rgba(6, 182, 212, 0.18) !important;
}

/* Flicker-free dragging: prevent child hover events from bubbling */
.table-dragging-active tr * {
  pointer-events: none !important;
}

/* Visual Drop insertion indicators on table cells */
tr.drag-over-top td {
  border-top: 3px dashed var(--accent-teal) !important;
}

tr.drag-over-bottom td {
  border-bottom: 3px dashed var(--accent-teal) !important;
}

/* Category divider row top/bottom border overrides for extra emphasis */
tr.section-divider-row.drag-over-top td {
  border-top: 4px solid var(--accent-teal) !important;
}

tr.section-divider-row.drag-over-bottom td {
  border-bottom: 4px solid var(--accent-teal) !important;
}

/* Slight background highlight for active drop target */
tr.drag-over-top, tr.drag-over-bottom {
  background-color: rgba(6, 182, 212, 0.06) !important;
}

/* Split Layout Grid (Database on the left, Basket on the right) */
@media (min-width: 1025px) {
  .app-main.split-layout-active {
    display: grid !important;
    grid-template-columns: 1fr 1.3fr !important;
    grid-template-rows: auto auto auto !important;
    gap: 20px !important;
    align-items: start !important;
  }
  
  .app-main.split-layout-active .panel-catalog {
    grid-column: 1 !important;
    grid-row: 1 / 3 !important;
    margin-bottom: 0 !important;
  }
  
  .app-main.split-layout-active .panel-top {
    grid-column: 2 !important;
    grid-row: 1 !important;
  }

  .app-main.split-layout-active .grid-layout {
    grid-column: 2 !important;
    grid-row: 2 !important;
    margin-top: 0 !important;
  }
  
  .app-main.split-layout-active .panel-export {
    grid-column: 1 / 3 !important;
    grid-row: 3 !important;
  }
}

/* Coefficients Dropdown */
.dropdown-container {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 100;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.dropdown-menu.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown-group {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

.dropdown-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 16px;
  letter-spacing: 0.5px;
}

.dropdown-item {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 8px 16px;
  text-align: left;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition-fast), color var(--transition-fast);
  width: 100%;
}

.dropdown-item:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
}

.dropdown-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

/* Version Notes Checklist styles */
.note-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.note-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

body.light-theme .note-item:hover {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.1);
}

.note-item.dragging {
  opacity: 0.4;
  border: 1px dashed var(--accent-color, #06b6d4);
  background: rgba(6, 182, 212, 0.1);
}

.note-drag-handle {
  color: var(--text-muted, #94a3b8);
  cursor: grab;
  padding: 2px 4px;
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  user-select: none;
}

.note-drag-handle:hover {
  color: var(--accent-color, #06b6d4);
}

.note-item input[type="checkbox"] {
  margin-top: 0;
  cursor: pointer;
}

.note-item span.note-text-span {
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.3;
  flex: 1;
  cursor: pointer;
  user-select: none;
}

.note-item.custom-note-item span.note-text-span {
  color: #06b6d4; /* cyan highlight for custom notes */
}

body.light-theme .note-item.custom-note-item span.note-text-span {
  color: #0891b2;
}

.note-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.btn-note-order {
  background: none;
  border: none;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all var(--transition-fast);
}

.btn-note-order:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main, #f8fafc);
}

body.light-theme .btn-note-order:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-main, #0f172a);
}

.btn-delete-note {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 3px 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  font-size: 0.75rem;
}

.btn-delete-note:hover {
  background: rgba(239, 68, 68, 0.15);
}









