:root {
  --bg-main: #0B0F19;
  --bg-card: #111827;
  --bg-card-hover: #172236;
  --bg-card-subtle: #1a2333;
  --border-color: #243046;
  --border-focus: #06b6d4;
  
  --text-main: #F3F4F6;
  --text-muted: #9CA3AF;
  --text-dark: #6B7280;

  --accent-cyan: #06B6D4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);
  --accent-emerald: #10B981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-amber: #F59E0B;
  --accent-rose: #EF4444;
  --accent-purple: #8B5CF6;

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(6, 182, 212, 0.15);
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(6, 182, 212, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.03) 0%, transparent 40%);
}

.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

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

.logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent-cyan), #3b82f6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 20px var(--accent-cyan-glow);
}

.logo-icon i {
  width: 28px;
  height: 28px;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #FFFFFF, #93C5FD);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  font-family: var(--font-sans);
}

.btn i {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-cyan-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(6, 182, 212, 0.4);
}

.btn-emerald {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-emerald-glow);
}

.btn-emerald:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
}

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

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

.btn-outline {
  background: transparent;
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-outline:hover {
  background: rgba(6, 182, 212, 0.1);
}

.btn-danger-sm {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-rose);
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 6px 12px;
  font-size: 0.775rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-danger-sm:hover {
  background: var(--accent-rose);
  color: #fff;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
}

.w-full {
  width: 100%;
}

/* Metric Ribbon */
.metric-ribbon {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.ribbon-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.ribbon-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.ribbon-card.primary {
  border-color: rgba(6, 182, 212, 0.4);
  background: linear-gradient(145deg, rgba(6, 182, 212, 0.08), var(--bg-card));
}

.ribbon-card.highlight {
  border-color: rgba(16, 185, 129, 0.4);
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.08), var(--bg-card));
}

.ribbon-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.ribbon-val {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.ribbon-val small {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-muted);
}

.ribbon-sub {
  font-size: 0.75rem;
  color: var(--text-dark);
  margin-top: 4px;
  display: block;
}

.text-accent {
  color: #34D399 !important;
}

/* Main Grid Layout */
.app-main-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  align-items: start;
}

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

/* Card Panels */
.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

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

.panel-header h3 {
  font-size: 1.125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
}

.panel-header h3 i {
  color: var(--accent-cyan);
  width: 20px;
  height: 20px;
}

/* Tabs */
.tabs-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: var(--bg-card-subtle);
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
}

.tab-btn i {
  width: 16px;
  height: 16px;
}

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

.tab-btn.active {
  background: var(--bg-card);
  color: var(--accent-cyan);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tab-content {
  display: none;
}

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

/* Forms */
.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

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

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-text, .input-select, .input-unit input {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}

.input-text:focus, .input-select:focus, .input-unit input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px var(--accent-cyan-glow);
}

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

.input-unit span {
  position: absolute;
  right: 12px;
  font-size: 0.8rem;
  color: var(--text-dark);
  font-weight: 600;
  pointer-events: none;
  font-family: var(--font-sans);
}

.input-unit span:first-child {
  position: absolute;
  left: 12px;
  right: auto;
}

.input-unit input:first-child:not(:last-child) {
  padding-right: 48px;
}

.input-unit span:first-child + input {
  padding-left: 36px;
}

.input-readonly, .input-unit input[readonly] {
  background: rgba(15, 23, 42, 0.75) !important;
  color: #38bdf8 !important;
  font-weight: 700 !important;
  border-color: rgba(56, 189, 248, 0.25) !important;
  cursor: not-allowed;
  user-select: none;
}

.input-readonly:focus, .input-unit input[readonly]:focus {
  border-color: rgba(56, 189, 248, 0.4) !important;
  box-shadow: none !important;
}

.input-locked {
  opacity: 0.95;
}

.time-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.hint {
  font-size: 0.725rem;
  color: var(--text-dark);
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge.exceeded {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-rose);
  border-color: rgba(239, 68, 68, 0.3);
}

.badge-mini {
  font-size: 0.65rem;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  padding: 2px 6px;
  border-radius: 4px;
}

.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border-color);
  font-size: 0.65rem;
  cursor: help;
}

.highlight-input label {
  color: #93C5FD;
}

.highlight-input .input-unit input {
  border-color: rgba(6, 182, 212, 0.4);
}

/* Alert Box */
.alert-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-top: 14px;
  font-size: 0.825rem;
  line-height: 1.4;
}

.alert-box i {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #FCD34D;
}

.alert-warning i {
  color: var(--accent-amber);
}

.hidden {
  display: none !important;
}

.action-btn-row {
  display: flex;
  gap: 12px;
}

.section-divider {
  height: 1px;
  background: var(--border-color);
  margin: 20px 0 16px 0;
}

h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* 3D Canvas Preview & Toggle */
.view-mode-toggle {
  display: flex;
  background: var(--bg-main);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  gap: 4px;
}

.btn-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
}

.btn-toggle i {
  width: 13px;
  height: 13px;
}

.btn-toggle:hover {
  color: #fff;
}

.btn-toggle.active {
  background: rgba(6, 182, 212, 0.2);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.4);
}

/* 3D Feature Toolbar */
.preview-3d-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.btn-tool {
  flex: 1;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.775rem;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
}

.btn-tool i {
  width: 14px;
  height: 14px;
}

.btn-tool:hover {
  color: #fff;
  border-color: var(--text-dark);
}

.btn-tool.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.4);
}

#btnToggleLeds.active {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border-color: rgba(245, 158, 11, 0.4);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
}

.canvas-3d-wrapper {
  width: 100%;
  height: 320px;
  background: #060911;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

#threeCanvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.canvas-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.overlay-badge {
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.overlay-dims {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 4px 10px;
  border-radius: 6px;
}

.controls-3d-hint {
  font-size: 0.75rem;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 4px;
}

.preview-footer-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-pill {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

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

.stat-pill .val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #fff;
}

/* Cost Breakdown */
.cost-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.cost-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.825rem;
  margin-bottom: 4px;
}

.cost-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.dot-filament { background: var(--accent-cyan); }
.dot-energy { background: var(--accent-amber); }
.dot-depreciation { background: var(--accent-purple); }
.dot-labor { background: #3b82f6; }
.dot-security { background: var(--text-muted); }

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-main);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.fill-filament { background: var(--accent-cyan); }
.fill-energy { background: var(--accent-amber); }
.fill-depreciation { background: var(--accent-purple); }
.fill-labor { background: #3b82f6; }
.fill-security { background: var(--text-muted); }

/* Summary Box */
.summary-final-box {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.summary-line strong {
  font-family: var(--font-mono);
  color: #fff;
}

.summary-line.highlight-total {
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  margin-top: 4px;
  font-size: 1rem;
  color: #fff;
  font-weight: 700;
}

.final-price-tag {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  color: #34D399;
}

.summary-subline {
  text-align: right;
  font-size: 0.8rem;
  color: var(--accent-cyan);
  margin-top: -4px;
}

.summary-subline b {
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

/* Table */
.table-responsive {
  overflow-x: auto;
}

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

.quote-table th {
  background: var(--bg-card-subtle);
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.quote-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-mono);
  color: var(--text-main);
}

.quote-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.btn-remove-row {
  background: none;
  border: none;
  color: var(--text-dark);
  cursor: pointer;
  transition: color 0.2s ease;
}

.btn-remove-row:hover {
  color: var(--accent-rose);
}

/* Utilities */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.text-center { text-align: center; }
.uppercase { text-transform: uppercase; }
.bold { font-weight: 700; }
.text-emerald { color: var(--accent-emerald) !important; }

/* Print Stylesheet */
.print-container {
  display: none;
}

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .app-header, .metric-ribbon, .column-left, .column-right {
    display: none !important;
  }
  .print-container {
    display: block !important;
    padding: 40px;
    font-family: Arial, sans-serif;
  }
  .print-header {
    border-bottom: 2px solid #000;
    padding-bottom: 15px;
    margin-bottom: 20px;
  }
  .print-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
  }
  .print-table th, .print-table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
  }
  .print-table th {
    background-color: #f3f4f6;
  }
}
