/* ---------- Generic card ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.card-glass {
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(22px) saturate(1.5);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 12px 40px rgba(46, 107, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
}

.card-title svg {
  width: 16px;
  height: 16px;
  color: var(--blue);
}

.card-title .card-extra {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
}

.card-title .card-extra:hover {
  color: var(--blue);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: var(--font);
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--grad-ai);
  color: #fff;
  box-shadow: 0 4px 14px rgba(46, 107, 255, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(46, 107, 255, 0.4);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-2);
}

.btn-secondary:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.btn-tertiary {
  background: transparent;
  color: var(--blue);
  padding: 6px 10px;
}

.btn-tertiary:hover {
  background: var(--blue-soft);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-quiet {
  background: var(--bg-soft);
  color: var(--text-2);
  border: 1px solid transparent;
  box-shadow: none;
}

.btn-quiet:hover {
  background: var(--grad-ai);
  color: #fff;
  box-shadow: 0 4px 14px rgba(46, 107, 255, 0.3);
}

/* ---------- Dropdown ---------- */

.dd {
  position: relative;
  user-select: none;
}

.dd-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 4px;
  display: none;
  flex-direction: column;
  min-width: 170px;
  z-index: 60;
}

.dd.open .dd-menu {
  display: flex;
  animation: kb-suggest-in 0.16s ease;
}

.filter-select.dd .dd-menu {
  bottom: auto;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
}

.dd-option {
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  cursor: pointer;
}

.dd-option:hover {
  background: var(--blue-soft);
  color: var(--blue-deep);
}

.dd-option.active {
  color: var(--blue);
  font-weight: 600;
}

/* ---------- Chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-2);
  white-space: nowrap;
}

.chip svg {
  width: 12px;
  height: 12px;
}

.chip-blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.chip-violet {
  background: var(--violet-soft);
  color: var(--violet);
}

.chip-cyan {
  background: var(--cyan-soft);
  color: #0e8fc9;
}

.chip-mint {
  background: var(--mint-soft);
  color: #12996f;
}

.chip-red {
  background: var(--red-soft);
  color: var(--red);
}

.chip-orange {
  background: var(--orange-soft);
  color: #e07f1a;
}

.chip-green {
  background: var(--green-soft);
  color: #15803d;
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  padding: 4px;
  border-radius: 12px;
  width: fit-content;
}

.tab {
  padding: 6px 16px;
  font-size: 13px;
  border-radius: 9px;
  color: var(--text-2);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: var(--font);
  transition: all 0.15s ease;
}

.tab.active {
  background: var(--surface);
  color: var(--blue);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ---------- Tables ---------- */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 13px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr {
  transition: background 0.12s ease;
}

.table tbody tr:hover {
  background: var(--bg-soft);
}

.table .cell-main {
  font-weight: 600;
  color: var(--text);
}

.table .cell-sub {
  font-size: 11.5px;
  color: var(--text-3);
}

/* ---------- Avatars ---------- */

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
}

.table .avatar {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.table .avatar:hover {
  transform: scale(1.4);
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 2;
}

.avatar-lg {
  width: 44px;
  height: 44px;
}

.avatar-stack {
  display: flex;
}

.avatar-stack .avatar {
  margin-left: -10px;
}

.avatar-stack .avatar:first-child {
  margin-left: 0;
}

.avatar-fallback {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
}

/* ---------- AI insight card ---------- */

.ai-insight {
  border-radius: var(--r-lg);
  background: var(--grad-ai-soft);
  border: 1px solid rgba(124, 92, 255, 0.16);
  box-shadow: var(--glow-ai);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.ai-insight::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 92, 255, 0.16), transparent 70%);
  pointer-events: none;
}

.ai-insight-bg {
  aspect-ratio: 800 / 333;
  background: url("../img/insight-bg.webp") center / 100% 100% no-repeat, var(--grad-ai-soft);
  padding: 14px 18px;
}

.ai-insight-bg::after {
  display: none;
}

.ai-insight-bg .rail-list {
  max-width: 56%;
}

.ai-insight .ai-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--grad-ai);
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.ai-insight .ai-tag svg {
  width: 12px;
  height: 12px;
}

/* ---------- KPI tile ---------- */

.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.kpi-tile .kpi-label {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-tile .kpi-label svg {
  width: 14px;
  height: 14px;
}

.kpi-tile .kpi-value {
  font-family: var(--font-num);
  font-size: 26px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: 0.5px;
}

.kpi-delta {
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
}

.kpi-delta svg {
  width: 12px;
  height: 12px;
}

.kpi-delta.up {
  color: var(--green);
}

.kpi-delta.down {
  color: var(--red);
}

.kpi-delta.warn {
  color: var(--orange);
}

/* ---------- Progress ---------- */

.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--grad-cyan);
  transition: width 0.4s ease;
}

/* ---------- Toast ---------- */

.toast-wrap {
  position: fixed;
  top: 76px;
  right: 28px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  animation: toast-in 0.25s ease;
}

.toast svg {
  width: 16px;
  height: 16px;
  color: var(--blue);
  flex-shrink: 0;
}

.toast.success {
  border-left-color: var(--green);
}

.toast.success svg {
  color: var(--green);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.hide {
  opacity: 0;
  transform: translateX(16px);
  transition: all 0.25s ease;
}

/* ---------- Pulse dot (AI working) ---------- */

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--grad-ai);
  animation: pulse 1.6s ease-in-out infinite;
  display: inline-block;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(46, 107, 255, 0.35);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(46, 107, 255, 0);
  }
}

/* ---------- Section header ---------- */

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-head h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-head h2 svg {
  width: 17px;
  height: 17px;
  color: var(--blue);
}

.section-head .more {
  font-size: 12.5px;
  color: var(--text-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.section-head .more:hover {
  color: var(--blue);
}

.section-head .more svg {
  width: 13px;
  height: 13px;
}

/* ---------- Page header ---------- */

.page-header {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.page-header .ph-text h1 {
  font-size: 22px;
  font-weight: 800;
  margin: 0;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 8px rgba(255, 255, 255, 0.95), 0 0 3px rgba(255, 255, 255, 0.9);
}

.page-header .ph-text p {
  margin: 4px 0 0;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-shadow: 0 1px 6px rgba(255, 255, 255, 0.95), 0 0 3px rgba(255, 255, 255, 0.9);
}

.page-header .ph-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

.page-header .ph-orb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  animation: orb-float 7s ease-in-out infinite;
  flex-shrink: 0;
}

/* ---------- Chart tooltip ---------- */

.chart-tooltip {
  position: absolute;
  transform: translate(-50%, -100%);
  background: var(--text);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
  box-shadow: var(--shadow-md);
}

.trend-summary {
  display: flex;
  gap: 14px;
  font-size: 11.5px;
  color: var(--text-3);
  margin: -6px 0 8px;
}

.trend-summary b {
  color: var(--text);
  font-family: var(--font-num);
  font-size: 13px;
}

/* ---------- Rail card list ---------- */

.rail-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rail-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12.5px;
}

.rail-item .ri-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rail-item .ri-icon svg {
  width: 15px;
  height: 15px;
}

.rail-item .ri-title {
  font-weight: 600;
  line-height: 1.4;
}

.rail-item .ri-sub {
  color: var(--text-3);
  font-size: 11.5px;
  margin-top: 1px;
}
