
/* ============================================================
   Vivid layout pass — dashboard + tiles (mockup alignment)
   Loaded after vivid.css. Dark theme only.
   ============================================================ */

/* KPI tiles: taller, glossy, with the mockup's arrow chip */
html:not([data-theme="light"]) .bento-grid > .kpi-card {
  min-height: 136px;
  padding: 18px 20px;
  border-radius: 18px;
  isolation: isolate;
}

html:not([data-theme="light"]) .bento-grid > .kpi-card::before {
  content: "\2192";
  position: absolute;
  right: 18px;
  bottom: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
  color: #fff;
  background: rgba(8, 18, 42, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.32);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  z-index: 2;
}

html:not([data-theme="light"]) .bento-grid > .kpi-card .kpi-label {
  font-size: 12.5px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  opacity: 0.92;
}

html:not([data-theme="light"]) .bento-grid > .kpi-card .kpi-value {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

html:not([data-theme="light"]) .bento-grid > .kpi-card .kpi-delta {
  font-size: 12.5px;
  opacity: 0.88;
  max-width: 74%;
}

/* Quick access: 2x2 glossy tiles like the phone mockup */
html:not([data-theme="light"]) .quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 4px;
}

html:not([data-theme="light"]) .quick-grid button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 6px;
  min-height: 118px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    radial-gradient(120% 100% at 90% 0%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(150deg, rgba(30, 58, 130, 0.96), rgba(10, 22, 52, 0.96));
  box-shadow: 0 14px 32px rgba(0, 10, 40, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  color: #fff;
  text-align: left;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

html:not([data-theme="light"]) .quick-grid button:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 44px rgba(20, 60, 160, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

html:not([data-theme="light"]) .quick-grid button svg {
  width: 26px;
  height: 26px;
  stroke: #fff;
  fill: none;
  stroke-width: 1.8;
  padding: 7px;
  box-sizing: content-box;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

html:not([data-theme="light"]) .quick-grid button span {
  font-size: 14px;
  font-weight: 650;
  line-height: 1.2;
}

html:not([data-theme="light"]) .quick-grid button small {
  font-size: 11.5px;
  color: rgba(214, 228, 255, 0.72);
}

html:not([data-theme="light"]) .quick-grid button:nth-child(2) {
  background:
    radial-gradient(120% 100% at 90% 0%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(150deg, rgba(14, 124, 96, 0.96), rgba(4, 40, 28, 0.96));
}

html:not([data-theme="light"]) .quick-grid button:nth-child(3) {
  background:
    radial-gradient(120% 100% at 90% 0%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(150deg, rgba(150, 96, 20, 0.96), rgba(50, 24, 4, 0.96));
}

html:not([data-theme="light"]) .quick-grid button:nth-child(4) {
  background:
    radial-gradient(120% 100% at 90% 0%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(150deg, rgba(92, 60, 190, 0.96), rgba(32, 16, 72, 0.96));
}

/* Bento headings pick up the display gradient from the mockup */
html:not([data-theme="light"]) .bento-title {
  font-size: 18px;
  letter-spacing: -0.01em;
}

/* Keep four KPI tiles on one row on wide screens, two on tablets */
@media (max-width: 1180px) {
  html:not([data-theme="light"]) .bento-grid > .kpi-card.span-3 { grid-column: span 6; }
}

@media (max-width: 720px) {
  html:not([data-theme="light"]) .bento-grid > .kpi-card.span-3 { grid-column: span 12; }
  html:not([data-theme="light"]) .quick-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html:not([data-theme="light"]) .quick-grid button { transition: none; }
}

/* ============================================================
   Bento safety + layout guards (last stylesheet loaded)
   ============================================================ */

/* Icon sizing guardrails — no SVG may stretch a card */
.ico { width: 16px; height: 16px; max-width: 16px; max-height: 16px; opacity: .8; vertical-align: middle; flex-shrink: 0; display: inline-block; }
main svg:not(.brand-svg):not(.leaflet-zoom-animated),
.bento svg, .btn svg,
.activity-item svg, .notif-icon svg, .bento-head svg, .quick-grid svg, .empty-state svg {
  max-width: 24px; max-height: 24px; flex-shrink: 0;
}
.activity-item svg, .notif-icon svg, .bento-head svg, .btn svg, .quick-grid svg { width: 18px; height: 18px; }
.empty-state svg { width: 36px; height: 36px; max-width: 36px; max-height: 36px; }
.nav-icon svg { width: 18px; height: 18px; }
.kpi-card .kpi-icon svg { width: 22px; height: 22px; }
.brand-infinity { width: 34px; height: 34px; flex: 0 0 auto; }
.auth-brand .brand-infinity { width: 34px; height: 34px; }

/* Proportional Bento grid */
.bento-grid > .bento:not([class*="span-"]) { grid-column: span 6; }
.bento-grid > .bento.system-health-card { grid-column: span 12; }
@media (max-width: 900px) {
  .bento-grid > .bento:not([class*="span-"]) { grid-column: span 12; }
}
.bento { border-radius: 16px; }

/* Topbar: one clean line, no overlap */
.topbar { gap: 10px; flex-wrap: nowrap; }
.topbar-actions { gap: 10px; flex-wrap: nowrap; white-space: nowrap; min-width: 0; }
.breadcrumbs { min-width: 0; overflow: hidden; white-space: nowrap; }
.breadcrumbs b { overflow: hidden; text-overflow: ellipsis; }
.global-search { flex-shrink: 0; white-space: nowrap; min-width: 190px; }
.global-search kbd { white-space: nowrap; }
.global-search input { min-width: 0; }
.global-search > span { display: inline-flex; flex: 0 0 auto; }
.topbar .btn, .topbar .btn-small { white-space: nowrap; min-height: 34px; }
.top-user { flex: 0 0 auto; white-space: nowrap; }
.top-logout { flex: 0 0 auto; white-space: nowrap; }
.top-divider { flex: 0 0 auto; }
#copilot-open { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
#copilot-open .ico { width: 15px; height: 15px; }
@media (max-width: 1440px) { .topbar .security-pill { padding: 3px 7px; font-size: 9px; } }
@media (max-width: 1320px) { .topbar .security-pill { display: none; } }
@media (max-width: 1100px) { .global-search { min-width: 150px; } #copilot-open span:last-child { display: none; } }

/* Full-width workspace when CORTEX is collapsed */
.main-area { margin-right: 0 !important; }

/* Thin dark scrollbars + no horizontal page scroll */
html { scrollbar-width: thin; scrollbar-color: rgba(148,163,184,0.26) transparent; }
* { scrollbar-width: thin; scrollbar-color: rgba(148,163,184,0.26) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.26); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,0.40); }
body, .app, .main-area { overflow-x: hidden; }

/* Key/value rows never touch */
.chart-legend { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; font-size: 12px; color: var(--text-secondary); }
.chart-legend > span { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.chart-total { font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 700; white-space: nowrap; }
.chart-total small { color: var(--text-muted); font-weight: 500; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-blue); flex: 0 0 auto; }
.legend-dot.cyan { background: #22D3EE; }
.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 8px; }
.bar-column { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.bar-value { font-size: 11px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.bar-track { flex: 1 1 auto; width: 100%; max-width: 34px; background: rgba(148,163,184,.12); border-radius: 8px; display: flex; align-items: flex-end; overflow: hidden; }
.bar-fill { width: 100%; background: linear-gradient(180deg,#22D3EE,#2563EB); border-radius: 8px; }
.bar-column > span { font-size: 10px; color: var(--text-muted); white-space: nowrap; }

.dept-list { display: flex; flex-direction: column; gap: 12px; }
.dept-row { display: flex; flex-direction: column; gap: 6px; }
.dept-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; min-width: 0; }
.dept-label b { margin-right: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); font-weight: 600; }
.dept-label small { font-variant-numeric: tabular-nums; color: var(--text-secondary); flex: 0 0 auto; white-space: nowrap; }
.dept-bullet { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--accent-blue); }
.dept-track { height: 6px; background: rgba(148,163,184,.14); border-radius: 999px; overflow: hidden; }
.dept-track span { display: block; height: 100%; background: linear-gradient(90deg,#2563EB,#22D3EE); border-radius: 999px; }

.activity-list { display: flex; flex-direction: column; }
.activity-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-card); min-width: 0; }
.activity-row:last-child { border-bottom: none; }
.activity-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: rgba(37,99,235,.12); color: #93C5FD; flex: 0 0 auto; }
.activity-row > div { min-width: 0; flex: 1 1 auto; }
.activity-row b { display: block; font-size: 13px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-row small { display: block; font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-row time { flex: 0 0 auto; font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.health-status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 18px; }
.health-status-grid > div { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 10px 0; border-bottom: 1px solid var(--border-card); min-width: 0; }
.health-status-grid > div small { flex: 1 1 auto; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.health-status-grid > div b { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; }
.health-status-grid > div p { flex: 1 1 100%; margin: 0; font-size: 11px; color: var(--text-muted); }

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.text-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; color: var(--accent-blue); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; padding: 4px 0; min-height: 0; }
.text-btn svg { width: 14px; height: 14px; }

/* Brand + sidebar */
.brand-type { min-width: 0; }
.brand-type b, .brand-type span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workspace-chip { max-width: 100%; overflow: hidden; white-space: nowrap; }
.workspace-chip .status-text { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; }
.sidebar-tagline { margin-top: 10px; padding: 10px 8px 2px; font-size: 10px; line-height: 1.4; color: var(--text-muted); letter-spacing: .02em; text-align: center; border-top: 1px solid var(--border-card); }
.copilot-mark { display: grid; place-items: center; }
.copilot-mark svg { width: 20px; height: 20px; }
.product-icon-svg { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 14px; background: rgba(37,99,235,.12); color: #93C5FD; }
.product-icon-svg svg { width: 26px; height: 26px; max-width: 26px; max-height: 26px; }

/* ---------------------------- Products launcher (clean Bento cards) ---------------------------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.product-card { display: flex; flex-direction: column; background: #0F172A; border: 1px solid rgba(148,163,184,.16); border-radius: 16px; overflow: hidden; transition: border-color .16s ease, transform .16s ease; }
.product-card:hover { border-color: rgba(148,163,184,.30); transform: translateY(-2px); }
.product-card.is-hidden { opacity: .55; }
.product-visual { position: relative; height: 104px; display: grid; place-items: center; background: #0B1222; border-bottom: 1px solid rgba(148,163,184,.12); }
.product-visual::after { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 92% at 50% 120%, var(--pa, #2563EB), transparent 70%); opacity: .20; pointer-events: none; }
.product-icon-svg { position: relative; z-index: 1; width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: rgba(15,23,42,.82); border: 1px solid rgba(148,163,184,.22); color: #E2E8F0; }
.product-icon-svg svg { width: 26px; height: 26px; max-width: 26px; max-height: 26px; }
.product-body { display: flex; flex-direction: column; gap: 8px; padding: 16px; flex: 1 1 auto; }
.product-name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; color: var(--text-primary); }
.product-tag { font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); background: rgba(148,163,184,.10); border: 1px solid rgba(148,163,184,.18); border-radius: 999px; padding: 2px 8px; }
.product-body p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--text-secondary); }
.product-foot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.product-foot .btn { min-height: 34px; }
.product-vis { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.product-hidden-tag { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-amber); }
.product-grid.editing .product-card { border-style: dashed; }

/* Sidebar collapse control (previously unstyled) */
.sidebar-collapse { margin-left: auto; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border-card); background: transparent; color: var(--text-muted); cursor: pointer; flex: 0 0 auto; font-size: 10px; line-height: 1; }
.sidebar-collapse:hover { color: var(--text-primary); background: var(--bg-card-hover); border-color: rgba(148,163,184,.28); }
