/* Show only the active page */
.page { display: none; }
.page.active { display: block; }

/* Root theme tokens */
:root {
  --bg: #f7f7fb;
  --panel: #ffffff;
  --text: #15171a;
  --text-muted: #6b7280;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --accent: #10b981;
  --danger: #ef4444;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger-light: #fef2f2;
  --primary-light: #eff6ff;
  --shadow: 0 8px 24px rgba(16,24,40,.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --panel: #171b21;
    --text: #e5e7eb;
    --text-muted: #9aa4b2;
    --muted: #9aa4b2;
    --border: #242a33;
    --primary: #3b82f6;
    --primary-600: #2563eb;
    --success: #10b981;
    --success-light: #064e3b;
    --warning: #f59e0b;
    --warning-light: #451a03;
    --danger-light: #450a0a;
    --primary-light: #1e3a8a;
    --shadow: 0 10px 24px rgba(0,0,0,.35);
  }
}
/* >>> Manual override: these come AFTER the media block so they win <<< */
body[data-theme="light"] {
  --bg: #f7f7fb;
  --panel: #ffffff;
  --text: #15171a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --shadow: 0 8px 24px rgba(16,24,40,.06);
}

body[data-theme="dark"] {
  --bg: #0f1216;
  --panel: #171b21;
  --text: #e5e7eb;
  --muted: #9aa4b2;
  --border: #242a33;
  --primary: #3b82f6;
  --primary-600: #2563eb;
  --shadow: 0 10px 24px rgba(0,0,0,.35);
}

/* Global */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
}

/* Header / Top Nav */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: grid; grid-template-columns: 220px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 32px; height: 32px; display: grid; place-items: center; background: var(--primary); color: white; border-radius: 8px; }
.title { font-weight: 700; letter-spacing: .2px; }

.tabs {
  display: flex; gap: 4px; align-items: center;
  padding: 4px; background: color-mix(in oklab, var(--panel), var(--border) 40%);
  border: 1px solid var(--border); border-radius: 10px;
}
.tabs .nav-group { position: relative; display:flex; }
.tabs .nav-group .tab { position: relative; }
.nav-dropdown { position:absolute; top:100%; left:0; background:var(--panel); border:1px solid var(--border); border-radius:10px; padding:6px 0; box-shadow:var(--shadow); min-width:190px; opacity:0; pointer-events:none; transform:translateY(4px); transition:opacity .15s, transform .15s; z-index:200; }
.nav-dropdown a { display:block; padding:8px 14px; font-weight:500; font-size:14px; text-decoration:none; color:var(--text); white-space:nowrap; }
.nav-dropdown a:hover { background:color-mix(in oklab, var(--panel), var(--border) 40%); }
.tabs .nav-group:hover .nav-dropdown, .tabs .nav-group:focus-within .nav-dropdown { opacity:1; pointer-events:auto; transform:translateY(0); }
.hidden { display:none !important; }
/* Tree view styles */
.tree-view { font-family: var(--font-stack); font-size: .85rem; line-height:1.25; }
.tree-node { display:flex; align-items:center; gap:4px; padding:2px 4px; border-radius:4px; cursor:pointer; }
.tree-node:hover { background: var(--bg-alt); }
.tree-children { margin-left:16px; border-left:1px solid var(--border); padding-left:4px; }
.tree-toggle { width:22px; height:22px; line-height:20px; text-align:center; cursor:pointer; font-weight:600; border:1px solid var(--border); border-radius:4px; background:var(--bg-alt); font-size:.7rem; user-select:none; }
.tree-toggle:hover { background: var(--accent); color:#fff; border-color: var(--accent); }
.tree-leaf .tree-toggle { visibility:hidden; }
.tree-meta { opacity:.6; font-size:.7rem; margin-left:4px; }
.tree-actions button { font-size:.6rem; }
.view-toggle button[aria-pressed="true"] { background: var(--accent); color:#fff; }
/* Overlay */
.overlay { position:fixed; inset:0; z-index:1000; display:flex; align-items:flex-start; justify-content:center; padding:40px 20px; }

/* Ensure modals appear above fullscreen views */
.fullscreen-view ~ .overlay,
.fullscreen-view + .overlay {
  z-index: 10001;
}
.overlay-backdrop { position:absolute; inset:0; background:rgba(0,0,0,.45); backdrop-filter:blur(2px); }

/* Special styling for edit modals in fullscreen mode */
.fullscreen-edit-modal .overlay-backdrop {
  background: transparent;
  backdrop-filter: none;
}

.fullscreen-edit-modal {
  justify-content: flex-start;
  align-items: flex-start;
  padding: 20px;
}

.fullscreen-edit-modal .overlay-panel {
  background: var(--panel);
  border: 2px solid var(--border);
  box-shadow: 0 10px 32px -4px rgba(0,0,0,.8);
  max-width: 400px;
  max-height: calc(100vh - 40px);
}
.overlay-panel { position:relative; background:var(--bg); color:var(--text); width: min(640px, 100%); max-height:100%; overflow:auto; border:1px solid var(--border); border-radius:10px; box-shadow:0 10px 32px -4px rgba(0,0,0,.5); padding:16px 20px 24px; display:flex; flex-direction:column; gap:12px; }
.overlay-header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.overlay-body { font-size:.85rem; line-height:1.35; display:flex; flex-direction:column; gap:16px; }
.overlay-body h4 { margin:0 0 4px; font-size:.75rem; text-transform:uppercase; letter-spacing:.5px; opacity:.7; }
.overlay-body ul { margin:4px 0 0 16px; padding:0; }
.overlay-body li { margin:2px 0; }
.ov-section { border-top:1px solid var(--border); padding-top:8px; }
.overlay .actions button { margin-right:6px; }
.overlay.hidden { display:none; }
.mini-kv { width:100%; border-collapse:collapse; font-size:.75rem; }
.mini-kv th { text-align:left; padding:2px 6px 2px 0; font-weight:600; opacity:.7; white-space:nowrap; }
.mini-kv td { padding:2px 4px; }
.entity-meta { font-size:.7rem; opacity:.65; margin-bottom:4px; }
.tab {
  appearance: none; background: transparent; border: 0;
  padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 600; cursor: pointer;
  text-decoration: none; /* remove underline */
}
.tab:hover, .tab:focus { color: var(--text); text-decoration: none; }
.tab.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

.actions { display: flex; align-items: center; gap: 10px; }

/* Theme toggle */
.theme-toggle { position: relative; }
.theme-toggle input { position: absolute; opacity: 0; }
.theme-toggle label {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  width: 64px; padding: 6px;
  background: color-mix(in oklab, var(--panel), var(--border) 40%);
  border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
}
.theme-toggle .sun, .theme-toggle .moon {
  display: grid; place-items: center; font-size: 14px; opacity: .6;
}
.theme-toggle input:checked + label .moon { opacity: 1; }
.theme-toggle input:not(:checked) + label .sun { opacity: 1; }

/* Layout */
.container { max-width: 1200px; margin: 18px auto; padding: 0 16px; }
.status { margin: 0 0 12px; color: var(--muted); }

/* Cards */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h2 { margin: 0; font-size: 18px; }
.card-body { padding: 16px; }

/* Forms */
.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.field { display: grid; gap: 6px; }
.field > label { font-size: 12px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary), transparent 80%); }
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.form-actions { margin-top: 12px; display: flex; gap: 8px; justify-content: flex-end; }

/* Attributes editor */
.attrs { margin-top: 16px; border: 1px dashed var(--border); border-radius: 12px; padding: 12px; }
.attrs-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.attr-list { display: grid; gap: 8px; }
.attr-row { display: grid; grid-template-columns: 2fr 3fr auto; gap: 8px; }
.attr-row .mini { min-width: 44px; }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--panel);
  padding: 10px 14px; border-radius: 10px; cursor: pointer; color: var(--text); font-weight: 600;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); color: white; border-color: var(--primary-600); }
.btn.primary:hover { background: var(--primary-600); }
.btn.success { background: var(--success); color: white; border-color: var(--success); }
.btn.success:hover { background: color-mix(in oklab, var(--success), black 20%); }
.btn.ghost { background: transparent; }
.btn.mini { padding: 6px 10px; }
.btn.danger { background: var(--danger); color:#fff; border-color: var(--danger); }
.btn.danger:hover { filter: brightness(.9); }
.btn.subtle { background: color-mix(in oklab, var(--panel), var(--border) 55%); }
.btn.subtle:hover { background: color-mix(in oklab, var(--panel), var(--border) 35%); }

/* Auto-refresh button styles */
.btn#toggle-auto-refresh {
  transition: all 0.2s ease;
}

.btn#toggle-auto-refresh.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  animation: pulse 2s infinite;
}

.btn#toggle-auto-refresh.active:hover {
  background: color-mix(in oklab, var(--accent), black 10%);
}

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

/* View switching buttons */
.view-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.view-controls .btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.view-controls .btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.view-controls .btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.view-controls .btn.active:hover {
  background: var(--primary-600);
}

.view-controls .btn svg {
  width: 14px;
  height: 14px;
}

/* List view styles */
.list-view-content {
  display: none;
}

.list-view-container {
  padding: 0;
}

.list-section {
  margin-bottom: 32px;
}

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

.list-section h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* Table improvements for list view */
.view-content .table-wrap {
  margin-bottom: 0;
}

.view-content .table th {
  font-weight: 600;
}

/* Back button styles */
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  border-radius: 6px;
  transition: all 0.2s ease;
  margin-right: 12px;
}

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

.back-btn svg {
  width: 12px;
  height: 12px;
}

/* Tree view styles - JSON-style viewer with containers */
.tree-view-content {
  display: none;
}

.tree-controls {
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.tree-controls .btn {
  padding: 6px 10px;
  font-size: 11px;
}

.tree-container {
  font-family: 'Segoe UI', 'System UI', sans-serif;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
}

.tree-root {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tree-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  overflow: hidden;
  transition: all 0.2s ease;
}

.tree-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tree-line {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s ease;
  user-select: none;
}

.tree-line:hover {
  background: var(--primary-light);
}

.tree-line.clickable {
  cursor: pointer;
}

.tree-line.no-children {
  border-bottom: none;
}

.tree-indent {
  display: inline-block;
  width: 20px;
  flex-shrink: 0;
}

.tree-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 12px;
  flex-shrink: 0;
  color: var(--muted);
  transition: all 0.2s ease;
}

.tree-icon.expandable {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  font-size: 10px;
}

.tree-icon.expandable:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.tree-icon.expanded {
  transform: rotate(90deg);
}

.tree-icon-empty {
  width: 16px;
  height: 16px;
  margin-right: 12px;
}

.tree-content {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 8px;
}

.tree-key {
  font-weight: 600;
  font-size: 14px;
}

.tree-separator {
  color: var(--muted);
  margin: 0 4px;
}

.tree-value {
  color: var(--muted);
  flex: 1;
  min-width: 0;
  font-size: 13px;
}

.tree-count {
  color: var(--muted);
  font-size: 11px;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-left: 8px;
}

.tree-type-building .tree-key {
  color: #2196F3;
}

.tree-type-building .tree-line {
  background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
}

.tree-type-asset .tree-key {
  color: #FF9800;
}

.tree-type-orphaned .tree-key {
  color: #9E9E9E;
}

.tree-type-orphaned .tree-line {
  background: linear-gradient(135deg, #FAFAFA 0%, #F5F5F5 100%);
}

.tree-actions {
  display: flex;
  gap: 6px;
  margin-left: 12px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tree-line:hover .tree-actions {
  opacity: 1;
}

.tree-actions .btn {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 4px;
  background: white;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.tree-actions .btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tree-actions .btn.view-btn {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.tree-actions .btn.view-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tree-children {
  background: var(--bg);
  padding: 8px 16px 16px 16px;
  display: none;
}

.tree-children.expanded {
  display: block;
}

.tree-children .tree-item {
  margin-left: 20px;
  border-left: 2px solid var(--primary-light);
  border-radius: 4px;
}

.tree-children .tree-line {
  background: var(--bg);
  padding: 8px 12px;
}

.tree-children .tree-line:hover {
  background: var(--bg-alt);
}

.tree-children .tree-node:last-child {
  margin-bottom: 0;
}

/* Asset nodes in tree */
.tree-asset {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin: 2px 0;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  background: var(--panel);
  border: 1px solid transparent;
}

.tree-asset:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Table-like tree view styles */
.tree-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-alt);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.tree-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s ease;
}

.tree-row:hover {
  background: var(--primary-light);
}

.tree-row.clickable {
  cursor: pointer;
}

.tree-column {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

.tree-column.name-column {
  flex: 2;
  min-width: 200px;
}

.tree-column.address-column,
.tree-column.type-column {
  flex: 1.5;
  min-width: 150px;
}

.tree-column.count-column,
.tree-column.building-column,
.tree-column.manufacturer-column {
  flex: 1;
  min-width: 120px;
}

.tree-column.actions-column {
  flex: 0 0 140px;
  justify-content: flex-end;
}

.tree-column.info-column {
  flex: 2;
  color: var(--muted);
  font-style: italic;
}

/* Tree level indentation */
.tree-level-1 .tree-column.name-column {
  padding-left: 24px;
}

.tree-level-2 .tree-column.name-column {
  padding-left: 48px;
}

.tree-level-3 .tree-column.name-column {
  padding-left: 72px;
}

/* Tree type styling */
.tree-type-building {
  background: var(--bg);
  font-weight: 500;
}

.tree-type-building:hover {
  background: var(--primary-light);
}

.tree-type-asset {
  background: var(--panel);
  font-size: 13px;
}

.tree-type-asset:hover {
  background: var(--primary-light);
}

.tree-type-orphaned {
  background: var(--bg-alt);
  color: var(--muted);
  font-style: italic;
}

/* Search controls */
.search-controls {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-alt);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.search-box {
  position: relative;
  max-width: 400px;
}

.search-input {
  width: 100%;
  padding: 10px 40px 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.search-input::placeholder {
  color: var(--muted);
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

/* Grouped list styles */
.grouped-section {
  margin-bottom: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}

.building-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}

.building-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.building-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.building-address {
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-count {
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.building-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.building-header.orphaned {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.building-header.orphaned h3 {
  color: var(--muted);
  font-style: italic;
}

.assets-table-container {
  background: var(--bg);
}

.assets-table {
  margin: 0;
  border: none;
}

.assets-table thead {
  background: var(--panel);
}

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

.asset-row {
  background: var(--bg);
}

.asset-row:hover {
  background: var(--primary-light);
}

.no-assets {
  padding: 24px;
  text-align: center;
  background: var(--panel);
  border-top: 1px solid var(--border);
}

.tree-asset-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tree-asset:hover .tree-asset-actions {
  opacity: 1;
}

.tree-asset-actions .btn {
  padding: 2px 6px;
  font-size: 10px;
  border-radius: 4px;
}

/* Template Form Styles */
.form-section {
  margin-bottom: 24px;
}

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

.section-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.checkbox-item:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.checkbox-item input[type="checkbox"] {
  margin: 0;
  vertical-align: middle;
}

.checkbox-item input[type="radio"] {
  margin: 0;
  vertical-align: middle;
}

.checkbox-field {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 40px;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  display: block;
}

/* Field Rows */
.field-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  background: var(--panel);
}

.field-row-content {
  width: 100%;
}

.field-row-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: flex-end;
}

.dropdown-options-preview {
  margin-top: 8px;
  padding: 8px;
  background: color-mix(in oklab, var(--panel), var(--border) 20%);
  border-radius: 4px;
  font-size: 12px;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 32px;
  border: 2px dashed var(--border);
  border-radius: 8px;
}

/* Template View Styles */
.template-view-content {
  max-width: 100%;
}

.template-info {
  margin-bottom: 24px;
}

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

.info-item label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-value {
  font-size: 14px;
  color: var(--text);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--primary-light);
  color: var(--primary);
}

.badge.active {
  background: var(--success-light);
  color: var(--success);
}

.badge.archived {
  background: var(--danger-light);
  color: var(--danger);
}

.badge.required {
  background: var(--warning-light);
  color: var(--warning);
}

.badge.complete {
  background: var(--success-light);
  color: var(--success);
}

.badge.incomplete {
  background: var(--warning-light);
  color: var(--warning);
}

/* Status toggle buttons */
.status-toggle-btn {
  appearance: none;
  border: 1px solid;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
  min-width: 80px;
}

.status-toggle-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.status-toggle-btn.status-ready {
  background: var(--success-light);
  color: var(--success);
  border-color: var(--success);
}

.status-toggle-btn.status-ready:hover:not(:disabled) {
  background: var(--success);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.status-toggle-btn.status-unset {
  background: var(--panel);
  color: var(--text-muted);
  border-color: var(--border);
}

.status-toggle-btn.status-unset:hover:not(:disabled) {
  background: var(--success-light);
  color: var(--success);
  border-color: var(--success);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.constraints-section {
  margin-top: 16px;
}

.constraints-section label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.constraints-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.constraint-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.template-fields,
.template-assignments {
  margin-bottom: 24px;
}

.template-fields h3,
.template-assignments h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
}

.template-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Dropdown Options Editor */
.dropdown-options-editor {
  max-width: 100%;
}

.options-list h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
}

.option-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 14px;
}

.add-option {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.new-option-input {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
}

.options-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Forms page specific styles */
.template-name {
  font-weight: 500;
  margin-bottom: 2px;
}

.field-count {
  font-size: 12px;
  color: var(--muted);
}

.field-preview {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  margin-top: 2px;
}

/* Inline table action group */
.action-buttons { display:flex; gap:4px; flex-wrap:wrap; }
.table .actions .btn { padding:4px 8px; font-size:11px; line-height:1.1; border-radius:6px; }

/* Tables */
.table-wrap { width: 100%; overflow: auto; border-radius: 12px; border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; min-width: 860px; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th { background: color-mix(in oklab, var(--panel), var(--border) 40%); text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.table tbody tr:hover { background: color-mix(in oklab, var(--panel), var(--border) 20%); }

/* Truncate template fields list */
table#ft_table td.fields-trunc { max-width:240px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* Modal enhancements */
.modal-overlay .overlay-panel.small { width: min(400px, 90%); }
.modal-overlay .overlay-panel.medium { width: min(600px, 90%); }
.modal-overlay .overlay-panel.large { width: min(800px, 90%); }
.modal-overlay .overlay-panel.extra-large { width: min(1400px, 98%); max-width: none; height: min(900px, 95vh); }

/* Enhanced Edit Element Modal Layout */
.edit-element-modal-container {
  display: flex;
  gap: 2rem;
  min-height: 60vh;
}

.modal-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.modal-column-left {
  flex: 1.2; /* Slightly wider for field selection */
}

.modal-column-right {
  flex: 1;
}

.form-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
}

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

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

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.field-selection {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

.field-table-container {
  width: 100%;
}

.field-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  table-layout: fixed;
}

.field-table thead th {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.field-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s ease;
}

.field-table tbody tr:hover {
  background: var(--hover);
}

.field-table tbody tr.field-group-header {
  background: var(--bg);
  font-weight: 600;
}

.field-table tbody tr.field-group-header:hover {
  background: var(--bg);
}

.field-table tbody tr.field-group-header td {
  padding: 8px 12px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.field-table td {
  padding: 6px 12px;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-display-col {
  width: 70px;
  text-align: center;
}

.field-name-col {
  width: auto;
  min-width: 180px;
}

.field-type-col {
  width: 90px;
  text-align: center;
}

.field-labels-col {
  width: 100px;
  text-align: center;
}

.field-editable-col {
  width: 100px;
  text-align: center;
}

.field-label {
  display: block;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}

.field-key {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.field-type {
  display: inline-block;
  background: var(--accent-bg);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}

.field-table input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

.field-table input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.field-selection-header {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Resizable Modal in Fullscreen Mode */
.fullscreen-edit-modal .modal-panel {
  position: relative !important;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
  border-radius: 12px;
  overflow: hidden;
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  max-height: 95vh;
}

/* Ensure modal body is scrollable */
.fullscreen-edit-modal .modal-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(95vh - 160px); /* Account for header, navbar, and footer */
  padding: 1.5rem;
  padding-top: 1rem; /* Reduced top padding since navbar provides separation */
}

/* Enhanced header for dragging */
.fullscreen-edit-modal .overlay-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  position: relative;
  user-select: none;
  flex-shrink: 0;
}

.fullscreen-edit-modal .modal-footer {
  flex-shrink: 0;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.fullscreen-edit-modal .overlay-header::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 3rem;
  transform: translateY(-50%);
  width: 20px;
  height: 4px;
  background: var(--muted);
  border-radius: 2px;
  box-shadow: 0 6px 0 var(--muted), 0 -6px 0 var(--muted);
  opacity: 0.5;
  pointer-events: none;
}

/* Snap visual feedback */
.fullscreen-edit-modal .modal-panel.snapping {
  box-shadow: 0 0 0 2px var(--primary), 0 20px 40px rgba(0,0,0,0.15);
}

.modal-resize-handle {
  position: absolute;
  background: transparent;
  z-index: 10;
  transition: background-color 0.2s ease;
}

.modal-resize-handle:hover {
  background: var(--primary);
  opacity: 0.2;
}

.modal-resize-handle:active {
  background: var(--primary);
  opacity: 0.4;
}

/* Corner handles */
.modal-resize-se {
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  cursor: se-resize;
}

.modal-resize-nw {
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  cursor: nw-resize;
}

.modal-resize-ne {
  top: 0;
  right: 0;
  width: 12px;
  height: 12px;
  cursor: ne-resize;
}

.modal-resize-sw {
  bottom: 0;
  left: 0;
  width: 12px;
  height: 12px;
  cursor: sw-resize;
}

/* Edge handles */
.modal-resize-n {
  top: 0;
  left: 12px;
  right: 12px;
  height: 6px;
  cursor: n-resize;
}

.modal-resize-s {
  bottom: 0;
  left: 12px;
  right: 12px;
  height: 6px;
  cursor: s-resize;
}

.modal-resize-e {
  top: 12px;
  bottom: 12px;
  right: 0;
  width: 6px;
  cursor: e-resize;
}

.modal-resize-w {
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 6px;
  cursor: w-resize;
}

/* Prevent text selection during resize/drag */
.fullscreen-edit-modal .modal-panel.resizing,
.fullscreen-edit-modal .modal-panel.dragging {
  user-select: none;
}

/* Modal positioning indicators */
.fullscreen-edit-modal .modal-panel[style*="left: 0px"] {
  border-left: 3px solid var(--primary);
}

.fullscreen-edit-modal .modal-panel[style*="top: 0px"] {
  border-top: 3px solid var(--primary);
}

/* Responsive design for smaller screens */
@media (max-width: 1024px) {
  .edit-element-modal-container {
    flex-direction: column;
    gap: 1rem;
  }
  
  .modal-column {
    flex: none;
  }
  
  .modal-overlay .overlay-panel.extra-large {
    width: min(98%, 100vw) !important;
    height: min(96%, 100vh) !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    right: auto !important;
  }
  
  /* Disable resize handles and dragging on smaller screens */
  .modal-resize-handle {
    display: none;
  }
  
  .fullscreen-edit-modal .overlay-header {
    cursor: default !important;
  }
  
  .fullscreen-edit-modal .overlay-header::after {
    display: none;
  }
}

/* Modal Navigation Navbar */
.modal-navbar {
  display: flex;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  background: var(--bg);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

.fullscreen-edit-modal .overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8px;
}

.fullscreen-edit-modal .overlay-header h3 {
  margin-bottom: 0;
  flex-shrink: 0;
}

.fullscreen-edit-modal .overlay-header .modal-navbar {
  margin-top: 0;
  margin-left: 0;
  margin-right: 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
  font-weight: 500;
  border-right: 1px solid var(--border);
}

.modal-tab:last-child {
  border-right: none;
}

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

.modal-tab.active {
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.modal-tab .tab-icon {
  font-size: 1.1rem;
}

.modal-tab .tab-label {
  font-weight: inherit;
}

/* Tab Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Field Configuration Styles */
.field-config-header {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.field-config-header h4 {
  margin: 0;
  color: var(--dark);
  font-size: 1rem;
}

#field-config-panel {
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
}

#field-config-panel .form-group {
  margin-bottom: 1rem;
}

#field-config-panel .form-group:last-child {
  margin-bottom: 0;
}

#field-selector {
  font-weight: 500;
}

#field-selector option:first-child {
  color: var(--secondary);
  font-style: italic;
}

.field-config-preview {
  margin-top: 0.5rem;
  padding: 0.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 0.875rem;
  color: var(--secondary);
}

/* Responsive navbar */
@media (max-width: 768px) {
  .modal-tab .tab-label {
    display: none;
  }
  
  .modal-tab .tab-icon {
    font-size: 1.3rem;
  }
  
  .modal-tab {
    padding: 12px 8px;
  }
}

/* Inline Editing Styles */
.editable-field {
  position: relative;
  display: inline-block;
}

.editable-value {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: background-color 0.2s ease;
}

.editable-value:hover {
  background-color: var(--hover);
  box-shadow: 0 0 0 1px var(--accent);
}

.inline-edit-form {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 6px;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  min-width: 150px;
}

.inline-input {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.inline-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.inline-edit-buttons {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.inline-edit-buttons .btn {
  padding: 4px 8px;
  font-size: 0.8rem;
  min-width: auto;
}

/* Table cell inline editing adjustments */
.data-table td .editable-field {
  display: block;
  width: 100%;
}

.data-table td .inline-edit-form {
  position: fixed;
  width: auto;
  min-width: 200px;
}

/* Grid item inline editing adjustments */
.grid-value .editable-field {
  display: inline;
  width: 100%;
}

.grid-value .inline-edit-form {
  position: absolute;
  width: calc(100% + 16px);
  left: -8px;
  top: -4px;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

.modal-error {
  margin-bottom: 16px;
}

.modal-error .error {
  padding: 12px;
  background: color-mix(in oklab, var(--danger) 10%, transparent);
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  font-size: 14px;
}

/* Form field enhancements */
.field label {
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field input[required] + label::after,
.field select[required] + label::after,
label[for$="_required"]::after {
  content: " *";
  color: var(--danger);
}

/* Attribute rows */
.attrs h4 {
  margin: 0 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
}

/* SPA-specific entity lists */
.entity-list { display: grid; gap: 12px; }
.entity-item {
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
  padding: 16px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
.entity-main { display: grid; gap: 4px; }
.entity-title { font-weight: 600; font-size: 16px; }
.entity-subtitle { color: var(--muted); font-size: 14px; }
.entity-actions { display: flex; gap: 6px; }

/* Page-specific styles */
.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.page-title { margin: 0; font-size: 24px; font-weight: 700; }
.page-actions { display: flex; gap: 10px; }

/* Responsive */
@media (max-width: 960px) {
  .app-header { grid-template-columns: 1fr; gap: 10px; }
  .tabs { flex-wrap: wrap; }
  .form-grid-3, .form-grid-2 { grid-template-columns: 1fr; }
}

/* Forms builder */
.fields-builder .field-row { display:flex; gap:.5rem; align-items:center; margin-bottom:.25rem; }
.fields-builder .field-row input,.fields-builder .field-row select { flex:1; }
.dynamic-fields .dyn-field { margin-bottom:.5rem; display:flex; flex-direction:column; }
.dynamic-fields .dyn-field label { font-weight:600; margin-bottom:4px; }
.dynamic-fields .dyn-field .req { color: var(--danger); margin-left:.2rem; }

/* Subtabs */
.subtabs { display:flex; gap:6px; margin:0 0 16px; flex-wrap:wrap; }
.subtab { border:1px solid var(--border); background:var(--panel); padding:6px 12px; border-radius:8px; cursor:pointer; }
.subtab.active { background:var(--primary); color:#fff; border-color:var(--primary-600); }
.subpage { display:none; }
.subpage.active { display:block; }

/* Assign targets */
.assign-targets { margin-top:12px; }
.assign-targets table { min-width: 100%; }
#edit_form_list .table-wrap { border:1px solid var(--border); }
#edit_form_table { min-width:100%; }
#edit_form_list { max-height:none !important; overflow:visible !important; }

/* View Modal Styles */
.field-value {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  min-height: 38px;
  display: flex;
  align-items: center;
  font-size: 14px;
}

.field-value a {
  color: var(--primary);
  text-decoration: none;
}

.field-value a:hover {
  text-decoration: underline;
}

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

.view-sections {
  margin-top: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.section-group h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.section-content {
  min-height: 100px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.2s;
}

.list-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.list-item-main {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-weight: 500;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-subtitle {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-actions {
  margin-left: 12px;
}

.loading-text, .empty-text, .error-text {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

.error-text {
  color: var(--danger);
}

.coming-soon {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* Job Form Styles */
.equipment-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
}

.equipment-item {
  display: flex;
  align-items: center;
  padding: 4px 0;
  cursor: pointer;
}

.equipment-item input[type="checkbox"] {
  margin-right: 8px;
}

.equipment-item:hover {
  background: var(--bg);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }
}

/* Template modal specific styles */
.dynamic-field {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  position: relative;
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.field-remove-btn {
  color: var(--error);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
}

.field-remove-btn:hover {
  background: var(--error-bg);
}

.add-field-btn {
  margin-top: 16px;
  width: 100%;
  padding: 12px;
  background: var(--primary-bg);
  color: var(--primary);
  border: 1px dashed var(--primary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.add-field-btn:hover {
  background: var(--primary);
  color: white;
}

.dropdown-options-editor {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 4px;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.option-item input {
  flex: 1;
}

.option-remove {
  color: var(--error);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
}

.add-option-btn {
  padding: 6px 12px;
  background: var(--secondary-bg);
  border: 1px solid var(--secondary);
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
}

.target-type-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.type-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
}

.type-checkbox.checked {
  background: var(--primary-bg);
  border-color: var(--primary);
}

/* Tooltip styles for dropdown fields */
.dropdown-badge {
  cursor: help;
  position: relative;
}

.dropdown-badge:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--panel);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 1000;
  margin-bottom: 4px;
}

/* Modal forms table styles */
.modal-panel .forms-table {
  margin-top: 1rem;
}

.modal-panel .forms-table .table {
  min-width: auto;
  font-size: 0.875rem;
}

.modal-panel .forms-table .table th,
.modal-panel .forms-table .table td {
  padding: 8px 10px;
}

.modal-panel .forms-table .table th {
  font-size: 11px;
}

.modal-panel .template-name {
  font-weight: 500;
}

.modal-panel .action-buttons {
  display: flex;
  gap: 0.25rem;
}

.modal-panel .action-buttons .btn.mini {
  padding: 2px 6px;
  font-size: 11px;
}

.modal-panel .forms-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.modal-panel .job-link {
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.modal-panel .job-link:hover {
  text-decoration: underline;
}

.modal-panel .empty-state,
.modal-panel .error-state {
  padding: 2rem;
  text-align: center;
}

.modal-panel .forms-loading {
  padding: 1rem;
  text-align: center;
  color: var(--muted);
}

/* ========== Assign Forms Target Table ========== */
.targets-table-container {
  margin-top: 1rem;
}

.targets-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

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

.targets-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text);
  font-size: 0.875rem;
}

.targets-table tbody tr:hover {
  background: var(--bg);
}

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

.target-type-badge {
  display: inline-block;
  width: 24px;
  height: 24px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  text-align: center;
  line-height: 24px;
  font-size: 0.75rem;
  font-weight: 600;
}

.target-name {
  font-weight: 500;
  color: var(--text);
}

.target-building {
  color: var(--muted);
  font-size: 0.875rem;
}

.target-details {
  color: var(--muted);
  font-size: 0.875rem;
}

.target-checkbox {
  margin: 0;
}

/* Filters section */
.filters-section {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.filters-section h3 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  color: var(--text);
}

/* Target type selection buttons */
.target-type-buttons {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.target-type-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.target-type-btn:hover {
  background: var(--bg);
}

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

/* Form grid for filters */
.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

@media (max-width: 768px) {
  .form-grid-3 {
    grid-template-columns: 1fr;
  }
  
  .targets-table {
    font-size: 0.875rem;
  }
  
  .targets-table th,
  .targets-table td {
    padding: 0.5rem;
  }
}

/* Import Modal Styles */
.import-steps {
  display: flex;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  flex-shrink: 0; /* Prevent steps from shrinking */
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  position: relative;
}

.step:not(:last-child):after {
  content: '';
  position: absolute;
  top: 15px;
  right: -50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 1;
}

.step.completed:not(:last-child):after {
  background: var(--accent);
}

.step-number {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  color: var(--muted);
  font-weight: 600;
  position: relative;
  z-index: 2;
}

.step.active .step-number {
  background: var(--primary);
  color: white;
}

.step.completed .step-number {
  background: var(--accent);
  color: white;
}

.step-label {
  font-size: 0.875rem;
  color: var(--muted);
  text-align: center;
}

.step.active .step-label {
  color: var(--text);
  font-weight: 600;
}

/* .import-content removed - content now flows directly in modal-body */

.import-footer {
  display: flex;
  justify-content: space-between;
  padding: 1rem 0;
  margin-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Upload Step */
.upload-step {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex: 1;
}

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

.upload-header h3 {
  margin: 0;
  color: var(--text);
}

.help-button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.help-button:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.upload-instructions {
  background: var(--bg);
  padding: 1.5rem;
  border-radius: 8px;
}

.upload-instructions h3 {
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.upload-instructions p {
  margin: 0 0 1rem 0;
  color: var(--muted);
}

.file-format-info, .data-requirements {
  margin-top: 1rem;
}

.file-format-info h4, .data-requirements h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: var(--text);
}

.file-format-info ul, .data-requirements ul {
  margin: 0;
  padding-left: 1.5rem;
  color: var(--muted);
}

.file-upload-area {
  display: flex;
  justify-content: center;
}

.file-drop-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--panel);
  width: 100%;
  max-width: 400px;
}

.file-drop-zone:hover,
.file-drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

.upload-content,
.file-selected-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
}

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

.upload-icon.selected {
  color: var(--success);
  background: rgba(34, 197, 94, 0.1);
  border-radius: 50%;
  width: 4rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.upload-text p {
  margin: 0.25rem 0;
  text-align: center;
}

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

.import-help-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 1rem;
  animation: slideDown 0.2s ease-out;
}

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

.help-section {
  margin-bottom: 1.5rem;
}

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

.help-section h4,
.help-section h5 {
  margin: 0 0 0.5rem 0;
  color: var(--text);
  font-size: 0.95rem;
}

.help-section h5 {
  font-size: 0.9rem;
  margin-top: 1rem;
}

.help-section p {
  margin: 0 0 0.5rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.help-section ul {
  margin: 0;
  padding-left: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.help-section li {
  margin-bottom: 0.25rem;
}

/* Legacy styles for backwards compatibility */
.file-selected {
  background: var(--panel);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.file-selected h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: var(--text);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

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

/* Import Modal Optimization */
.import-modal .overlay-panel {
  max-height: 85vh;
}

.import-modal .modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(85vh - 120px); /* Account for header and footer */
}

/* Preview Step */
.preview-step {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.preview-header h3 {
  margin: 0 0 0.25rem 0;
  color: var(--text);
}

.preview-header p {
  margin: 0;
  color: var(--muted);
}

.data-preview-table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.data-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

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

.data-preview-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text);
}

.data-preview-table td {
  color: var(--text);
}

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

.preview-info {
  text-align: center;
  padding: 1rem;
}

.preview-error {
  text-align: center;
  padding: 2rem;
  background: var(--bg);
  border-radius: 8px;
}

.preview-error h3 {
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.preview-error p {
  margin: 0;
  color: var(--muted);
}

/* Configure Step */
.configure-step {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex: 1;
}

.template-selection h3 {
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.template-selection p {
  margin: 0 0 1rem 0;
  color: var(--muted);
}

.template-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.template-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.template-option:hover {
  background: var(--bg);
}

.template-info h4 {
  margin: 0 0 0.25rem 0;
  color: var(--text);
}

.template-description {
  margin: 0 0 0.5rem 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.template-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.selected-template-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.template-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.import-configuration {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.config-section {
  background: var(--panel);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.config-section h4 {
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.config-section p {
  margin: 0 0 1rem 0;
  color: var(--muted);
}

.target-type-selection {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.radio-option input[type="radio"] {
  margin: 0;
}

.target-selection {
  margin-top: 1rem;
}

.target-select {
  width: 100%;
  max-width: 300px;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}

.mapping-table {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mapping-header {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  font-weight: 600;
  color: var(--text);
}

.mapping-row {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  align-items: center;
}

.mapping-row:hover {
  background: var(--bg);
}

.col-form-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

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

.required {
  color: var(--danger);
  font-weight: bold;
}

.column-mapping-select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}

.preview-value {
  font-size: 0.875rem;
  color: var(--muted);
  font-style: italic;
}

/* Import Mode Section */
.import-mode-section {
  background: var(--panel);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.import-mode-section h4 {
  margin: 0 0 1rem 0;
  color: var(--text);
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.radio-option {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  transition: all 0.2s;
}

.radio-option:hover {
  background: var(--bg);
  border-color: var(--primary);
}

.radio-option input[type="radio"] {
  margin: 0;
  align-self: flex-start;
}

.radio-option label {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.option-description {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.4;
}

.radio-option input[type="radio"]:checked {
  accent-color: var(--primary);
}

.radio-option:has(input[type="radio"]:checked) {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

/* Confirm Step */
.confirm-step {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.import-summary {
  display: flex;
  gap: 2rem;
  background: var(--bg);
  padding: 1.5rem;
  border-radius: 8px;
}

.summary-item {
  flex: 1;
  text-align: center;
}

.summary-item strong {
  display: block;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.duplicate-jobs-section {
  background: var(--panel);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.duplicate-jobs-section h4 {
  margin: 0 0 1rem 0;
  color: var(--text);
}

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

.duplicate-job-item {
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.duplicate-job-item .job-name {
  color: var(--text);
  margin-bottom: 0.25rem;
}

.duplicate-job-item .job-details {
  font-size: 0.875rem;
  color: var(--muted);
}

.more-duplicates {
  padding: 0.75rem;
  text-align: center;
  font-style: italic;
  color: var(--muted);
  background: var(--bg);
  border-radius: 6px;
}
.confirm-step {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex: 1;
}

.confirm-step h3 {
  margin: 0 0 1rem 0;
  color: var(--text);
}

.import-summary {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.summary-section {
  padding: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.summary-section h4 {
  margin: 0 0 0.75rem 0;
  color: var(--text);
}

.summary-section ul {
  margin: 0;
  padding-left: 1.5rem;
  color: var(--text);
}

.summary-section li {
  margin: 0.25rem 0;
}

.mapping-summary {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mapping-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 6px;
}

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

.arrow {
  color: var(--muted);
}

.column-name {
  color: var(--muted);
  font-family: monospace;
}

.import-warnings {
  background: #fef3cd;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 1rem;
}

.warning-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.warning-icon {
  font-size: 1.1rem;
}

.warning-text {
  color: #92400e;
}

/* Attribute Mapping Suggestion Styles */
.attribute-mapping-suggestions {
  margin-top: 1rem;
  padding: 1rem;
  background: #f0f9ff;
  border: 1px solid #0ea5e9;
  border-radius: 8px;
}

.attribute-mapping-suggestions h5 {
  margin: 0 0 0.75rem 0;
  color: #0369a1;
  font-size: 0.875rem;
  font-weight: 600;
}

.suggestion-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: #ffffff;
  border-radius: 6px;
  border: 1px solid #bae6fd;
  font-size: 0.875rem;
}

.import-column {
  font-family: monospace;
  font-weight: 600;
  color: #1e40af;
  background: #dbeafe;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

.arrow {
  color: #0369a1;
  font-weight: bold;
}

.existing-attribute {
  font-family: monospace;
  font-weight: 600;
  color: #059669;
  background: #d1fae5;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

.suggestion-note {
  font-size: 0.75rem;
  color: #6b7280;
  font-style: italic;
}

.suggestion-explanation {
  margin: 0;
  font-size: 0.75rem;
  color: #374151;
  line-height: 1.4;
}

.suggestion-explanation small {
  font-size: inherit;
}

/* Dark theme support for attribute mapping suggestions */
@media (prefers-color-scheme: dark) {
  .attribute-mapping-suggestions {
    background: #1e293b;
    border-color: #0ea5e9;
  }
  
  .attribute-mapping-suggestions h5 {
    color: #38bdf8;
  }
  
  .suggestion-item {
    background: #334155;
    border-color: #475569;
  }
  
  .import-column {
    color: #60a5fa;
    background: #1e3a8a;
  }
  
  .existing-attribute {
    color: #34d399;
    background: #064e3b;
  }
  
  .suggestion-explanation {
    color: #d1d5db;
  }
}

body[data-theme="dark"] .attribute-mapping-suggestions {
  background: #1e293b;
  border-color: #0ea5e9;
}

body[data-theme="dark"] .attribute-mapping-suggestions h5 {
  color: #38bdf8;
}

body[data-theme="dark"] .suggestion-item {
  background: #334155;
  border-color: #475569;
}

body[data-theme="dark"] .import-column {
  color: #60a5fa;
  background: #1e3a8a;
}

body[data-theme="dark"] .existing-attribute {
  color: #34d399;
  background: #064e3b;
}

body[data-theme="dark"] .suggestion-explanation {
  color: #d1d5db;
}

/* Form Validation Styles */
.field input.error {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.1);
}

.field input.success {
  border-color: #059669;
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.1);
}

.field-error {
  color: #dc2626;
  font-size: 0.8rem;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.field-error:before {
  content: "⚠";
  font-weight: bold;
}

/* Assignment Method Styles */
.assignment-method-selection {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.assignment-method-selection .radio-option {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
  transition: all 0.2s ease;
}

.assignment-method-selection .radio-option:hover {
  background: var(--bg);
  border-color: var(--primary);
}

.assignment-method-selection .radio-option:has(input:checked) {
  background: rgba(37, 99, 235, 0.1);
  border-color: var(--primary);
}

.single-target-selection,
.column-target-selection {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.column-target-selection label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text);
}

.column-select,
.target-select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.875rem;
}

.column-select:focus,
.target-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.column-preview {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 6px;
  border-left: 4px solid var(--primary);
}

.column-preview code {
  background: var(--panel);
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
}

.column-preview code.valid-id {
  background: rgba(16, 185, 129, 0.1);
  border-color: #10b981;
  color: #059669;
}

.column-preview code.invalid-id {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #dc2626;
}

.error-text {
  color: #dc2626 !important;
}

.success-text {
  color: #059669 !important;
}

.available-targets {
  margin-top: 1rem;
}

.available-targets summary {
  cursor: pointer;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text);
}

.available-targets summary:hover {
  background: var(--panel);
}

.target-list {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: var(--panel);
  border-radius: 4px;
  border: 1px solid var(--border);
  max-height: 200px;
  overflow-y: auto;
}

.target-list > div {
  padding: 0.25rem 0;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border);
}

.target-list > div:last-child {
  border-bottom: none;
}

.target-list code {
  font-family: monospace;
  background: var(--bg);
  padding: 0.125rem 0.25rem;
  border-radius: 2px;
  margin-right: 0.5rem;
}

/* Template Creation Styles */
.template-option.recommended {
  border: 2px solid var(--accent);
  background: rgba(16, 185, 129, 0.05);
}

.recommended-badge {
  background: var(--accent);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

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

.divider:before,
.divider:after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.divider span {
  padding: 0 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.template-creation-step {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.template-creation-header h3 {
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.template-creation-header p {
  margin: 0;
  color: var(--muted);
}

.template-basic-info {
  background: var(--panel);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

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

.form-group:last-child {
  margin-bottom: 0;
}

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

/* Input with unit styling */
.input-with-unit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.input-with-unit input[type="number"] {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--panel);
  color: var(--text);
  font-size: 0.875rem;
}

.input-with-unit input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 0.125rem rgba(59, 130, 246, 0.25);
}

.input-unit {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  min-width: 20px;
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.875rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.help-text {
  margin: 0.25rem 0 0.5rem 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.checkbox-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  margin: 0;
}

.checkbox-option input[type="checkbox"] {
  margin: 0;
}

.fields-configuration {
  background: var(--panel);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.fields-configuration h4 {
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.fields-configuration p {
  margin: 0 0 1rem 0;
  color: var(--muted);
}

.fields-table {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.fields-header {
  display: grid;
  grid-template-columns: 1.5fr 1.5fr 1fr 80px 1fr;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  font-weight: 600;
  color: var(--text);
  font-size: 0.875rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1.5fr 1.5fr 1fr 80px 1fr;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  align-items: center;
}

.field-row:hover {
  background: var(--bg);
}

.col-csv-column strong {
  color: var(--text);
  font-family: monospace;
}

.field-label-input,
.field-type-select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.8rem;
}

.field-label-input:focus,
.field-type-select:focus {
  outline: none;
  border-color: var(--primary);
}

.col-required {
  display: flex;
  justify-content: center;
}

.field-required-checkbox {
  margin: 0;
}

.checkmark {
  font-size: 0.8rem;
}

.sample-value {
  font-size: 0.8rem;
  color: var(--muted);
  font-family: monospace;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Export Modal Compact Styles */
.export-summary {
  background: var(--bg);
  padding: 12px;
  border-radius: 4px;
  margin-bottom: 15px;
  font-size: 14px;
  border: 1px solid var(--border);
}

.export-count {
  font-weight: bold;
  color: var(--text);
}

.count-number {
  color: var(--primary);
  font-size: 16px;
}

.filter-tag {
  display: inline-block;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  margin: 0 3px;
  color: var(--text);
}

.export-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 15px;
}

.options-column {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 4px;
}

.options-column h4 {
  margin: 0 0 10px 0;
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

/* Option Buttons */
.option-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.option-button:hover {
  background: var(--panel);
  border-color: var(--primary);
}

.option-button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.option-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.option-label {
  font-size: 13px;
  font-weight: 500;
}

/* Field Buttons */
.field-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.field-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 12px;
}

.field-button:hover {
  background: var(--panel);
  border-color: var(--primary);
}

.field-button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.field-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.field-label {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tooltip styles */
.option-button:hover::after,
.field-button:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 1000;
  margin-bottom: 5px;
  max-width: 250px;
  white-space: normal;
  text-align: center;
}

.option-button:hover::before,
.field-button:hover::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--text);
  z-index: 1000;
  margin-bottom: 1px;
}

@media (max-width: 768px) {
  .import-steps {
    flex-direction: column;
    gap: 1rem;
  }
  
  .step:not(:last-child):after {
    display: none;
  }
  
  .mapping-header,
  .mapping-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .template-option {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  
  .selected-template-info {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  
  .fields-header,
  .field-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .checkbox-group {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .export-options-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .field-buttons {
    grid-template-columns: 1fr;
  }
  
  .option-buttons {
    gap: 6px;
  }
  
  .field-button,
  .option-button {
    font-size: 11px;
    padding: 6px 8px;
  }
}

/* Import modal styling for theme compatibility */
.modal-container .form-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.modal-container .form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--panel);
  color: var(--text);
  font-size: 0.875rem;
}

.modal-container .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modal-container .radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-container .radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.modal-container .radio-label {
  color: var(--text);
  font-size: 0.875rem;
}

.modal-container .preview-section {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
}

.modal-container .preview-code {
  background: var(--bg);
  color: var(--text);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  border: 1px solid var(--border);
  font-family: 'Courier New', monospace;
  font-size: 0.8125rem;
}

.modal-container .help-text {
  color: var(--muted);
  font-size: 0.8125rem;
  margin-bottom: 0.5rem;
}

.modal-container .config-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-container .config-section:last-child {
  border-bottom: none;
}

/* Template recommendation styling */
.template-recommended {
  border: 2px solid var(--accent) !important;
  background: var(--bg);
}

.match-badge {
  background: var(--accent);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.template-divider {
  margin: 1rem 0;
  border-top: 1px solid var(--border);
}

/* Form Assignment Modal Styles */
.form-assignment-content {
  padding: 0;
}

.assignment-info {
  margin-bottom: 1.5rem;
}

.assignment-info h4 {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

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

.entity-icon {
  font-size: 1.5rem;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.entity-details {
  flex: 1;
}

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

.entity-type {
  font-size: 0.875rem;
  color: var(--muted);
  text-transform: capitalize;
}

.assignment-options h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.assignment-options p {
  margin: 0 0 1rem 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.option-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.full-width {
  width: 100%;
  justify-content: center;
}

.assignment-note {
  margin-top: 1.5rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  border-left: 3px solid var(--primary);
}

.assignment-note p {
  margin: 0;
  font-size: 0.875rem;
}

.assignment-note strong {
  color: var(--text);
}

/* Quick Assign Modal Styles */
.quick-assign-content {
  padding: 0;
}

.assignment-target {
  margin-bottom: 1.5rem;
}

.assignment-target h4 {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.template-selection {
  margin-bottom: 1.5rem;
}

.template-selection h4 {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.template-info {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.template-preview {
  font-size: 0.875rem;
}

.template-preview strong {
  color: var(--text);
  display: block;
  margin-bottom: 0.5rem;
}

.template-description {
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.template-fields {
  color: var(--muted);
  font-size: 0.75rem;
}

.assignment-options {
  margin-bottom: 1rem;
}

.assignment-options .field {
  margin-bottom: 0;
}

.no-templates-message {
  padding: 1rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.no-templates-message p {
  margin: 0 0 0.75rem 0;
  font-size: 0.875rem;
}

.no-templates-message p:last-child {
  margin-bottom: 0;
}

.no-templates-message ol {
  margin: 0.5rem 0 0.75rem 1.25rem;
  font-size: 0.875rem;
}

.no-templates-message li {
  margin-bottom: 0.25rem;
}

.label-preview {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.label-preview small {
  font-size: 0.75rem;
}

#preview-text {
  font-weight: 500;
  color: var(--text);
}

/* Views Page Styles */
.views-page {
  max-width: 1200px;
  margin: 0 auto;
}

.views-list {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.view-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: box-shadow 0.2s ease;
}

.view-item:hover {
  box-shadow: var(--shadow);
}

.view-info h3 {
  margin: 0 0 0.25rem 0;
  color: var(--text);
  font-size: 1.1rem;
}

.view-info p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.view-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.view-display {
  margin-top: 2rem;
}

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

.view-header h2 {
  margin: 0;
  color: var(--text);
}

.view-content {
  display: grid;
  gap: 2rem;
}

.view-element {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

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

.element-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
}

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

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

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

.data-table th {
  background: var(--bg);
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 0.75rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
  background: var(--bg);
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  padding: 1rem;
}

.grid-item {
  padding: 1rem;
  background: var(--bg); /* Default background, can be overridden by card background color setting */
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  word-wrap: break-word;
  word-break: break-word;
}

.grid-field {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.grid-field:last-child {
  margin-bottom: 0;
}

.grid-field label {
  font-weight: 500;
  color: var(--muted);
  margin-right: 0.5rem;
}

.grid-field span {
  color: var(--text);
  text-align: right;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

/* Conditional formatting overrides - higher specificity to override theme colors */
body .grid-item.conditional-text-color .grid-field label,
body .grid-item.conditional-text-color .grid-field span,
body .grid-item.conditional-text-color .grid-field-no-label span,
body[data-theme="light"] .grid-item.conditional-text-color .grid-field label,
body[data-theme="light"] .grid-item.conditional-text-color .grid-field span,
body[data-theme="light"] .grid-item.conditional-text-color .grid-field-no-label span,
body[data-theme="dark"] .grid-item.conditional-text-color .grid-field label,
body[data-theme="dark"] .grid-item.conditional-text-color .grid-field span,
body[data-theme="dark"] .grid-item.conditional-text-color .grid-field-no-label span {
  color: inherit !important;
}

/* Line wrapping disabled - enforce single line with ellipsis */
.grid-item.no-line-wrap .grid-field span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid-item.no-line-wrap .grid-field label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Custom line spacing support - views page specific */
.views-page .grid-item.custom-line-spacing .grid-field,
.fullscreen-view .grid-item.custom-line-spacing .grid-field {
  margin-bottom: var(--custom-line-spacing, 0.5rem);
}

.views-page .grid-item.custom-line-spacing .grid-field:last-child,
.fullscreen-view .grid-item.custom-line-spacing .grid-field:last-child {
  margin-bottom: 0;
}

/* Allow true zero spacing for views page */
.views-page .grid-item.zero-line-spacing .grid-field,
.fullscreen-view .grid-item.zero-line-spacing .grid-field {
  margin-bottom: 0 !important;
}

.filter-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.filter-text {
  color: var(--text);
  font-size: 0.9rem;
}

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

.empty-state p {
  margin: 0;
  font-size: 1rem;
}

/* Filter Modal Styles */
#operator-group,
#value-group,
#preview-container {
  transition: opacity 0.2s ease;
}

#filter-preview {
  margin: 0;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-style: italic;
  color: var(--text);
}

#match-count {
  margin: 0.5rem 0 0 0;
  color: var(--muted);
}

/* Field Selection Styles */
.field-selection {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem;
  background: var(--panel);
}

.field-selection-header {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.field-group {
  margin-bottom: 1rem;
}

.field-group:last-child {
  margin-bottom: 0;
}

.field-group h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.25rem;
}

.field-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.field-checkbox:hover {
  background: var(--bg);
}

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

.field-checkbox span {
  font-weight: 500;
  color: var(--text);
}

.field-checkbox small {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75rem;
}

.form-help {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Enhanced element header styles */
.element-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.element-info {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0 1rem;
}

/* Grid element enhancements */
.grid-field-no-label {
  margin-bottom: 0.5rem;
}

.grid-field-no-label:last-child {
  margin-bottom: 0;
}

/* Line wrapping disabled for no-label fields */
.grid-item.no-line-wrap .grid-field-no-label .grid-value {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Custom line spacing for no-label fields - views page specific */
.views-page .grid-item.custom-line-spacing .grid-field-no-label,
.fullscreen-view .grid-item.custom-line-spacing .grid-field-no-label {
  margin-bottom: var(--custom-line-spacing, 0.5rem);
}

.views-page .grid-item.custom-line-spacing .grid-field-no-label:last-child,
.fullscreen-view .grid-item.custom-line-spacing .grid-field-no-label:last-child {
  margin-bottom: 0;
}

/* Allow true zero spacing for no-label fields on views page */
.views-page .grid-item.zero-line-spacing .grid-field-no-label,
.fullscreen-view .grid-item.zero-line-spacing .grid-field-no-label {
  margin-bottom: 0 !important;
}

.grid-value {
  display: block;
  color: var(--text);
  font-weight: 500;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
}

.grid-value:last-child {
  border-bottom: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .view-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .view-actions {
    align-self: flex-end;
  }
  
  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .element-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .element-actions {
    align-self: flex-end;
  }
  
  .element-info {
    margin: 0;
    align-self: flex-start;
  }
  
  .grid-container {
    grid-template-columns: 1fr;
  }
  
  .filter-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .field-checkboxes {
    grid-template-columns: 1fr;
  }
  
  .field-selection-header {
    flex-direction: column;
  }
}

/* Fullscreen View Styles */
.fullscreen-view {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  cursor: none; /* Hide cursor by default */
}

.fullscreen-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 10001;
  cursor: default; /* Show cursor in header area */
}

/* Auto-hide buttons when not hovering */
.fullscreen-header .fullscreen-controls,
.fullscreen-header .fullscreen-left-controls {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out;
}

/* Show buttons and cursor when hovering over header */
.fullscreen-header:hover .fullscreen-controls,
.fullscreen-header:hover .fullscreen-left-controls {
  opacity: 1;
  pointer-events: auto;
}

.fullscreen-header:hover {
  cursor: default;
}

/* Always show the title */
.fullscreen-title {
  opacity: 1 !important;
  pointer-events: none !important; /* Allow clicks to pass through, but keep it visible */
}

.fullscreen-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 25px;
  max-width: none;
  position: relative;
}

.fullscreen-title {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  flex: none;
  z-index: 1;
  pointer-events: none; /* Allow clicks to pass through to buttons behind */
}

.fullscreen-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fullscreen-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Show cursor when hovering over interactive elements */
.fullscreen-view .resizable-element,
.fullscreen-view .btn,
.fullscreen-view .editable-field,
.fullscreen-view .element-edit-controls {
  cursor: auto !important;
}

/* Show cursor in edit mode */
.fullscreen-view .dashboard-canvas.edit-mode {
  cursor: default !important;
}

.dashboard-canvas {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: auto;
  background: 
    linear-gradient(rgba(0,0,0,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.05) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* Dark mode grid background */
body[data-theme="dark"] .dashboard-canvas {
  background: 
    linear-gradient(rgba(255,255,255,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 20px 20px;
}

.dashboard-canvas.edit-mode {
  background-color: #f8f9fa;
}

/* Dark mode edit mode background */
body[data-theme="dark"] .dashboard-canvas.edit-mode {
  background-color: #1a1f26;
}

/* Resizable Element Styles */
.resizable-element {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  background: white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.resizable-element:hover {
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.resizable-element.edit-mode {
  border: 2px solid #007bff;
  box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.element-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}

.element-edit-controls {
  position: absolute;
  top: -2px;
  right: -2px;
  z-index: 100;
  display: flex;
  gap: 2px;
  background: rgba(255,255,255,0.95);
  padding: 4px;
  border-radius: 4px;
  border: 1px solid #dee2e6;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.element-edit-controls .btn {
  padding: 4px 6px;
  font-size: 12px;
  min-width: auto;
  border-radius: 3px;
}

.element-drag-handle {
  cursor: move;
  padding: 4px 6px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  font-size: 10px;
  color: #6c757d;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.element-drag-handle:hover {
  background: #e9ecef;
  color: #495057;
}

.element-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.element-header-mini {
  padding: 10px 15px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.element-header-mini h4 {
  margin: 0;
  color: #2c3e50;
  font-size: 14px;
}

.element-header-mini small {
  color: #6c757d;
  font-size: 12px;
}

/* Resize Handles - Direct children of .resizable-element */

.resize-handle {
  position: absolute;
  background: transparent;
  pointer-events: all;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 100;
}

.resizable-element.edit-mode .resize-handle {
  opacity: 0;
}

.resizable-element.edit-mode:hover .resize-handle {
  opacity: 0.1;
  background: var(--primary, #007bff);
}

.resize-handle:hover {
  background: var(--primary, #007bff) !important;
  opacity: 0.4 !important;
}

.resize-handle:active {
  background: var(--primary, #007bff) !important;
  opacity: 0.6 !important;
}

/* Corner handles - larger grab areas */
.fullscreen-view .resize-handle.resize-se,
.resize-handle.resize-se {
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  cursor: se-resize !important;
}

.fullscreen-view .resize-handle.resize-ne,
.resize-handle.resize-ne {
  top: 0;
  right: 0;
  width: 12px;
  height: 12px;
  cursor: ne-resize !important;
}

.fullscreen-view .resize-handle.resize-nw,
.resize-handle.resize-nw {
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  cursor: nw-resize !important;
}

.fullscreen-view .resize-handle.resize-sw,
.resize-handle.resize-sw {
  bottom: 0;
  left: 0;
  width: 12px;
  height: 12px;
  cursor: sw-resize !important;
}

/* Edge handles - full side grab areas */
.fullscreen-view .resize-handle.resize-n,
.resize-handle.resize-n {
  top: 0;
  left: 12px;
  right: 12px;
  height: 6px;
  cursor: n-resize !important;
}

.fullscreen-view .resize-handle.resize-s,
.resize-handle.resize-s {
  bottom: 0;
  left: 12px;
  right: 12px;
  height: 6px;
  cursor: s-resize !important;
}

.fullscreen-view .resize-handle.resize-e,
.resize-handle.resize-e {
  top: 12px;
  bottom: 12px;
  right: 0;
  width: 6px;
  cursor: e-resize !important;
}

.fullscreen-view .resize-handle.resize-w,
.resize-handle.resize-w {
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 6px;
  cursor: w-resize !important;
}

/* Prevent text selection during resize operations */
.resizable-element.resizing,
.resizable-element.dragging {
  user-select: none;
}

/* Fullscreen responsive adjustments */
@media (max-width: 768px) {
  .fullscreen-actions {
    padding: 10px 15px;
  }
  
  .fullscreen-title {
    font-size: 18px;
  }
  
  .dashboard-canvas {
    background-size: 15px 15px;
  }
  
  .resizable-element {
    min-width: 200px !important;
    min-height: 150px !important;
  }
  
  .element-edit-controls {
    position: relative;
    top: 0;
    right: 0;
    margin-bottom: 8px;
    justify-content: center;
  }
}

/* Fullscreen element compatibility - ensure regular view elements work in resizable containers */
.resizable-element .element-content.view-element {
  width: 100%;
  height: 100%;
  border: none; /* Remove border since resizable-element provides it */
  border-radius: 0; /* Remove border radius since resizable-element provides it */
  box-shadow: none; /* Remove shadow since resizable-element provides it */
  margin: 0;
  display: flex;
  flex-direction: column;
}

.resizable-element .element-content.view-element .element-header {
  flex-shrink: 0;
  border-radius: 0;
}

.resizable-element .element-content.view-element .table-container,
.resizable-element .element-content.view-element .grid-container {
  flex: 1;
  overflow: auto;
}

.resizable-element .element-content.view-element .table-note,
.resizable-element .element-content.view-element .grid-note {
  flex-shrink: 0;
  padding: 8px 15px;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
  font-size: 12px;
  color: #6c757d;
  text-align: center;
}

/* =========================== 
   AUTHENTICATION STYLES
   =========================== */

/* Auth container in header */
#auth-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* User info display */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

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

.user-dropdown button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 0.5rem 0;
    min-width: 140px;
    max-width: 180px;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-details {
    padding: 0.6rem 0.75rem;
}

.user-email {
    font-size: 0.8rem;
    color: var(--text);
    font-weight: 500;
}

.user-role {
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: capitalize;
    margin-top: 0.25rem;
}

.dropdown-menu hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.5rem 0;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.4rem 0.75rem;
    background: none;
    border: none;
    text-align: left;
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-item:hover {
    background: var(--bg);
}

/* Login modal */
.auth-modal {
    max-width: 400px;
    width: 90%;
}

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

.auth-modal .form-group {
    margin-bottom: 1rem;
}

.auth-modal .form-group:last-child {
    margin-bottom: 0;
}

.auth-modal label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text);
    font-weight: 500;
    font-size: 0.875rem;
}

.auth-modal input[type="email"],
.auth-modal input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel);
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-modal input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.error-message {
    color: var(--danger);
    font-size: 0.875rem;
    padding: 0.5rem 0;
    min-height: 1.5rem;
}

/* Authentication state messages */
.auth-required {
    text-align: center;
    padding: 2rem;
    background: var(--panel);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.auth-required h3 {
    margin: 0 0 1rem 0;
    color: var(--text);
}

.auth-required p {
    margin: 0 0 1.5rem 0;
    color: var(--muted);
}

/* Loading states */
.auth-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 0.5rem;
    color: var(--muted);
}

.auth-loading .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Landing Page Styles */
.landing-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.landing-hero {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.hero-content {
    max-width: 450px;
    width: 100%;
    text-align: center;
}

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

.app-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2d3748;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.login-section {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    backdrop-filter: blur(10px);
}

.login-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 1.5rem 0;
    text-align: center;
}

.login-form {
    width: 100%;
}

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

.login-form .form-group:last-child {
    margin-bottom: 0;
}

.login-form label {
    display: block;
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.login-form input[type="email"],
.login-form input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 1rem;
    color: #2d3748;
    transition: border-color 0.2s ease;
    background: white;
}

.login-form input[type="email"]:focus,
.login-form input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.error-message {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    text-align: center;
    min-height: 1.25rem;
}

.btn.large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    font-weight: 600;
    width: 100%;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-title {
        font-size: 2rem;
    }
    
    .login-section {
        margin: 0 1rem;
        padding: 2rem;
    }
    
    .hero-content {
        padding: 0 1rem;
    }
}

/* ========= Management Page Styles ========= */
.management-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}

.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
}

.management-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  flex-wrap: wrap;
}

.nav-btn {
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

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

.management-content {
  min-height: 400px;
}

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

.section-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

.management-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (max-width: 768px) {
  .management-grid {
    grid-template-columns: 1fr;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .management-nav {
    flex-direction: column;
  }
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

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

.data-list {
  max-height: 500px;
  overflow-y: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  background: var(--bg);
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.data-table tr:hover {
  background: var(--bg);
}

.data-table .actions {
  white-space: nowrap;
}

.data-table .actions .btn {
  margin-right: 0.5rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
}

.badge.admin {
  background: var(--danger);
  color: white;
}

.badge.manager {
  background: var(--primary);
  color: white;
}

.badge.user {
  background: var(--accent);
  color: white;
}

.status.active {
  color: var(--accent);
  font-weight: 600;
}

.status.inactive {
  color: var(--danger);
  font-weight: 600;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.action-buttons .btn {
  justify-content: flex-start;
  text-align: left;
}

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

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

.error {
  text-align: center;
  padding: 2rem;
  color: var(--danger);
  font-weight: 500;
}

.stats-container {
  margin-top: 1rem;
}

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

.stat-item {
  text-align: center;
  padding: 1rem;
  background: var(--bg);
  border-radius: 0.5rem;
  border: 1px solid var(--border);
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.info-container {
  color: var(--muted);
  line-height: 1.6;
}

.info-container p {
  margin-bottom: 1rem;
}

.info-container ul {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.info-container li {
  margin-bottom: 0.5rem;
}

/* Form styles for management modals */
.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.checkbox-label:hover {
  background: var(--bg);
  border-color: var(--primary);
}

.checkbox-label input[type="checkbox"] {
  margin: 0;
}

.checkbox-label input[type="checkbox"]:checked + span {
  color: var(--primary);
  font-weight: 500;
}

/* Alert styles for management */
.alert {
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

.alert h4 {
  margin: 0 0 0.5rem 0;
  font-weight: 600;
}

.alert p {
  margin: 0;
}

.alert ul {
  margin: 0.5rem 0 0 0;
  padding-left: 1.5rem;
}

.alert.alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.alert.alert-warning {
  background: #fffbeb;
  border: 1px solid #fed7aa;
  color: #92400e;
}

.alert.alert-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

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

/* Dark mode alert adjustments */
body[data-theme="dark"] .alert.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

body[data-theme="dark"] .alert.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

body[data-theme="dark"] .alert.alert-danger,
body[data-theme="dark"] .alert.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* Button variants for management */
.btn.small {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
}

.btn.warning {
  background: #f59e0b;
  color: white;
}

.btn.warning:hover {
  background: #d97706;
}

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

.btn.danger:hover {
  background: #dc2626;
}

/* Management page responsive adjustments */
@media (max-width: 640px) {
  .management-page {
    padding: 1rem;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .permissions-grid {
    grid-template-columns: 1fr;
  }
  
  .data-table {
    font-size: 0.8rem;
  }
  
  .data-table th,
  .data-table td {
    padding: 0.5rem;
  }
}
