/* /app preview — layout-only additions on top of vpx-webkit.css.
   Webkit's zel-stat-card, zel-mini-stat, zel-table, zel-status-dot, zel-badge,
   zel-btn-*, zel-card, zel-select are used directly in the markup.
   Only grid scaffolding, a missing colour variant, and sidebar extras live here. */

/* Keep the fixed webkit topbar clear of page content/topbars */
:root {
  --topbar-height: 56px;
}

.app-container {
  padding-top: var(--topbar-height);
}

.main-content {
  min-height: calc(100vh - var(--topbar-height));
}

/* Settings/accounting local topbars should sit below the global topbar,
   never on top of it (which blocks search/theme/notification controls). */
.main-content > .topbar {
  position: sticky;
  top: var(--topbar-height);
  z-index: 90;
}

/* Red stat-icon variant (not in webkit) */
.zel-stat-icon.red { background: rgba(255,69,58,0.1); color: #ff453a; }

/* SaaS rail group label — platform scope warning */
.zel-nav-label-danger {
  color: #ff453a;
  font-weight: 600;
  letter-spacing: 0.06em;
}

/* Stat cards row */
.v2-stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

/* Quick stats row */
.v2-mini-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.65rem;
}

/* Two-column activity split */
.v2-activity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.v2-activity-card {
  display: flex;
  flex-direction: column;
  min-height: 460px;
}

/* Table column widths for activity rows */
.v2-col-dot   { width: 1.25rem; padding-right: 0 !important; }
.v2-col-title { width: 22%; }
.v2-col-msg   { min-width: 0; }
.v2-col-time  { width: 130px; text-align: right !important; white-space: nowrap; }

/* Topbar search form */
.v2-search-form { margin: 0; }

/* Compact icon-only button for tight toolbar/form field layouts */
.zel-btn-icon {
  padding: 0.55rem 0.55rem;
  min-width: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.zel-btn-icon i {
  margin: 0;
}

.zel-tenant-switch {
  min-width: 10.8rem;
}

.zel-tenant-combo {
  width: 10.8rem;
  min-width: 10.8rem;
  max-width: 10.8rem;
}

.zel-tenant-combo-input {
  min-width: 0;
}

.zel-tenant-combo--readonly {
  cursor: default !important;
  pointer-events: none;
}

.zel-tenant-combo--readonly,
.zel-tenant-combo--readonly * {
  cursor: default !important;
}

.zel-tenant-combo--readonly .zel-tenant-combo-caret {
  display: none;
}

.zel-tenant-menu {
  width: 10.8rem;
  min-width: 10.8rem;
  max-width: 10.8rem;
}

#tenantList .zel-tenant-item,
#tenantList .zel-tenant-item.active,
#tenantList .zel-tenant-item:hover {
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
}

#tenantList .zel-tenant-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.34rem 0.45rem;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
}

#tenantList .zel-tenant-item:hover,
#tenantList .zel-tenant-item.active {
  background: var(--bg-tertiary);
}

#tenantList .zel-tenant-item-body {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#tenantList .zel-tenant-item-name {
  flex: 1;
  min-width: 0;
  text-align: left;
}

#tenantList .zel-tenant-item-id {
  flex-shrink: 0;
  font-size: 0.68rem;
  line-height: 1;
  color: var(--text-secondary);
  opacity: 0.9;
  text-align: right;
}

#tenantList .zel-tenant-item .zel-tenant-icon.zel-tenant-icon-lead {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-sm);
  background: rgba(31, 111, 235, 0.14);
  color: var(--accent-blue);
  font-size: 0.6rem;
  flex: 0 0 auto;
}

.v2-admin-table {
  table-layout: fixed;
}

.v2-checkbox-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.v2-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}

.v2-checkbox:hover {
  border-color: var(--accent-blue);
  background: var(--bg-tertiary);
}

.v2-checkbox:checked {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
}

.v2-checkbox:checked::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}

.v2-bulkbar {
  position: sticky;
  bottom: 0.85rem;
  z-index: 80;
  margin-top: 0.85rem;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: var(--shadow-lg);
}

.v2-bulkbar.show {
  display: flex;
}

.v2-bulkbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.v2-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(280px, 0.9fr);
  gap: 1rem;
  align-items: start;
}

.v2-detail-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.v2-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.v2-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.v2-form-grid label span {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.v2-record-kv {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.v2-record-kv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
  padding: 0.1rem 0;
}

.v2-record-kv-row span {
  color: var(--text-secondary);
}

.v2-article-content,
.v2-article-preview {
  line-height: 1.65;
}

.v2-mini-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.v2-mini-list-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
}

.v2-mini-list-item span {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.v2-faq-tree {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.v2-faq-category-btn,
.v2-faq-article-link {
  width: 100%;
  text-align: left;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.v2-faq-category-btn:hover,
.v2-faq-article-link:hover {
  border-color: var(--accent-blue);
  background: rgba(31,111,235,0.08);
  color: var(--text-white);
}

.v2-faq-category-btn.active {
  border-color: var(--accent-blue);
  background: rgba(31,111,235,0.14);
  color: var(--text-white);
}

.v2-faq-article-link {
  align-items: flex-start;
  flex-direction: column;
}

.v2-faq-article-link span {
  color: var(--text-secondary);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.v2-public-faq-layout,
.v2-settings-grid,
.v2-health-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 1rem;
}

.v2-settings-grid,
.v2-health-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* Recent tickets in sidebar */
.v2-recent-tickets {
  border-top: 1px solid var(--border-color);
  overflow: hidden;
  flex: 0 0 222px;
  max-height: 222px;
}

/* Platform status card slot (replaces recent tickets on SaaS admin/settings) */
.v2-platform-card-slot {
  border-top: 1px solid var(--border-color);
  overflow: hidden;
  flex: 0 0 220px;
  max-height: 220px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.35rem 0.35rem 0.25rem;
}

.v2-platform-card-slot .server-status-card {
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.v2-recent-tickets-label {
  padding: 0.5rem 0.45rem 0.1rem 0.45rem;
}

.v2-recent-loading {
  font-size: 0.72rem;
  display: block;
  padding: 0.25rem 0.45rem;
  color: var(--text-secondary);
}

#recent-tickets-list,
#v2-recent-tickets-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 0.35rem;
  /* Spacing between rows — keep line-height normal so descenders aren't clipped */
  row-gap: 0.1rem;
  align-items: center;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.1rem 0;
}

.v2-recent-ticket-item {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  transition: var(--transition);
  min-width: 0;
  text-decoration: none !important;
  font-size: 0.82rem;
  line-height: 1.25;
  letter-spacing: 0.005rem;
  overflow: visible;
}

.v2-recent-ticket-item:hover {
  background: rgba(31,111,235,0.1);
  color: inherit;
}

@supports not (grid-template-columns: subgrid) {
  #recent-tickets-list,
  #v2-recent-tickets-list {
    display: block;
  }

  .v2-recent-ticket-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    grid-column: unset;
  }
}

.v2-recent-ticket-id {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
  cursor: pointer;
}

.v2-recent-ticket-row {
  display: contents;
}

.v2-recent-ticket-sep {
  display: none;
}

.v2-recent-ticket-subject {
  font-weight: 500;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.v2-recent-ticket-item--title-only {
  display: block;
  overflow-x: hidden;
  overflow-y: visible;
  min-width: 0;
  line-height: 1.25;
  padding: 0.12rem 0.45rem;
}

.v2-recent-ticket-item--title-only .v2-recent-ticket-subject {
  display: block;
  font-weight: 350;
  max-width: 100%;
  line-height: 1.25;
}

/* legacy single-line title (customer panel etc.) */
.v2-recent-ticket-title {
  font-size: 0.70rem;
  line-height: 1.07;
  font-weight: 500;
  color: var(--text-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.v2-recent-ticket-meta {
  font-size: 0.65rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Sidebar/menu scrolling behavior: keep recent-tickets fixed, scroll nav with hidden scrollbar */
.zel-sidebar {
  overflow: hidden;
}

.zel-nav {
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.zel-nav::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* Sidebar action bar */
.v2-sidebar-bar {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.25rem;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.v2-sidebar-bar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
  background: transparent;
  border: none;
  flex: 0 0 auto;
  font-size: 0.9rem;
}

.v2-sidebar-bar-icon:hover,
.v2-sidebar-bar-icon.active {
  background: rgba(31,111,235,0.12);
  color: var(--text-white);
}

.v2-sidebar-bar-add {
  margin-left: 0;
  width: 100%;
  height: 34px;
  background: transparent;
  color: var(--accent-blue, #1f6feb) !important;
  border: none;
  box-shadow: none;
  font-size: 0.8rem;
}

.v2-sidebar-bar-add:hover {
  background: rgba(31,111,235,0.12);
  color: var(--text-white, #f0f6fc) !important;
}

.v2-sidebar-create-wrap {
  position: relative;
  width: 100%;
}

.v2-sidebar-create-menu {
  position: absolute;
  bottom: calc(100% + 3px);
  left: auto;
  min-height: 16rem;
  right: -5px;
  width: max-content;
  min-width: 11.5rem;
  max-width: calc(var(--sidebar-width, 11.25rem) - 0.5rem);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--border-color, #30363d);
  background: var(--bg-card, #161b22);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.v2-sidebar-create-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm, 6px);
  background: transparent;
  color: var(--text-primary, #f0f6fc);
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
}

.v2-sidebar-create-item:hover {
  background: rgba(31, 111, 235, 0.12);
}

.v2-sidebar-create-item i {
  width: 14px;
  text-align: center;
  color: var(--accent-blue, #1f6feb);
}

.v2-sidebar-create-item span {
  white-space: nowrap;
}

@media (max-width: 1079.98px) and (min-width: 820px) {
  .v2-sidebar-bar {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-columns: unset;
    gap: 0.2rem;
    padding: 0.3rem;
  }

  .v2-sidebar-bar-icon,
  .v2-sidebar-bar-add {
    height: 30px;
    font-size: 0.85rem;
  }

  .v2-sidebar-create-menu {
    left: calc(100% + 6px);
    right: auto;
    bottom: 0;
    max-width: 14rem;
  }
}

.v2-align-center {
  align-items: center;
}

.v2-m0 {
  margin: 0;
}

.v2-cluster-wrap {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.v2-input-flex {
  min-width: 220px;
  flex: 1;
}

.v2-input-min-160 {
  min-width: 160px;
}

.v2-card-p0 {
  padding: 0;
}

.v2-card-p-sm {
  padding: 0.5rem;
}

.v2-header-pad {
  padding: 0.75rem 1rem;
}

.v2-table-footer-pad {
  padding: 0.65rem 0.85rem;
}

.v2-pane-hidden {
  display: none;
}

.v2-grid-faq {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 1rem;
  align-items: start;
}

.v2-kicker-sm {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  padding: 0.15rem .65rem .15rem;
}

.v2-loading-inline {
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 0.3rem 0.5rem;
}

.v2-w-24 { width: 24px; }
.v2-w-36 { width: 36px; }
.v2-w-70 { width: 70px; }
.v2-w-78 { width: 78px; }
.v2-w-80 { width: 80px; }
.v2-w-85 { width: 85px; }
.v2-w-88 { width: 88px; }
.v2-w-100 { width: 100px; }
.v2-w-120 { width: 120px; }
.v2-w-125 { width: 125px; }
.v2-w-135 { width: 135px; }
.v2-w-140 { width: 140px; }
.v2-w-150 { width: 150px; }
.v2-w-160 { width: 160px; }
.v2-w-200 { width: 200px; }

.v2-pl-9 {
  padding-left: 0.9rem;
}

/* Responsive */
@media (max-width: 1199.98px) {
  .v2-stat-grid  { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .v2-mini-grid  { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 991.98px) {
  .v2-activity-grid { grid-template-columns: 1fr; }
  .v2-detail-grid,
  .v2-public-faq-layout { grid-template-columns: 1fr; }
}

@media (max-width: 767.98px) {
  .v2-stat-grid,
  .v2-mini-grid  { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .v2-col-time   { width: 90px; font-size: 0.65rem; }
  .v2-form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 575.98px) {
  .v2-stat-grid  { grid-template-columns: 1fr; }
  .v2-mini-grid  { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .v2-col-msg    { display: none; }
}
