/* Adapted from Holdings_Dashboard_Starter_Kit/dashboard_template.html, scoped under
   #holdings-dashboard so it doesn't leak into the surrounding Bootstrap layout. Keeps its own
   light/dark variables since this component is visually self-contained. */
#holdings-dashboard {
  --surface-1: #fcfcfb; --page: #f9f9f7; --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --border: rgba(11, 11, 11, 0.10);
  --good: #006300; --bad: #d03b3b;
  --c1: #2a78d6; --c2: #1baf7a; --c3: #eda100; --c4: #4a3aa7; --c5: #e34948; --c6: #e87ba4;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  #holdings-dashboard {
    --surface-1: #1a1a19; --page: #0d0d0d; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --border: rgba(255, 255, 255, 0.10);
    --good: #0ca30c; --bad: #e66767;
    --c1: #3987e5; --c2: #199e70; --c3: #c98500; --c4: #9085e9; --c5: #e66767; --c6: #d55181;
  }
}
#holdings-dashboard h2 {
  font-size: 13px; font-weight: 600; color: var(--ink-2); text-transform: uppercase;
  letter-spacing: .04em; margin: 26px 0 10px;
}
#holdings-dashboard .hd-topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
#holdings-dashboard .hd-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#holdings-dashboard .hd-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
#holdings-dashboard button, #holdings-dashboard select, #holdings-dashboard input[type=text] {
  font: inherit; color: var(--ink); background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
#holdings-dashboard button:hover { border-color: var(--muted); }
#holdings-dashboard .hd-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 16px; }
#holdings-dashboard .hd-tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
#holdings-dashboard .hd-tile .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
#holdings-dashboard .hd-tile .val { font-size: 22px; font-weight: 650; margin-top: 4px; }
#holdings-dashboard .hd-tile .d { font-size: 12px; margin-top: 2px; color: var(--ink-2); }
#holdings-dashboard .up { color: var(--good); } #holdings-dashboard .dn { color: var(--bad); }
#holdings-dashboard .hd-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-top: 10px; }
#holdings-dashboard .hd-expbar { display: flex; height: 34px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--page); }
#holdings-dashboard .hd-expbar div { position: relative; min-width: 2px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; }
#holdings-dashboard .hd-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
#holdings-dashboard .hd-legend span { display: inline-flex; align-items: center; gap: 6px; }
#holdings-dashboard .hd-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
#holdings-dashboard table { width: 100%; border-collapse: collapse; }
#holdings-dashboard th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--grid); cursor: pointer; user-select: none; white-space: nowrap; }
#holdings-dashboard th:first-child, #holdings-dashboard td:first-child { text-align: left; }
#holdings-dashboard th.asc::after { content: " \2191"; } #holdings-dashboard th.desc::after { content: " \2193"; }
#holdings-dashboard td { padding: 6px 8px; border-bottom: 1px solid var(--grid); text-align: right; font-variant-numeric: tabular-nums; }
#holdings-dashboard tr:hover td { background: color-mix(in srgb, var(--c1) 6%, transparent); }
#holdings-dashboard td .sym { font-weight: 600; }
#holdings-dashboard .hd-badge { font-size: 10px; padding: 1px 6px; border-radius: 99px; border: 1px solid var(--border); color: var(--muted); margin-left: 6px; vertical-align: 1px; }
#holdings-dashboard .hd-badge.live { color: var(--good); border-color: var(--good); }
#holdings-dashboard .hd-badge.long { color: var(--c2); border-color: var(--c2); }
#holdings-dashboard .hd-badge.short { color: var(--c3); border-color: var(--c3); }
#holdings-dashboard .hd-badge.manual { color: var(--c4); border-color: var(--c4); cursor: help; }
#holdings-dashboard .hd-badge.group { color: var(--c1); border-color: var(--c1); }
#holdings-dashboard tr.hd-expandable { cursor: pointer; }
#holdings-dashboard .hd-expand-mark { display: inline-block; width: 12px; color: var(--muted); font-size: 10px; }
#holdings-dashboard tr.hd-lot-detail td { padding: 0; background: var(--page); border-bottom: 1px solid var(--grid); }
#holdings-dashboard .hd-lot-table { width: 100%; }
#holdings-dashboard .hd-lot-table td { border-bottom: 1px solid var(--border); text-align: left; padding: 5px 8px 5px 28px; font-size: 12.5px; }
#holdings-dashboard .hd-lot-table tr:last-child td { border-bottom: none; }
#holdings-dashboard .hd-lot-date { color: var(--ink-2); display: inline-block; min-width: 90px; }
#holdings-dashboard .hd-lot-qty { display: inline-block; min-width: 140px; font-variant-numeric: tabular-nums; }
#holdings-dashboard .hd-lot-basis { display: inline-block; min-width: 220px; font-variant-numeric: tabular-nums; }
#holdings-dashboard .hd-lot-subtotal td { font-weight: 650; border-top: 1px solid var(--muted); }
#holdings-dashboard .hd-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
#holdings-dashboard .hd-filters input { font-size: 12px; padding: 5px 9px; }
#holdings-dashboard .hd-exp-toggle { display: flex; gap: 6px; margin-bottom: 10px; }
#holdings-dashboard .hd-exp-toggle button { font-size: 12px; padding: 4px 10px; }
#holdings-dashboard .hd-exp-toggle button.active { background: var(--c1); color: #fff; border-color: var(--c1); }
#holdings-dashboard tfoot td { font-weight: 650; border-top: 2px solid var(--muted); border-bottom: none; }
#holdings-dashboard .hd-note { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
#holdings-dashboard .hd-err { color: var(--bad); font-size: 12px; margin-left: 8px; }
@media (max-width: 700px) {
  #holdings-dashboard .hide-m { display: none; }
  /* Lot-detail spans use generous min-widths on desktop (issue #37) that would otherwise force
     this row wider than the phone viewport - see issue #103. */
  #holdings-dashboard .hd-lot-qty { min-width: 0; }
  #holdings-dashboard .hd-lot-basis { min-width: 0; }
}

/* Table -> stacked-card pattern below md (issue #103), scoped for this component's own tables
   (#hd-tlh, #hd-holdings) since they don't use Bootstrap's .table class - see site.css's
   table.table-cards for the equivalent applied to the rest of the app's Bootstrap tables. Lot
   detail/subtotal rows (.hd-lot-row) already render as a single full-width cell (colspan) and
   are left as-is; only the top-level holding/lot rows convert to cards. */
@media (max-width: 767.98px) {
  #holdings-dashboard table.hd-cards thead {
    display: none;
  }

  #holdings-dashboard table.hd-cards,
  #holdings-dashboard table.hd-cards tbody,
  #holdings-dashboard table.hd-cards tfoot {
    display: block;
  }

  #holdings-dashboard table.hd-cards tbody > tr:not(.hd-lot-detail),
  #holdings-dashboard table.hd-cards tfoot tr {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 8px;
  }

  #holdings-dashboard table.hd-cards tbody > tr:not(.hd-lot-detail) td,
  #holdings-dashboard table.hd-cards tfoot td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    text-align: right;
    border-bottom: 1px solid var(--grid);
    padding: 4px 0;
  }

  #holdings-dashboard table.hd-cards tbody > tr:not(.hd-lot-detail) td:last-child,
  #holdings-dashboard table.hd-cards tfoot td:last-child {
    border-bottom: none;
  }

  #holdings-dashboard table.hd-cards td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    font-weight: 600;
    text-align: left;
    color: var(--muted);
    flex-shrink: 0;
  }

  #holdings-dashboard table.hd-cards td.hd-headline {
    display: block;
    order: -1;
    text-align: left;
    border-bottom: 1px solid var(--grid);
    padding-bottom: 6px;
    margin-bottom: 4px;
  }

  #holdings-dashboard table.hd-cards td.hd-headline::before {
    content: none;
  }

  /* Lot detail/subtotal rows stay full-width single cells - no card chrome of their own. */
  #holdings-dashboard table.hd-cards tr.hd-lot-detail,
  #holdings-dashboard table.hd-cards tr.hd-lot-detail td {
    display: block;
  }
}
