:root {
  /* Industrial CAD Color Palette (Inspired by modern CAD tools & red accents) */
  --cad-red-primary: #d32f2f;
  --cad-red-dark: #9a0007;
  --cad-red-hover: #b71c1c;
  --cad-red-light: rgba(211, 47, 47, 0.12);
  --cad-red-border: rgba(211, 47, 47, 0.4);
  
  /* CAD Slate & Metallic Workspace Grays */
  --bg-dark: #0f1217;
  --bg-header: #151921;
  --bg-panel: #181d27;
  --bg-panel-hover: #212735;
  --bg-input: #1e2430;
  
  /* Accent & Status Colors */
  --accent-cyan: #38bdf8;
  --accent-blue: #29b6f6;
  --accent-emerald: #34d399;
  --accent-purple: #c084fc;
  --accent-amber: #fbbf24;
  
  /* Text & Typography */
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  /* Borders & Spacing */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: #2a3243;
  --border-active: var(--cad-red-primary);
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.4;
}

/* ==========================================================================
   Top App Header
   ========================================================================== */
.app-header {
  height: 48px;
  background: var(--bg-header);
  border-bottom: 2px solid var(--cad-red-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  position: relative;
  z-index: 10;
}

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

.cad-icon {
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.brand-title {
  font-weight: 700;
  font-size: 14px;
  color: #ffffff;
  letter-spacing: 0.3px;
  font-family: var(--font-mono);
}

.brand-subtitle {
  color: var(--cad-red-primary);
  font-weight: 600;
  font-size: 13px;
  margin-left: 4px;
  font-family: 'Inter', sans-serif;
}

.brand-badge {
  font-size: 10px;
  background: rgba(211, 47, 47, 0.15);
  color: #ff6b6b;
  border: 1px solid rgba(211, 47, 47, 0.4);
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
}

.cad-status-tag {
  background: var(--bg-panel);
  color: var(--text-muted);
  border: 1px solid var(--border-medium);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ==========================================================================
   Main Workspace Layout (Full Height Fixed Split)
   ========================================================================== */
.workspace {
  display: flex;
  height: calc(100vh - 48px);
  width: 100vw;
  overflow: hidden;
}

/* ==========================================================================
   Left Sidebar Pane
   ========================================================================== */
.sidebar {
  width: 295px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-medium);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
}

.sidebar-scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Custom Thin Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.25);
}
::-webkit-scrollbar-thumb {
  background: #343e52;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--cad-red-primary);
}

/* Compact Drop Zone in Sidebar */
.compact-drop-zone {
  border: 2px dashed var(--border-medium);
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.compact-drop-zone:hover, .compact-drop-zone.dragover {
  border-color: var(--cad-red-primary);
  background: var(--cad-red-light);
  box-shadow: 0 0 12px rgba(211, 47, 47, 0.2);
}

.drop-label {
  font-weight: 700;
  font-size: 12px;
  color: var(--text-main);
}

.drop-sublabel {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Sidebar Section Box */
.sidebar-box {
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 10px;
}

.sidebar-box-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 4px;
}

/* Dense Key-Value Metadata Table */
.kv-table {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
}

.kv-table td {
  padding: 4px 0;
  vertical-align: top;
}

.kv-key {
  color: var(--text-muted);
  width: 42%;
}

.kv-val {
  font-weight: 600;
  color: var(--text-main);
  word-break: break-all;
  font-family: var(--font-mono);
}

/* ==========================================================================
   Action Button System
   ========================================================================== */
.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  white-space: nowrap;
  font-family: inherit;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(180deg, #d32f2f 0%, #9a0007 100%);
  color: #ffffff;
  border-color: #ef5350;
  box-shadow: 0 2px 6px rgba(211, 47, 47, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #e53935 0%, #b71c1c 100%);
  box-shadow: 0 4px 10px rgba(211, 47, 47, 0.4);
}

.btn-success {
  background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
  color: #ffffff;
  border-color: #4ade80;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3);
}

.btn-success:hover {
  background: linear-gradient(180deg, #22c55e 0%, #166534 100%);
  box-shadow: 0 4px 10px rgba(22, 163, 74, 0.4);
}

.btn-secondary {
  background: var(--bg-header);
  color: var(--text-main);
  border-color: var(--border-medium);
}

.btn-secondary:hover {
  background: var(--bg-panel-hover);
  border-color: #434e63;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
}

.btn-full {
  width: 100%;
}

/* ==========================================================================
   Sidebar Navigation Menu
   ========================================================================== */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  width: 100%;
}

.nav-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
  border-left-color: rgba(211, 47, 47, 0.4);
}

.nav-btn.active {
  color: #ffffff;
  background: var(--cad-red-light);
  border-color: var(--cad-red-border);
  border-left: 3px solid var(--cad-red-primary);
  font-weight: 600;
}

.nav-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 9999px;
  font-family: var(--font-mono);
}

.nav-btn.active .nav-badge {
  background: rgba(211, 47, 47, 0.3);
  color: #ffffff;
}

/* ==========================================================================
   Right Main Details Panel & Viewport Area
   ========================================================================== */
.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
}

.main-top-bar {
  height: 48px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

.main-top-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.main-scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  scroll-behavior: smooth;
}

/* Inspector Sections */
.inspector-section {
  margin-bottom: 28px;
  scroll-margin-top: 14px;
}

.inspector-section:last-child {
  margin-bottom: 60px;
}

.section-heading {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border-medium);
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.section-heading::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 32px;
  height: 2px;
  background: var(--cad-red-primary);
}

/* Cards & Tables */
.panel-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.dense-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.dense-card h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--cad-red-primary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 4px;
}

.dense-table-wrapper {
  background: var(--bg-panel);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

table.dense-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

table.dense-table th, table.dense-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-medium);
}

table.dense-table th {
  background: var(--bg-header);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

table.dense-table tr:hover td {
  background: var(--bg-input);
}

code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-cyan);
}

/* Feature Tree Items */
.tree-row {
  font-size: 12px;
  padding: 5px 10px;
  border-left: 3px solid var(--cad-red-primary);
  background: var(--bg-input);
  margin-bottom: 4px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s ease;
}

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

.type-tag {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: rgba(211, 47, 47, 0.15);
  color: #ff6b6b;
  border: 1px solid rgba(211, 47, 47, 0.3);
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
}

/* ==========================================================================
   CAD Viewport Preview Area
   ========================================================================== */
#preview-area {
  background: radial-gradient(circle, #222b3a 0%, #0d1117 100%);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 20px;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}

#preview-area::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
}

#preview-area img {
  max-width: 100%;
  max-height: 480px;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  z-index: 1;
}

/* Utilities */
.hidden {
  display: none !important;
}

.empty-state {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-muted);
  font-size: 12px;
  background: var(--bg-panel);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-md);
}
