/**
 * HT ERP Enterprise Theme - Application Layer
 * ------------------------------------------------------------------
 * استایل اختصاصی Layout، Dashboard، صفحات ماژول و نمودار ساختاری.
 * این فایل مستقل از سورس Bootstrap و پلاگین‌ها نگهداری می‌شود.
 */

/* Base document */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--ht-border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: var(--ht-border-strong);
  border-radius: 999px;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  font-family: var(--ht-font-family);
  color: var(--ht-text);
  background-color: var(--ht-bg);
  background-image:
    linear-gradient(var(--ht-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--ht-grid-line) 1px, transparent 1px),
    radial-gradient(circle at 75% -10%, rgba(var(--ht-primary-rgb), .12), transparent 32%),
    radial-gradient(circle at 10% 90%, rgba(var(--ht-cyan-rgb), .05), transparent 28%);
  background-size: 42px 42px, 42px 42px, auto, auto;
  transition: background-color var(--ht-transition), color var(--ht-transition);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

/* Main application shell */
.app-shell {
  min-height: 100vh;
}

.app-sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 1040;
  width: var(--ht-sidebar-width);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(10, 22, 37, .98), rgba(7, 16, 29, .98));
  border-inline-end: 1px solid var(--ht-border);
  box-shadow: -18px 0 50px rgba(0, 0, 0, .14);
  transition: width var(--ht-transition), transform var(--ht-transition);
}

html[data-theme="light"] .app-sidebar {
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(242,247,252,.98));
}

.sidebar-brand {
  min-height: var(--ht-topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--ht-border);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: -.5px;
  background: linear-gradient(145deg, var(--ht-primary), #0b4ca6);
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 15px;
  box-shadow: var(--ht-glow-primary);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 1px solid rgba(var(--ht-primary-rgb), .22);
  border-radius: 18px;
}

.brand-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
  white-space: nowrap;
}

.brand-subtitle {
  display: block;
  margin-top: 3px;
  color: var(--ht-text-muted);
  font-size: .73rem;
  white-space: nowrap;
}

.sidebar-nav-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 24px;
}

.sidebar-section-title {
  margin: 16px 10px 9px;
  color: var(--ht-text-muted);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .02em;
}

.sidebar-search {
  position: sticky;
  top: 0;
  z-index: 2;
  margin-bottom: 12px;
  padding-block: 2px 8px;
  background: linear-gradient(180deg, var(--ht-bg-secondary) 72%, transparent);
}

.sidebar-menu {
  display: grid;
  gap: 6px;
}

.sidebar-module {
  border: 1px solid transparent;
  border-radius: 13px;
  overflow: hidden;
  transition: background-color var(--ht-transition-fast), border-color var(--ht-transition-fast);
}

.sidebar-module:hover {
  background: color-mix(in srgb, var(--ht-surface-3) 58%, transparent);
  border-color: var(--ht-border);
}

.sidebar-module.is-active {
  background: linear-gradient(90deg, rgba(var(--ht-primary-rgb), .17), rgba(var(--ht-primary-rgb), .04));
  border-color: rgba(var(--ht-primary-rgb), .25);
  box-shadow: inset -3px 0 0 var(--ht-primary);
}

.sidebar-module-button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--ht-text-soft);
  background: transparent;
  border: 0;
  text-align: right;
}

.sidebar-module-button:hover,
.sidebar-module.is-active .sidebar-module-button {
  color: var(--ht-text);
}

.sidebar-module-icon {
  width: 28px;
  flex: 0 0 28px;
  text-align: center;
  color: var(--ht-text-muted);
}

.sidebar-module.is-active .sidebar-module-icon {
  color: var(--ht-primary);
}

.sidebar-module-label {
  flex: 1;
  min-width: 0;
  font-size: .88rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-module-chevron {
  color: var(--ht-text-muted);
  font-size: .72rem;
  transition: transform var(--ht-transition-fast);
}

.sidebar-module.is-open .sidebar-module-chevron {
  transform: rotate(180deg);
}

.sidebar-children {
  display: none;
  padding: 0 45px 9px 10px;
}

.sidebar-module.is-open .sidebar-children {
  display: grid;
  gap: 3px;
}

.sidebar-child-link {
  position: relative;
  padding: 8px 10px;
  color: var(--ht-text-muted);
  border-radius: 9px;
  font-size: .78rem;
  transition: color var(--ht-transition-fast), background-color var(--ht-transition-fast);
}

.sidebar-child-link::before {
  content: "";
  position: absolute;
  top: 50%;
  right: -12px;
  width: 5px;
  height: 5px;
  background: var(--ht-border-strong);
  border-radius: 50%;
  transform: translateY(-50%);
}

.sidebar-child-link:hover,
.sidebar-child-link.is-active {
  color: var(--ht-text);
  background: color-mix(in srgb, var(--ht-primary) 9%, transparent);
}

.sidebar-child-link.is-active::before {
  background: var(--ht-primary);
  box-shadow: 0 0 10px rgba(var(--ht-primary-rgb), .75);
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--ht-border);
}

.sidebar-system-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--ht-text-muted);
  background: var(--ht-surface-2);
  border: 1px solid var(--ht-border);
  border-radius: 13px;
  font-size: .75rem;
}

.status-pulse {
  width: 9px;
  height: 9px;
  background: var(--ht-success);
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(54, 212, 143, .08), 0 0 18px rgba(54, 212, 143, .55);
}

/* Top navigation */
.app-topbar {
  position: fixed;
  inset-block-start: 0;
  inset-inline-start: var(--ht-sidebar-width);
  inset-inline-end: 0;
  z-index: 1035;
  height: var(--ht-topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--ht-bg) 82%, transparent);
  border-bottom: 1px solid var(--ht-border);
  backdrop-filter: blur(18px);
  transition: inset-inline-start var(--ht-transition);
}

.topbar-start,
.topbar-end {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  position: relative;
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  color: var(--ht-text-muted);
  background: var(--ht-surface-glass);
  border: 1px solid var(--ht-border);
  border-radius: 12px;
  transition: color var(--ht-transition-fast), border-color var(--ht-transition-fast), transform var(--ht-transition-fast);
}

.icon-button:hover {
  color: var(--ht-text);
  border-color: rgba(var(--ht-primary-rgb), .42);
  transform: translateY(-1px);
}

.notification-dot {
  position: absolute;
  top: -4px;
  left: -3px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding-inline: 4px;
  color: #fff;
  background: var(--ht-danger);
  border: 2px solid var(--ht-bg);
  border-radius: 999px;
  font-size: .62rem;
  font-weight: 800;
}

.command-search {
  width: min(520px, 38vw);
}

.command-search .form-control {
  padding-inline-start: 44px;
}

.command-search-icon {
  position: absolute;
  top: 50%;
  right: 15px;
  z-index: 3;
  color: var(--ht-text-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.command-shortcut {
  position: absolute;
  top: 50%;
  left: 10px;
  z-index: 3;
  padding: 3px 7px;
  color: var(--ht-text-muted);
  background: var(--ht-surface-3);
  border: 1px solid var(--ht-border);
  border-radius: 7px;
  font-size: .66rem;
  transform: translateY(-50%);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 12px;
  background: var(--ht-surface-glass);
  border: 1px solid var(--ht-border);
  border-radius: 14px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #2388ff, #0e447f);
  border-radius: 11px;
  font-weight: 800;
}

.user-name {
  display: block;
  color: var(--ht-text);
  font-size: .8rem;
  font-weight: 700;
  line-height: 1.3;
}

.user-role {
  display: block;
  color: var(--ht-text-muted);
  font-size: .66rem;
}

/* Main content */
.app-main {
  min-height: 100vh;
  margin-inline-start: var(--ht-sidebar-width);
  padding-top: var(--ht-topbar-height);
  transition: margin-inline-start var(--ht-transition);
}

.app-content {
  width: 100%;
  max-width: var(--ht-content-max);
  margin-inline: auto;
  padding: 24px;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0 0 7px;
  font-size: clamp(1.35rem, 2vw, 2rem);
  font-weight: 850;
  letter-spacing: -.02em;
}

.page-description {
  margin: 0;
  color: var(--ht-text-muted);
  font-size: .88rem;
}

.breadcrumb-tech {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  color: var(--ht-text-muted);
  font-size: .72rem;
}

.page-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* Enterprise visual cards */
.enterprise-card {
  position: relative;
  isolation: isolate;
}

.enterprise-card::before {
  content: "";
  position: absolute;
  inset-inline: 16px;
  inset-block-start: 0;
  z-index: -1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--ht-primary-rgb), .55), transparent);
  opacity: .65;
}

.enterprise-card .card-body {
  padding: 18px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title-main {
  margin: 0;
  font-size: .92rem;
  font-weight: 750;
}

.card-title-meta {
  color: var(--ht-text-muted);
  font-size: .7rem;
}

/* KPI cards */
.kpi-card {
  min-height: 158px;
}

.kpi-card .card-body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.kpi-label {
  color: var(--ht-text-muted);
  font-size: .78rem;
}

.kpi-value {
  margin-top: 8px;
  font-size: clamp(1.25rem, 1.7vw, 1.72rem);
  font-weight: 850;
  letter-spacing: -.03em;
}

.kpi-unit {
  color: var(--ht-text-muted);
  font-size: .7rem;
}

.kpi-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: var(--kpi-color, var(--ht-primary));
  background: color-mix(in srgb, var(--kpi-color, var(--ht-primary)) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--kpi-color, var(--ht-primary)) 28%, transparent);
  border-radius: 14px;
  box-shadow: 0 0 24px color-mix(in srgb, var(--kpi-color, var(--ht-primary)) 12%, transparent);
}

.kpi-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.kpi-trend {
  color: var(--ht-success);
  font-size: .72rem;
  font-weight: 700;
}

.kpi-trend.is-negative {
  color: var(--ht-danger);
}

.mini-sparkline {
  width: 94px;
  height: 34px;
  overflow: visible;
}

.mini-sparkline path {
  fill: none;
  stroke: var(--kpi-color, var(--ht-primary));
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--kpi-color, var(--ht-primary)) 45%, transparent));
}

/* Charts */
.chart-host {
  width: 100%;
  min-height: 330px;
}

.chart-host.chart-host-sm {
  min-height: 260px;
}

.chart-host.chart-host-lg {
  min-height: 380px;
}

.chart-loading {
  min-height: inherit;
  display: grid;
  place-items: center;
  color: var(--ht-text-muted);
  font-size: .8rem;
}

/* Timeline and activity */
.activity-list {
  display: grid;
  gap: 5px;
}

.activity-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: background-color var(--ht-transition-fast), border-color var(--ht-transition-fast);
}

.activity-item:hover {
  background: var(--ht-surface-2);
  border-color: var(--ht-border);
}

.activity-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--activity-color, var(--ht-primary));
  background: color-mix(in srgb, var(--activity-color, var(--ht-primary)) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--activity-color, var(--ht-primary)) 22%, transparent);
  border-radius: 11px;
}

.activity-title {
  color: var(--ht-text-soft);
  font-size: .78rem;
  font-weight: 650;
}

.activity-meta {
  margin-top: 3px;
  color: var(--ht-text-muted);
  font-size: .66rem;
}

.activity-time {
  color: var(--ht-text-muted);
  font-size: .66rem;
  white-space: nowrap;
}

/* Task list */
.task-list {
  display: grid;
  gap: 8px;
}

.task-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: color-mix(in srgb, var(--ht-surface-2) 75%, transparent);
  border: 1px solid var(--ht-border);
  border-radius: 12px;
}

.task-priority {
  width: 8px;
  height: 8px;
  background: var(--task-color, var(--ht-primary));
  border-radius: 50%;
  box-shadow: 0 0 12px color-mix(in srgb, var(--task-color, var(--ht-primary)) 60%, transparent);
}

.task-name {
  font-size: .76rem;
  font-weight: 650;
}

.task-meta {
  color: var(--ht-text-muted);
  font-size: .64rem;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: .67rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
}

.status-success {
  color: var(--ht-success);
  background: rgba(54, 212, 143, .09);
  border-color: rgba(54, 212, 143, .22);
}

.status-info {
  color: var(--ht-info);
  background: rgba(69, 185, 255, .09);
  border-color: rgba(69, 185, 255, .22);
}

.status-warning {
  color: var(--ht-warning);
  background: rgba(246, 183, 60, .09);
  border-color: rgba(246, 183, 60, .22);
}

.status-danger {
  color: var(--ht-danger);
  background: rgba(255, 95, 109, .09);
  border-color: rgba(255, 95, 109, .22);
}

/* Quick action grid */
.quick-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 66px;
  padding: 11px;
  color: var(--ht-text-soft);
  background: var(--ht-surface-2);
  border: 1px solid var(--ht-border);
  border-radius: 13px;
  transition: color var(--ht-transition-fast), border-color var(--ht-transition-fast), transform var(--ht-transition-fast);
}

.quick-action:hover {
  color: var(--ht-text);
  border-color: rgba(var(--ht-primary-rgb), .35);
  transform: translateY(-2px);
}

.quick-action i {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--ht-primary);
  background: rgba(var(--ht-primary-rgb), .09);
  border-radius: 10px;
}

.quick-action span {
  font-size: .74rem;
  font-weight: 650;
}

/* System health */
.health-metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.health-label {
  color: var(--ht-text-muted);
  font-size: .7rem;
}

.health-value {
  font-size: .72rem;
  font-weight: 750;
}

.health-bar {
  height: 6px;
  overflow: hidden;
  background: var(--ht-surface-3);
  border-radius: 999px;
}

.health-bar > span {
  display: block;
  height: 100%;
  width: var(--health-value, 50%);
  background: linear-gradient(90deg, var(--health-color, var(--ht-primary)), color-mix(in srgb, var(--health-color, var(--ht-primary)) 60%, #fff));
  border-radius: inherit;
  box-shadow: 0 0 12px color-mix(in srgb, var(--health-color, var(--ht-primary)) 42%, transparent);
}

/* Module page */
.module-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  background:
    linear-gradient(125deg, rgba(var(--ht-primary-rgb), .11), transparent 44%),
    var(--ht-surface-1);
}

.module-hero::after {
  content: "";
  position: absolute;
  top: -80px;
  left: -60px;
  width: 240px;
  height: 240px;
  border: 1px solid rgba(var(--ht-primary-rgb), .18);
  border-radius: 50%;
  box-shadow: 0 0 0 35px rgba(var(--ht-primary-rgb), .025), 0 0 0 70px rgba(var(--ht-primary-rgb), .018);
}

.module-hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
}

.module-hero-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  color: var(--ht-primary);
  background: rgba(var(--ht-primary-rgb), .1);
  border: 1px solid rgba(var(--ht-primary-rgb), .24);
  border-radius: 18px;
  font-size: 1.45rem;
  box-shadow: var(--ht-glow-primary);
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.module-tile {
  position: relative;
  min-height: 146px;
  padding: 18px;
  background: var(--ht-surface-1);
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-sm);
  transition: transform var(--ht-transition), border-color var(--ht-transition), box-shadow var(--ht-transition);
}

.module-tile:hover {
  transform: translateY(-4px);
  border-color: rgba(var(--ht-primary-rgb), .35);
  box-shadow: var(--ht-shadow-md), var(--ht-glow-primary);
}

.module-tile-index {
  display: inline-grid;
  place-items: center;
  width: 31px;
  height: 31px;
  margin-bottom: 14px;
  color: var(--ht-primary);
  background: rgba(var(--ht-primary-rgb), .09);
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 800;
}

.module-tile-title {
  margin: 0 0 7px;
  font-size: .9rem;
  font-weight: 750;
}

.module-tile-description {
  margin: 0;
  color: var(--ht-text-muted);
  font-size: .72rem;
  line-height: 1.9;
}

.module-tile-arrow {
  position: absolute;
  left: 16px;
  bottom: 16px;
  color: var(--ht-text-muted);
}

/* Components showcase */
.showcase-section {
  margin-bottom: 20px;
}

.library-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  color: var(--ht-cyan);
  background: rgba(var(--ht-cyan-rgb), .07);
  border: 1px solid rgba(var(--ht-cyan-rgb), .17);
  border-radius: 999px;
  font-size: .64rem;
  font-weight: 700;
}

/* Visio-like architecture map */
.architecture-canvas {
  position: relative;
  min-height: 980px;
  overflow: auto;
  padding: 40px;
  background:
    linear-gradient(var(--ht-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--ht-grid-line) 1px, transparent 1px),
    var(--ht-surface-1);
  background-size: 28px 28px;
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-sm);
}

.architecture-map {
  position: relative;
  min-width: 1120px;
  min-height: 900px;
}

.architecture-core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 220px;
  height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  color: #fff;
  background: radial-gradient(circle at 35% 30%, #2693ff, #0b407c 58%, #082342);
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 50%;
  box-shadow: 0 0 0 12px rgba(var(--ht-primary-rgb), .04), 0 0 0 28px rgba(var(--ht-primary-rgb), .025), 0 0 50px rgba(var(--ht-primary-rgb), .25);
  transform: translate(-50%, -50%);
}

.architecture-core strong {
  display: block;
  font-size: 1.35rem;
}

.architecture-core small {
  display: block;
  margin-top: 7px;
  color: rgba(255,255,255,.72);
}

.architecture-node {
  position: absolute;
  width: 210px;
  min-height: 92px;
  padding: 14px;
  background: var(--ht-surface-2);
  border: 1px solid var(--ht-border-strong);
  border-radius: 16px;
  box-shadow: var(--ht-shadow-sm);
  transform: translate(-50%, -50%);
}

.architecture-node::after {
  content: "";
  position: absolute;
  inset-inline-start: 16px;
  inset-block-start: 0;
  width: 42px;
  height: 2px;
  background: var(--node-color, var(--ht-primary));
  box-shadow: 0 0 12px var(--node-color, var(--ht-primary));
}

.architecture-node-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 6px;
  font-size: .8rem;
  font-weight: 750;
}

.architecture-node-title i {
  color: var(--node-color, var(--ht-primary));
}

.architecture-node-meta {
  color: var(--ht-text-muted);
  font-size: .65rem;
  line-height: 1.7;
}

.architecture-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.architecture-svg line {
  stroke: rgba(var(--ht-primary-rgb), .24);
  stroke-width: 1.25;
  stroke-dasharray: 5 7;
}

/* Command palette */
.command-results {
  display: grid;
  gap: 6px;
  max-height: 430px;
  overflow-y: auto;
}

.command-result {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  color: var(--ht-text-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  text-align: right;
}

.command-result:hover,
.command-result.is-focused {
  color: var(--ht-text);
  background: var(--ht-surface-2);
  border-color: var(--ht-border);
}

.command-result-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--ht-primary);
  background: rgba(var(--ht-primary-rgb), .09);
  border-radius: 10px;
}

.command-result small {
  color: var(--ht-text-muted);
}

/* Collapsed desktop sidebar state */
body.sidebar-collapsed .app-sidebar {
  width: var(--ht-sidebar-collapsed-width);
}

body.sidebar-collapsed .app-topbar {
  inset-inline-start: var(--ht-sidebar-collapsed-width);
}

body.sidebar-collapsed .app-main {
  margin-inline-start: var(--ht-sidebar-collapsed-width);
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .sidebar-module-label,
body.sidebar-collapsed .sidebar-module-chevron,
body.sidebar-collapsed .sidebar-section-title,
body.sidebar-collapsed .sidebar-search,
body.sidebar-collapsed .sidebar-children,
body.sidebar-collapsed .sidebar-system-status span {
  display: none !important;
}

body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .sidebar-module-button,
body.sidebar-collapsed .sidebar-system-status {
  justify-content: center;
}

body.sidebar-collapsed .sidebar-module-button {
  padding-inline: 0;
}

body.sidebar-collapsed .sidebar-module-icon {
  color: var(--ht-text-soft);
  font-size: 1rem;
}

/* Footer */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding-top: 18px;
  color: var(--ht-text-muted);
  border-top: 1px solid var(--ht-border);
  font-size: .68rem;
}


/* ==================================================================
   Enterprise v1.1 visual/runtime refinements
   Libraries: project layer only; Bootstrap and plugin sources untouched.
   ================================================================== */

/* Keep layout geometry stable while vendor icons are still downloading. */
.fa-solid,
.fa-regular,
.fa-brands {
  min-width: 1em;
  text-align: center;
}

/* Higher-tech shell with restrained blue accents instead of an all-blue wash. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(135deg, transparent 0 49.85%, rgba(var(--ht-primary-rgb), .035) 50%, transparent 50.15%) 0 0 / 160px 160px,
    radial-gradient(circle at 45% 0%, rgba(var(--ht-primary-rgb), .08), transparent 30%),
    radial-gradient(circle at 5% 75%, rgba(var(--ht-cyan-rgb), .035), transparent 24%);
}

.app-sidebar::after {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-end: -1px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(var(--ht-primary-rgb), .52), transparent);
  pointer-events: none;
}

.app-topbar::after {
  content: "";
  position: absolute;
  inset-inline: 18px;
  inset-block-end: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--ht-primary-rgb), .45), rgba(var(--ht-cyan-rgb), .24), transparent);
  pointer-events: none;
}

.enterprise-card {
  overflow: hidden;
  contain: layout paint;
  transform: translateZ(0);
}

.enterprise-card::after {
  content: "";
  position: absolute;
  inset-block-start: 10px;
  inset-inline-end: 10px;
  width: 18px;
  height: 18px;
  border-block-start: 1px solid rgba(var(--ht-primary-rgb), .34);
  border-inline-end: 1px solid rgba(var(--ht-primary-rgb), .34);
  opacity: .7;
  pointer-events: none;
}

.enterprise-card:hover {
  border-color: color-mix(in srgb, var(--ht-primary) 24%, var(--ht-border));
  box-shadow: var(--ht-shadow-sm), 0 0 0 1px rgba(var(--ht-primary-rgb), .04), 0 0 34px rgba(var(--ht-primary-rgb), .045);
}

/* Live enterprise telemetry strip between page heading and KPI cards. */
.ops-telemetry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding: 11px 14px;
  background: linear-gradient(90deg, rgba(var(--ht-primary-rgb), .075), rgba(13, 25, 40, .72) 42%, rgba(13, 25, 40, .58));
  border: 1px solid var(--ht-border);
  border-radius: 14px;
  box-shadow: inset 0 1px rgba(255,255,255,.025);
}

html[data-theme="light"] .ops-telemetry {
  background: linear-gradient(90deg, rgba(var(--ht-primary-rgb), .08), rgba(255,255,255,.88));
}

.ops-telemetry__lead,
.ops-telemetry__metrics,
.ops-telemetry__metrics > span {
  display: flex;
  align-items: center;
}

.ops-telemetry__lead { gap: 10px; min-width: max-content; }
.ops-telemetry__lead strong { display:block; font-size:.74rem; letter-spacing:.03em; }
.ops-telemetry__lead small { display:block; margin-top:2px; color:var(--ht-text-muted); font-size:.62rem; }
.ops-live-dot { width:9px; height:9px; flex:0 0 auto; background:var(--ht-success); border-radius:50%; box-shadow:0 0 0 5px rgba(54,212,143,.07),0 0 18px rgba(54,212,143,.5); }
.ops-telemetry__metrics { justify-content:flex-end; flex-wrap:wrap; gap:8px; }
.ops-telemetry__metrics > span { gap:8px; padding:6px 10px; background:rgba(255,255,255,.018); border:1px solid var(--ht-border); border-radius:9px; }
.ops-telemetry__metrics small { color:var(--ht-text-muted); font-size:.6rem; }
.ops-telemetry__metrics strong { color:var(--ht-text-soft); font-size:.68rem; font-weight:750; }

/* Chart containers reserve space from first paint, preventing layout jumps. */
.chart-host {
  position: relative;
  overflow: hidden;
  contain: layout paint size;
  background:
    linear-gradient(var(--ht-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--ht-grid-line) 1px, transparent 1px);
  background-size: 36px 36px;
  border-radius: 12px;
}

.chart-host > div[style] { direction:ltr; }
.chart-loading { position:absolute; inset:0; min-height:0; }
.chart-loading::before { content:""; width:22px; height:22px; margin-inline-end:9px; border:2px solid var(--ht-border-strong); border-block-start-color:var(--ht-primary); border-radius:50%; animation:chartSpin .75s linear infinite; }
.chart-error { min-height:inherit; display:grid; place-items:center; padding:20px; color:var(--ht-text-muted); text-align:center; font-size:.74rem; }
@keyframes chartSpin { to { transform:rotate(360deg); } }

/* Lightweight table remains usable without waiting for DataTables. */
.table-responsive {
  min-width: 0;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

#recentOrdersTable { min-width: 650px; }

/* Avoid off-canvas page scroll when the mobile menu is open. */
body.sidebar-mobile-open { overflow:hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior:auto !important; animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; }
}

/* ==================================================================
   Enterprise v1.2 layout integrity and live-dashboard layer
   ------------------------------------------------------------------
   Project CSS only. Bootstrap, amCharts and plugin vendor files remain
   untouched so future upgrades do not inherit local edits.
   ================================================================== */

/* Explicit physical positioning keeps the RTL sidebar on the right in
   browsers that differ in logical-property handling. */
.app-sidebar {
  right: 0;
  left: auto;
  overflow-x: hidden;
  border-right: 0;
  border-left: 1px solid var(--ht-border);
  box-shadow: -18px 0 50px rgba(0, 0, 0, .14);
}

.app-topbar {
  right: var(--ht-sidebar-width);
  left: 0;
  min-width: 0;
  transition: right var(--ht-transition);
}

.app-main {
  margin-right: var(--ht-sidebar-width);
  margin-left: 0;
  min-width: 0;
  transition: margin-right var(--ht-transition);
}

body.sidebar-collapsed .app-topbar {
  right: var(--ht-sidebar-collapsed-width);
  left: 0;
}

body.sidebar-collapsed .app-main {
  margin-right: var(--ht-sidebar-collapsed-width);
  margin-left: 0;
}

/* Prevent the brand and collapse control from stacking over each other. */
body.sidebar-collapsed .sidebar-brand {
  position: relative;
  justify-content: center;
  padding-inline: 8px;
}

body.sidebar-collapsed .sidebar-brand [data-sidebar-collapse] {
  display: none !important;
}

body.sidebar-collapsed .brand-lockup {
  cursor: pointer;
}

body.sidebar-collapsed .brand-mark::before {
  content: "بازکردن";
  position: absolute;
  top: calc(100% + 10px);
  right: 50%;
  z-index: 4;
  padding: 4px 7px;
  color: var(--ht-text-muted);
  background: var(--ht-surface-1);
  border: 1px solid var(--ht-border);
  border-radius: 7px;
  font-size: .58rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(50%) translateY(-3px);
  pointer-events: none;
  transition: opacity var(--ht-transition-fast), transform var(--ht-transition-fast);
}

body.sidebar-collapsed .brand-lockup:hover .brand-mark::before {
  opacity: 1;
  transform: translateX(50%) translateY(0);
}

/* Each flex/grid child may shrink without forcing cards or controls outside
   their Bootstrap column. This is the unglamorous cure for expensive chaos. */
.app-shell,
.app-content,
.row > *,
.enterprise-card,
.enterprise-card .card-body,
.card-title-row > *,
.topbar-start,
.topbar-end,
.ops-telemetry__lead,
.ops-telemetry__metrics,
.kpi-top > div {
  min-width: 0;
}

.sidebar-module-button,
.sidebar-child-link,
.quick-action,
.command-result {
  max-width: 100%;
}

.chart-host {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

/* Revenue distribution uses an HTML legend and center label so amCharts is
   never asked to squeeze labels into a narrow responsive card. */
.revenue-distribution-layout {
  display: grid;
  grid-template-columns: minmax(210px, .95fr) minmax(150px, .75fr);
  align-items: center;
  gap: 14px;
  min-height: 330px;
}

.revenue-chart-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;
  max-height: 310px;
}

.chart-host.chart-host-revenue {
  position: absolute;
  inset: 0;
  min-height: 0;
}

.revenue-chart-center {
  position: absolute;
  top: 50%;
  right: 50%;
  z-index: 2;
  width: 42%;
  display: grid;
  place-items: center;
  text-align: center;
  transform: translate(50%, -50%);
  pointer-events: none;
}

.revenue-chart-center small,
.revenue-chart-center span {
  color: var(--ht-text-muted);
  font-size: clamp(.58rem, .7vw, .7rem);
  line-height: 1.55;
}

.revenue-chart-center strong {
  color: var(--ht-text);
  font-size: clamp(1.25rem, 2vw, 1.85rem);
  line-height: 1.25;
}

.revenue-legend {
  display: grid;
  gap: 8px;
}

.revenue-legend-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  color: var(--ht-text-soft);
  background: color-mix(in srgb, var(--ht-surface-2) 70%, transparent);
  border: 1px solid var(--ht-border);
  border-radius: 10px;
  font-size: .7rem;
}

.revenue-legend-item__dot {
  width: 8px;
  height: 8px;
  background: var(--legend-color);
  border-radius: 50%;
  box-shadow: 0 0 12px color-mix(in srgb, var(--legend-color) 58%, transparent);
}

.revenue-legend-item strong {
  color: var(--ht-text);
  font-size: .72rem;
}

/* Live refresh controller. */
.ops-refresh {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 10px;
  color: var(--ht-text-soft);
  background: color-mix(in srgb, var(--ht-primary) 8%, var(--ht-surface-2));
  border: 1px solid rgba(var(--ht-primary-rgb), .25);
  border-radius: 9px;
  font-size: .66rem;
  white-space: nowrap;
}

.ops-refresh:hover {
  color: var(--ht-text);
  border-color: rgba(var(--ht-primary-rgb), .5);
}

.ops-refresh.is-refreshing i {
  animation: htRefreshSpin .8s linear infinite;
}

[data-kpi-value],
[data-telemetry],
[data-revenue-total] {
  transition: opacity 120ms ease, transform 120ms ease;
}

.is-data-updating [data-kpi-value],
.is-data-updating [data-telemetry],
.is-data-updating [data-revenue-total] {
  opacity: .42;
  transform: translateY(2px);
}

@keyframes htRefreshSpin {
  to { transform: rotate(-360deg); }
}

/* Component page alignment safeguards. */
.showcase-section {
  margin-bottom: 16px;
}

.showcase-section form > [class*="col-"],
.showcase-section .input-group,
.showcase-section .select2-container,
.showcase-section .bootstrap-tagsinput {
  min-width: 0;
}

.showcase-section .form-label {
  display: block;
  margin-bottom: 8px;
  color: var(--ht-text-soft);
  font-size: .78rem;
  font-weight: 650;
}

.showcase-section .form-text {
  min-height: 1.2rem;
  margin-top: 6px;
  color: var(--ht-text-muted);
  font-size: .66rem;
  overflow-wrap: anywhere;
}

.showcase-section .input-group {
  flex-wrap: nowrap;
}
