.mb-0 { margin-bottom: 0 !important; }
.mb-3 { margin-bottom: 1rem !important; }
.d-none { display: none !important; }

.page-header-flex {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-actions {
  display: flex;
  gap: 10px;
}

.section-title {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 700;
  color: #0b1b44;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: #64748b;
  line-height: 1.5;
}

.case-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.case-no-label {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 4px;
}

.case-no {
  font-size: 28px;
  font-weight: 700;
  color: #0b1b44;
}

/* detail blocks */
.detail-grid,
.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.detail-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-item,
.kv-item,
.note-item {
  background: #fbfdff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.detail-label,
.kv-label,
.note-item-title {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 6px;
}

.detail-value,
.kv-value,
.note-item-value {
  font-size: 16px;
  font-weight: 600;
  color: #0f172a;
  word-break: break-word;
}

.detail-subvalue {
  margin-top: 6px;
  font-size: 13px;
  color: #64748b;
  word-break: break-word;
}

.note-box {
  min-height: 90px;
  white-space: pre-wrap;
  background: #fbfdff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  color: #334155;
  line-height: 1.7;
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.app-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-soft-primary {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.badge-soft-info {
  background: #ecfeff;
  color: #0f766e;
  border-color: #a5f3fc;
}

.badge-soft-warning {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.badge-soft-success {
  background: #ecfdf5;
  color: #15803d;
  border-color: #bbf7d0;
}

.badge-soft-secondary {
  background: #f8fafc;
  color: #475569;
  border-color: #e2e8f0;
}

/* realtime status */
.status-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.status-subtitle {
  margin-top: 6px;
  font-size: 13px;
  color: #64748b;
}

.status-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
}

.status-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #2563eb;
  animation: pulse-live 1.4s infinite;
}

@keyframes pulse-live {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.30); }
  70% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0.00); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.00); }
}

.circle-progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.circle-step {
  position: relative;
  text-align: center;
  padding: 10px 8px 0;
}

.circle-node-wrap {
  position: relative;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.circle-line {
  position: absolute;
  top: 50%;
  left: calc(50% + 42px);
  width: calc(100% - 20px);
  height: 6px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.circle-line::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
}

.circle-step:last-child .circle-line {
  display: none;
}

.circle-node {
  position: relative;
  z-index: 2;
  width: 84px;
  height: 84px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 2px solid #dbe5f1;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  transition: all .25s ease;
}

.circle-title {
  margin-top: 12px;
  font-size: 15px;
  font-weight: 700;
  color: #475569;
  line-height: 1.4;
}

.circle-subtitle {
  margin-top: 6px;
  min-height: 34px;
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.45;
}

.circle-state-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
  background: #f1f5f9;
  color: #64748b;
}

.circle-step.pending .circle-line { background: #e2e8f0; }

.circle-step.done .circle-node {
  background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 0 0 10px rgba(37, 99, 235, 0.12);
}
.circle-step.done .circle-title { color: #1d4ed8; }
.circle-step.done .circle-state-label {
  background: #dbeafe;
  color: #1d4ed8;
}
.circle-step.done .circle-line {
  background: linear-gradient(90deg, #60a5fa 0%, #2563eb 100%);
}

.circle-step.active .circle-node {
  background: linear-gradient(180deg, #facc15 0%, #eab308 100%);
  border-color: #eab308;
  color: #78350f;
  box-shadow: 0 0 0 12px rgba(234, 179, 8, 0.16);
  animation: pulse-node-yellow 1.6s infinite;
}
.circle-step.active .circle-title { color: #a16207; }
.circle-step.active .circle-state-label {
  background: #fef3c7;
  color: #a16207;
}
.circle-step.active .circle-line { background: #fde68a; }
.circle-step.active .circle-line::after {
  opacity: 1;
  background: linear-gradient(
    90deg,
    rgba(234, 179, 8, 0) 0%,
    rgba(234, 179, 8, 0.25) 20%,
    rgba(234, 179, 8, 0.95) 50%,
    rgba(250, 204, 21, 0.95) 70%,
    rgba(234, 179, 8, 0) 100%
  );
  background-size: 180px 100%;
  animation: line-flow 1.3s linear infinite;
}

.circle-step.cancelled .circle-node {
  background: linear-gradient(180deg, #f87171 0%, #dc2626 100%);
  border-color: #dc2626;
  color: #fff;
  box-shadow: 0 0 0 12px rgba(220, 38, 38, 0.14);
}
.circle-step.cancelled .circle-title { color: #b91c1c; }
.circle-step.cancelled .circle-state-label {
  background: #fee2e2;
  color: #b91c1c;
}
.circle-step.cancelled .circle-line {
  background: linear-gradient(90deg, #f87171 0%, #dc2626 100%);
}

@keyframes line-flow {
  from { transform: translateX(-120px); }
  to { transform: translateX(220px); }
}

@keyframes pulse-node-yellow {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 12px rgba(234, 179, 8, 0.16);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 22px rgba(234, 179, 8, 0.03);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 12px rgba(234, 179, 8, 0.16);
  }
}

/* tabs + content in one block */
.case-tabs-card {
  overflow: hidden;
}

.case-tabs-shell {
  padding: 0;
}

.case-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px 18px 0;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
  border-bottom: 1px solid var(--border);
}

.case-tab-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #cfdcf3;
  border-bottom: none;
  background: linear-gradient(180deg, #f4f8ff 0%, #e8f0ff 100%);
  color: #475569;
  padding: 12px 18px;
  border-radius: 16px 16px 0 0;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: box-shadow .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
}

.case-tab-btn:hover {
  color: #1d4ed8;
  border-color: #9dbcf7;
  background: linear-gradient(180deg, #ffffff 0%, #eef5ff 100%);
}

.case-tab-btn.is-active {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  border-color: #2563eb;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.12);
}

.case-tab-panels {
  background: #fff;
  padding: 18px;
}

.case-tab-panel {
  display: none;
}

.case-tab-panel.is-active {
  display: block;
}

.tab-section-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}

.tab-section-body {
  padding: 22px;
}

.tab-block + .tab-block {
  margin-top: 22px;
}

.tab-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #dbe7fb, transparent);
  margin: 22px 0;
}

/* photos */
.case-photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.case-photo-item {
  display: block;
  text-decoration: none;
  background: #fbfdff;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}

.case-photo-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.case-photo-img {
  display: block;
  width: 100%;
  height: 170px;
  object-fit: cover;
  background: #f1f5f9;
}

.case-photo-name {
  padding: 10px 12px;
  font-size: 13px;
  color: #334155;
  word-break: break-word;
}

.chat-empty {
  color: #64748b;
  text-align: center;
  padding: 14px;
}

/* floating chat */
.floating-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 360px;
  max-width: calc(100vw - 24px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
  overflow: hidden;
  z-index: 3000;
}

.floating-chat.minimized .floating-chat-body {
  display: none;
}

.floating-chat.hidden {
  display: none;
}

.floating-chat.has-unread {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12), 0 18px 40px rgba(15, 23, 42, 0.18);
}

.floating-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
}

.floating-chat-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e3a8a;
  line-height: 1.2;
}

.floating-chat-subtitle {
  margin-top: 3px;
  font-size: 12px;
  color: #475569;
}

.floating-chat-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  cursor: pointer;
}

.floating-chat-body {
  display: flex;
  flex-direction: column;
  height: 420px;
}

.chat-messages {
  flex: 1;
  overflow: auto;
  padding: 14px;
  background: #f8fafc;
}

.chat-row {
  margin-bottom: 12px;
}

.chat-row.me {
  text-align: right;
}

.chat-bubble {
  display: inline-block;
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-row.other .chat-bubble {
  background: #fff;
  border: 1px solid var(--border);
  color: #0f172a;
  border-bottom-left-radius: 4px;
}

.chat-row.me .chat-bubble {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-meta {
  margin-top: 4px;
  font-size: 11px;
  color: #64748b;
}

.chat-form {
  border-top: 1px solid var(--border);
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.floating-chat-toggle {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2990;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.25);
  cursor: pointer;
}

.floating-chat-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #facc15;
}

/* responsive */
@media (max-width: 1199.98px) {
  .circle-progress {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 24px;
  }

  .circle-step:nth-child(2) .circle-line,
  .circle-step:nth-child(4) .circle-line {
    display: none;
  }
}

@media (max-width: 767.98px) {
  .page-header-flex,
  .case-head,
  .status-head,
  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .case-tabs {
    padding: 14px 14px 0;
  }

  .case-tab-btn {
    width: 100%;
    justify-content: flex-start;
    border-radius: 14px;
    border-bottom: 1px solid #cfdcf3;
    transform: none !important;
  }

  .case-tab-panels,
  .tab-section-body {
    padding: 14px;
  }

  .detail-grid,
  .kv-grid,
  .note-grid,
  .circle-progress {
    grid-template-columns: 1fr;
  }

  .circle-node {
    width: 72px;
    height: 72px;
    font-size: 28px;
  }

  .circle-line {
    display: none;
  }

  .floating-chat {
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
  }

  .floating-chat-toggle {
    right: 12px;
    bottom: 12px;
  }
}