@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', system-ui, sans-serif;
  
  --bg-dark: #0b0f19;
  --panel-bg: #1e293b;
  --panel-border: #334155;
  --input-bg: #0f172a;
  --input-border: #475569;
  
  --primary-cyan: #0284c7;
  --primary-cyan-hover: #0369a1;
  --accent-purple: #8b5cf6;
  --accent-purple-hover: #7c3aed;
  --accent-indigo: #6366f1;
  --accent-blue: #38bdf8;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  
  --shadow-main: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 20px rgba(56, 189, 248, 0.05);
  --shadow-button: 0 4px 14px rgba(2, 132, 199, 0.35);
  --shadow-purple: 0 4px 14px rgba(139, 92, 246, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-main);
  padding: 24px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1440px;
  margin: 0 auto;
}

/* --- HEADER --- */
header {
  margin-bottom: 24px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 18px;
}

h1 {
  margin: 0 0 8px;
  font-family: var(--font-heading);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 50%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sub {
  margin: 0;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 400;
}

/* --- TOOLBAR --- */
.toolbar {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  box-shadow: var(--shadow-main);
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.toolbar-row {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.value-badge {
  background: rgba(2, 132, 199, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* --- FILTER GROUPS & TAB BUTTONS --- */
.filter-group {
  display: inline-flex;
  gap: 4px;
  background: var(--input-bg);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
}

.tab-btn {
  padding: 8px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--primary-cyan), var(--primary-cyan-hover));
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

/* --- FORM CONTROLS --- */
.styled-select,
.styled-number,
.file-input {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 9px 14px;
  font-family: var(--font-main);
  font-size: 13.5px;
  font-weight: 500;
  outline: none;
  transition: all 0.2s ease;
  height: 40px;
}

.styled-select {
  cursor: pointer;
  min-width: 220px;
}

.styled-select:focus,
.styled-number:focus,
.file-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.file-input {
  max-width: 260px;
  cursor: pointer;
}

.file-input::-webkit-file-upload-button {
  background: #1e293b;
  color: var(--text-primary);
  border: 1px solid var(--input-border);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  margin-right: 10px;
  transition: all 0.2s ease;
}

.file-input::-webkit-file-upload-button:hover {
  background: #334155;
}

.range-group {
  min-width: 240px;
  flex: 1;
}

.styled-range {
  width: 100%;
  accent-color: var(--accent-blue);
  cursor: pointer;
  height: 6px;
  background: var(--input-bg);
  border-radius: 999px;
  margin-top: 6px;
}

.inline-controls {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 14px;
}

.mini-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.styled-number {
  width: 75px;
  text-align: center;
}

.styled-color {
  width: 44px;
  height: 40px;
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  cursor: pointer;
}

.checkbox-card {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  padding: 0 14px;
  height: 40px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
  user-select: none;
  transition: all 0.2s ease;
}

.checkbox-card:hover {
  border-color: var(--input-border);
  background: #152033;
}

.checkbox-card input[type=checkbox] {
  width: 17px;
  height: 17px;
  accent-color: var(--primary-cyan);
  cursor: pointer;
}

/* --- ACTION BUTTONS --- */
.btn-group {
  display: flex;
  gap: 12px;
  margin-left: auto;
  align-items: flex-end;
}

button.pdflib {
  padding: 10px 20px;
  border: 0;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 13.5px;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 42px;
  white-space: nowrap;
}

button.pdfview {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  box-shadow: var(--shadow-button);
}

button.pdfview:hover {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.5);
}

button.pdfdownload {
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  box-shadow: var(--shadow-purple);
}

button.pdfdownload:hover {
  background: linear-gradient(135deg, #a78bfa 0%, #7c3aed 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

button.pdflib:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* --- STAGE & CANVAS --- */
.stage {
  background: var(--panel-bg);
  border-radius: var(--radius-xl);
  padding: 24px;
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-main);
}

.svgbox {
  width: 100%;
  max-width: 1150px;
  margin: 0 auto;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  background: #020617;
  overflow: hidden;
  padding: 20px;
  box-sizing: border-box;
}

svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

.info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.status {
  font-weight: 600;
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  gap: 8px;
}

.status::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #38bdf8;
  border-radius: 50%;
  box-shadow: 0 0 10px #38bdf8;
}

.note {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-top: 18px;
  line-height: 1.6;
  background: var(--input-bg);
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-border);
  border-left-width: 4px;
  border-left-color: var(--accent-blue);
}

/* --- LOADING MODAL --- */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.loading-card {
  background: var(--panel-bg);
  border: 1px solid var(--accent-blue);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-xl);
  padding: 36px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 420px;
  width: 90%;
  animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popIn {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--panel-border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.loading-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.loading-bar-wrap {
  width: 100%;
  height: 8px;
  background: var(--input-bg);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--panel-border);
}

.loading-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  border-radius: 999px;
  width: 0%;
  transition: width 0.3s ease;
}

.loading-step {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}
