/* Cold Chain Intelligence Platform */
:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel2: #18202b;
  --line: #243040;
  --txt: #e6edf3;
  --muted: #8b9bad;
  --accent: #22c3e6;   /* cold cyan */
  --accent2: #34d399; /* brand green */
  --warn: #fbbf24;
  --bad: #f87171;
  --good: #4ade80;
  --radius: 12px;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--txt);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- LOGIN ---------- */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #10202b 0%, var(--bg) 60%);
}
.login-card {
  width: 340px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 26px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.lb-mark {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-size: 24px; background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #04222b;
}
.lb-title { font-weight: 700; font-size: 16px; }
.lb-sub { color: var(--muted); font-size: 12px; }
.login-hint { text-align: center; color: var(--muted); font-size: 13px; margin: 4px 0 14px; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin-bottom: 18px; }
.pin-dots span {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line);
  transition: all .15s;
}
.pin-dots span.on { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 12px var(--accent); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button {
  height: 58px; font-size: 20px; border-radius: 12px; cursor: pointer;
  background: var(--panel2); color: var(--txt); border: 1px solid var(--line);
  transition: all .12s;
}
.keypad button:hover { background: #1f2a38; }
.keypad button:active { transform: scale(.96); }
.kp-go { background: linear-gradient(135deg, var(--accent), var(--accent2)) !important; color: #04222b !important; font-weight: 800; border: none !important; }
.kp-alt { color: var(--muted); }
.login-msg { text-align: center; min-height: 20px; margin-top: 14px; font-size: 13px; color: var(--bad); }
.login-foot { color: var(--muted); font-size: 11px; margin-top: 20px; }

/* ---------- APP SHELL ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #04222b;
}
.brand-txt { font-size: 13px; line-height: 1.15; color: var(--muted); }
.brand-txt b { color: var(--txt); font-size: 15px; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.nav button {
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  padding: 10px 12px; border-radius: 10px; border: none; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 14px;
}
.nav button .ic { width: 18px; text-align: center; }
.nav button:hover { background: var(--panel2); color: var(--txt); }
.nav button.active { background: var(--panel2); color: var(--txt); box-shadow: inset 3px 0 0 var(--accent); }
.logout {
  margin-top: 10px; padding: 9px; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid var(--line); font-size: 13px;
}
.logout:hover { color: var(--txt); border-color: var(--accent); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 14px 26px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 40;
}
.search-box { position: relative; flex: 1; max-width: 640px; }
.search-box input {
  width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--txt); font-size: 14px;
}
.search-box input:focus { outline: none; border-color: var(--accent); }
.search-results {
  position: absolute; top: 46px; left: 0; right: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; max-height: 60vh; overflow-y: auto; z-index: 50;
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
}
.sr-item { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.sr-item:hover { background: var(--panel2); }
.sr-kind { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.sr-title { font-weight: 600; font-size: 14px; }
.sr-snip { color: var(--muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-tag { color: var(--muted); font-size: 12px; }

.content { padding: 24px 26px 80px; }

/* ---------- COMPONENTS ---------- */
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 22px; margin: 0 0 4px; }
.page-head p { color: var(--muted); margin: 0; font-size: 14px; }

.grid { display: grid; gap: 14px; }
.cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.card.click { cursor: pointer; transition: border-color .12s, transform .12s; }
.card.click:hover { border-color: var(--accent); transform: translateY(-2px); }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .n { font-size: 28px; font-weight: 800; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stats-row { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--line); font-size: 12px; color: var(--muted);
}
.chip.on { background: rgba(34,195,230,.15); border-color: var(--accent); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
button.chip { cursor: pointer; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.tag-retailer, .tag-grocery { background: rgba(34,195,230,.15); color: var(--accent); }
.tag-supplier, .tag-grower, .tag-processor { background: rgba(52,211,153,.15); color: var(--accent2); }
.tag-carrier, .tag-3pl, .tag-4pl { background: rgba(251,191,36,.15); color: var(--warn); }
.tag-distributor, .tag-foodservice { background: rgba(167,139,250,.18); color: #c4b5fd; }
.tag-cold_storage { background: rgba(96,165,250,.18); color: #93c5fd; }
.tag-tech { background: rgba(248,113,113,.15); color: var(--bad); }

.co-card h3 { margin: 0 0 4px; font-size: 16px; }
.co-card .co-meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.co-card .co-desc { font-size: 13px; color: #c3cfdb; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* detail */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 8px; }
.back-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 0; margin-bottom: 12px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; margin: 14px 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.section { margin-top: 26px; }
.section h2 { font-size: 16px; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }

.insight-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.insight { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 14px; }
.insight h4 { margin: 0 0 6px; font-size: 13px; color: var(--accent); }
.insight p, .insight li { font-size: 13px; color: #c9d5e1; line-height: 1.45; margin: 0; }
.insight ul { margin: 0; padding-left: 18px; }
.insight.green { border-left-color: var(--accent2); }
.insight.green h4 { color: var(--accent2); }

.req-list { counter-reset: r; display: grid; gap: 10px; }
.req-item { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 12px 44px; position: relative; }
.req-item::before {
  counter-increment: r; content: counter(r); position: absolute; left: 12px; top: 12px;
  width: 22px; height: 22px; border-radius: 6px; background: var(--panel2); color: var(--accent);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.req-item .q { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.req-item .a { font-size: 14px; margin-top: 3px; color: #d6e0ea; line-height: 1.45; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--panel2); }

.badge { padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge.confirmed { background: rgba(74,222,128,.15); color: var(--good); }
.badge.reported { background: rgba(34,195,230,.15); color: var(--accent); }
.badge.suspected { background: rgba(251,191,36,.15); color: var(--warn); }
.badge.unknown { background: var(--panel2); color: var(--muted); }

/* map */
#map { height: 68vh; border-radius: var(--radius); border: 1px solid var(--line); }
.map-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.map-toolbar select {
  padding: 9px 12px; border-radius: 10px; background: var(--panel); color: var(--txt);
  border: 1px solid var(--line); font-size: 13px;
}
.map-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--txt); }
.leaflet-popup-content { font-size: 13px; }
.leaflet-popup-content b { color: var(--accent); }

/* glossary */
.gloss-item { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.gloss-item .g-term { font-size: 15px; font-weight: 700; }
.gloss-item .g-abbr { color: var(--muted); font-size: 12px; font-weight: 400; }
.gloss-item .g-def { font-size: 13px; color: #cdd8e3; margin-top: 6px; line-height: 1.45; }
.gloss-item .g-plain { font-size: 13px; color: var(--accent2); margin-top: 6px; }
.gloss-item .g-meta { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* university */
.lesson { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.lesson .l-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.lesson h3 { margin: 0; font-size: 16px; }
.lesson .l-body { font-size: 13px; color: #cdd8e3; line-height: 1.55; }
.lesson .l-take { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.lesson .l-take li { font-size: 13px; color: var(--accent2); margin-bottom: 3px; }
.level { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--panel2); color: var(--muted); }

.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 40px; }

/* discovery */
.disc-badge { color: var(--accent2); font-weight: 600; }
.disc-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.disc-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.disc-form select, .disc-form input {
  padding: 9px 11px; border-radius: 10px; background: var(--panel2); color: var(--txt);
  border: 1px solid var(--line); font-size: 13px; min-width: 160px;
}
.disc-form input[type=number] { min-width: 90px; }

/* news / buying triggers */
.news-list { display: grid; gap: 10px; }
.news-item { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.news-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.news-date { color: var(--muted); font-size: 11px; margin-left: auto; }
.news-co { color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; }
.news-co:hover { text-decoration: underline; }
.news-title { font-size: 14px; font-weight: 600; color: var(--txt); display: block; }
.news-title:hover { color: var(--accent); }
.news-snip { font-size: 12px; color: #c3cfdb; margin-top: 5px; line-height: 1.45; }
.news-src { font-size: 11px; color: var(--muted); margin-top: 6px; }
.trig { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid; }

/* temperature-recall callout + commodities */
.temp-callout {
  background: rgba(248,113,113,.12); border: 1px solid rgba(248,113,113,.4);
  border-left: 4px solid var(--bad); border-radius: 10px; padding: 12px 14px;
  font-size: 13px; color: #ffd9d9; margin: 14px 0; line-height: 1.45;
}
.temp-callout b { color: #ff8a8a; }
.com-card h3 { margin: 0; font-size: 16px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.note { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12px; color: var(--muted); margin-top: 8px; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .brand { width: 100%; }
}
