:root {
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Light Theme */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #e2e8f0;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-text: #ffffff;
  --accent: #38bdf8;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --success: #10b981;
  --warning: #f59e0b;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  --trans-fast: 120ms ease;
  --trans-normal: 180ms ease;
}

[data-theme="dark"] {
  --bg-app: #090d16;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-subtle: #1e293b;
  --bg-hover: #334155;
  --border-subtle: #1e293b;
  --border-strong: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-text: #ffffff;
  --accent: #0284c7;
  --danger: #f87171;
  --danger-bg: #450a0a;
  --danger-border: #7f1d1d;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-app: #090d16;
    --bg-surface: #0f172a;
    --bg-surface-elevated: #1e293b;
    --bg-subtle: #1e293b;
    --bg-hover: #334155;
    --border-subtle: #1e293b;
    --border-strong: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-text: #ffffff;
    --accent: #0284c7;
    --danger: #f87171;
    --danger-bg: #450a0a;
    --danger-border: #7f1d1d;
  }
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

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

.brand-icon {
  width: 2rem;
  height: 2rem;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
/* Main Layout */
.app-main {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 1.5rem;
  align-items: start;
}

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

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.section-details {
  border-bottom: 1px solid var(--border-subtle);
}
.section-details:last-child {
  border-bottom: none;
}

.section-summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  transition: background-color var(--trans-fast);
}

.section-summary:hover {
  background-color: var(--bg-subtle);
}

.section-content {
  padding: 1.25rem;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-text, .select, .textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--trans-fast), box-shadow var(--trans-fast);
  outline: none;
}

.input-text:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

.textarea {
  min-height: 4.5rem;
  resize: vertical;
}

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

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

  justify-content: center;
}

.brand h1 {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand .tagline {
  font-size: 0.8125rem;
  color: var(--text-muted);
}
/* Segmented Control / Type Tabs */
.segmented-control {
  display: flex;
  background: var(--bg-subtle);
  padding: 0.25rem;
  border-radius: var(--radius-lg);
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented-control::-webkit-scrollbar { display: none; }

.segmented-btn {
  flex: 1;
  white-space: nowrap;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--trans-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
}
.segmented-btn:hover { color: var(--text-main); }
.segmented-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* Radio Cards (dot/eye styles) */
.radio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 0.5rem;
}

.radio-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.625rem 0.25rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  cursor: pointer;
  transition: all var(--trans-fast);
  text-align: center;
}
.radio-card:hover {
  border-color: var(--text-muted);
  background: var(--bg-subtle);
}
.radio-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.radio-card:has(input:checked) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.radio-card-icon {
  width: 1.75rem;
  height: 1.75rem;
  color: var(--text-main);
}
.radio-card:has(input:checked) .radio-card-icon {
  color: var(--primary);
}
.radio-card-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
}
.radio-card:has(input:checked) .radio-card-label {
  color: var(--primary);
  font-weight: 600;
}

/* Color Pickers */
.color-field-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.color-input-wrapper {
  position: relative;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
}

.color-picker {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  cursor: pointer;
  border: none;
  background: none;
}

.color-hex-input {
  font-family: var(--font-mono);
  max-width: 6.5rem;
}

.swatches-row {
  display: flex;
  gap: 0.375rem;
  margin-top: 0.25rem;
}

.swatch {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: transform var(--trans-fast);
  padding: 0;
}
.swatch:hover {
  transform: scale(1.15);
}

/* Switches, Buttons, Preview, Toasts */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
}

.switch {
  position: relative;
  display: inline-block;
  width: 2.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-hover);
  transition: var(--trans-fast);
  border-radius: 1.25rem;
  border: 1px solid var(--border-strong);
}
.slider::before {
  position: absolute;
  content: "";
  height: 0.875rem;
  width: 0.875rem;
  left: 0.125rem;
  bottom: 0.125rem;
  background-color: #fff;
  transition: var(--trans-fast);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .slider {
  background-color: var(--primary);
  border-color: var(--primary);
}
.switch input:checked + .slider::before {
  transform: translateX(1rem);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--trans-fast);
  text-decoration: none;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: var(--primary-text); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-surface); border-color: var(--border-strong); color: var(--text-main); }
.btn-secondary:hover { background: var(--bg-subtle); }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-icon { padding: 0.5rem; border-radius: var(--radius-md); color: var(--text-muted); background: transparent; border: 1px solid var(--border-subtle); }
.btn-icon:hover { color: var(--text-main); background: var(--bg-subtle); }

/* Preview Sticky Card */
.preview-container {
  position: sticky;
  top: 5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-box {
  width: 100%;
  aspect-ratio: 1;
  max-width: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  position: relative;
}

.preview-box.is-transparent {
  background-image: 
    linear-gradient(45deg, #cbd5e1 25%, transparent 25%), 
    linear-gradient(-45deg, #cbd5e1 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #cbd5e1 75%), 
    linear-gradient(-45deg, transparent 75%, #cbd5e1 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.preview-box svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-error {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  text-align: center;
  width: 100%;
  display: none;
}
.preview-error.visible { display: block; }

.capacity-wrapper {
  width: 100%;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.capacity-bar {
  width: 100%;
  height: 0.375rem;
  background: var(--bg-hover);
  border-radius: 999px;
  overflow: hidden;
}
.capacity-fill {
  height: 100%;
  width: 0%;
  background: var(--success);
  transition: width var(--trans-normal), background-color var(--trans-normal);
}
.capacity-fill.warn { background: var(--warning); }
.capacity-fill.error { background: var(--danger); }
.capacity-text { font-size: 0.75rem; color: var(--text-muted); text-align: center; }

.preview-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  margin-top: 1rem;
}
.preview-btn-row { display: flex; gap: 0.5rem; width: 100%; }
.preview-btn-row .btn { flex: 1; }

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 0.625rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  pointer-events: auto;
}

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--bg-subtle);
  transition: all var(--trans-fast);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-dim);
}

/* Print Only QR */
@media print {
  body * { visibility: hidden; }
  .preview-box, .preview-box * { visibility: visible; }
  .preview-box { position: absolute; left: 0; top: 0; width: 100%; max-width: none; }
}

