/* =========================================================================
   Bahar — Revolut-inspired dark theme with animated emerald gradients
   ========================================================================= */

:root {
  /* surfaces */
  --bg:           #04110b;
  --bg-deep:      #020805;
  --panel:        rgba(18, 36, 27, 0.62);
  --panel-fill:   rgba(16, 33, 25, 0.92); /* opaque panel fill — same glass look, no per-frame blur (smooth scroll) */
  --panel-solid:  #0e2018;
  --font-display: "Sora", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --panel-hi:     rgba(28, 54, 40, 0.78);
  --line:         rgba(140, 200, 168, 0.13);
  --line-strong:  rgba(140, 200, 168, 0.22);

  /* ink */
  --ink:        #e6f4ec;
  --ink-soft:   #8fb0a0;
  --ink-faint:  #5d7869;

  /* brand */
  --accent:        #2ee59d;    /* neon emerald */
  --accent-deep:   #14a874;
  --accent-soft:   rgba(46, 229, 157, 0.16);
  --accent-glow:   rgba(46, 229, 157, 0.45);
  --accent-mute:   rgba(46, 229, 157, 0.08);

  /* status palette (re-tinted for dark) */
  --good:    #46e6a3;
  --warn:    #ffc564;
  --bad:     #ff6f6f;
  --info:    #6bb8ff;
  --violet:  #b389ff;

  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 16px 40px rgba(0, 0, 0, .35);
  --shadow-hi: 0 4px 14px rgba(0,0,0,.4), 0 28px 60px rgba(0, 0, 0, .55);
  --ring: 0 0 0 1px var(--line-strong);
}

* { box-sizing: border-box; }

html, body { background: var(--bg-deep); }

body {
  margin: 0;
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "ss02", "cv11";
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
}

/* =========================================================================
   Animated background — three drifting radial blobs + grid overlay
   ========================================================================= */
body::before, body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
  filter: blur(80px);
  opacity: 0.55;
  will-change: transform;
}

body::before {
  width: 720px; height: 720px;
  left: -180px; top: -200px;
  background: radial-gradient(circle, #1ad48b 0%, rgba(26, 212, 139, 0) 60%);
  animation: drift-a 26s ease-in-out infinite alternate;
}
body::after {
  width: 820px; height: 820px;
  right: -220px; bottom: -240px;
  background: radial-gradient(circle, #0db273 0%, rgba(13, 178, 115, 0) 60%);
  animation: drift-b 32s ease-in-out infinite alternate;
}

/* third blob lives on .layout so it sits in front of body but behind UI */
.layout::before {
  content: "";
  position: fixed; pointer-events: none; z-index: 0;
  width: 560px; height: 560px;
  left: 40%; top: 30%;
  background: radial-gradient(circle, #34d0ff 0%, rgba(52, 208, 255, 0) 60%);
  filter: blur(90px);
  opacity: 0.22;
  animation: drift-c 38s ease-in-out infinite alternate;
}

@keyframes drift-a {
  0%   { transform: translate(0, 0)        scale(1); }
  50%  { transform: translate(180px, 80px) scale(1.18); }
  100% { transform: translate(60px, 240px) scale(0.95); }
}
@keyframes drift-b {
  0%   { transform: translate(0, 0)         scale(1); }
  50%  { transform: translate(-160px, -90px) scale(1.12); }
  100% { transform: translate(-60px, -220px) scale(0.92); }
}
@keyframes drift-c {
  0%   { transform: translate(0, 0)         scale(1)   rotate(0deg); }
  50%  { transform: translate(-220px, 140px) scale(1.2) rotate(40deg); }
  100% { transform: translate(120px, -140px) scale(0.9) rotate(-30deg); }
}

/* subtle dot grid on top of blobs */
.layout::after {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(rgba(140,200,168,0.06) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: .7;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 80%);
}

/* =========================================================================
   Layout
   ========================================================================= */
.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

/* =========================================================================
   Sidebar — glass panel with subtle gradient
   ========================================================================= */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  padding: 22px 14px 14px;
  background: linear-gradient(180deg, rgba(8,22,16,0.88) 0%, rgba(4,14,10,0.94) 100%);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: var(--ink-soft);
  display: flex; flex-direction: column;
  z-index: 5;
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.sidebar .leaf {
  width: 34px;
  height: 34px;
  display: block;
  filter: drop-shadow(0 0 8px var(--accent-glow));
  animation: leaf-pulse 4s ease-in-out infinite;
}
@keyframes leaf-pulse {
  0%, 100% { filter: drop-shadow(0 0 4px var(--accent-glow)); }
  50%      { filter: drop-shadow(0 0 14px var(--accent-glow)); }
}
.brand-name {
  font-size: 19px; font-weight: 700; color: #fff;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #fff 0%, #b9ffd9 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-sub { font-size: 11px; color: var(--ink-faint); letter-spacing: 0.03em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; padding-right: 4px; }
.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }

.nav-tier {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-faint); margin: 16px 8px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: transparent; border: 0; color: var(--ink-soft); cursor: pointer;
  padding: 10px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
  position: relative;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-item:hover:not(.disabled):not(.active) {
  background: rgba(255,255,255,.04);
  color: var(--ink);
  transform: translateX(2px);
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(46,229,157,.22) 0%, rgba(20,168,116,.14) 100%);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(46,229,157,.32);
}
.nav-item.active::before {
  content: "";
  position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 99px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.nav-item.disabled { color: var(--ink-faint); cursor: default; }
.nav-item.add {
  color: var(--accent); border: 1px dashed rgba(46,229,157,.3);
  margin-top: 10px; justify-content: center;
}
.nav-tag {
  margin-left: auto; font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-faint);
}
.nav-item.active .nav-tag { color: #b9ffd9; }
.nav-tag.phase {
  font-variant-numeric: tabular-nums;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(46,229,157,0.08);
  color: rgba(46,229,157,0.85);
  letter-spacing: .03em;
  font-weight: 600;
  font-size: 9.5px;
}

/* Inline SVG icon — emerald-tinted line-art replacing emojis */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}
.icon svg { display: block; }
.nav-item .icon { color: var(--ink-soft); transition: color .18s ease; }
.nav-item:hover .icon { color: var(--accent); }
.nav-item.active .icon { color: var(--accent); filter: drop-shadow(0 0 6px var(--accent-glow)); }
.phase-tile .icon { color: var(--accent); }
.section-title .icon { margin-right: 8px; }
h3 .icon { margin-right: 6px; vertical-align: -3px; }
.nav-item.active .nav-tag.phase {
  background: rgba(46,229,157,0.22);
  color: #d6ffec;
}

/* =========================================================================
   Main column
   ========================================================================= */
.main { min-width: 0; position: relative; z-index: 1; }

.viewbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 34px;
  background: rgba(8, 22, 16, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 4;
}
.viewbar h1 {
  margin: 0; font-size: 22px; letter-spacing: -.015em; color: #fff;
  font-weight: 700;
}
.view-sub { margin: 4px 0 0; font-size: 13px; color: var(--ink-soft); }
.view-actions { display: flex; align-items: center; gap: 14px; }
.updated { font-size: 12.5px; color: var(--ink-soft); }

.refresh-btn {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #052013; border: 0;
  padding: 10px 18px; border-radius: 10px;
  font-size: 13.5px; font-weight: 700;
  letter-spacing: -.005em;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.refresh-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.3); filter: brightness(1.06); }
.refresh-btn:active { transform: translateY(0); }
.refresh-btn:disabled { opacity: .55; cursor: progress; }

.content {
  max-width: 1040px; margin: 0 auto; padding: 28px 34px 80px;
  animation: fade-in .35s ease-out;
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-soft); margin: 28px 2px 14px;
}

/* =========================================================================
   Stats strip — animated counters with glow
   ========================================================================= */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 8px; }
.stat {
  background: var(--panel-fill); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 18px;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
  transition: transform .2s ease, border-color .2s ease;
}
.stat::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 0% 0%, rgba(46,229,157,.08), transparent 50%);
  pointer-events: none;
}
.stat:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.stat-num {
  font-size: 26px; font-weight: 700; letter-spacing: -.025em;
  color: #fff;
  background: linear-gradient(135deg, #fff 0%, #c2f2da 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-label { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

/* =========================================================================
   Cards / panels (glass)
   ========================================================================= */
.panel,
.card,
.doc-preview {
  background: var(--panel-fill);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.panel:hover, .card:hover { border-color: var(--line-strong); }
.panel h3 { margin: 0 0 4px; font-size: 14.5px; color: #fff; font-weight: 600; }
.panel .from { font-size: 11.5px; color: var(--ink-soft); margin-bottom: 14px; }

.card {
  display: grid; grid-template-columns: 100px 1fr; gap: 20px;
  padding: 20px 22px;
}

/* =========================================================================
   Deal cards — scoring column + body
   ========================================================================= */
.score-col { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 2px; }
.score-num {
  font-size: 34px; font-weight: 800; letter-spacing: -.035em; line-height: 1;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, #b9ffd9 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.score-track {
  width: 100%; height: 6px; background: rgba(255,255,255,.06);
  border-radius: 99px; overflow: hidden;
}
.score-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  box-shadow: 0 0 8px var(--accent-glow);
}
.score-cap { font-size: 10.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }

.deal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.company { font-size: 17px; font-weight: 700; letter-spacing: -.015em; color: #fff; }
.country { font-size: 13px; color: var(--ink-soft); }

.badge {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 10px; border-radius: 99px;
  border: 1px solid transparent;
}

.facts { font-size: 13.5px; margin: 10px 0 8px; color: var(--ink); }
.facts .muted { color: var(--ink-soft); }
.why { font-size: 13.5px; color: var(--ink-soft); line-height: 1.55; margin: 0 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  font-size: 11.5px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 4px 10px; border-radius: 8px;
}
.next {
  display: flex; align-items: baseline; gap: 10px;
  border-top: 1px dashed var(--line);
  padding-top: 12px; font-size: 13.5px;
}
.owes {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 8px; border-radius: 7px; flex-shrink: 0;
}
.owes-us { background: var(--accent-soft); color: var(--accent); }
.owes-buyer { background: rgba(107,184,255,.16); color: var(--info); }
.owes-unclear { background: rgba(255,197,100,.16); color: var(--warn); }

/* stage badges — dark variants */
.stage-won         { background: rgba(70,230,163,.16); color: var(--good); }
.stage-contracting { background: rgba(70,200,200,.16); color: #5cd6cb; }
.stage-negotiation { background: rgba(107,184,255,.16); color: var(--info); }
.stage-quotation   { background: rgba(179,137,255,.16); color: var(--violet); }
.stage-samples     { background: rgba(255,197,100,.16); color: var(--warn); }
.stage-inquiry     { background: rgba(255,255,255,.06);  color: var(--ink-soft); }
.stage-stalled     { background: rgba(255,153,90,.16); color: #ff995a; }
.stage-lost        { background: rgba(255,111,111,.16); color: var(--bad); }

/* =========================================================================
   Executive (Brain) briefing
   ========================================================================= */
.briefing {
  border-left: 3px solid var(--accent);
  margin-bottom: 18px;
  background: linear-gradient(135deg, rgba(46,229,157,.06) 0%, var(--panel) 60%);
}
.brief-h { font-size: 15px; font-weight: 700; margin-bottom: 12px; color: #fff; }
.brief-pri { margin: 0 0 14px; padding-left: 22px; }
.brief-pri li { font-size: 14px; line-height: 1.75; font-weight: 600; color: var(--ink); }
.brief-narr { font-size: 13.5px; line-height: 1.7; color: var(--ink-soft); white-space: pre-wrap; margin: 0; }

.brain-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mini {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-top: 1px solid var(--line); font-size: 13.5px;
}
.mini:first-of-type { border-top: 0; }
.mini .l { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mini .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; flex-shrink: 0; }
.todo {
  display: flex; gap: 10px; padding: 10px 0;
  border-top: 1px solid var(--line); font-size: 13.5px; color: var(--ink);
}
.todo:first-of-type { border-top: 0; }
.todo .dot { color: var(--accent); font-weight: 800; }

/* =========================================================================
   Risk / Procurement banner
   ========================================================================= */
.model-banner {
  display: flex; flex-wrap: wrap; gap: 28px; align-items: center;
  background: linear-gradient(135deg, rgba(46,229,157,.12) 0%, rgba(8,22,16,.85) 100%);
  border: 1px solid var(--line-strong);
  color: #e7efe9; border-radius: 16px; padding: 20px 24px;
  position: relative; overflow: hidden;
}
.model-banner::after {
  content: ""; position: absolute; right: -60px; top: -60px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  pointer-events: none;
}
.model-banner .mb-title { font-size: 14px; font-weight: 700; color: #fff; }
.model-banner .mb-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.metric { text-align: center; position: relative; }
.metric .v {
  font-size: 26px; font-weight: 800; color: #fff; letter-spacing: -.02em;
  background: linear-gradient(135deg, #fff 0%, #b9ffd9 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.metric .k { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }

/* Bars */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row {
  display: grid; grid-template-columns: 180px 1fr 38px;
  align-items: center; gap: 10px; font-size: 13px; color: var(--ink);
}
.bar-row .lab { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); }
.bar-track {
  background: rgba(255,255,255,.05); border-radius: 99px;
  height: 18px; overflow: hidden;
  border: 1px solid var(--line);
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  border-radius: 99px;
  box-shadow: 0 0 10px var(--accent-glow);
  transition: width .6s ease-out;
}
.bar-row .n { text-align: right; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.bars.money .bar-row { grid-template-columns: 150px 1fr 104px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.rej {
  display: grid; grid-template-columns: 84px 1fr auto; gap: 12px;
  padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; align-items: baseline;
}
.rej:first-of-type { border-top: 0; }
.rej .d { color: var(--ink-soft); font-size: 12px; white-space: nowrap; }
.rej .s { min-width: 0; color: var(--ink); }
.rej .dest { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }

.muted-note { font-size: 12px; color: var(--ink-soft); margin-top: 10px; }
.empty { color: var(--ink-soft); text-align: center; padding: 44px; }

/* =========================================================================
   Detail drill-in
   ========================================================================= */
.clickable { cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s; }
.clickable:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hi);
}
.back-btn {
  background: rgba(255,255,255,.06) !important;
  color: var(--ink) !important;
  box-shadow: none !important;
}
.back-btn:hover { background: rgba(255,255,255,.1) !important; transform: none !important; }
.detail-head { display: flex; align-items: center; gap: 18px; margin-bottom: 10px; }
.detail-head .score-num { font-size: 48px; }
.msg { padding: 12px 0; border-top: 1px solid var(--line); }
.msg:first-child { border-top: 0; }
.msg-meta {
  font-size: 11px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 5px;
}
.msg-us .msg-meta { color: var(--accent); }
.msg-body { font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; color: var(--ink); }

/* =========================================================================
   Deal maker draft
   ========================================================================= */
.draft { margin-top: 14px; }
.draft-lab {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-soft); margin: 12px 0 5px;
}
.draft-subj, .draft-body, .draft-to {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit; font-size: 13.5px;
  color: var(--ink);
  background: rgba(0,0,0,.25);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.draft-subj:focus, .draft-body:focus, .draft-to:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.draft-body { line-height: 1.55; resize: vertical; }
.draft-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.draft-to { flex: 1; min-width: 150px; padding: 9px 11px; font-size: 13px; }
.send-go {
  background: linear-gradient(135deg, #ff9b66 0%, #ff6a3d 100%) !important;
  color: #1a0a05 !important;
  box-shadow: 0 4px 16px rgba(255,107,61,.35), inset 0 1px 0 rgba(255,255,255,.25) !important;
}

/* =========================================================================
   Contract audit
   ========================================================================= */
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.tier {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  padding: 4px 10px; border-radius: 99px;
}
.tier-CRITICAL { background: rgba(255,111,111,.18); color: var(--bad); }
.tier-HIGH     { background: rgba(255,153,90,.18);  color: #ff995a; }
.tier-MEDIUM   { background: rgba(255,197,100,.18); color: var(--warn); }
.tier-LOW      { background: rgba(70,230,163,.16);  color: var(--good); }

/* =========================================================================
   Margin pills
   ========================================================================= */
.mpill { font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 99px; }
.mg-hi  { background: rgba(70,230,163,.16); color: var(--good); }
.mg-mid { background: rgba(255,197,100,.18); color: var(--warn); }
.mg-lo  { background: rgba(255,111,111,.18); color: var(--bad); }
.mg-na  { background: rgba(255,255,255,.05); color: var(--ink-soft); }

/* =========================================================================
   Callout banners
   ========================================================================= */
.callout {
  background: linear-gradient(135deg, rgba(255,111,111,.10), rgba(255,111,111,.04));
  border: 1px solid rgba(255,111,111,.28);
  color: #ffc7c2;
  padding: 13px 15px; border-radius: 12px;
  font-size: 13.5px; line-height: 1.5; margin-bottom: 4px;
}
.callout-ok {
  background: linear-gradient(135deg, rgba(70,230,163,.10), rgba(70,230,163,.04));
  border: 1px solid rgba(70,230,163,.28);
  color: #c2f2d8;
  padding: 13px 15px; border-radius: 12px;
  font-size: 13.5px; line-height: 1.5;
}

/* =========================================================================
   ERP section tabs
   ========================================================================= */
.erp-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }

/* =========================================================================
   Cost formula editor
   ========================================================================= */
.cf-line { margin-bottom: 10px; font-size: 14px; color: var(--ink); }
.cf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.cf-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--ink); }
.cf-num {
  width: 90px; padding: 5px 8px;
  border: 1px solid var(--line-strong); border-radius: 7px;
  background: rgba(0,0,0,.25); color: var(--ink); font-size: 13px;
}
.cf-num:focus { outline: none; border-color: var(--accent); }
.cf-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.cf-toggle.back-btn { opacity: .65; }
.cf-group { margin-top: 12px; }
.cf-gtitle {
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-soft); margin-bottom: 7px;
}
.cf-group .cf-cell { margin-bottom: 5px; }
.cf-toggle { text-align: left; }

/* =========================================================================
   Balance sheet / income statement
   ========================================================================= */
.bs-tot td { border-top: 1px solid var(--line-strong); padding-top: 8px; font-weight: 700; color: #fff; }

/* Source provenance badges — visible everywhere a number is reconciled */
.src {
  display: inline-block;
  font-size: 9.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 6px; border-radius: 5px;
  margin-left: 6px;
  vertical-align: middle;
  cursor: help;
  border: 1px solid transparent;
}
.src-excel_stocktake { background: rgba(70,230,163,.14); color: var(--good); border-color: rgba(70,230,163,.3); }
.src-subledger       { background: rgba(107,184,255,.14); color: var(--info); border-color: rgba(107,184,255,.3); }
.src-bahar_computed  { background: rgba(179,137,255,.14); color: var(--violet); border-color: rgba(179,137,255,.3); }
.src-erp_gl          { background: rgba(255,255,255,.05); color: var(--ink-soft); border-color: var(--line); }
.src-none            { background: rgba(255,111,111,.14); color: var(--bad); border-color: rgba(255,111,111,.3); }

/* Reconciliation log */
.recon-row { padding: 10px 0; border-top: 1px solid var(--line); }
.recon-row:first-child { border-top: 0; }
.recon-head { display: flex; align-items: center; gap: 10px; }
.recon-metric {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px; color: var(--ink);
  background: rgba(0,0,0,.25); padding: 3px 7px; border-radius: 6px;
  border: 1px solid var(--line);
}
.recon-val {
  margin-left: auto;
  font-size: 13px; font-weight: 700; color: #fff;
  font-variant-numeric: tabular-nums;
}
.recon-why { font-size: 12px; color: var(--ink-soft); margin-top: 5px; line-height: 1.5; }

/* =========================================================================
   Logistics workflow strip
   ========================================================================= */
.lg-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0; }
.lg-stage {
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700;
  padding: 6px 12px; border-radius: 99px;
  border: 1px solid rgba(46,229,157,.18);
}
.lg-arrow { color: var(--ink-faint); font-weight: 700; }

/* =========================================================================
   Tables — KEEP layout intact, restyle for dark glass
   ========================================================================= */
.tbl-wrap {
  overflow-x: auto; padding: 0;
  max-height: 620px; overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0,0,0,.18);
}
.tbl-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.tbl-wrap::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }

.tbl {
  width: 100%; border-collapse: collapse; font-size: 13px;
  color: var(--ink);
}
.tbl th {
  text-align: left;
  color: var(--ink-soft); font-weight: 600;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-strong);
  position: sticky; top: 0;
  background: #0a1610;
}
.tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; color: #fff; }
.tbl td.cust { color: var(--ink-soft); font-size: 11.5px; }
.tbl tbody tr { transition: background .12s ease; }
.tbl tbody tr:hover { background: rgba(46,229,157,.05); }
.cli-row, .inv-row { cursor: pointer; }

.doc-preview { margin-top: 10px; overflow: hidden; }

select.draft-to {
  background: rgba(0,0,0,.25);
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
                    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 16px) center, calc(100% - 11px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
select.draft-to option { background: #0e2018; color: var(--ink); }

/* =========================================================================
   Inbox triage cards
   ========================================================================= */
.inbox-list { padding: 4px 6px; }
.ibx { border-bottom: 1px solid var(--line); }
.ibx:last-child { border-bottom: 0; }
.ibx-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 8px; cursor: pointer;
  transition: background .12s ease;
  border-radius: 8px;
}
.ibx-head:hover { background: rgba(46,229,157,.05); }
.ibx-sender {
  font-weight: 700; font-size: 13.5px; color: var(--ink);
  white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis;
}
.ibx-headline {
  flex: 1; font-size: 13.5px; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ibx-dept {
  font-size: 10.5px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .05em; flex-shrink: 0;
}
.ibx-date { font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; flex-shrink: 0; }
.ibx-trash, .ibx-restore {
  background: none; border: 0; cursor: pointer;
  font-size: 14px; opacity: .45; flex-shrink: 0; padding: 3px 5px;
  color: var(--ink-soft);
  transition: opacity .12s ease;
}
.ibx-trash:hover, .ibx-restore:hover { opacity: 1; }
.ibx-body { padding: 4px 12px 16px; }
.ibx-bullets {
  margin: 6px 0 12px; padding-left: 22px;
  font-size: 13.5px; line-height: 1.65; color: var(--ink);
}
.ibx-action { font-size: 13px; color: var(--accent); margin-bottom: 10px; font-weight: 600; }
.ibx-out { margin-top: 8px; }

/* =========================================================================
   Login + user box
   ========================================================================= */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  box-shadow: var(--shadow-hi);
  padding: 36px 32px; width: 340px;
  display: flex; flex-direction: column; gap: 14px;
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  animation: fade-in .5s ease-out;
}
.login-brand {
  font-size: 28px; font-weight: 700; letter-spacing: -.015em;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-sub { font-size: 13px; color: var(--ink-soft); margin-bottom: 10px; }
.login-card input {
  border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 12px 14px; font: inherit; font-size: 14px;
  background: rgba(0,0,0,.3); color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.login-card input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-btn { width: 100%; padding: 12px; }
.login-err { color: var(--bad); font-size: 13px; text-align: center; }

.userbox {
  margin-top: auto; padding: 16px 8px 4px;
  border-top: 1px solid var(--line);
}
.ub-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.ub-roles { font-size: 11px; color: var(--ink-faint); margin: 2px 0 10px; }
.ub-logout {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  border-radius: 9px;
  padding: 8px 10px; font-size: 12.5px;
  cursor: pointer; width: 100%;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.ub-logout:hover {
  background: rgba(46,229,157,.06);
  color: var(--accent);
  border-color: rgba(46,229,157,.3);
}

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .brain-grid, .two-col { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .bar-row { grid-template-columns: 130px 1fr 34px; }
  .content { padding: 22px 18px 60px; }
}

/* prefers-reduced-motion: disable drifting blobs for a11y */
@media (prefers-reduced-motion: reduce) {
  body::before, body::after, .layout::before, .sidebar .leaf {
    animation: none !important;
  }
  .content { animation: none; }
}

/* button utility classes — used by Statements upload, mapping wizard, divergence resolver */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #1cc985);
  color: #02110a;
  border: none;
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .12s ease, filter .12s ease;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-primary:disabled { opacity: .55; cursor: progress; }

.btn-ghost {
  background: rgba(255,255,255,.06);
  color: #e9efea;
  border: 1px solid rgba(255,255,255,.08);
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease;
}
.btn-ghost:hover { background: rgba(255,255,255,.12); }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0 4px;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-link:hover { filter: brightness(1.15); }

/* ============================================================================
   Print / PDF — Discovery insights consulting deliverable
   ============================================================================ */

/* The cover page is hidden on-screen, shown only when printing. */
.print-only { display: none; }
@media print {
  /* Hide chrome we don't want in the PDF */
  .sidebar,
  .viewbar,
  .nav,
  #disc-pane-archive,
  #ins-narr-refresh,
  .btn-link,
  .btn-primary,
  .userbox { display: none !important; }

  body, html { background: #fff !important; color: #000 !important; }
  .layout { display: block !important; }
  .main, .content { padding: 0 !important; margin: 0 !important; max-width: 100% !important; }

  /* Force dark→light translation for paper */
  .panel, .stat {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #999 !important;
    page-break-inside: avoid;
    box-shadow: none !important;
  }
  .panel h3, .stat-num, b { color: #000 !important; }
  .panel .from, .muted, .muted-note, .stat-label { color: #444 !important; }
  .section-title { color: #000 !important; border-bottom: 1px solid #000; padding-bottom: 4px; margin: 18px 0 8px; }
  .tbl th { color: #000 !important; border-bottom-color: #999 !important; }
  .tbl td { color: #000 !important; border-bottom-color: #ddd !important; }
  .tbl td.num { color: #000 !important; }
  .bar-track { background: #eee !important; }
  .bar-fill { background: #2ee59d !important; }
  .src { border: 1px solid #999 !important; color: #000 !important; background: #f5f5f5 !important; }

  /* Force the cover page visible + full-page */
  .print-only { display: block !important; }
  .print-cover {
    page-break-after: always;
    height: 100vh;
    width: 100%;
    background: #0a1612 !important;
    color: #fff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
  }
  .print-cover-inner {
    padding: 80px;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .print-cover * { color: inherit !important; }

  /* SVG charts — keep colored on paper, just darker accent */
  svg { color-adjust: exact !important; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  /* Page setup */
  @page {
    size: A4;
    margin: 14mm 12mm;
  }

  /* Avoid page breaks mid-table where possible */
  .tbl-wrap, .bars { page-break-inside: avoid; }
}

/* ============================================================================
   12-phase workflow strip — shown on The Brain
   ============================================================================ */

.phase-strip-panel {
  margin-bottom: 18px;
  background: linear-gradient(135deg, rgba(46,229,157,0.04), rgba(107,184,255,0.03));
}

.phase-strip {
  display: flex;
  align-items: stretch;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 2px 8px;
}
.phase-strip::-webkit-scrollbar { height: 4px; }
.phase-strip::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }

.phase-tile {
  flex: 1 0 92px;
  min-width: 92px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: all .15s ease;
  color: var(--ink-soft);
}
.phase-tile:hover {
  background: rgba(46,229,157,0.08);
  border-color: rgba(46,229,157,0.3);
  color: #fff;
  transform: translateY(-2px);
}
.phase-num {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.phase-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 26px;
}
.phase-title {
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
  color: var(--ink);
}
.phase-arrow {
  align-self: center;
  color: var(--ink-faint);
  font-size: 14px;
  flex-shrink: 0;
}

/* Hide arrows when sidebar squishes the strip into a vertical scroll */
@media (max-width: 1000px) {
  .phase-arrow { display: none; }
}

/* ============================================================================
   Historical / Live mode banner — financial views
   ============================================================================ */

.mode-banner {
  margin-bottom: 14px;
  border-left: 3px solid var(--info);
}
.mode-banner.mode-historical {
  background: linear-gradient(135deg, rgba(107,184,255,0.05), rgba(46,229,157,0.02));
  border-left-color: var(--info);
}
.mode-banner.mode-live {
  background: linear-gradient(135deg, rgba(46,229,157,0.07), rgba(20,168,116,0.03));
  border-left-color: var(--accent);
}

.mode-toggle {
  display: inline-flex;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  gap: 1px;
}
.mode-btn {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
}
.mode-btn:hover:not(.active) { color: var(--ink); background: rgba(255,255,255,0.03); }
.mode-btn.active {
  background: var(--accent);
  color: #0a1612;
  font-weight: 600;
}

/* ============================================================================
   Expandable rows — top-N tables/bars with a "Show all" toggle
   ============================================================================ */

.row-expander tr.extra,
.row-expander .bar-row.extra { display: none; }

.row-expander.show-all tr.extra { display: table-row; }
.row-expander.show-all .bar-row.extra { display: grid; }

.show-all-btn {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 12px;
  font-size: 11.5px;
  color: var(--accent);
  background: transparent;
  border: 1px solid rgba(46, 229, 157, 0.25);
  border-radius: 14px;
  cursor: pointer;
  transition: all .15s ease;
  font-weight: 500;
}
.show-all-btn:hover {
  background: rgba(46, 229, 157, 0.08);
  border-color: rgba(46, 229, 157, 0.5);
}
.row-expander {
  text-align: left;
}
.row-expander > .show-all-bar {
  text-align: center;
  padding: 6px 0 0;
}

/* ============================================================================
   Inbox triage — confidence, unsure flag, full-email, reassign
   ============================================================================ */
.ibx-conf {
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px;
  border: 1px solid currentColor; font-variant-numeric: tabular-nums;
}
.ibx-triage {
  font-size: 10px; font-weight: 600; color: var(--warn);
  background: rgba(255,197,100,0.12); border: 1px solid rgba(255,197,100,0.35);
  padding: 1px 7px; border-radius: 10px; letter-spacing: .3px;
}
.ibx-needs-triage { box-shadow: inset 3px 0 0 var(--warn); }
.ibx-secondguess { font-size: 11px; margin: 0 0 6px; }
.ibx-btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.ibx-reassign {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  padding: 6px 0 0; border-top: 1px dashed var(--line);
}
.ibx-reassign select {
  background: var(--panel-solid); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
}
.ibx-fulltext { margin-top: 10px; }
.ibx-emailtext {
  background: #020a06; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; max-height: 360px; overflow-y: auto;
  font-size: 11.5px; line-height: 1.5; color: var(--ink-soft);
  white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Menlo, monospace;
}

/* ---- Drill-down modal (commodity/buyer/supplier/port/lot info pages opened
   from any page outside Discovery) ---- */
.drill-modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(2, 8, 5, 0.72);
  backdrop-filter: blur(3px);
  align-items: flex-start; justify-content: center;
  padding: 4vh 16px; overflow-y: auto;
}
.drill-modal-card {
  position: relative;
  width: 100%; max-width: 1080px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 22px 24px 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}
.drill-modal-close {
  position: sticky; float: right; top: 0;
  margin: -6px -6px 0 0;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--panel-hi); color: var(--ink);
  border: 1px solid var(--line-strong); cursor: pointer;
  font-size: 15px; line-height: 1; z-index: 2;
}
.drill-modal-close:hover { background: var(--line-strong); }

/* =========================================================================
   Form sheet — animated pop-up for "add supplier / shipment / lot / journal"
   ========================================================================= */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 1100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 4vh; overflow-y: auto;
  background: radial-gradient(120% 90% at 50% 0%, rgba(8,28,20,.55), rgba(2,8,5,.72));
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: sheet-fade .18s ease-out;
}
.sheet-card {
  width: 100%; max-width: 640px; position: relative;
  background:
    radial-gradient(140% 120% at 0% 0%, rgba(46,229,157,.07), transparent 45%),
    linear-gradient(160deg, #12281d 0%, #0a1812 100%);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: 0 32px 90px rgba(0,0,0,.62), 0 0 0 1px rgba(46,229,157,.05) inset;
  padding: 26px 28px 24px;
  animation: sheet-pop .28s cubic-bezier(.18,.92,.24,1);
}
.sheet-card.wide { max-width: 900px; }
@keyframes sheet-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes sheet-pop {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
.sheet-close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--panel-hi); border: 1px solid var(--line-strong);
  color: var(--ink); cursor: pointer; font-size: 17px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .15s;
}
.sheet-close:hover { background: var(--line-strong); transform: rotate(90deg); }

/* the existing forms wrap fields in .panel — neutralise it so it doesn't double-frame */
.sheet-body .panel { background: transparent; border: none; box-shadow: none; padding: 0; }
.sheet-body .section-title {
  font-family: var(--font-display); font-size: 18px; font-weight: 700;
  color: #fff; margin: 2px 40px 18px 2px; letter-spacing: -.01em;
}
.sheet-body label.muted { font-size: 11.5px !important; letter-spacing: .02em; }

/* polished inputs inside the sheet */
.sheet-body input, .sheet-body textarea, .sheet-body select {
  background: rgba(6,16,11,.72) !important;
  border: 1px solid var(--line-strong) !important;
  border-radius: 10px !important;
  color: var(--ink); font-family: inherit; font-size: 13px;
  padding: 9px 11px !important;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.sheet-body input:focus, .sheet-body textarea:focus, .sheet-body select:focus {
  outline: none;
  border-color: var(--accent) !important;
  background: rgba(8,20,14,.95) !important;
  box-shadow: 0 0 0 3px rgba(46,229,157,.16);
}
.sheet-body input::placeholder, .sheet-body textarea::placeholder { color: var(--ink-faint); }

/* display font on headings + brand for a sharper look */
h1, .brand-name, .section-title { font-family: var(--font-display); letter-spacing: -.01em; }

.sheet-body .section-title button { display: none; }  /* sheet has its own ✕ */
