/* KALMAT Screener — extras.css
   Advanced-feature styles: command palette (Ctrl+K), compare overlay,
   trade-plan calculator. Consumes the design tokens declared in style.css;
   never redeclares tokens and never restyles core components. */

/* ================= Command palette (Ctrl+K / Cmd+K) ================= */

.cmdk{
  position: fixed;
  inset: 0;
  z-index: 290; /* above gate/search overlays, below toast (300) */
  background: rgba(9,14,22,.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
}
:root[data-theme="light"] .cmdk{ background: rgba(20,32,45,.35); }
.cmdk-panel{
  width: min(580px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: cmdk-in .14s ease-out;
}
@keyframes cmdk-in{
  from{ opacity: 0; transform: translateY(-8px) scale(.985); }
  to{ opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce){
  .cmdk-panel{ animation: none; }
}
.cmdk-bar{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.cmdk-ic{
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
}
.cmdk-bar input{
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
.cmdk-bar input::placeholder{ color: var(--faint); }
.cmdk-kbd{
  font: 600 10.5px/1 var(--mono);
  color: var(--faint);
  border: 1px solid var(--border-2);
  border-radius: 5px;
  padding: 3px 5px;
  text-transform: uppercase;
}
.cmdk-list{
  max-height: min(56vh, 460px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
}
.cmdk-hd{
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 9px 10px 4px;
}
.cmdk-row{
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 9px;
  padding: 9px 10px;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.cmdk-row:hover{ background: var(--surface-2); }
.cmdk-row.sel{
  background: var(--accent-wash);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.cmdk-ric{
  flex: 0 0 22px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.cmdk-row.sel .cmdk-ric{ color: var(--accent-ink); }
.cmdk-lbl{
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmdk-lbl b{ font-weight: 650; }
.cmdk-sym{
  color: var(--muted);
  font: 600 11px/1 var(--mono);
  margin-left: 4px;
}
.cmdk-hint{
  flex: none;
  color: var(--faint);
  font-size: 11.5px;
}
.cmdk-none{
  padding: 22px 14px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}
@media (max-width: 560px){
  .cmdk{ padding: 8vh 8px 8px; }
  .cmdk-kbd{ display: none; }
}

/* ==================== Compare overlay (.fsov.cmpov) ==================== */

.cmpov{ padding: 18px; }
.cmpov .fsin.cmpin{
  width: min(900px, 100%);
  height: auto;
  max-height: 94vh;
}
.cmpbody{
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px 20px;
}
.cmphead{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.cmpchips{
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cmpchip{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink);
}
.cmpchip.cmpme{
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.cmpdrop{
  background: none;
  border: 0;
  color: var(--faint);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  border-radius: 4px;
}
.cmpdrop:hover{ color: var(--red); }
.cmpaddw{ position: relative; }
.cmpaddw .cmpq{
  width: 180px;
  height: 32px;
  font-size: 13px;
}
.cmphits{
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  width: min(300px, 74vw);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.cmphit{
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.cmphit:hover,
.cmphit:focus-visible{ background: var(--accent-wash); }
.cmphit b{ font-weight: 650; }
.cmpnone{ padding: 8px 10px; font-size: 12.5px; }
.cmpsegs{ flex: none; }
.cmpchart{
  background: var(--ch-paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px 4px;
  margin-bottom: 14px;
  min-height: 160px;
}
.cmptbl{
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cmptbl th,
.cmptbl td{
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}
.cmptbl thead th{
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.cmptbl tbody th{
  text-align: left;
  font-weight: 500;
  color: var(--muted);
}
.cmptbl tbody tr:last-child th,
.cmptbl tbody tr:last-child td{ border-bottom: 0; }
@media (max-width: 560px){
  .cmpov{ padding: 0; }
  .cmpov .fsin.cmpin{
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    border: 0;
  }
  .cmpbody{ padding: 10px 12px 16px; }
  .cmpaddw .cmpq{ width: 140px; }
}

/* ============== Trade-plan calculator (drawer trade panel) ============== */

.tplan{ padding: 4px 0 8px; }
.tpnote{ font-size: 12.5px; margin: 6px 0 12px; }
.tpgrid{
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.tpfield{ display: block; min-width: 0; }
.tpfield .eyebrow{ display: block; margin-bottom: 4px; }
.tpwrap{
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 9px;
  padding: 0 10px;
  height: 38px;
}
.tpwrap:focus-within{
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-wash);
}
.tpwrap i{
  font-style: normal;
  color: var(--faint);
  font-size: 12px;
  flex: none;
}
.tpwrap .tpin{
  flex: 1;
  min-width: 0;
  width: 100%;
  background: none;
  border: 0;
  outline: none;
  color: var(--ink);
  font: 650 14px/1.2 var(--mono);
  -moz-appearance: textfield;
  appearance: textfield;
}
.tpwrap .tpin::-webkit-outer-spin-button,
.tpwrap .tpin::-webkit-inner-spin-button{ -webkit-appearance: none; margin: 0; }
.dstats.tpstats{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.tpstats .muted{ display: block; font-size: 11.5px; margin-top: 2px; }
.tptbl{
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tptbl th,
.tptbl td{
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.tptbl thead th{
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}
.tptbl thead th.num{ text-align: right; }
.tptbl td.num{
  text-align: right;
  font-family: var(--mono);
  white-space: nowrap;
}
.tptbl tbody tr:last-child td{ border-bottom: 0; }
.tpcap{ font-size: 12px; margin-top: 8px; }
@media (max-width: 700px){
  .tpgrid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Compare button in the drawer header: keep the glyph readable */
.cmpbtn span{ margin-right: 2px; }
@media (max-width: 640px){
  .cmpbtn{ padding-left: 8px; padding-right: 8px; }
}

/* ========== "Describe it" NL builder (screen editor drawer) ========== */

.scrnl{ margin: 0 0 16px; }
.scrnl .eyebrow{ margin-bottom: 6px; }
.scrnl-row{
  display: flex;
  gap: 8px;
  align-items: center;
}
.scrnl-in{
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 9px;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
}
.scrnl-in::placeholder{ color: var(--faint); }
.scrnl-in:focus{
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-wash);
}
.scrnl-hint{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 8px 0 0;
  font-size: 12px;
}
.scrnl-ex{
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scrnl-echo{
  margin: 8px 0 0;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.5;
}
.scrnl-echo .ig{ color: var(--faint); }
.scrnl-apply{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
}
.scrnl-ind{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 8px 0 0;
  font-size: 12px;
}

/* ===== Concentration guard (risk panel + tomorrow's-orders card) =====
   Amber at ≥60% in one industry group, red at ≥80% — informational only. */
.concwarn{
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 0 4px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.5;
}
.concwarn.amber{
  background: var(--wash-amber);
  color: var(--gold-ink);
}
.concwarn.red{
  background: var(--wash-red);
  color: var(--red);
}
.concwarn .faint{ color: inherit; opacity: .75; }

/* ================ Header market switcher (.mktsw IN | US) ================ */
/* Compact segmented pill, left of the account chip; core.js builds it.
   Uses design tokens only, so it follows both themes automatically. */
.mktsw{
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  padding: 2px;
  margin-right: 10px;
}
.mktsw button{
  border: 0;
  background: none;
  color: var(--muted);
  font: 700 10.5px/1 var(--mono);
  letter-spacing: .05em;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .12s ease, background .12s ease;
}
.mktsw button:hover{ color: var(--ink); }
.mktsw button:focus-visible{
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-wash);
}
.mktsw button.on{
  background: var(--accent-wash);
  color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px var(--accent);
  cursor: default;
}
:root[data-theme="light"] .mktsw{ background: var(--surface); }
@media (max-width: 560px){
  .mktsw{ margin-right: 6px; }
  .mktsw button{ padding: 5px 7px; }
}
