/* components.css: panel, button, input, pill, segmented, kbd, tables — split out of rally.css. */
/* ------------------------------------------------------------
   Panel
   ------------------------------------------------------------ */
.panel {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border: 1px solid var(--line);
  border-radius: var(--r);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(120% 60% at 50% -20%, oklch(0.4 0.04 var(--hue-info) / 0.1), transparent 55%);
  z-index: 0;
}
.panel > * { position: relative; z-index: 1; }
.panel > .panel-head { z-index: 3; }

.panel-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--line);
  min-height: 34px;
  flex-shrink: 0;
}
.panel-head h3 {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
  padding: 0;
  border: 0;
}
.panel-head .sub {
  color: var(--text-4);
  font-size: 10px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
}
.panel-body {
  padding: var(--sp-3) var(--sp-4);
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.panel-body.flush { padding: 0; }
.panel-body.col   { display: flex; flex-direction: column; }

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--ctrl);
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text-2);
  background: oklch(0.2 var(--bg-chroma) var(--bg-hue) / 0.6);
  font-size: 11px;
  line-height: 1;
  transition: all 0.12s ease;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover  { color: var(--text-1); border-color: var(--line-strong); background: var(--bg-2); }
.btn.ghost  { background: transparent; }
.btn.sm     { height: 22px; font-size: 10px; padding: 0 8px; }
.btn.xs     { height: 18px; font-size: 9px;  padding: 0 6px; }
.btn.icon   { padding: 0; width: var(--ctrl); }
.btn.primary {
  background: linear-gradient(180deg, var(--pos-bg), transparent);
  border-color: oklch(0.55 0.12 var(--hue-pos) / 0.6);
  color: var(--pos);
  font-weight: 500;
}
.btn.primary:hover { box-shadow: var(--glow-pos); }
.btn.danger {
  background: linear-gradient(180deg, var(--neg-bg), transparent);
  border-color: oklch(0.55 0.14 var(--hue-neg) / 0.6);
  color: var(--neg);
  font-weight: 500;
}
.btn.danger:hover { box-shadow: var(--glow-neg); }
.btn.info {
  background: linear-gradient(180deg, var(--info-bg), transparent);
  border-color: oklch(0.55 0.12 var(--hue-info) / 0.6);
  color: var(--info);
}
.btn.on {
  color: var(--info);
  border-color: oklch(0.55 0.14 var(--hue-info) / 0.55);
  background: var(--info-bg);
}

/* ------------------------------------------------------------
   Inputs
   ------------------------------------------------------------ */
.input, .select {
  height: var(--ctrl);
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text-1);
  background: oklch(0.12 var(--bg-chroma) var(--bg-hue));
  font-size: 11px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  font-family: inherit;
}
.input:focus, .select:focus {
  border-color: oklch(0.55 0.12 var(--hue-info) / 0.7);
  box-shadow: 0 0 0 3px oklch(0.55 0.12 var(--hue-info) / 0.1);
}
.input.num { font-family: var(--font-mono); }
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 24px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 4 L5 7 L8 4' stroke='%2388929c' stroke-width='1.2' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* ------------------------------------------------------------
   Pills
   ------------------------------------------------------------ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  color: var(--text-2);
  background: oklch(0.18 var(--bg-chroma) var(--bg-hue) / 0.8);
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.pill.pos { color: var(--pos); border-color: oklch(0.55 0.12 var(--hue-pos) / 0.5); }
.pill.pos .dot { background: var(--pos); box-shadow: 0 0 8px var(--pos); }
.pill.neg { color: var(--neg); border-color: oklch(0.55 0.14 var(--hue-neg) / 0.5); }
.pill.neg .dot { background: var(--neg); }
.pill.info { color: var(--info); border-color: oklch(0.55 0.12 var(--hue-info) / 0.55); background: var(--info-bg); }
.pill.info .dot { background: var(--info); }
.pill.warn { color: var(--warn); border-color: oklch(0.55 0.12 85 / 0.5); }

/* ------------------------------------------------------------
   Segmented control
   ------------------------------------------------------------ */
.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  gap: 2px;
  height: var(--ctrl);
}
.segmented button {
  padding: 0 10px;
  font-size: 10px;
  color: var(--text-3);
  border-radius: 3px;
  transition: all 0.12s;
  cursor: pointer;
  background: transparent;
  border: 0;
  font-family: inherit;
}
.segmented button:hover { color: var(--text-1); }
.segmented button.on {
  color: var(--text-1);
  background: var(--bg-3);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

/* ------------------------------------------------------------
   Keyboard hint
   ------------------------------------------------------------ */
.kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text-3);
  background: oklch(0.14 var(--bg-chroma) var(--bg-hue));
}

/* ------------------------------------------------------------
   Tables
   ------------------------------------------------------------ */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  table-layout: auto;
}
table.data th {
  text-align: left;
  font-weight: 500;
  color: var(--text-4);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: oklch(0.16 var(--bg-chroma) var(--bg-hue) / 0.9);
  position: sticky; top: 0; z-index: 1;
  user-select: none;
}
table.data th[data-k] { cursor: pointer; }
table.data td {
  padding: 0 8px;
  height: var(--row);
  border-bottom: 1px solid oklch(0.22 var(--bg-chroma) var(--bg-hue) / 0.35);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* Tabular data is mono by default — every panel showing numbers in a
     table (prices, qty, P&L, durations, dates) reads cleaner with
     fixed-width digits. Stats, Trading, Intelligence already opted in
     locally; this lifts that decision to the global primitive. Screener
     cells that need a different look use cell-level classes (.num is
     already mono, .tk-name overrides etc.). */
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
/* Right-align numeric cells consistently across panels — opt-in via
   class="num" or the legacy class="r" on the <th> / <td>. Both names
   are accepted so existing markup (Stats / Trading use .num,
   Intelligence uses .r in ~96 places) doesn't need bulk renames. */
table.data th.num, table.data td.num,
table.data th.r,   table.data td.r { text-align: right; }
table.data tr:not(:first-child) { cursor: pointer; }
table.data tr:not(:first-child):hover td { background: oklch(0.23 var(--bg-chroma) var(--bg-hue) / 0.5); }
table.data tr.sel td { background: oklch(0.3 0.06 var(--hue-info) / 0.18); }

.pos-c { color: var(--pos); }
.neg-c { color: var(--neg); }
.neu-c { color: var(--text-3); }

/* flashes */
@keyframes flashpos { from { background: oklch(0.4 0.12 var(--hue-pos) / 0.5); } to { background: transparent; } }
@keyframes flashneg { from { background: oklch(0.4 0.14 var(--hue-neg) / 0.5); } to { background: transparent; } }
.flash-pos td { animation: flashpos 0.8s ease-out; }
.flash-neg td { animation: flashneg 0.8s ease-out; }

