:root {
  --bg-dark: #0b0f19;
  --bg-card: #111827;
  --bg-card-hover: #1f2937;
  --border-color: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.25);
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--cyan), var(--primary));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: bold;
  box-shadow: 0 0 15px var(--cyan-glow);
}

.logo-title {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(90deg, #fff, var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge-server {
  background: #1e293b;
  color: var(--cyan);
  border: 1px solid #334155;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* Main Container */
main {
  flex: 1;
  padding: 1.5rem 2rem;
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 1.5rem;
  max-width: 1700px;
  margin: 0 auto;
  width: 100%;
}

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

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

/* Upload Area */
.dropzone {
  border: 2px dashed #334155;
  border-radius: 10px;
  padding: 1.75rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(15, 23, 42, 0.6);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--cyan);
  background: rgba(6, 182, 212, 0.08);
}

.dropzone-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--cyan);
}

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

.dropzone-text strong {
  color: var(--text-main);
}

/* 3D Viewport */
#viewport-3d {
  width: 100%;
  height: 240px;
  background: #070a13;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  border: 1px solid #1e293b;
  margin-top: 0.75rem;
}

.viewport-overlay {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--cyan);
  pointer-events: none;
}

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

label {
  display: block;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

select, input[type="number"], input[type="text"] {
  width: 100%;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: #fff;
  font-size: 0.85rem;
}

select:focus, input:focus {
  outline: none;
  border-color: var(--cyan);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Button */
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--cyan), var(--primary));
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.85rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px var(--cyan-glow);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--primary));
}

.kpi-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.kpi-val {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
}

.kpi-val.highlight {
  color: var(--cyan);
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Progress Section */
.progress-bar-container {
  background: #1e293b;
  border-radius: 9999px;
  height: 10px;
  overflow: hidden;
  margin: 0.75rem 0;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--primary));
  width: 0%;
  transition: width 0.4s ease;
}

.terminal-box {
  background: #060911;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 0.75rem;
  font-family: monospace;
  font-size: 0.8rem;
  color: #38bdf8;
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* Image Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
}

.tab-content {
  display: none;
}

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

.result-img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.2s;
}

.result-img:hover {
  transform: scale(1.01);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: #0f172a;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #1e293b;
}

tr:hover td {
  background: var(--bg-card-hover);
  cursor: pointer;
}

.status-badge {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.completed { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.status-badge.running { background: rgba(6, 182, 212, 0.15); color: var(--cyan); }
.status-badge.queued { background: rgba(245, 158, 11, 0.15); color: var(--yellow); }
.status-badge.failed { background: rgba(239, 68, 68, 0.15); color: var(--red); }

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 100;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
  justify-content: center;
  align-items: center;
}

.modal.active { display: flex; }

.modal-content {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 0 25px rgba(0,0,0,0.8);
}
