/* ════════════════════════════════════════════════
   TOKENS
════════════════════════════════════════════════ */
:root {
  --bg:           #f0f4f8;
  --surface:      #ffffff;
  --surface-2:    #f5f8fc;
  --surface-3:    #eaf1f8;
  --border:       #d8e3ef;
  --border-h:     #a8c0d8;

  --blue:         #1a5fad;
  --blue-mid:     #2271c3;
  --blue-dim:     rgba(26,95,173,.09);
  --blue-glow:    rgba(26,95,173,.2);

  --green:        #0d7c4b;
  --green-dim:    rgba(13,124,75,.09);
  --amber:        #b45309;
  --amber-dim:    rgba(180,83,9,.09);
  --red:          #c2252b;
  --red-dim:      rgba(194,37,43,.09);

  --text:         #162035;
  --text-2:       #3d5470;
  --text-3:       #7a96b4;

  --ml:           #9a6f00;
  --amz:          #b55000;
  --shopee:       #b52020;
  --ali:          #a01818;
  --vd:           #0d7c4b;

  --radius:       14px;
  --radius-sm:    9px;
  --radius-xs:    6px;
  --nav-h:        60px;
  --t:            180ms cubic-bezier(.4,0,.2,1);

  --font:         'DM Sans', sans-serif;
  --font-d:       'Syne', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --shadow-sm:    0 1px 4px rgba(0,20,60,.07);
  --shadow:       0 3px 14px rgba(0,20,60,.1);
  --shadow-lg:    0 8px 32px rgba(0,20,60,.13);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-top: var(--nav-h);
  background-image:
    radial-gradient(ellipse 80% 40% at 50% 0, rgba(26,95,173,.05) 0%, transparent 65%),
    repeating-linear-gradient(0deg,   transparent 0, transparent 39px, rgba(180,205,225,.4) 40px),
    repeating-linear-gradient(90deg,  transparent 0, transparent 39px, rgba(180,205,225,.4) 40px);
}

/* ════════════════════════════════════════════════
   NAV BAR
════════════════════════════════════════════════ */
.app-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: var(--nav-h);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 24px;
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  text-decoration: none;
}

.nav-brand-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--blue-mid));
  display: grid; place-items: center; font-size: 16px;
  box-shadow: 0 2px 8px var(--blue-glow);
}

.nav-brand-name {
  font-family: var(--font-d); font-size: 1.2rem; font-weight: 800;
  background: linear-gradient(90deg, var(--text) 40%, var(--blue));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.nav-tools {
  display: flex; align-items: center; gap: 4px; overflow-x: auto;
  scrollbar-width: none; flex: 1;
}
.nav-tools::-webkit-scrollbar { display: none; }

.nav-tool-btn {
  font-family: var(--font); font-size: .78rem; font-weight: 600;
  padding: 6px 14px; border-radius: 20px; border: none;
  background: transparent; color: var(--text-2);
  cursor: pointer; transition: all var(--t); white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}

.nav-tool-btn:hover { background: var(--surface-3); color: var(--text); }
.nav-tool-btn.active { background: var(--blue-dim); color: var(--blue); }

.nav-tool-btn .tool-icon { font-size: .9rem; }

.nav-actions { display: flex; gap: 8px; flex-shrink: 0; }

.nav-btn {
  font-family: var(--font); font-size: .75rem; font-weight: 600;
  padding: 6px 12px; border-radius: var(--radius-xs);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; transition: all var(--t);
  display: flex; align-items: center; gap: 5px;
}
.nav-btn:hover { border-color: var(--border-h); color: var(--text); background: var(--surface-2); }

/* ════════════════════════════════════════════════
   SHELL
════════════════════════════════════════════════ */
.app-shell { max-width: 1160px; margin: 0 auto; padding: 32px 24px 80px; }

/* ════════════════════════════════════════════════
   TOOLS (sections)
════════════════════════════════════════════════ */
.tool-section { display: none; }
.tool-section.active { display: block; animation: fadeIn .22s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ════════════════════════════════════════════════
   TOOL HEADER
════════════════════════════════════════════════ */
.tool-header { margin-bottom: 28px; }
.tool-title { font-family: var(--font-d); font-size: 1.45rem; font-weight: 800; color: var(--text); }
.tool-desc  { font-size: .85rem; color: var(--text-3); margin-top: 4px; }

/* ════════════════════════════════════════════════
   CARD
════════════════════════════════════════════════ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  margin-bottom: 16px; box-shadow: var(--shadow-sm);
  transition: border-color var(--t), box-shadow var(--t);
}
.card:hover { border-color: var(--border-h); box-shadow: var(--shadow); }

.card-title {
  font-family: var(--font-d); font-size: .7rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--text-3);
  margin-bottom: 18px; display: flex; align-items: center; gap: 10px;
}
.card-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.step-badge {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--blue-dim); border: 1px solid var(--blue);
  display: inline-grid; place-items: center;
  font-size: .65rem; font-weight: 800; color: var(--blue);
  font-family: var(--font-mono); flex-shrink: 0;
}

/* ════════════════════════════════════════════════
   INPUT SYSTEM
════════════════════════════════════════════════ */
.input-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.input-grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }

.input-group { display: flex; flex-direction: column; gap: 5px; }

.input-group label {
  font-size: .73rem; font-weight: 600; color: var(--text-2);
  letter-spacing: .03em; display: flex; align-items: center; gap: 5px;
}

.input-wrap { position: relative; }

/* ── Prefix/suffix via flex (never overlaps) ── */
.input-addon {
  display: flex; align-items: stretch;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
  overflow: hidden;
}
.input-addon:focus-within {
  border-color: var(--blue); background: #fff;
  box-shadow: 0 0 0 3px var(--blue-dim);
}
.input-addon-pfx,
.input-addon-sfx {
  display: flex; align-items: center;
  padding: 0 10px;
  font-family: var(--font-mono); font-size: .72rem;
  color: var(--text-3); white-space: nowrap;
  background: var(--surface-3);
  border-right: 1px solid var(--border);
  flex-shrink: 0; user-select: none;
  line-height: 1;
}
.input-addon-sfx {
  border-right: none; border-left: 1px solid var(--border);
}
.input-addon input[type="number"] {
  flex: 1; border: none !important; border-radius: 0 !important;
  background: transparent !important; box-shadow: none !important;
  outline: none; padding: 9px 10px;
  font-family: var(--font-mono); font-size: .85rem; color: var(--text);
  width: 0; min-width: 0;
  -moz-appearance: textfield;
}
.input-addon input[type="number"]:focus { box-shadow: none !important; }
.input-addon input::-webkit-outer-spin-button,
.input-addon input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* Keep old pfx/sfx classes as no-op so nothing breaks */
.pfx, .sfx { display: none; }
.has-pfx input, .has-sfx input { padding-left: 10px; padding-right: 10px; }

input[type="number"], input[type="text"], select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--font-mono); font-size: .85rem;
  padding: 9px 11px; outline: none;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
  -moz-appearance: textfield;
  box-shadow: inset 0 1px 3px rgba(0,20,60,.05);
}
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; }

input:focus, select:focus, textarea:focus {
  border-color: var(--blue); background: #fff;
  box-shadow: 0 0 0 3px var(--blue-dim);
}

select {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a96b4' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
  padding-right: 30px;
}

/* ════════════════════════════════════════════════
   TABS (platform / mode)
════════════════════════════════════════════════ */
.tab-strip { display: flex; gap: 6px; flex-wrap: wrap; }

.tab-btn {
  font-family: var(--font); font-size: .78rem; font-weight: 600;
  padding: 7px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-2); cursor: pointer; transition: all var(--t);
  white-space: nowrap; display: flex; align-items: center; gap: 6px;
}
.tab-btn:hover { color: var(--text); border-color: var(--border-h); background: var(--surface-2); }
.tab-btn.active { color: var(--blue); border-color: var(--blue); background: var(--blue-dim); }
.tab-btn[data-platform="ml"].active    { color:var(--ml);    border-color:var(--ml);    background:rgba(154,111,0,.07); }
.tab-btn[data-platform="amazon"].active{ color:var(--amz);   border-color:var(--amz);   background:rgba(181,80,0,.07); }
.tab-btn[data-platform="shopee"].active{ color:var(--shopee);border-color:var(--shopee);background:rgba(181,32,32,.07); }
.tab-btn[data-platform="aliexpress"].active{color:var(--ali);border-color:var(--ali);   background:rgba(160,24,24,.07); }
.tab-btn[data-platform="vd"].active    { color:var(--vd);    border-color:var(--vd);    background:rgba(13,124,75,.07); }
.tab-btn[data-platform="all"].active   { color:var(--blue);  border-color:var(--blue);  background:var(--blue-dim); }

/* ════════════════════════════════════════════════
   PLATFORM INPUT SECTIONS
════════════════════════════════════════════════ */
.platform-section {
  display: none; margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border);
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px;
}
.platform-section.active { display: grid; }

/* ════════════════════════════════════════════════
   CTA BUTTON
════════════════════════════════════════════════ */
.cta-btn {
  width: 100%; margin-top: 18px; padding: 13px 28px;
  background: linear-gradient(135deg, var(--blue), var(--blue-mid));
  border: none; border-radius: var(--radius-sm); color: #fff;
  font-family: var(--font-d); font-size: .9rem; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; cursor: pointer;
  transition: all var(--t); box-shadow: 0 4px 16px var(--blue-glow);
}
.cta-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 24px var(--blue-glow); }
.cta-btn:active { transform: none; }

.btn-sm {
  font-family: var(--font); font-size: .75rem; font-weight: 600;
  padding: 6px 12px; border-radius: var(--radius-xs);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; transition: all var(--t);
}
.btn-sm:hover { border-color: var(--border-h); color: var(--text); }
.btn-sm.danger { border-color: #fca5a5; color: var(--red); background: var(--red-dim); }
.btn-sm.primary { border-color: var(--blue); color: var(--blue); background: var(--blue-dim); }

/* ════════════════════════════════════════════════
   KPI STRIP
════════════════════════════════════════════════ */
.kpi-strip {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 20px;
}

.kpi-chip {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  box-shadow: var(--shadow-sm); transition: all var(--t);
}
.kpi-chip:hover { box-shadow: var(--shadow); border-color: var(--border-h); }
.kpi-chip-label { font-size: .67rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; }
.kpi-chip-value { font-family: var(--font-mono); font-size: 1.1rem; font-weight: 700; color: var(--text); margin-top: 4px; }
.kpi-chip-sub   { font-size: .68rem; color: var(--text-3); margin-top: 2px; }

/* ════════════════════════════════════════════════
   RESULTS GRID & CARDS
════════════════════════════════════════════════ */
#results-section { display: none; }
#results-section.visible { display: block; animation: fadeIn .25s ease; }

.results-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
}
.results-title { font-family: var(--font-d); font-size: 1.1rem; font-weight: 700; }
.results-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }

.result-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t), box-shadow var(--t);
  animation: cardIn .3s ease both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.result-card:nth-child(2) { animation-delay: .05s; }
.result-card:nth-child(3) { animation-delay: .10s; }
.result-card:nth-child(4) { animation-delay: .15s; }
.result-card:nth-child(5) { animation-delay: .20s; }
.result-card:nth-child(6) { animation-delay: .25s; }
.result-card:nth-child(7) { animation-delay: .30s; }
.result-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.rc-head {
  padding: 16px 18px 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.rc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.rc-name { font-family: var(--font-d); font-size: .88rem; font-weight: 700; }

.rc-body { padding: 14px 18px; flex: 1; }

.cost-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 0; border-bottom: 1px solid rgba(180,205,225,.5);
  gap: 8px;
}
.cost-row:last-child { border: none; }
.cost-label { font-size: .75rem; color: var(--text-2); flex: 1; }
.cost-right { display: flex; align-items: baseline; gap: 8px; flex-shrink: 0; }
.cost-val { font-family: var(--font-mono); font-size: .8rem; font-weight: 500; color: var(--text); }
.cost-pct { font-family: var(--font-mono); font-size: .68rem; color: var(--text-3); min-width: 42px; text-align: right; }

.rc-foot { border-top: 1px solid var(--border); }
.total-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 11px 18px; background: var(--surface-2); gap: 8px;
}
.total-label { font-size: .78rem; font-weight: 600; color: var(--text-2); }
.total-right { display: flex; gap: 8px; align-items: baseline; }
.total-val { font-family: var(--font-mono); font-size: .88rem; font-weight: 700; color: var(--text); }
.total-pct { font-family: var(--font-mono); font-size: .68rem; color: var(--text-3); }

.margin-block { padding: 12px 18px; }
.margin-top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.margin-label  { font-size: .75rem; font-weight: 600; color: var(--text-2); }
.margin-val-group { display: flex; align-items: center; gap: 8px; }
.margin-val { font-family: var(--font-mono); font-size: 1rem; font-weight: 700; }
.margin-badge { font-size: .62rem; font-weight: 700; padding: 2px 7px; border-radius: 4px; letter-spacing: .05em; }

.margin-bar { height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.margin-fill { height: 100%; border-radius: 3px; transition: width .5s cubic-bezier(.4,0,.2,1); }

.good  { color: var(--green); }
.warn  { color: var(--amber); }
.bad   { color: var(--red); }
.bg-good { background: var(--green-dim); color: var(--green); }
.bg-warn { background: var(--amber-dim); color: var(--amber); }
.bg-bad  { background: var(--red-dim);   color: var(--red); }
.fill-good { background: linear-gradient(90deg, var(--green), #16a34a); }
.fill-warn { background: linear-gradient(90deg, var(--amber), #d97706); }
.fill-bad  { background: linear-gradient(90deg, var(--red),   #e04040); }

.extra-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 18px 12px; font-size: .72rem; color: var(--text-3);
}
.extra-val { font-family: var(--font-mono); font-size: .72rem; font-weight: 500; color: var(--text-2); }

/* Price computed mode */
.price-block {
  padding: 12px 18px;
  display: flex; justify-content: space-between; align-items: center;
}
.price-label { font-size: .75rem; color: var(--text-2); font-weight: 600; }
.price-val   { font-family: var(--font-mono); font-size: 1.1rem; font-weight: 700; color: var(--blue); }

/* ════════════════════════════════════════════════
   TOOLTIPS
════════════════════════════════════════════════ */
.tip { position: relative; cursor: help; }
.tip-icon {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface-3); border: 1px solid var(--border-h);
  display: inline-grid; place-items: center;
  font-size: .58rem; color: var(--text-3); font-style: normal; font-weight: 700;
}
.tip-box {
  display: none; position: absolute; bottom: calc(100% + 7px); left: 0;
  background: var(--text); color: #fff; border-radius: var(--radius-xs);
  padding: 8px 12px; font-size: .7rem; line-height: 1.45;
  white-space: nowrap; max-width: 240px; white-space: normal;
  font-weight: 400; font-family: var(--font); z-index: 500;
  box-shadow: var(--shadow-lg); pointer-events: none; width: 220px;
}
.tip:hover .tip-box { display: block; }

/* ════════════════════════════════════════════════
   TOOL 2 — BREAK-EVEN
════════════════════════════════════════════════ */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .two-col { grid-template-columns: 1fr; } }

.fixed-cost-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

.fixed-cost-row {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-xs); padding: 8px 10px;
  animation: fadeIn .18s ease;
}
.fixed-cost-row input[type="text"]   { flex: 2; font-size: .82rem; font-family: var(--font); }
.fixed-cost-row input[type="number"] { flex: 1; }
.fixed-cost-row .rm-btn {
  background: none; border: none; color: var(--text-3);
  cursor: pointer; font-size: 1rem; padding: 0 4px; transition: color var(--t);
}
.fixed-cost-row .rm-btn:hover { color: var(--red); }

/* BE results panel */
.be-results { display: none; }
.be-results.visible { display: block; }

.be-kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px; margin-bottom: 20px;
}

.be-kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
  box-shadow: var(--shadow-sm); text-align: center;
}
.be-kpi-icon  { font-size: 1.4rem; margin-bottom: 6px; }
.be-kpi-label { font-size: .68rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; }
.be-kpi-val   { font-family: var(--font-mono); font-size: 1.15rem; font-weight: 700; color: var(--text); margin-top: 4px; }
.be-kpi-sub   { font-size: .7rem; color: var(--text-3); margin-top: 2px; }

/* Scenario table */
.be-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.be-table thead th {
  background: var(--surface-2); padding: 10px 14px;
  text-align: left; font-weight: 600; color: var(--text-2);
  border-bottom: 2px solid var(--border); font-size: .75rem;
  letter-spacing: .04em;
}
.be-table tbody td {
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: .8rem;
}
.be-table tbody tr:hover { background: var(--surface-2); }
.be-table .highlight td { background: var(--blue-dim); font-weight: 600; }
.be-table .be-label { font-family: var(--font); font-size: .78rem; color: var(--text-2); }

/* Progress visual bar */
.be-visual { margin: 20px 0; }
.be-bar-wrap { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 18px; }
.be-bar-title { font-size: .75rem; font-weight: 600; color: var(--text-2); margin-bottom: 12px; }
.be-bar-stack { height: 32px; border-radius: 6px; overflow: hidden; display: flex; }
.be-bar-fixed { background: linear-gradient(90deg, #93c5fd, var(--blue)); transition: width .5s ease; }
.be-bar-var   { background: linear-gradient(90deg, var(--amber), #f59e0b); transition: width .5s ease; }
.be-bar-margin{ background: linear-gradient(90deg, var(--green), #16a34a); transition: width .5s ease; }
.be-bar-legend { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: .72rem; color: var(--text-2); }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

/* ════════════════════════════════════════════════
   TOOL 3 — DISCOUNT SIMULATOR
════════════════════════════════════════════════ */
.disc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .disc-grid { grid-template-columns: 1fr; } }

.slider-group { display: flex; flex-direction: column; gap: 8px; }
.slider-row { display: flex; align-items: center; gap: 12px; }
input[type="range"] {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 3px; background: var(--border);
  outline: none; cursor: pointer; transition: background var(--t);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--blue); box-shadow: 0 2px 6px var(--blue-glow); cursor: pointer;
}
input[type="range"]:hover { background: var(--border-h); }

.slider-val-box {
  width: 56px; text-align: center;
  font-family: var(--font-mono); font-size: .88rem; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-xs); padding: 5px 0; color: var(--text);
}

.disc-result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 16px; }

.disc-chip {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.disc-chip-label { font-size: .68rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.disc-chip-val   { font-family: var(--font-mono); font-size: 1.1rem; font-weight: 700; margin-top: 4px; }
.disc-chip-delta { font-size: .72rem; margin-top: 3px; font-weight: 500; }
.delta-neg { color: var(--red); }
.delta-pos { color: var(--green); }
.delta-neu { color: var(--text-3); }

/* Comparison visual */
.disc-compare { display: flex; gap: 16px; align-items: flex-end; margin-top: 10px; }
.disc-bar-group { flex: 1; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.disc-bar-label { font-size: .7rem; color: var(--text-3); font-weight: 600; }
.disc-bar-outer { width: 100%; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.disc-bar-inner { height: 100px; border-radius: 4px; transition: height .4s ease, background .3s; }
.disc-price-label { font-family: var(--font-mono); font-size: .8rem; font-weight: 600; color: var(--text); }

/* ════════════════════════════════════════════════
   TOOL 4 — CMP (Custo Médio Ponderado)
════════════════════════════════════════════════ */
.lot-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.lot-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr auto;
  gap: 8px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-xs); padding: 10px 12px;
  animation: fadeIn .18s ease;
}
.lot-row .lot-num { font-family: var(--font-mono); font-size: .7rem; font-weight: 700; color: var(--text-3); text-align: center; }

.cmp-result {
  display: none; background: linear-gradient(135deg, var(--blue-dim), rgba(26,95,173,.04));
  border: 1.5px solid var(--blue); border-radius: var(--radius-sm);
  padding: 20px 24px; text-align: center;
}
.cmp-result.visible { display: block; animation: fadeIn .25s ease; }
.cmp-result-label { font-size: .75rem; font-weight: 600; color: var(--blue); text-transform: uppercase; letter-spacing: .07em; }
.cmp-result-val   { font-family: var(--font-mono); font-size: 2rem; font-weight: 700; color: var(--blue); margin: 6px 0; }
.cmp-result-sub   { font-size: .78rem; color: var(--text-2); }

.cmp-lot-table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: .8rem; }
.cmp-lot-table th { background: var(--surface-2); padding: 8px 12px; text-align: right; font-weight: 600; color: var(--text-2); font-size: .72rem; border-bottom: 1px solid var(--border); }
.cmp-lot-table th:first-child { text-align: left; }
.cmp-lot-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: right; font-family: var(--font-mono); }
.cmp-lot-table td:first-child { text-align: left; font-family: var(--font); color: var(--text-2); font-size: .78rem; }
.cmp-lot-table tfoot td { font-weight: 700; background: var(--surface-2); }

/* ════════════════════════════════════════════════
   TOOL 5 — HISTÓRICO
════════════════════════════════════════════════ */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; box-shadow: var(--shadow-sm);
  transition: border-color var(--t); cursor: pointer;
  animation: fadeIn .2s ease;
}
.history-item:hover { border-color: var(--border-h); }
.history-meta { font-size: .7rem; color: var(--text-3); margin-top: 3px; }
.history-name { font-size: .85rem; font-weight: 600; color: var(--text); }
.history-kpis { display: flex; gap: 12px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.history-kpi-item { text-align: right; }
.history-kpi-label { font-size: .65rem; color: var(--text-3); }
.history-kpi-val   { font-family: var(--font-mono); font-size: .82rem; font-weight: 600; }
.history-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.history-empty { text-align: center; padding: 48px; color: var(--text-3); font-size: .875rem; }
.history-empty-icon { font-size: 2rem; margin-bottom: 10px; }

/* ════════════════════════════════════════════════
   TOAST
════════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--blue); border-radius: var(--radius-sm);
  padding: 11px 16px; font-size: .8rem; font-weight: 500;
  box-shadow: var(--shadow-lg); color: var(--text);
  display: flex; align-items: center; gap: 8px;
  transform: translateY(20px); opacity: 0; pointer-events: none;
  transition: all .25s cubic-bezier(.4,0,.2,1);
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ════════════════════════════════════════════════
   LIVE PILL
════════════════════════════════════════════════ */
.live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px; font-size: .69rem; color: var(--text-3);
  margin-bottom: 24px; box-shadow: var(--shadow-sm);
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 5px var(--green); animation: blink 2s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ════════════════════════════════════════════════
   DIVIDER
════════════════════════════════════════════════ */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .app-shell { padding: 24px 14px 60px; }
  .kpi-strip { grid-template-columns: 1fr 1fr; }
  .results-grid { grid-template-columns: 1fr; }
  .disc-grid { grid-template-columns: 1fr; }
  .lot-row { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; }
}

/* ════════════════════════════════════════════════
   SECTION LABEL (decorative)
════════════════════════════════════════════════ */
.section-label {
  font-size: .7rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-3);
  margin: 24px 0 10px; display: flex; align-items: center; gap: 10px;
}
.section-label::before, .section-label::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* Calc mode toggle */
.mode-toggle { display: flex; gap: 6px; margin-bottom: 0; }

/* Info banner */
.info-banner {
  background: var(--blue-dim); border: 1px solid rgba(26,95,173,.2);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: .78rem; color: var(--blue); display: flex; gap: 10px;
  align-items: flex-start; margin-bottom: 16px;
}
.info-banner .info-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

/* Mode explanation cards */
.mode-explainer {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0;
}
@media (max-width: 560px) { .mode-explainer { grid-template-columns: 1fr; } }

.mode-card {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; cursor: pointer; transition: all var(--t);
  background: var(--surface-2); position: relative; overflow: hidden;
}
.mode-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--border);
  transition: background var(--t);
}
.mode-card.mode-card-active { border-color: var(--blue); background: var(--surface); box-shadow: 0 2px 12px var(--blue-glow); }
.mode-card.mode-card-active::before { background: linear-gradient(90deg, var(--blue), #4da6ff); }
.mode-card:hover:not(.mode-card-active) { border-color: var(--border-h); background: var(--surface); }

.mc-icon { font-size: 1.5rem; margin-bottom: 8px; }
.mc-title {
  font-family: var(--font-d); font-size: .88rem; font-weight: 700;
  color: var(--text); margin-bottom: 5px; display: flex; align-items: center; gap: 8px;
}
.mc-badge {
  font-size: .6rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  background: var(--blue-dim); color: var(--blue); border-radius: 4px; padding: 2px 7px;
}
.mode-card-active .mc-badge { background: var(--blue); color: #fff; }

.mc-desc { font-size: .77rem; color: var(--text-2); line-height: 1.55; margin-bottom: 10px; }

.mc-formula {
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-family: var(--font-mono); font-size: .72rem; color: var(--text-2);
  line-height: 1.6;
}
.mc-formula strong { color: var(--blue); font-weight: 600; }

.mc-example {
  margin-top: 10px; padding: 8px 10px; background: rgba(26,95,173,.04);
  border-left: 2px solid var(--blue); border-radius: 0 4px 4px 0;
  font-size: .72rem; color: var(--text-2); line-height: 1.5;
}
.mc-example strong { color: var(--text); }

/* Import from calc button */
.import-btn {
  font-size: .75rem; font-weight: 600; color: var(--blue);
  background: var(--blue-dim); border: 1px solid rgba(26,95,173,.25);
  border-radius: var(--radius-xs); padding: 5px 10px;
  cursor: pointer; transition: all var(--t);
}
.import-btn:hover { background: rgba(26,95,173,.14); }