/* ================================================================
   BeanSight — stylesheet
   Warm, light, minimal. Inter for UI, JetBrains Mono for numbers.
   ================================================================ */

:root {
  --bg:            #f7f3ee;
  --surface:       #ffffff;
  --surface-2:     #fbf9f6;
  --surface-3:     #f1ece5;
  --border:        #e6ded4;
  --border-strong: #d6cbbd;

  --text:          #1f1915;
  --text-2:        #5f554d;
  --text-3:        #8f857b;

  --espresso:      #4a2c20;
  --espresso-2:    #5e3a2b;
  --accent:        #c2652a;
  --accent-soft:   #f7e6da;

  --green:         #2f7d4f;
  --green-soft:    #e3f1e8;
  --amber:         #b7791f;
  --amber-soft:    #fbefd6;
  --red:           #b93a2b;
  --red-soft:      #fae3df;
  --blue:          #2b6cb0;
  --blue-soft:     #e2ecf8;

  --bean-crease:   #f7f3ee;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(31, 25, 21, 0.05);
  --shadow-md: 0 6px 20px -8px rgba(31, 25, 21, 0.18);
  --ease: 0.18s ease;
}

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

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: inline-block; width: 1em; height: 1em; vertical-align: -0.15em; flex-shrink: 0; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--text-2); }
.small { font-size: 0.82rem; }
.mono { font-family: var(--mono); font-size: 0.82em; }
.accent { color: var(--accent); }

/* ── Header ───────────────────────────────────────────────────── */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(247, 243, 238, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 28px; height: 60px; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; color: var(--espresso); }
.brand-mark.small { width: 18px; height: 18px; }
.brand-name { font-size: 1.05rem; }

.site-nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.site-nav a {
  color: var(--text-2); font-weight: 500; font-size: 0.9rem;
  padding: 6px 10px; border-radius: var(--r-sm); transition: background var(--ease), color var(--ease);
}
.site-nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-icon-link { display: inline-flex; align-items: center; gap: 6px; }

.status-pill {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.8rem; font-weight: 500; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 999px; white-space: nowrap;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 3px rgba(47, 125, 79, 0.18); }
.status-dot.warn { background: var(--amber); box-shadow: 0 0 0 3px rgba(183, 121, 31, 0.18); }
.status-dot.bad { background: var(--red); box-shadow: 0 0 0 3px rgba(185, 58, 43, 0.18); }

/* ── Hero ─────────────────────────────────────────────────────── */

.hero { padding: 56px 0 36px; max-width: 760px; }
.eyebrow {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 14px;
}
.hero h1 { font-size: clamp(1.8rem, 3.4vw, 2.6rem); line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; color: var(--espresso); }
.lede { margin-top: 16px; font-size: 1.05rem; color: var(--text-2); max-width: 680px; }

/* ── Cards ────────────────────────────────────────────────────── */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.card-head h2 { font-size: 0.95rem; font-weight: 600; }
.card-body { padding: 20px; flex: 1; }

/* ── Analyzer ─────────────────────────────────────────────────── */

.analyzer { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; align-items: start; }
.upload-body { display: flex; flex-direction: column; gap: 16px; }

.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-md); background: var(--surface-2);
  padding: 40px 20px; text-align: center; cursor: pointer; outline: none;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: border-color var(--ease), background var(--ease);
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon {
  width: 46px; height: 46px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--accent); font-size: 20px; margin-bottom: 6px;
}
.dropzone-title { font-weight: 600; }
.dropzone-title .link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.dropzone-sub { font-size: 0.82rem; color: var(--text-2); }

.preview { display: flex; flex-direction: column; gap: 10px; }
.preview img {
  width: 100%; max-height: 300px; object-fit: contain; border-radius: var(--r-md);
  background: var(--surface-3); border: 1px solid var(--border);
}
.preview-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 0.85rem; }
.preview-meta .mono:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
.field-hint { font-size: 0.78rem; color: var(--text-3); }
.segmented { display: inline-flex; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent; border: none; border-radius: 7px; padding: 7px 12px;
  font-size: 0.84rem; font-weight: 500; color: var(--text-2); cursor: pointer;
  transition: background var(--ease), color var(--ease), box-shadow var(--ease);
}
.seg svg { font-size: 15px; }
.seg:hover { color: var(--text); }
.seg.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.seg.active[data-value="green"] { color: var(--green); }
.seg.active[data-value="roasted"] { color: var(--accent); }

.tips { list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 0.84rem; color: var(--text-2); }
.tips li { display: flex; gap: 10px; align-items: flex-start; }
.tips svg { font-size: 16px; margin-top: 2px; color: var(--accent); }
.tips strong { color: var(--text); font-weight: 600; }

.actions { display: flex; gap: 10px; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 0.92rem; padding: 11px 18px; border-radius: var(--r-md);
  border: 1px solid transparent; cursor: pointer; transition: background var(--ease), border-color var(--ease), transform var(--ease), box-shadow var(--ease);
}
.btn svg { font-size: 17px; }
.btn:active { transform: translateY(1px); }
.btn-primary { flex: 1; background: var(--espresso); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--espresso-2); box-shadow: var(--shadow-md); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-link { background: none; border: none; color: var(--accent); font-size: 0.84rem; font-weight: 500; cursor: pointer; padding: 4px 0; align-self: flex-start; }
.btn-link:hover { text-decoration: underline; }

/* Results */
.results-body { min-height: 320px; display: flex; flex-direction: column; }
.empty-state, .loading-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  text-align: center; color: var(--text-3); padding: 40px 20px; min-height: 280px;
}
.empty-state svg { font-size: 40px; opacity: 0.6; }
.empty-state p, .loading-state p { font-size: 0.9rem; max-width: 280px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.results { display: flex; flex-direction: column; gap: 14px; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.stage { border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; background: var(--surface); }
.stage-label { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); }
.stage-num {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--espresso); color: #fff; font-family: var(--mono); font-size: 0.7rem; font-weight: 600; letter-spacing: 0;
}

.roast-row { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
.roast-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; color: var(--espresso); line-height: 1.1; }

.mini-bars { display: flex; flex-direction: column; gap: 5px; }
.mini-bar { display: grid; grid-template-columns: 58px 1fr 44px; align-items: center; gap: 8px; font-size: 0.76rem; color: var(--text-2); }
.mini-bar .track { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.mini-bar .fill { height: 100%; border-radius: 999px; background: var(--border-strong); transition: width 0.4s ease; }
.mini-bar.top .fill { background: var(--accent); }
.mini-bar.top { color: var(--text); font-weight: 600; }
.mini-bar .val { font-family: var(--mono); text-align: right; font-size: 0.72rem; }

.note {
  display: flex; gap: 8px; align-items: flex-start; font-size: 0.8rem; color: var(--text-2);
  background: var(--amber-soft); border-left: 3px solid var(--amber); padding: 8px 12px; border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.note svg { color: var(--amber); margin-top: 2px; }

.route-chip {
  align-self: center; display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.78rem; font-weight: 500; color: var(--text-2);
  padding: 4px 12px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border);
}
.route-chip svg { font-size: 14px; }
.route-chip.green { color: var(--green); background: var(--green-soft); border-color: transparent; }
.route-chip.roasted { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

.defect-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.defect-name { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; }
.defect-desc { font-size: 0.86rem; color: var(--text-2); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.74rem; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.chip.amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.chip.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.chip.blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.chip.pink { background: #f9e4f7; color: #9b2f8f; border-color: transparent; }
.chip .mono { opacity: 0.8; }

.bars { display: flex; flex-direction: column; gap: 7px; }
.bar { display: grid; grid-template-columns: 150px 1fr 48px; align-items: center; gap: 10px; font-size: 0.8rem; color: var(--text-2); }
.bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar .fill { height: 100%; border-radius: 999px; background: var(--border-strong); transition: width 0.4s ease; }
.bar.top { color: var(--text); font-weight: 600; }
.bar.top .fill { background: var(--accent); }
.bar .val { font-family: var(--mono); font-size: 0.74rem; text-align: right; }

.annotated img { width: 100%; max-height: 360px; object-fit: contain; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--r-md); }
.annotated figcaption { margin-top: 6px; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 14px; display: flex; flex-direction: column; }
.stat-value { font-family: var(--mono); font-size: 1.4rem; font-weight: 600; line-height: 1.1; }
.stat-label { font-size: 0.74rem; color: var(--text-2); margin-top: 2px; }

/* ── Sections ─────────────────────────────────────────────────── */

.section { padding: 56px 0 0; }
.section-head { margin-bottom: 22px; }
.section-head h2 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.015em; color: var(--espresso); }
.section-head p { margin-top: 4px; font-size: 0.92rem; }

/* Pipeline */
.pipeline { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 2fr); gap: 16px; align-items: stretch; }
.pipe-branches { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pipe-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sm); }
.pipe-card.green { border-top: 3px solid var(--green); }
.pipe-card.roasted { border-top: 3px solid var(--accent); }
.pipe-top { display: flex; align-items: center; justify-content: space-between; }
.pipe-icon { font-size: 22px; color: var(--text-3); }
.pipe-card.green .pipe-icon { color: var(--green); }
.pipe-card.roasted .pipe-icon { color: var(--accent); }
.pipe-card h3 { font-size: 1rem; font-weight: 600; }
.pipe-card p { font-size: 0.86rem; color: var(--text-2); flex: 1; }
.pipe-card strong { color: var(--text); font-weight: 600; }
.specs { display: grid; grid-template-columns: repeat(3, auto); gap: 10px 16px; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 2px; }
.specs div { display: flex; flex-direction: column; gap: 1px; }
.specs dt { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); font-weight: 600; }
.specs dd { font-size: 0.82rem; font-weight: 600; font-family: var(--mono); }

.pipe-fork { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text-3); padding: 0 4px; }
.pipe-fork svg { font-size: 22px; }
.fork-label { font-family: var(--mono); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.fork-label:first-child { color: var(--green); }
.fork-label:last-child { color: var(--accent); }

.footnote { margin-top: 18px; font-size: 0.8rem; color: var(--text-3); max-width: 820px; }

.notice {
  display: flex; gap: 10px; align-items: flex-start; font-size: 0.86rem; color: var(--text-2);
  background: var(--amber-soft); border: 1px solid rgba(183, 121, 31, 0.25); border-radius: var(--r-md);
  padding: 10px 14px; margin-bottom: 16px;
}
.notice svg { color: var(--amber); font-size: 16px; margin-top: 2px; }

/* KPIs & activity */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow-sm); }
.kpi-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); font-weight: 600; }
.kpi-value { font-family: var(--mono); font-size: 1.45rem; font-weight: 600; color: var(--text); line-height: 1.2; }

.activity-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }

.table-wrap { overflow-x: auto; max-height: 440px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.table th { position: sticky; top: 0; background: var(--surface); text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); font-weight: 600; padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }
.table-empty { text-align: center; padding: 36px 16px !important; color: var(--text-3); white-space: normal !important; }
.thumb { width: 36px; height: 36px; border-radius: var(--r-sm); object-fit: cover; border: 1px solid var(--border); display: block; }
.thumb-ph { width: 36px; height: 36px; border-radius: var(--r-sm); background: var(--surface-3); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-3); }
.cell-main { color: var(--text); font-weight: 600; }
.cell-sub { font-size: 0.74rem; color: var(--text-3); margin-top: 1px; }

/* ── Footer ───────────────────────────────────────────────────── */

.site-footer { margin-top: 72px; border-top: 1px solid var(--border); padding: 24px 0 40px; font-size: 0.84rem; color: var(--text-2); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer-left { display: inline-flex; align-items: center; gap: 10px; }
.footer-left strong { color: var(--text); }
.footer-right { display: inline-flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.footer-right a { font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }

/* ── Toasts ───────────────────────────────────────────────────── */

.toast-container { position: fixed; bottom: 22px; right: 22px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: #fff; font-size: 0.84rem; font-weight: 500;
  padding: 10px 16px; border-radius: var(--r-md); box-shadow: var(--shadow-md); max-width: 340px;
  animation: toast-in 0.2s ease;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.2s ease, transform 0.2s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 960px) {
  .analyzer, .activity-grid { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: 1fr; }
  .pipe-fork { flex-direction: row; justify-content: center; }
  .pipe-fork svg { transform: rotate(90deg); }
  .kpis { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .header-inner { gap: 12px; }
  .site-nav { display: none; }
  .hero { padding: 36px 0 24px; }
  .pipe-branches { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .roast-row { grid-template-columns: 1fr; }
  .bar { grid-template-columns: 110px 1fr 44px; }
  .stat-row { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .stat { padding: 8px 10px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}
