/* ── Application Layout: Shell, Sidebar, Topbar, Navigation & Viewports ── */

/* ── App Shell ───────────────────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  max-width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--ink);
  color: var(--ink-text);
  display: flex;
  flex-direction: column;
  padding: 14px 10px 14px 12px;
  gap: 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 10;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.sidebar::-webkit-scrollbar {
  width: 5px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}
.brandrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px 10px 6px;
  border-bottom: 1px solid var(--ink-line);
}
.sidebar-brand-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}
.sidebar-brand-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.sidebar-logo {
  height: 28px;
  width: auto;
  max-width: 130px;
  object-fit: contain;
  display: block;
}
.sidebar-tenant-logo-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.sidebar-tenant-logo-wrap .tenant-logo-badge.sm {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  padding: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}
.tenant-badge-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #2F8FE8;
  background: rgba(47, 143, 232, 0.14);
  border: 1px solid rgba(47, 143, 232, 0.32);
  padding: 0 9px;
  height: 22px;
  line-height: 1;
  border-radius: 11px;
  white-space: nowrap;
  box-sizing: border-box;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Tenant Logo Badge System & Saudi Emblem */
.saudi-logo-badge,
.tenant-logo-badge {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  box-sizing: border-box;
}
.saudi-logo-badge {
  background: linear-gradient(135deg, #0b5028, #022613);
  border: 1px solid rgba(212, 175, 55, 0.5);
  box-shadow: 0 10px 15px -3px rgba(0, 108, 53, 0.2);
}
.shawarmer-logo-badge {
  background: #7E183D !important;
  border: 1px solid rgba(253, 184, 19, 0.35) !important;
  box-shadow: 0 8px 16px -2px rgba(126, 24, 61, 0.35);
}
.saudi-logo-badge.sm,
.tenant-logo-badge.sm {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  padding: 0;
  overflow: hidden;
}
.saudi-logo-badge.lg,
.tenant-logo-badge.lg {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
}
.tenant-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.saudi-emblem {
  width: 100%;
  height: 100%;
  fill: #D4AF37;
  display: block;
}

/* Super Admin Tenant Workspaces Table Logo & Avatar (Option B) */
.tenant-table-logo,
.tenant-table-avatar {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  overflow: hidden;
}
.tenant-table-logo {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  padding: 0;
  overflow: hidden;
}
.tenant-table-logo.saudi-style {
  background: linear-gradient(135deg, #0b5028, #022613);
  border: 1px solid rgba(212, 175, 55, 0.5);
  box-shadow: 0 4px 10px rgba(0, 108, 53, 0.25);
  padding: 0;
}
.tenant-table-logo.shawarmer-style {
  background: #7E183D;
  border: 1px solid rgba(253, 184, 19, 0.4);
  box-shadow: 0 4px 10px rgba(126, 24, 61, 0.25);
  padding: 0;
}
.tenant-table-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.tenant-table-avatar {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  letter-spacing: -0.02em;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Live Stream Status Indicator */
.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 229, 153, 0.12);
  border: 1px solid rgba(0, 229, 153, 0.35);
  color: #00e599;
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  padding: 4px 12px;
  border-radius: 20px;
}
.live-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00e599;
  box-shadow: 0 0 8px #00e599;
  animation: livePulse 1.8s infinite ease-in-out;
}
@keyframes livePulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 229, 153, 0.7); }
  70% { transform: scale(1.15); box-shadow: 0 0 0 6px rgba(0, 229, 153, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 229, 153, 0); }
}

.sa-tenant-switcher {
  padding: 0 4px 9px 4px;
  border-bottom: 1px solid var(--ink-line);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.sa-switch-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6B7570;
  font-weight: 600;
}
.sa-tenant-select {
  width: 100%;
  background: #111A24;
  color: #F7F5F1;
  border: 1px solid #233446;
  border-radius: 8px;
  padding: 6.5px 9px;
  font-size: 12px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}
.sa-tenant-select:hover, .sa-tenant-select:focus {
  border-color: #2F8FE8;
  box-shadow: 0 0 0 2px rgba(47, 143, 232, 0.2);
}
.sa-tenant-select option {
  background-color: #111A24;
  color: #F7F5F1;
}

/* Custom Modern Workspace Dropdown */
.sa-select-wrap.custom-tenant-dropdown {
  position: relative;
  width: 100%;
}
.sa-tenant-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(17, 26, 36, 0.95);
  color: #F7F5F1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  box-sizing: border-box;
}
.sa-tenant-trigger:hover,
.sa-tenant-trigger:focus-visible {
  border-color: #2F8FE8;
  background: rgba(24, 35, 48, 0.98);
  box-shadow: 0 0 0 2px rgba(47, 143, 232, 0.25);
}
.sa-tenant-trigger-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
}
.sa-tenant-trigger-icon {
  font-size: 13px;
  flex-shrink: 0;
}
.sa-tenant-trigger-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.sa-tenant-trigger-arrow {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.custom-tenant-dropdown:has(.sa-tenant-menu:not(.hidden)) .sa-tenant-trigger-arrow {
  transform: rotate(180deg);
}
.sa-tenant-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  width: 100%;
  box-sizing: border-box;
  background: rgba(15, 22, 29, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 5px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.75), 0 0 1px 1px rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1060;
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  animation: saDropdownIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes saDropdownIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.sa-tenant-menu.hidden {
  display: none !important;
}
.sa-tenant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 12px;
  color: #E2E8F0;
  gap: 8px;
}
.sa-tenant-item:hover {
  background: rgba(47, 143, 232, 0.16);
  color: #FFFFFF;
}
.sa-tenant-item.selected {
  background: rgba(47, 143, 232, 0.22);
  color: #2F8FE8;
  font-weight: 600;
}
.sa-tenant-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.sa-tenant-item-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sa-tenant-item-check {
  font-size: 12px;
  color: #00e599;
  flex-shrink: 0;
}
.brandmark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand-primary);
  font-weight: 700;
  font-size: 13px;
  color: #FFFFFF;
  flex: none;
}
.brandtext {
  font-size: 14px;
  font-weight: 600;
  color: #F7F5F1;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brandsub {
  font-size: 11px;
  color: var(--ink-muted);
}
.navgroup {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.navlabel {
  font-size: 11px;
  color: #6B7570;
  padding: 5px 9px 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.navitem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  color: var(--ink-text);
  background: none;
  border: none;
  width: 100%;
  text-align: start;
  font-size: 14px;
}
.navitem:hover { background: rgba(255, 255, 255, 0.06); }
.navitem.active { background: var(--brand-primary); color: #fff; font-weight: 500; }
.navitem svg { flex: none; }

/* Expandable nav chevrons */
.nav-expand-chevron {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--r-sm);
  opacity: 0.55;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, background 0.15s ease;
  cursor: pointer;
  flex: none;
}
.navitem:hover .nav-expand-chevron {
  opacity: 0.85;
}
.nav-expand-chevron:hover {
  opacity: 1 !important;
  background: rgba(255, 255, 255, 0.12);
}
.nav-expand-chevron.expanded {
  transform: rotate(90deg);
  opacity: 1;
}
[dir="rtl"] .nav-expand-chevron {
  transform: rotate(180deg);
}
[dir="rtl"] .nav-expand-chevron.expanded {
  transform: rotate(90deg);
}

/* Sub-navigation items collapsible accordion (under Assistant & Linzy) */
.nav-subgroup {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-inline-start: 18px;
  position: relative;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin-top: 0;
  margin-bottom: 0;
  transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, margin 0.2s ease;
  pointer-events: none;
}
.nav-subgroup.expanded {
  max-height: 1500px; /* room for a tenant's full dashboard list & categories */
  opacity: 1;
  overflow: visible;
  margin-top: 3px;
  margin-bottom: 4px;
  pointer-events: auto;
}
.nav-subgroup::before {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 6px;
  inset-inline-start: 16px;
  width: 1.5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 1px;
}
.navitem.nav-subitem {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  padding-inline-start: 12px;
  border-radius: var(--r-sm);
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.01em;
  transition: background 0.15s ease, color 0.15s ease;
  cursor: pointer;
}
.navitem.nav-subitem span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.navitem.nav-subitem:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-text);
}
/* Selected sub-item keeps the brand highlight, also on hover */
.navitem.nav-subitem.active,
.navitem.nav-subitem.active:hover {
  background: var(--brand-primary);
  color: #fff;
  font-weight: 600;
}
.navitem.nav-subitem.active svg,
.navitem.nav-subitem.active:hover svg {
  opacity: 1;
  color: #fff;
}
.navitem.nav-subitem-nested {
  padding-inline-start: 26px;
  font-size: 12px;
  opacity: 0.9;
}

/* ── Dashboard Categories Navigation Accordion ───────────────────────────── */
.nav-category-block {
  display: flex;
  flex-direction: column;
}
.nav-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 8px;
  padding-inline-start: 10px;
  border-radius: var(--r-sm);
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  background: transparent;
  border: none;
  text-align: start;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-category-header:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-text);
}
.nav-category-header.active {
  color: #fff;
  font-weight: 600;
}
.nav-category-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--ink-muted);
  transition: transform 0.2s ease, color 0.15s ease;
}
.nav-category-chevron.expanded {
  transform: rotate(90deg);
}
[dir="rtl"] .nav-category-chevron {
  transform: rotate(180deg);
}
[dir="rtl"] .nav-category-chevron.expanded {
  transform: rotate(90deg);
}
.nav-category-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-category-badge {
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--ink-muted);
  margin-inline-start: auto;
  flex-shrink: 0;
}
.nav-category-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-inline-start: 16px;
  position: relative;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.18s ease;
}
.nav-category-items.expanded {
  max-height: 500px;
  opacity: 1;
  overflow: visible;
  margin-top: 1px;
  margin-bottom: 2px;
}
.nav-category-items::before {
  content: '';
  position: absolute;
  top: 2px;
  bottom: 4px;
  inset-inline-start: 14px;
  width: 1.2px;
  background: rgba(255, 255, 255, 0.1);
}
.nav-sub-empty {
  padding: 5px 10px 5px 24px;
  font-size: 12px;
  font-style: italic;
  color: rgba(255, 255, 255, 0.42);
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: color 0.15s ease, background 0.15s ease;
  user-select: none;
}
[dir="rtl"] .nav-sub-empty {
  padding: 5px 24px 5px 10px;
}
.nav-sub-empty:hover {
  color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.04);
}

.input-sm {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-sm:hover,
.input-sm:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(47, 143, 232, 0.15);
}

.input-sm option {
  background-color: #FFFFFF;
  color: #0B0F11;
  padding: 6px 8px;
}

.sidefoot {
  margin-top: auto;
  border-top: 1px solid var(--ink-line);
  padding: 12px 10px 4px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.kv {
  font-size: 11.5px;
  color: var(--ink-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.kv b {
  color: var(--ink-text);
  font-weight: 500;
  font-family: var(--mono);
  font-size: 11px;
}

/* Sign out button styling */
.sidebar .sidefoot .btn-signout {
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF !important;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--r-full);
  font-weight: 500;
  padding: 7px 13px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.sidebar .sidefoot .btn-signout:hover {
  background: rgba(180, 72, 60, 0.25);
  color: #FF8F82 !important;
  border-color: rgba(244, 63, 94, 0.6);
  box-shadow: 0 2px 10px rgba(180, 72, 60, 0.25);
}

/* Relocated Lens Logo under Sign out */
.sidebar-foot-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 10px;
  margin-top: 3px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-foot-lens-logo {
  height: 20.5px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  opacity: 0.82;
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: block;
  user-select: none;
}
.sidebar-foot-lens-logo:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.btn-delete {
  background: rgba(180, 72, 60, 0.1);
  color: var(--danger);
  border: 1px solid rgba(180, 72, 60, 0.25);
  border-radius: var(--r-sm);
  padding: 5px 10px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-delete:hover {
  background: var(--danger);
  color: #FFFFFF;
  border-color: var(--danger);
}

@keyframes spin { 100% { transform: rotate(360deg); } }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.spacer { flex: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--r-full);
  font-size: 12px;
  background: var(--ok-bg);
  color: var(--ok-fg);
  font-family: var(--mono);
}
.chip-line {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.topbar-session-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}
.topbar-session-pill:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}
.topbar-session-pill .dot {
  background: var(--brand-primary);
  box-shadow: 0 0 6px var(--brand-primary);
  flex: none;
}
.topbar-session-pill.hidden {
  display: none !important;
}

.topbar-token-counters {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--text-2);
  user-select: none;
  transition: opacity 0.2s ease;
}
.topbar-token-counters.hidden {
  display: none !important;
}
.topbar-token-counters .token-metric {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.topbar-token-counters .token-lbl {
  color: var(--text-3);
  font-weight: 500;
  text-transform: lowercase;
}
.topbar-token-counters .token-val {
  color: var(--text);
  font-weight: 600;
}
.topbar-token-counters .token-metric.token-total .token-val {
  color: var(--brand-primary, #6366f1);
}
@media (max-width: 900px) {
  .topbar-token-counters {
    display: none !important;
  }
}

.topbar-assistant-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-assistant-actions.hidden {
  display: none !important;
}
.topbar-history-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}
.topbar-history-btn:hover, .topbar-history-btn.active {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}
.topbar-history-btn .badge {
  background: rgba(47, 143, 232, 0.15);
  color: var(--brand-primary);
  font-weight: 600;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
}
.topbar-history-btn .badge:empty {
  display: none !important;
}

.seg {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  overflow: hidden;
  background: var(--surface);
}
.seg button {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
}
.seg button.on {
  background: var(--brand-primary);
  color: #fff;
  font-weight: 600;
}

.view {
  padding: 26px 32px;
  max-width: 1300px;
  width: 100%;
}


/* ── Hero & Home ─────────────────────────────────────────────────────────── */
.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 30px;
  display: flex;
  gap: 24px;
  align-items: center;
  margin-bottom: 22px;
}
.herologo {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--brand-primary);
  color: #fff;
  font-weight: 700;
  font-size: 22px;
  flex: none;
}
.hero h2 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: -0.02em;
  font-weight: 600;
}
.hero p {
  margin: 0;
  color: var(--text-2);
  max-width: 680px;
}

.grid { display: grid; gap: 16px; }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media(max-width: 1000px) { .g3, .g2 { grid-template-columns: 1fr; } }

.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
  text-align: start;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tile h3 { margin: 0; font-size: 17px; font-weight: 600; }
.tile p { margin: 0; font-size: 14px; color: var(--text-2); }
.tile .metric { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.delta-up { color: var(--ok-fg); font-size: 13px; font-family: var(--mono); }
.delta-dn { color: var(--warn); font-size: 13px; font-family: var(--mono); }

.tile-pinned {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tile-pinned-artifact {
  grid-column: 1 / -1;
  padding: 22px 24px;
}

.tile-pinned-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.tile-pinned-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.tile-pinned-title-wrap h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-artifact-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #6366f1;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.tile-pinned-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.tile-action-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-3);
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
  padding: 0;
}

.tile-action-btn:hover {
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
  border-color: rgba(99, 102, 241, 0.25);
  transform: scale(1.06);
}

.tile-action-btn:active {
  transform: scale(0.94);
}

.tile-unpin-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-3);
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
  padding: 0;
}
.tile-unpin-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.28);
  transform: scale(1.06);
}
.tile-unpin-btn:active {
  transform: scale(0.94);
}

.tile-answer-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-1, #334155);
  font-weight: 500;
}

[data-theme="dark"] .tile-answer-text {
  color: var(--text-1, #e2e8f0);
}

/* Artifact Frame Container inside Pinned Tile */
.pinned-artifact-container {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.pinned-artifact-frame {
  width: 100%;
  height: 480px;
  border: none;
  display: block;
  background: transparent;
}

/* Footer & SQL Query Disclosure */
.tile-pinned-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .tile-pinned-footer {
  border-top-color: rgba(255, 255, 255, 0.06);
}

.tile-status-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-family: var(--mono);
  color: var(--ok-fg, #10b981);
  font-weight: 500;
}

.tile-status-live .live-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok-fg, #10b981);
  box-shadow: 0 0 6px var(--ok-fg, #10b981);
}

.tile-sql-details {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
}

.tile-sql-summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-3);
  cursor: pointer;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--line);
  user-select: none;
  transition: all 0.15s ease;
}

[data-theme="dark"] .tile-sql-summary {
  background: rgba(255, 255, 255, 0.04);
}

.tile-sql-summary:hover {
  color: var(--text-1);
  border-color: rgba(99, 102, 241, 0.4);
}

.tile-sql-pre {
  width: 100%;
  max-width: 600px;
  max-height: 180px;
  overflow: auto;
  font-size: 11px;
  line-height: 1.45;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--bg-card, #090d16);
  color: #94a3b8;
  border: 1px solid var(--line);
  margin-top: 6px;
  white-space: pre-wrap;
  word-break: break-all;
  text-align: start;
}

.sectionhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 14px;
}
.sectionhead h3 { margin: 0; font-size: 16px; font-weight: 600; }

/* ── Embedded Dashboards View ────────────────────────────────────────────── */
.dash-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.dash-tab-btn {
  padding: 9px 18px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.dash-tab-btn:hover { border-color: var(--brand-primary); color: var(--brand-primary); }
.dash-tab-btn.active {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
  font-weight: 600;
}
.dash-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  transition: all 0.15s ease;
}
.dash-action-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: var(--bg);
}
.dash-action-btn.primary {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
}
.dash-action-btn.primary:hover {
  filter: brightness(1.08);
  color: #fff;
}
.dash-iframe-wrap {
  width: 100%;
  height: calc(100vh - 180px);
  min-height: 600px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
  position: relative;
}
.dash-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ── Dashboard Empty State View ──────────────────────────────────────────── */
.dash-empty-state-wrap {
  padding: 18px 0;
  width: 100%;
}
.dash-empty-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 24px 28px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}
.dash-empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.dash-empty-subtitle {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-3);
}
/* Tenant home page dashboard (metadata.json "homeDashboard"): sized to its content by App.fitHomeDashboard */
.home-dash-wrap {
  width: 100%;
  margin-bottom: 18px;
  border-radius: var(--r-lg);
  overflow: hidden;
}
.home-dash-frame {
  display: block;
  width: 100%;
  height: 80vh; /* until the content height is measured */
  border: none;
}

/* ── Full-Width Stretched Viewports (Live Stream, Dashboards & Studies) ──────────── */
.view.view-live,
.view.view-dashboards,
.view.view-studies {
  max-width: 100% !important;
  width: 100% !important;
  padding: 8px 16px 16px 16px !important;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: calc(100vh - 65px);
  box-sizing: border-box;
}

.view.view-dashboards .dash-iframe-wrap,
.view.view-studies .dash-iframe-wrap {
  width: 100% !important;
  max-width: 100% !important;
  flex: 1;
  height: calc(100vh - 122px) !important;
  min-height: 820px;
  border-radius: var(--r-lg, 12px);
  border: 1px solid var(--line);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  background: var(--surface, #ffffff);
  position: relative;
  overflow: hidden;
}

.view.view-live .dash-iframe-wrap {
  width: 100% !important;
  max-width: 100% !important;
  flex: 1;
  height: calc(100vh - 128px) !important;
  min-height: 750px;
  border-radius: var(--r-lg, 12px);
  border: 1px solid rgba(0, 229, 153, 0.28);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  background: #070d09;
  position: relative;
  overflow: hidden;
}

.view.view-live .dash-iframe,
.view.view-dashboards .dash-iframe,
.view.view-studies .dash-iframe {
  width: 100% !important;
  height: 100% !important;
  border: none;
  display: block;
}

.view.view-live .live-stream-tabs {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}


/* ── Responsive Window Interactivity ─────────────────────────────────────── */
@media (max-width: 1100px) {
  .history-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .history-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  .assistant-history-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    border-radius: 0;
    z-index: 1050;
    box-shadow: -8px 0 28px rgba(0, 0, 0, 0.35);
    transform: translateX(100%);
    display: flex !important;
  }

  [dir="rtl"] .assistant-history-sidebar {
    right: auto;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.35);
  }

  .assistant-history-sidebar.open {
    transform: translateX(0);
  }

  .assistant-history-sidebar.collapsed {
    transform: translateX(100%);
    display: flex !important;
  }

  [dir="rtl"] .assistant-history-sidebar.collapsed {
    transform: translateX(-100%);
  }
}

.chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 4px 6px 6px 4px;
  box-sizing: border-box;
  overflow: visible;
}

/* Dynamic 2x2 grid when history sidebar is open or viewport is constrained */
.assistant-layout.history-open .chips {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 1200px) {
  .chips {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .chips,
  .assistant-layout.history-open .chips {
    grid-template-columns: 1fr;
  }
}

.suggest {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: start;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.suggest:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: rgba(47, 143, 232, 0.06);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(47, 143, 232, 0.12);
}
.suggest-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  width: 100%;
  text-align: inherit;
}

.composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 22px;
  padding: 6px 8px 6px 16px;
  width: 100%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, border-radius 0.15s ease;
}
.composer:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(47, 143, 232, 0.2);
}
.composer textarea,
.composer input {
  flex: 1;
  border: none;
  background: none;
  padding: 8px 0;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  resize: none;
  max-height: 160px;
  min-height: 22px;
  overflow-y: auto;
}
.composer textarea::placeholder,
.composer input::placeholder {
  color: var(--text-3);
}
.iconbtn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--brand-primary);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-bottom: 2px;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.iconbtn:hover {
  transform: scale(1.05);
}
.empty { color: var(--text-3); text-align: center; padding: 40px 0; }
