/* ==============================
   佐敦涂料录入系统 — 馨涂3.0
   Jotun brand: gold #8b6914, warm cream
   ============================== */

/* ── CSS Variables ── */
:root {
  --accent: #8b6914;
  --accent2: #2e7d32;
  --accent-light: #f5ead6;
  --bg-primary: #faf8f5;
  --bg-secondary: #f0ebe3;
  --bg-card: #ffffff;
  --bg-hover: #faf6ee;
  --bg-input: #fdfcfa;
  --border: #e8dcc8;
  --card-bg: #ffffff;
  --text-primary: #1a1612;
  --text-secondary: #6b6054;
  --text-muted: #a89d8e;
  --success: #2e7d32;
  --warning: #e65100;
  --danger: #c62828;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.header {
  background: linear-gradient(135deg, #f5ead6 0%, #fdf6ec 60%, #fff 100%);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(139,105,20,0.08);
}
.header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}

/* ── User Area ── */
#userArea {
  font-size: 13px;
  color: var(--text-secondary);
}
#userArea img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--accent-light);
}
#userArea a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  transition: color 0.2s;
}
#userArea a:hover { color: var(--danger); }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 0;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.tab:hover {
  color: var(--accent);
  background: rgba(139,105,20,0.04);
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ── Main Content ── */
.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

/* ── Search ── */
.search-section {
  position: relative;
  margin-bottom: 16px;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  z-index: 1;
}
.search-input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,105,20,0.1);
}
.search-input::placeholder { color: var(--text-muted); }

/* ── Search Dropdown ── */
.search-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 50;
  margin-top: 4px;
}
.dropdown-item {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--bg-secondary);
  transition: background 0.15s;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item .highlight {
  background: rgba(139,105,20,0.15);
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 600;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.7;
}
.empty-state .msg {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

/* ── Section Title ── */
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.count {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── History Section ── */
.history-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

/* ── Timeline ── */
.timeline {
  margin-top: 12px;
  max-height: 400px;
  overflow-y: auto;
}
.timeline-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--bg-secondary);
  animation: fadeIn 0.3s ease;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.timeline-content {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
}
.timeline-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.timeline-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-light);
  color: var(--accent);
  margin-right: 4px;
}
.timeline-tag.result {
  background: #e8f5e9;
  color: var(--success);
}

/* ── Form Section ── */
.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.form-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-group {
  display: flex;
  flex-direction: column;
}
.form-group.full-width {
  grid-column: 1 / -1;
}
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.required::after {
  content: ' *';
  color: var(--danger);
}
.form-control {
  padding: 10px 12px;
  font-size: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  font-family: var(--font);
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,105,20,0.1);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control {
  min-height: 80px;
  resize: vertical;
}
select.form-control {
  appearance: none;
  background-image: url(data:image/svg+xml,%3Csvg width=10 height=6 viewBox=0 0 10 6 xmlns=http://www.w3.org/2000/svg%3E%3Cpath d=M1 1l4 4 4-4 stroke=%23a89d8e fill=none stroke-width=1.5 stroke-linecap=round/%3E%3C/svg%3E);
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ── Submit Row ── */
.submit-row {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}
.btn-primary {
  background: linear-gradient(135deg, #a07b1a 0%, #8b6914 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(139,105,20,0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #b8911f 0%, #a07b1a 100%);
  box-shadow: 0 4px 12px rgba(139,105,20,0.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Image Upload (compact) ── */
.image-upload-area {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.image-upload-area:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}
.upload-hint {
  color: var(--text-muted);
  font-size: 12px;
}
.image-preview-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.img-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  position: relative;
  overflow: hidden;
}
.img-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.img-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.img-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.3);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
}
.img-overlay.error-overlay {
  background: rgba(198,40,40,0.6);
}
.btn-add-image {
  width: 48px;
  height: 48px;
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
  flex-shrink: 0;
}
.btn-add-image:hover { border-color: var(--accent); }

/* ── Toast ── */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}
.toast.success {
  background: var(--success);
  color: #fff;
}
.toast.error {
  background: var(--danger);
  color: #fff;
}
.toast.warning {
  background: var(--warning);
  color: #fff;
}

/* ── Loading Spinner ── */
.loading-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Warehouse / Scoring specific ── */
.ob-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
}
.ob-stock-info {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.ob-inv-id { display: none; }

/* Material dropdowns */
.rm-product-dd, .wr-mat-dd, .cm-dropdown {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  z-index: 60;
  width: 100%;
}
.cm-price-info {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.arr { color: var(--text-muted); font-size: 12px; }

/* ── Mobile ── */
@media (max-width: 640px) {
  .header { padding: 12px 14px 0; }
  .header h1 { font-size: 17px; }
  .tab { padding: 8px 12px; font-size: 12px; }
  .main { padding: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .search-input { font-size: 14px; }
  .submit-row { flex-direction: column; }
  .submit-row .btn { width: 100%; }
}

@media (max-width: 375px) {
  .tab { padding: 8px 8px; font-size: 11px; }
}

/* ── Recent Records ── */
.recent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.recent-item:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateX(2px);
}
.recent-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
.recent-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.recent-date {
  font-size: 12px;
  color: var(--text-muted);
}
.recent-stage {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-light);
  color: var(--accent);
}

/* ── Dropdown visible state ── */
.search-dropdown.visible {
  display: block !important;
}

/* ── 审批瀑布流响应式 ── */
@media (min-width: 768px) {
  .mysub-grid { grid-template-columns: repeat(4, 1fr) !important; }
}
