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

:root {
  --primary: #4f6ef7;
  --primary-hover: #3b5de7;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f5f5f5;
  --bg-card: #ffffff;
  --bg-input: #f9fafb;
  --text: #1f2937;
  --text-dim: #6b7280;
  --border: #e5e7eb;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Header */
.header {
  background: #fff;
  padding: 16px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 { font-size: 18px; font-weight: 700; }
.header p { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* Container */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px 16px 120px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--border);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

/* Parse Section */
.parse-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.parse-box label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-wrap {
  flex: 1;
  position: relative;
}

.input-wrap input {
  width: 100%;
  padding: 10px 32px 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.input-wrap input:focus { border-color: var(--primary); }

.input-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  background: var(--border);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.input-wrap input:not(:placeholder-shown) ~ .input-clear,
.input-wrap input.has-value ~ .input-clear {
  display: flex;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Notice */
.notice {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #92400e;
}

/* Loading */
.loading { text-align: center; padding: 32px; color: var(--text-dim); }
.loading .spinner {
  display: inline-block; width: 28px; height: 28px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Model Card */
.model-card {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.model-header { display: flex; gap: 12px; padding: 14px; }
.model-cover { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--bg); }
.model-info { flex: 1; min-width: 0; }
.model-info h3 { font-size: 14px; font-weight: 600; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-info .author { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.model-stats { display: flex; gap: 10px; font-size: 11px; color: var(--text-dim); }

/* Instance List */
.instance-list { padding: 0 14px 14px; }

.instance-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
}

.instance-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.instance-title { font-size: 13px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.instance-weight { font-size: 15px; font-weight: 700; color: var(--success); margin-left: 8px; }

.instance-meta { display: flex; gap: 12px; font-size: 11px; color: var(--text-dim); margin-bottom: 8px; }

.instance-bottom { display: flex; justify-content: space-between; align-items: center; }
.instance-price { font-size: 16px; font-weight: 700; color: #dc2626; }
.instance-price small { font-size: 11px; font-weight: 400; color: var(--text-dim); }

.qty-control { display: flex; align-items: center; gap: 4px; }
.qty-btn {
  width: 26px; height: 26px; border: 1px solid var(--border); background: #fff;
  color: var(--text); border-radius: 6px; font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.qty-btn:hover { border-color: var(--primary); color: var(--primary); }
.qty-value { width: 28px; text-align: center; font-size: 14px; font-weight: 600; }

/* Filaments */
.filament-dots { display: flex; gap: 3px; align-items: center; }
.filament-dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.1); }

/* Cart Float */
.cart-float {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 1px solid var(--border);
  padding: 10px 16px; z-index: 99;
  display: flex; justify-content: space-between; align-items: center;
}
.cart-float.hidden { display: none; }
.cart-info { display: flex; align-items: center; gap: 10px; }
.cart-badge { background: var(--primary); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.cart-total { font-size: 17px; font-weight: 700; color: #dc2626; }
.cart-total small { font-size: 11px; color: var(--text-dim); font-weight: 400; }

/* Cart Detail */
.cart-detail { background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 16px; border: 1px solid var(--border); }
.cart-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.cart-item:last-child { border-bottom: none; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 600; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-item-spec { color: var(--text-dim); font-size: 12px; }
.cart-item-price { font-weight: 600; color: #dc2626; white-space: nowrap; margin: 0 10px; }
.cart-item-remove { color: var(--text-dim); cursor: pointer; font-size: 16px; padding: 4px; }
.cart-item-remove:hover { color: var(--danger); }

.cart-summary { display: flex; justify-content: space-between; align-items: center; padding-top: 10px; margin-top: 6px; border-top: 2px solid var(--border); }
.cart-summary .total-label { font-size: 13px; color: var(--text-dim); }
.cart-summary .total-price { font-size: 20px; font-weight: 700; color: #dc2626; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.hidden { display: none; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 0; width: 100%; max-width: 380px; max-height: 70vh; border: 1px solid var(--border); display: flex; flex-direction: column; }
.modal-box .modal-header { padding: 16px 24px 0; flex-shrink: 0; }
.modal-box .modal-scroll { flex: 1; overflow-y: auto; padding: 24px; padding-bottom: 10px; }
.modal-box .modal-footer { padding: 10px 24px 16px; flex-shrink: 0; }
.modal-box h3 { font-size: 16px; margin-bottom: 14px; text-align: center; }
.modal-box input, .modal-box textarea { width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; outline: none; margin-bottom: 10px; }
.modal-box input:focus, .modal-box textarea:focus { border-color: var(--primary); }
.modal-box textarea { resize: vertical; min-height: 50px; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions .btn { flex: 1; }

/* Orders */
.order-card { background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 10px; border: 1px solid var(--border); }
.order-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.order-no { font-weight: 700; font-size: 13px; color: var(--primary); }
.order-status { padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.status-0 { background: #fef3c7; color: #92400e; }
.status-1 { background: #d1fae5; color: #065f46; }
.status-2 { background: #dbeafe; color: #1e40af; }
.status-3 { background: #d1fae5; color: #047857; }
.status-4 { background: #fee2e2; color: #991b1b; }
.order-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.order-items-list { border-top: 1px solid var(--border); padding-top: 8px; }
.order-item-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; }
.order-item-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-item-row .detail { color: var(--text-dim); margin: 0 6px; }
.order-item-row .price { color: #dc2626; font-weight: 600; white-space: nowrap; }

/* Models List */
.model-list-item {
  background: #fff;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  display: flex;
  gap: 12px;
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.model-list-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.model-list-cover { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; flex-shrink: 0; background: var(--bg); }
.model-list-info { flex: 1; min-width: 0; }
.model-list-info h4 { font-size: 13px; font-weight: 600; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-list-info .meta { font-size: 11px; color: var(--text-dim); }
.model-list-info .specs { font-size: 11px; color: var(--primary); margin-top: 2px; }

/* Empty */
.empty { text-align: center; padding: 32px 16px; color: var(--text-dim); }
.empty .icon { font-size: 40px; margin-bottom: 8px; }
.empty p { font-size: 13px; }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
.pagination button { width: 30px; height: 30px; border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 6px; cursor: pointer; font-size: 12px; }
.pagination button.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  padding: 12px 0 8px;
}

.search-tips {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.search-tips p { margin-bottom: 4px; font-weight: 600; color: var(--text); }
.search-tips ul { padding-left: 16px; }
.search-tips li { margin-bottom: 2px; }
.search-tips b { color: var(--primary); }

/* Color Select Trigger */
.color-select-trigger { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.color-trigger-btn { font-size: 12px !important; }
.color-selected-label { font-size: 12px; font-weight: 600; color: var(--primary); }

/* Color Modal Grid */
.color-modal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
.color-modal-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px; border: 2px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: all 0.15s; text-align: center; position: relative;
}
.color-modal-item:hover { border-color: var(--primary); background: #f0f4ff; }
.color-modal-item.selected { border-color: var(--primary); background: #e8eeff; box-shadow: 0 0 0 1px var(--primary); }
.color-modal-item img { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; }
.color-modal-item .color-no-img { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: var(--bg-input); border-radius: 6px; font-size: 20px; }
.color-modal-name { font-size: 11px; color: var(--text); font-weight: 500; }
.color-zoom {
  position: absolute; top: 4px; right: 4px;
  width: 18px; height: 18px; font-size: 10px;
  background: rgba(0,0,0,0.45); color: #fff;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.color-modal-item:hover .color-zoom { opacity: 1; }

/* Color Preview Lightbox */
.color-preview-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7); z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.color-preview-overlay.hidden { display: none; }
.color-preview-box {
  background: #fff; border-radius: 12px; padding: 16px;
  max-width: 90vw; max-height: 90vh; text-align: center;
}
.color-preview-box img { max-width: 100%; max-height: 70vh; border-radius: 8px; object-fit: contain; }
.color-preview-name { font-size: 15px; font-weight: 600; margin-top: 10px; }

@media (max-width: 480px) {
  .instance-bottom { flex-wrap: wrap; gap: 6px; }
}
