/* Wise Dark Dashboard system — calm dark cockpit, green as precision instrument */

:root {
  --canvas: #0e0f0c;
  --surface: #14160f;
  --card: #1a1c19;
  --hover: #21241f;
  --text: #f5f5f0;
  --muted: #a3a59f;
  --dim: #6e716a;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --white6: rgba(255, 255, 255, 0.06);
  --green: #9fe870;
  --green-dark: #163300;
  --green-soft: #cdffad;
  --warn: #ffd11a;
  --danger: #ff7a82;
  --info: #38c8ff;
}

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

body {
  background: var(--canvas);
  color: var(--text);
  font-family: 'Inter', Helvetica, Arial, sans-serif;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: 0.18px;
  font-feature-settings: 'calt' on;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Nav ---------- */
.topnav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
  background: rgba(14, 15, 12, 0.85);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1280px; margin: 0 auto; padding: 14px 32px;
  display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--green); color: var(--green-dark);
  font-weight: 900; font-size: 12px;
  display: grid; place-items: center;
}
.brand-name { font-weight: 900; font-size: 17px; letter-spacing: -0.01em; }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-link {
  text-decoration: none; color: var(--muted);
  padding: 8px 14px; border-radius: 9999px; font-size: 15px; font-weight: 600;
  transition: all 0.15s;
}
.nav-link:hover { background: rgba(159, 232, 112, 0.06); color: var(--text); }
.nav-link.active { background: rgba(159, 232, 112, 0.1); color: var(--green); }
.nav-right { display: flex; align-items: center; gap: 14px; }
.live-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 9999px;
  background: rgba(159, 232, 112, 0.08);
  border: 1px solid rgba(159, 232, 112, 0.2);
  color: var(--green); font-size: 13px; font-weight: 700;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(159, 232, 112, 0.14);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green-soft));
  color: var(--green-dark); font-weight: 900; font-size: 15px;
  display: grid; place-items: center;
}

/* ---------- Page scaffold ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 56px 32px 80px; }
.view.hidden { display: none; }

.page-head {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px;
  align-items: end; margin-bottom: 48px;
}
.page-head.solo { grid-template-columns: 1fr; }
.eyebrow {
  font-size: 13px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--green); margin-bottom: 14px;
}
.display {
  font-weight: 900; font-size: 72px; line-height: 0.85;
  letter-spacing: -0.02em; margin-bottom: 20px;
}
.display.sm { font-size: 56px; }
.display .green { color: var(--green); }
.display .hero-caveat { display: block; font-size: 15px; font-weight: 700; letter-spacing: 0; color: var(--warn); margin-top: 8px; }
.lede { font-size: 18px; font-weight: 400; color: var(--muted); line-height: 1.44; max-width: 620px; }
.lede strong { color: var(--text); font-weight: 700; }

/* ---------- Cards ---------- */
.card, .card-lg {
  background: var(--card);
  box-shadow: 0 0 0 1px var(--line);
  border-radius: 30px;
  padding: 28px;
}
.card-lg { border-radius: 40px; padding: 36px; }

.hero-chart { display: flex; flex-direction: column; gap: 8px; }
.hero-stat { font-size: 28px; font-weight: 900; line-height: 0.9; font-variant-numeric: tabular-nums; }
.hero-chart svg { width: 100%; height: 90px; margin-top: 8px; }
.chart-foot { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--dim); }
.chart-foot .now { color: var(--green); font-weight: 700; }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi {
  background: var(--card); border-radius: 30px; padding: 28px;
  box-shadow: 0 0 0 1px var(--line);
  transition: all 0.2s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px var(--line-strong); }
.kpi-label {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); margin-bottom: 10px;
}
.kpi-value {
  font-size: 64px; font-weight: 900; line-height: 0.85;
  font-variant-numeric: tabular-nums; margin-bottom: 14px;
}
.kpi-value.good { color: var(--green); }
.kpi-value.warn { color: var(--warn); }
.kpi-value.bad { color: var(--danger); }
.kpi-foot { font-size: 13px; font-weight: 400; color: var(--dim); }

/* ---------- Split layout ---------- */
.split { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; align-items: start; }
.side-col { display: flex; flex-direction: column; gap: 24px; }

.panel-head {
  display: flex; align-items: end; justify-content: space-between;
  margin-bottom: 22px;
}
.panel-title { font-weight: 900; font-size: 34px; line-height: 0.85; letter-spacing: -0.01em; }
.panel-title.sm { font-size: 24px; }
.panel-meta { font-size: 13px; font-weight: 600; color: var(--muted); text-align: right; }

/* ---------- Alerts queue ---------- */
.prio-group { margin-bottom: 18px; }
.prio-head {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--dim); margin: 14px 4px 10px;
}
.alert-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px 20px;
  margin-bottom: 10px;
  transition: border-color 0.15s;
}
.alert-item:hover { border-color: var(--line-strong); }
.alert-row { display: flex; align-items: flex-start; gap: 14px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; }
.status-dot.critical { background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 122, 130, 0.16); }
.status-dot.medium { background: var(--warn); box-shadow: 0 0 0 4px rgba(255, 209, 26, 0.14); }
.status-dot.low { background: var(--info); box-shadow: 0 0 0 4px rgba(56, 200, 255, 0.14); }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-size: 15px; font-weight: 700; margin-bottom: 3px; }
.alert-source { font-size: 12px; font-weight: 600; color: var(--dim); margin-bottom: 8px; }
.alert-detail { font-size: 13px; font-weight: 400; color: var(--muted); line-height: 1.5; }
.alert-detail strong { color: var(--text); font-weight: 700; }
.alert-reco {
  margin-top: 10px; padding: 10px 14px; border-radius: 12px;
  background: rgba(159, 232, 112, 0.06);
  font-size: 13px; font-weight: 400; color: var(--muted); line-height: 1.5;
}
.alert-reco b { color: var(--green); font-weight: 700; }
.alert-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.alert-item.snoozed { opacity: 0.55; }
.alert-resolution {
  margin-top: 10px; padding: 10px 14px; border-radius: 12px;
  background: var(--white6); font-size: 13px; font-weight: 400; color: var(--muted);
}
.alert-resolution b { color: var(--green); }
.empty-note { font-size: 14px; font-weight: 400; color: var(--dim); padding: 20px 4px; }

/* ---------- Buttons ---------- */
.btn {
  border: none; cursor: pointer; font-family: inherit;
  border-radius: 9999px; font-weight: 600; font-size: 14px;
  padding: 9px 18px; display: inline-flex; align-items: center; gap: 8px;
  transition: all 0.15s;
}
.btn:hover { transform: scale(1.05); }
.btn:active { transform: scale(0.95); }
.btn.primary { background: var(--green); color: var(--green-dark); font-weight: 700; }
.btn.primary:hover { background: var(--green-soft); }
.btn.ghost {
  background: var(--white6); color: var(--text);
  border: 1px solid var(--line-strong);
}
.btn.ghost:hover { background: rgba(255, 255, 255, 0.1); }
.btn.sm { font-size: 13px; padding: 7px 14px; }
.btn:disabled { opacity: 0.5; cursor: wait; transform: none; }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex; align-items: center;
  padding: 4px 11px; border-radius: 9999px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
}
.pill.good { background: rgba(159, 232, 112, 0.14); color: var(--green); }
.pill.warn { background: rgba(255, 209, 26, 0.14); color: var(--warn); }
.pill.danger { background: rgba(255, 122, 130, 0.16); color: var(--danger); }
.pill.info { background: rgba(56, 200, 255, 0.14); color: var(--info); }
.pill.dim { background: var(--white6); color: var(--muted); }

/* ---------- List rows ---------- */
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 16px;
  transition: background 0.15s;
}
.row:hover { background: var(--hover); }
.row-mark {
  width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.row-mark.good { background: rgba(159, 232, 112, 0.12); color: var(--green); }
.row-mark.warn { background: rgba(255, 209, 26, 0.12); color: var(--warn); }
.row-mark.danger { background: rgba(255, 122, 130, 0.14); color: var(--danger); }
.row-mark.info { background: rgba(56, 200, 255, 0.12); color: var(--info); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 700; }
.row-meta { font-size: 13px; font-weight: 400; color: var(--muted); }
.row-end { text-align: right; font-size: 13px; font-weight: 600; color: var(--muted); }
.row-end .big { font-size: 15px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Health bars ---------- */
.hbar { height: 6px; border-radius: 9999px; background: var(--white6); overflow: hidden; margin-top: 6px; }
.hbar > div { height: 100%; border-radius: 9999px; }
.hbar .good { background: var(--green); }
.hbar .warn { background: var(--warn); }
.hbar .danger { background: var(--danger); }

/* ---------- Intake ---------- */
.channel-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.chan-tab {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 18px; border-radius: 9999px; cursor: pointer; transition: all 0.15s;
}
.chan-tab:hover { color: var(--text); border-color: var(--line-strong); }
.chan-tab.active { background: rgba(159, 232, 112, 0.1); color: var(--green); border-color: rgba(159, 232, 112, 0.3); }

.samples { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.sample-chip {
  border: none; cursor: pointer; font-family: inherit;
  background: var(--white6); color: var(--muted);
  font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 9999px;
  transition: all 0.15s;
}
.sample-chip:hover { color: var(--text); background: rgba(255, 255, 255, 0.1); }

textarea#intakeText {
  width: 100%; min-height: 260px; resize: vertical;
  background: var(--hover); border: 1px solid var(--line); border-radius: 20px;
  color: var(--text); font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 13px; line-height: 1.6; padding: 18px; outline: none;
}
textarea#intakeText:focus { border-color: rgba(159, 232, 112, 0.4); }
.intake-actions { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.engine-note { font-size: 13px; font-weight: 400; color: var(--dim); }

.extract-empty { font-size: 14px; font-weight: 400; color: var(--dim); padding: 12px 0; line-height: 1.6; }
.x-section { margin-bottom: 18px; }
.x-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dim); margin-bottom: 8px; }
.x-kv { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.x-kv .kv {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 12px; font-size: 13px;
}
.kv span { color: var(--dim); font-weight: 600; margin-right: 6px; }
.kv b { color: var(--text); font-weight: 700; }
.x-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.x-table th { text-align: left; color: var(--dim); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.x-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); font-weight: 600; font-variant-numeric: tabular-nums; }
.issue { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; font-size: 13px; font-weight: 400; color: var(--muted); line-height: 1.5; }
.issue .status-dot { margin-top: 5px; }
.goto-queue { margin-top: 14px; }

/* ---------- ERP tables ---------- */
.erp-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.erp-table th {
  text-align: left; color: var(--dim); font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.erp-table td { padding: 12px; border-bottom: 1px solid var(--line); font-weight: 600; font-variant-numeric: tabular-nums; vertical-align: top; }
.erp-table tr:hover td { background: var(--hover); }
.erp-table .sub { font-size: 12px; color: var(--dim); font-weight: 400; }
#erpTabs { margin-bottom: 24px; }

/* ---------- Suppliers ---------- */
.supplier-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.sup-card { background: var(--card); border-radius: 30px; padding: 28px; box-shadow: 0 0 0 1px var(--line); transition: all 0.2s; }
.sup-card:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px var(--line-strong); }
.sup-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.sup-name { font-size: 18px; font-weight: 900; }
.sup-loc { font-size: 13px; font-weight: 400; color: var(--dim); }
.sup-stat { margin-bottom: 14px; }
.sup-stat .lab { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.sup-stat .lab b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Audit ---------- */
.audit-row { display: flex; gap: 16px; padding: 14px 8px; border-bottom: 1px solid var(--line); }
.audit-ts { font-size: 12px; color: var(--dim); font-weight: 600; white-space: nowrap; padding-top: 2px; min-width: 130px; }
.audit-main { flex: 1; }
.audit-actor { font-size: 12px; font-weight: 700; color: var(--green); margin-bottom: 2px; }
.audit-detail { font-size: 13px; font-weight: 400; color: var(--muted); line-height: 1.5; }

/* ---------- Footer / toast ---------- */
.foot {
  max-width: 1280px; margin: 0 auto; padding: 24px 32px 48px;
  display: flex; justify-content: space-between; align-items: center;
  color: var(--dim); font-size: 13px; font-weight: 400;
  border-top: 1px solid var(--line);
}
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--card); border: 1px solid rgba(159, 232, 112, 0.3);
  color: var(--text); font-size: 14px; font-weight: 600;
  padding: 14px 22px; border-radius: 9999px; z-index: 100;
  box-shadow: 0 0 0 1px var(--line);
  max-width: 80vw;
}
.toast.hidden { display: none; }
.toast b { color: var(--green); }

/* ---------- v2: sim bar ---------- */
.sim-bar { display: flex; align-items: center; gap: 8px; }
.sim-date {
  font-size: 13px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
  background: var(--white6); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 9999px;
}
.nav-badge { color: var(--warn); font-weight: 700; }

/* ---------- v2: accent tile (the ONE solid green tile, secondary slot) ---------- */
.accent-tile { background: var(--green); box-shadow: none; }
.accent-tile .kpi-label.dark { color: rgba(22, 51, 0, 0.7); }
.accent-tile .kpi-value.dark { color: var(--green-dark); }
.accent-tile .kpi-foot.dark { color: rgba(22, 51, 0, 0.7); }

/* ---------- v2: day log ---------- */
.day-log { max-height: 520px; overflow-y: auto; }
.log-day {
  font-size: 13px; font-weight: 700; color: var(--green);
  margin: 14px 0 6px; letter-spacing: 0.04em;
}
.log-day:first-child { margin-top: 0; }
.log-line {
  font-size: 13px; font-weight: 400; color: var(--muted);
  padding: 4px 0 4px 12px; border-left: 2px solid var(--line);
  line-height: 1.5;
}

/* ---------- v2: mail items ---------- */
.mail-item {
  border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
  transition: border-color 0.15s;
}
.mail-item:hover { border-color: var(--line-strong); }
.mail-head { display: flex; gap: 14px; align-items: flex-start; }
.mail-body {
  margin-top: 12px; padding: 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  font-family: 'SF Mono', 'Menlo', monospace; font-size: 12px;
  line-height: 1.6; color: var(--muted); white-space: pre-wrap;
}
.mail-body.hidden { display: none; }

/* ---------- v2: supplier hint ---------- */
.sup-hint {
  margin-top: 16px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12px; font-weight: 400; color: var(--dim); line-height: 1.5;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .page-head, .split { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .supplier-grid { grid-template-columns: 1fr; }
  .display { font-size: 48px; }
  .nav-links { display: none; }
}
@media (max-width: 576px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page { padding: 32px 24px 64px; }
}
