/* Tremac portal v2 — super-admin presentation layer (body.tremac-portal-v2). Opt-out via TremacDashboardV2.disable(). */

body.tremac-portal-v2 {
  --tdv2-shadow: 0 1px 2px rgba(7, 27, 56, 0.04), 0 8px 24px rgba(7, 27, 56, 0.06);
  --tdv2-radius: 12px;
}

body.tremac-portal-v2 .view {
  background: #f3f6fa;
}

html[data-theme="dark"] body.tremac-portal-v2 .view {
  background: #0f172a;
}

body.tremac-portal-v2 #pageTitle {
  font-size: 26px;
  letter-spacing: -0.03em;
}

body.tremac-portal-v2 #pageSubtitle {
  color: #64748b;
  max-width: 52ch;
}

html[data-theme="dark"] body.tremac-portal-v2 #pageSubtitle {
  color: #94a3b8;
}

/* Top bar */
body.tremac-portal-v2 .topbar {
  border-bottom-color: #e8edf3;
  box-shadow: 0 1px 0 rgba(7, 27, 56, 0.04);
}

body.tremac-portal-v2 #signedInRole[hidden] {
  display: none !important;
}

/* Sidebar polish */
body.tremac-portal-v2 .sidebar {
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

body.tremac-portal-v2 .nav-item.active {
  box-shadow: inset 3px 0 0 var(--gold);
}

body.tremac-portal-v2 .nav-item .nav-icon svg {
  stroke-width: 1.65;
}

/* Dashboard KPIs — premium, not heavy */
body.tremac-portal-v2 .tdv2-reference-dashboard .trd-kpis {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
}

body.tremac-portal-v2 .tdv2-reference-dashboard .trd-kpi {
  min-height: 102px;
  border-radius: var(--tdv2-radius);
  border: 1px solid #e3e8ef;
  box-shadow: var(--tdv2-shadow);
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
}

body.tremac-portal-v2 .tdv2-reference-dashboard .trd-kpi-action:hover,
body.tremac-portal-v2 .tdv2-reference-dashboard .trd-kpi-action:focus-visible {
  border-color: color-mix(in srgb, var(--gold) 45%, #e3e8ef);
  box-shadow: var(--tdv2-shadow), 0 0 0 1px rgba(199, 154, 74, 0.12);
  transform: none;
}

body.tremac-portal-v2 .tdv2-reference-dashboard .trd-kpi-value {
  font-size: 28px;
  letter-spacing: -0.03em;
}

body.tremac-portal-v2 .tdv2-reference-dashboard .trd-kpi-icon {
  border-radius: 10px;
  background: #f4f6f9;
  border-color: #e5eaf0;
}

body.tremac-portal-v2 .tdv2-reference-dashboard .trd-stock-card {
  border-color: color-mix(in srgb, var(--gold) 35%, #e3e8ef);
}

/* Panels */
body.tremac-portal-v2 .tdv2-reference-dashboard .trd-panel {
  border-radius: var(--tdv2-radius);
  border-color: #e3e8ef;
  box-shadow: var(--tdv2-shadow);
}

body.tremac-portal-v2 .tdv2-reference-dashboard .trd-panel-head h2 {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

body.tremac-portal-v2 .tdv2-reference-dashboard .trd-op-activity-filters button {
  border-radius: 999px;
  font-weight: 700;
}

body.tremac-portal-v2 .tdv2-reference-dashboard .trd-op-activity-filters button.active,
body.tremac-portal-v2 .tdv2-reference-dashboard .trd-op-activity-filters button[aria-pressed="true"] {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

body.tremac-portal-v2 .tdv2-reference-dashboard .trd-chart-row {
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.75fr);
}

body.tremac-portal-v2 .tdv2-reference-dashboard .trd-bottom-row {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
}

body.tremac-portal-v2 .tdv2-reference-dashboard .trd-table th {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

body.tremac-portal-v2 .tdv2-reference-dashboard .trd-live-item {
  border-radius: 8px;
  margin: 4px 8px;
  border: 1px solid transparent;
}

body.tremac-portal-v2 .tdv2-reference-dashboard .trd-live-action:hover,
body.tremac-portal-v2 .tdv2-reference-dashboard .trd-live-action:focus-visible {
  border-color: #e3e8ef;
  background: #f8fafc;
}

/* Module pages — shared polish (same APIs, same DOM) */
body.tremac-portal-v2 .view .panel,
body.tremac-portal-v2 .view .card,
body.tremac-portal-v2 .view .stat {
  border-radius: var(--tdv2-radius);
  box-shadow: var(--tdv2-shadow);
}

body.tremac-portal-v2 .view .panel-head h2,
body.tremac-portal-v2 .view #pageTitle {
  letter-spacing: -0.02em;
}

body.tremac-portal-v2 .view .toolbar {
  margin-bottom: 16px;
}

body.tremac-portal-v2 .view .search,
body.tremac-portal-v2 .view .filter,
body.tremac-portal-v2 .view .button {
  border-radius: 10px;
}

body.tremac-portal-v2 .view table th {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

@media (max-width: 1500px) {
  body.tremac-portal-v2 .tdv2-reference-dashboard .trd-kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Match the base dashboard breakpoint with the same v2 selector specificity.
   Without this override, the v2 two-column rules win over dashboard-redesign.css
   and crush the left analysis panel on tablets and phones. */
@media (max-width: 1280px) {
  body.tremac-portal-v2 .tdv2-reference-dashboard .trd-chart-row,
  body.tremac-portal-v2 .tdv2-reference-dashboard .trd-bottom-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1100px) {
  body.tremac-portal-v2 .tdv2-reference-dashboard .trd-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body.tremac-portal-v2 .tdv2-reference-dashboard .trd-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.tremac-portal-v2 .tdv2-reference-dashboard .trd-chart-row,
  body.tremac-portal-v2 .tdv2-reference-dashboard .trd-bottom-row,
  body.tremac-portal-v2 .tdv2-reference-dashboard .trd-panel {
    width: 100%;
    min-width: 0;
  }
}

/* Dark theme — v2 overrides must not fight dashboard-redesign dark tokens */
html[data-theme="dark"] body.tremac-portal-v2 {
  --tdv2-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.25);
}

html[data-theme="dark"] body.tremac-portal-v2 .topbar {
  border-bottom-color: #334155;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

html[data-theme="dark"] body.tremac-portal-v2 .tdv2-reference-dashboard .trd-kpi {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

html[data-theme="dark"] body.tremac-portal-v2 .tdv2-reference-dashboard .trd-kpi-action:hover,
html[data-theme="dark"] body.tremac-portal-v2 .tdv2-reference-dashboard .trd-kpi-action:focus-visible {
  border-color: color-mix(in srgb, var(--gold) 45%, #334155);
  box-shadow: var(--tdv2-shadow), 0 0 0 1px rgba(199, 154, 74, 0.18);
}

html[data-theme="dark"] body.tremac-portal-v2 .tdv2-reference-dashboard .trd-kpi-icon {
  background: #0f172a;
  border-color: #475569;
}

html[data-theme="dark"] body.tremac-portal-v2 .tdv2-reference-dashboard .trd-stock-card {
  border-color: color-mix(in srgb, var(--gold) 35%, #334155);
}

html[data-theme="dark"] body.tremac-portal-v2 .tdv2-reference-dashboard .trd-panel {
  border-color: #334155;
}

html[data-theme="dark"] body.tremac-portal-v2 .tdv2-reference-dashboard .trd-op-activity-filters button.active,
html[data-theme="dark"] body.tremac-portal-v2 .tdv2-reference-dashboard .trd-op-activity-filters button[aria-pressed="true"] {
  background: #334155;
  border-color: #475569;
  color: #f8fafc;
}

html[data-theme="dark"] body.tremac-portal-v2 .tdv2-reference-dashboard .trd-live-action:hover,
html[data-theme="dark"] body.tremac-portal-v2 .tdv2-reference-dashboard .trd-live-action:focus-visible {
  border-color: #475569;
  background: #334155;
}
