:root {
  --green: #2d6a4f;
  --green-light: #52b788;
  --green-pale: #d8f3dc;
  --accent: #40916c;
  --bg: #f8fdf9;
  --surface: #ffffff;
  --surface2: #f1f8f4;
  --border: #d0e8d8;
  --text: #1b2e23;
  --text-muted: #5a7a66;
  --danger: #e53935;
  --warning: #f9a825;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(45,106,79,0.10);
  --shadow-lg: 0 8px 32px rgba(45,106,79,0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Navbar ── */
.navbar {
  background: var(--green);
  color: white;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.nav-brand { display: flex; align-items: center; gap: 0.5rem; margin-right: 1rem; }
.nav-logo { font-size: 1.4rem; }
.nav-title { font-weight: 700; font-size: 1rem; white-space: nowrap; }
.nav-links { display: flex; gap: 0.25rem; flex: 1; flex-wrap: wrap; }

/* ── Hamburger ── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  margin-left: auto;
  z-index: 101;
}
.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.nav-btn {
  background: transparent;
  color: rgba(255,255,255,0.8);
  border: none;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  transition: all 0.2s;
}
.nav-btn:hover, .nav-btn.active { background: rgba(255,255,255,0.15); color: white; }
.nav-status { display: flex; gap: 0.5rem; align-items: center; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #888; transition: background 0.3s; }
.status-dot.online { background: #4caf50; }
.status-dot.offline { background: #e53935; }

/* ── Pages ── */
main { padding: 1.5rem; max-width: 1200px; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Hero ── */
.hero { text-align: center; padding: 3rem 1rem 2rem; }
.hero h1 { font-size: 2rem; font-weight: 700; color: var(--green); margin-bottom: 0.75rem; }
.hero p { color: var(--text-muted); font-size: 1.05rem; margin-bottom: 2rem; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1.25rem; border-radius: 8px; border: none;
  font-family: inherit; font-size: 0.9rem; font-weight: 500;
  cursor: pointer; transition: all 0.2s; text-decoration: none;
}
.btn-primary { background: var(--green); color: white; }
.btn-primary:hover { background: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary { background: var(--surface2); color: var(--green); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--green-pale); }
.btn-accent { background: var(--green-light); color: white; }
.btn-accent:hover { background: var(--accent); }
.btn-lg { padding: 0.8rem 1.75rem; font-size: 1rem; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }
.w-full { width: 100%; justify-content: center; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-3px); }
.stat-card.green { background: var(--green-pale); border-color: var(--green-light); }
.stat-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--green); }
.stat-label { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── Info Cards ── */
.info-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-top: 1rem; }
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.info-card h3 { font-size: 0.95rem; color: var(--green); margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.4rem; }
.info-card p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; line-height: 1.5; }

/* ── Page Header ── */
.page-header { margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.5rem; color: var(--green); display: flex; align-items: center; gap: 0.5rem; }
.page-header p { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; }

/* ── Forms ── */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group label { font-size: 0.82rem; font-weight: 500; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
  width: 100%;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--green-light); box-shadow: 0 0 0 3px rgba(82,183,136,0.15);
}

/* ── File Drop ── */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
}
.file-drop:hover { border-color: var(--green-light); background: var(--green-pale); }
.image-preview-grid { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.image-preview-grid img { width: 80px; height: 80px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* ── Result Panel ── */
.result-panel { margin-top: 1.5rem; }
.result-success { background: var(--green-pale); border: 1px solid var(--green-light); border-radius: var(--radius); padding: 1.5rem; }
.result-success h3 { color: var(--green); margin-bottom: 1rem; }
.result-grid { display: grid; grid-template-columns: 1fr auto; gap: 2rem; align-items: start; }
.qr-container { text-align: center; }
.qr-code { width: 160px; height: 160px; border: 3px solid var(--green); border-radius: 8px; }
.qr-code-sm { width: 80px; height: 80px; border: 2px solid var(--border); border-radius: 6px; }
.qr-label { font-size: 0.75rem; color: var(--text-muted); margin: 0.5rem 0; }

/* ── Badges ── */
.uid-badge {
  background: var(--green);
  color: white;
  font-family: monospace;
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}
.type-badge {
  margin-left: 0.5rem;
  background: var(--green-pale);
  color: var(--green);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ── Scan / DPP ── */
.scan-container { max-width: 700px; }
.input-group-custom { display: flex; gap: 0.5rem; }
.img-search-divider { display: flex; align-items: center; gap: 0.75rem; margin: 1.2rem 0 0.9rem; color: var(--text-muted); font-size: 0.85rem; }
.img-search-divider::before, .img-search-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.img-search-area { border: 2px dashed var(--border); border-radius: 12px; padding: 1.5rem; text-align: center; cursor: pointer; transition: border-color 0.2s, background 0.2s; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.img-search-area:hover, .img-search-area.drag-over { border-color: var(--green); background: var(--green-pale); }
.img-search-area p { margin: 0; font-size: 0.9rem; }
.img-search-result { margin-top: 1rem; background: var(--surface2); border-radius: 12px; padding: 1rem; }
.img-id-header { font-weight: 600; margin-bottom: 0.6rem; color: var(--green); font-size: 0.9rem; }
.img-id-grid { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.75rem; font-size: 0.87rem; align-items: baseline; margin-bottom: 0.6rem; }
.img-id-grid span { color: var(--text-muted); }
.img-matches-title { font-size: 0.82rem; color: var(--text-muted); margin: 0.75rem 0 0.4rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.img-match-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.6rem; border-radius: 8px; cursor: pointer; font-size: 0.86rem; border: 1px solid var(--border); margin-bottom: 0.35rem; background: var(--surface); transition: background 0.15s; flex-wrap: wrap; }
.img-match-item:hover { background: var(--green-pale); border-color: var(--green); }
.input-group-custom input { flex: 1; padding: 0.6rem 0.9rem; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 0.9rem; }
.dpp-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-top: 1.5rem; box-shadow: var(--shadow-lg); }
.dpp-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.dpp-header h3 { font-size: 1.2rem; color: var(--green); }
.dpp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.dpp-section h4 { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; font-weight: 600; }
.dpp-section p, .dpp-section li { font-size: 0.85rem; line-height: 1.6; }
.dpp-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.dpp-image-strip { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.dpp-product-img { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; transition: transform 0.2s, box-shadow 0.2s; }
.dpp-product-img:hover { transform: scale(1.05); box-shadow: var(--shadow-lg); }
.dpp-product-img--zoom { width: 280px; height: 280px; cursor: zoom-out; z-index: 10; position: relative; }

/* ── Chat ── */
.repair-container { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; }
@media (max-width: 768px) { .repair-container { grid-template-columns: 1fr; } }
.chat-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; height: 600px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.msg { display: flex; gap: 0.75rem; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }
.msg-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--green-pale); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.msg.user .msg-avatar { background: var(--green); }
.msg-bubble { background: var(--surface2); border-radius: 12px; padding: 0.7rem 1rem; font-size: 0.88rem; line-height: 1.5; max-width: 75%; }
.msg.user .msg-bubble { background: var(--green); color: white; }
.msg-bubble.streaming::after { content: '▋'; animation: blink 0.6s infinite; }
.msg-bubble p { margin: 0 0 0.4rem; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 0.3rem 0; padding-left: 1.4rem; }
.msg-bubble li { margin: 0.15rem 0; }
.msg-bubble code { background: rgba(0,0,0,0.1); border-radius: 3px; padding: 0.1em 0.3em; font-size: 0.85em; font-family: monospace; }
.msg-bubble pre { background: rgba(0,0,0,0.1); border-radius: 6px; padding: 0.6rem; overflow-x: auto; margin: 0.4rem 0; }
.msg-bubble pre code { background: none; padding: 0; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3, .msg-bubble h4 { font-size: 1em; font-weight: 600; margin: 0.4rem 0 0.2rem; }
.msg-bubble strong { font-weight: 600; }
.msg-bubble a { color: var(--green); }
@keyframes blink { 50% { opacity: 0; } }
.chat-input-area { padding: 0.75rem; border-top: 1px solid var(--border); }
.quick-buttons { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.quick-btn { background: var(--green-pale); border: 1px solid var(--border); color: var(--green); font-size: 0.75rem; padding: 0.25rem 0.6rem; border-radius: 20px; cursor: pointer; font-family: inherit; }
.quick-btn:hover { background: var(--green); color: white; }
.input-row { display: flex; gap: 0.5rem; align-items: flex-end; }
.input-row textarea { flex: 1; padding: 0.6rem; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 0.88rem; resize: none; }
.send-btn { height: 40px; align-self: flex-end; }

/* ── Sidebar ── */
.repair-sidebar { display: flex; flex-direction: column; gap: 1rem; }
.sidebar-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.sidebar-card h4 { font-size: 0.85rem; color: var(--green); margin-bottom: 0.75rem; font-weight: 600; }
.co2-display, .tips-display { margin-top: 0.75rem; background: var(--green-pale); border-radius: 8px; padding: 0.75rem; font-size: 0.83rem; line-height: 1.6; }

/* ── Video ── */
.video-container { max-width: 700px; }
.video-setup-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; max-width: 480px; }
.video-setup-card h3 { color: var(--green); margin-bottom: 1.5rem; }
.video-call-ui { display: block; }
.video-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.video-wrapper { position: relative; border-radius: var(--radius); overflow: hidden; background: #1a1a1a; aspect-ratio: 4/3; }
.video-wrapper video { width: 100%; height: 100%; object-fit: cover; }
.video-label { position: absolute; bottom: 8px; left: 12px; background: rgba(0,0,0,0.6); color: white; font-size: 0.8rem; padding: 0.2rem 0.5rem; border-radius: 4px; }
.connecting-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.7); display: flex; flex-direction: column; align-items: center; justify-content: center; color: white; }
.spinner { width: 40px; height: 40px; border: 3px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 0.5rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.video-controls { display: flex; gap: 0.75rem; justify-content: center; margin-bottom: 1rem; }
.ctrl-btn { width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; background: var(--surface2); color: var(--text); transition: all 0.2s; }
.ctrl-btn:hover { background: var(--green); color: white; }
.ctrl-btn.active { background: var(--green); color: white; }
.ctrl-btn.danger { background: var(--danger); color: white; }
.ctrl-btn.danger:hover { opacity: 0.85; }
.session-chat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.session-chat-messages { height: 120px; overflow-y: auto; margin-bottom: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; }
.session-chat-messages .sc-msg { font-size: 0.82rem; }
.session-chat-messages .sc-msg strong { color: var(--green); }

/* ── B2B ── */
.b2b-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; }
.b2b-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); transition: transform 0.2s; }
.b2b-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.b2b-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.b2b-card h3 { color: var(--green); margin-bottom: 0.5rem; }
.b2b-card p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; line-height: 1.5; }
.b2b-card ul { list-style: none; margin-bottom: 1rem; }
.b2b-card ul li { font-size: 0.82rem; padding: 0.2rem 0; color: var(--text-muted); }
.b2b-card ul li::before { content: '✓ '; color: var(--green); }

/* ── Mobile Responsive ── */
@media (max-width: 640px) {
  .hamburger { display: flex; }
  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--green);
    padding: 0.75rem 1rem 1rem;
    gap: 0.25rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 99;
  }
  .nav-links.open { display: flex; }
  .nav-btn { text-align: left; padding: 0.6rem 1rem; font-size: 0.95rem; }
  .nav-status { margin-left: 0; }
  .navbar { flex-wrap: wrap; position: relative; }
  .nav-brand { flex: 1; }
}

/* ── Image Slots Grid ── */
.label-hint { font-weight: 400; font-size: 0.8rem; color: var(--text-muted); }
.image-slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.6rem;
  margin-top: 0.5rem;
}
.img-slot {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.img-slot-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.img-slot--label .img-slot-title { color: var(--green); }
.label-ai-badge {
  background: var(--green);
  color: white;
  font-size: 0.65rem;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  letter-spacing: 0.05em;
}
.img-slot-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border);
  border-radius: 8px;
  aspect-ratio: 1;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
  position: relative;
  background: var(--bg);
  gap: 0.25rem;
}
.img-slot-drop:hover, .img-slot-drop.drag-over {
  border-color: var(--green-light);
  background: var(--green-pale);
}
.img-slot--label .img-slot-drop { border-color: var(--green-light); border-style: solid; }
.img-slot-icon { font-size: 1.4rem; color: var(--text-muted); }
.img-slot-hint { font-size: 0.68rem; color: var(--text-muted); }
.img-slot-preview {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.img-slot--filled .img-slot-drop { border-style: solid; border-color: var(--green-light); }

/* ── Analyze Image ── */
.analyze-image-wrap { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.analyze-result {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  line-height: 1.6;
}
.analyze-result strong { color: var(--green); }
.analyze-result .filled-badge {
  display: inline-block;
  background: var(--green-pale);
  color: var(--green);
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
  font-size: 0.78rem;
  margin-left: 0.3rem;
}

/* ── Toast ── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 999; }
.toast { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 1.25rem; box-shadow: var(--shadow-lg); font-size: 0.88rem; animation: slideIn 0.3s ease; max-width: 320px; }
.toast.success { border-left: 3px solid #4caf50; }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--green-light); }
@keyframes slideIn { from { transform: translateX(80px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Utilities ── */
.hidden { display: none !important; }
.fs-2 { font-size: 2rem; }

/* ── DPP card focus highlight (fires on image-match / lookup scroll) ── */
@keyframes dppCardPulse {
  0%   { box-shadow: var(--shadow), 0 0 0 0 rgba(76,175,80,0.55); }
  40%  { box-shadow: var(--shadow), 0 0 0 10px rgba(76,175,80,0.18); }
  100% { box-shadow: var(--shadow), 0 0 0 18px rgba(76,175,80,0); }
}
.dpp-card--focus {
  animation: dppCardPulse 0.9s ease-out forwards;
  scroll-margin-top: 72px; /* 60px sticky navbar + 12px breathing room */
}
