/*
  Dr. Babak Mashayekhi Dental Clinic - Design System Tokens
  Anti-Slop Invariant: Editorial, Calm, Tailored. Zero Neon/Purple Clichés.
*/

:root {
  --sky: #ecf1f4;
  --sky-hi: #f4f7f9;
  --mist: #fbfcfd;
  --slate: #2f3a45;
  --slate-dim: #69757f;
  --dawn: #f0a985;
  --dawn-deep: #d9805a;
  --peri: #93b4d1;
  --dew: #8fbf9e;
  --coral: #e0695c;
  --hair: #dce4ea;
  --placeholder: #9aa6af;
  --dawn-rgb: 240, 169, 133;
  --slate-rgb: 47, 58, 69;

  --fa: "Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --radius-card: 16px;
  --radius-pill: 999px;
  --radius-input: 12px;

  --shadow-card: 0 1px 3px rgba(var(--slate-rgb), 0.04), 0 4px 12px rgba(var(--slate-rgb), 0.02);
  --shadow-float: 0 8px 30px rgba(var(--slate-rgb), 0.06);

  --motion-fast: 0.15s ease;
  --motion-med: 0.25s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--fa);
  background-color: var(--sky);
  color: var(--slate);
  line-height: 1.6;
  direction: rtl;
  min-height: 100vh;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(1200px 480px at 70% -8%, rgba(var(--dawn-rgb), 0.14), transparent 60%),
              linear-gradient(180deg, var(--sky-hi) 0%, var(--sky) 38%);
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px 48px;
}

/* Header */
.site-header,
.header-main {
  position: sticky;
  top: 12px;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(251, 252, 253, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--hair);
  border-radius: var(--radius-card);
  box-shadow: 0 4px 16px rgba(47, 58, 69, 0.06);
  margin-bottom: 16px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo-badge {
  width: 48px;
  height: 48px;
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 4px;
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-titles h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--slate);
  letter-spacing: -0.01em;
}

.brand-titles p {
  font-size: 0.85rem;
  color: var(--slate-dim);
}

.header-status-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--sky-hi);
  border: 1px solid var(--hair);
  color: var(--slate);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dew);
  box-shadow: 0 0 0 0 rgba(143, 191, 158, 0.7);
  animation: pulse-ring 2s infinite cubic-bezier(0.66, 0, 0, 1);
}

.pulse-dot.warning {
  background: var(--dawn);
  box-shadow: 0 0 0 0 rgba(240, 169, 133, 0.7);
}

.pulse-dot.error {
  background: var(--coral);
  box-shadow: 0 0 0 0 rgba(224, 105, 92, 0.7);
  animation: none;
}

@keyframes pulse-ring {
  to {
    box-shadow: 0 0 0 8px rgba(143, 191, 158, 0);
  }
}

.btn-refresh {
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: var(--radius-input);
  padding: 6px 14px;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--slate);
  cursor: pointer;
  transition: all var(--motion-fast);
}

.btn-refresh:hover {
  background: var(--sky);
  border-color: var(--slate-dim);
}

/* Metrics Grid */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  transition: transform var(--motion-fast), box-shadow var(--motion-fast);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-float);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.metric-title {
  font-size: 0.88rem;
  color: var(--slate-dim);
  font-weight: 500;
}

.metric-tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--sky);
  color: var(--slate);
  border: 1px solid var(--hair);
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--slate);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.metric-subtext {
  font-size: 0.78rem;
  color: var(--slate-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Layout Split */
.layout-split {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr);
  gap: 20px;
}

.panel-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Card Container */
.card-panel {
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--hair);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--sky-hi);
}

.card-title-group h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--slate);
}

.card-title-group p {
  font-size: 0.8rem;
  color: var(--slate-dim);
  margin-top: 2px;
}

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

/* Kanban Board View - Professional Wide Layout */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  min-height: 320px;
}

.kanban-lane {
  background: var(--sky);
  border-radius: 14px;
  padding: 14px 12px;
  border: 1px solid var(--hair);
  display: flex;
  flex-direction: column;
  min-height: 300px;
}

.lane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid var(--hair);
}

.lane-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--slate);
  letter-spacing: -0.01em;
}

.lane-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--mist);
  border: 1px solid var(--hair);
  color: var(--slate);
  font-family: var(--mono);
}

.lane-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 420px;
  padding-left: 2px;
  flex: 1;
}

.kanban-task-card {
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(var(--slate-rgb), 0.04);
  transition: all var(--motion-fast);
}

.kanban-task-card:hover {
  border-color: var(--dawn-deep);
  transform: translateY(-1px);
  box-shadow: var(--shadow-float);
}

.task-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.task-id {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--slate-dim);
  direction: ltr;
  font-weight: 600;
}

.task-priority {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--sky);
  font-weight: 600;
}

.task-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--slate);
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  color: var(--slate-dim);
  border-top: 1px solid var(--hair);
  padding-top: 8px;
  margin-top: 6px;
}

.task-assignee {
  background: var(--sky-hi);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--hair);
  font-weight: 500;
  font-family: var(--mono);
  font-size: 0.68rem;
}

/* Empty state */
.empty-placeholder {
  text-align: center;
  padding: 24px 12px;
  color: var(--slate-dim);
  font-size: 0.82rem;
  font-style: italic;
}

/* Data Table */
.data-table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: right;
}

.data-table th {
  background: var(--sky-hi);
  padding: 10px 14px;
  color: var(--slate);
  font-weight: 600;
  border-bottom: 1px solid var(--hair);
  font-size: 0.78rem;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--hair);
  color: var(--slate);
}

.data-table tr:hover td {
  background: var(--sky);
}

/* Pills & Badges */
.badge-profile {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--sky);
  border: 1px solid var(--hair);
  color: var(--slate);
}

.badge-priority {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.priority-1 {
  background: #fdf2f2;
  color: var(--coral);
  border: 1px solid #f8d7da;
}

.priority-2 {
  background: #fff8f5;
  color: var(--dawn-deep);
  border: 1px solid #fde2d7;
}

.priority-3 {
  background: var(--sky);
  color: var(--slate-dim);
  border: 1px solid var(--hair);
}

.badge-status {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
}

.status-ok, .status-done, .status-scheduled {
  background: #f0f7f3;
  color: #3b7e52;
}

.status-running {
  background: #fff8f5;
  color: var(--dawn-deep);
}

.status-blocked, .status-error, .status-failed {
  background: #fdf2f2;
  color: var(--coral);
}

/* Cron List */
.cron-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cron-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--sky-hi);
  border: 1px solid var(--hair);
  transition: background var(--motion-fast);
}

.cron-item:hover {
  background: var(--sky);
}

.cron-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cron-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--slate);
}

.cron-sched {
  font-size: 0.72rem;
  color: var(--slate-dim);
  font-family: var(--mono);
  direction: ltr;
  text-align: right;
}

.cron-status-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

/* System Pulse Bars */
.pulse-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bar-label-group {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--slate);
}

.bar-track {
  width: 100%;
  height: 8px;
  background: var(--hair);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--slate);
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}

.bar-fill.accent {
  background: var(--dawn-deep);
}

.bar-fill.dew {
  background: var(--dew);
}

/* Timeline Activity */
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 320px;
  overflow-y: auto;
}

.timeline-entry {
  display: flex;
  gap: 12px;
  position: relative;
  padding-bottom: 4px;
}

.timeline-bullet {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dawn);
  margin-top: 5px;
  flex-shrink: 0;
}

.timeline-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.timeline-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--slate);
  line-height: 1.3;
}

.timeline-time {
  font-size: 0.7rem;
  color: var(--slate-dim);
  font-family: var(--mono);
}

/* Responsive Refinements */
@media (max-width: 1200px) {
  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .layout-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .kanban-board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .container {
    padding: 12px 14px 32px;
  }
  .site-header,
  .header-main {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 14px 16px;
    width: 100%;
    box-sizing: border-box;
  }
  .brand-section {
    width: 100%;
  }
  .header-status-area {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }
  .metric-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .kanban-board {
    grid-template-columns: 1fr;
  }
  .brand-titles h1 {
    font-size: 1.15rem;
  }
  .brand-titles p {
    font-size: 0.78rem;
  }
  .table-responsive,
  .modal-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  .metric-card {
    padding: 14px 16px;
  }
  .metric-value {
    font-size: 1.4rem;
  }
  .status-pill {
    font-size: 0.72rem;
    padding: 4px 10px;
  }
  .btn-refresh {
    padding: 5px 12px;
    font-size: 0.74rem;
  }
}

/* =========================================================
   Tab Navigation & Editorial Refinements
   ========================================================= */
.tab-nav {
  position: sticky;
  top: 98px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(251, 252, 253, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--hair);
  border-radius: var(--radius-card);
  padding: 8px 12px;
  margin-bottom: 24px;
  box-shadow: 0 4px 16px rgba(47, 58, 69, 0.05);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn,
.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 22px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-input);
  font-family: 'Vazirmatn', var(--fa);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--slate-dim);
  cursor: pointer;
  transition: all var(--motion-fast);
  white-space: nowrap;
}

.tab-btn:hover {
  background: var(--sky-hi);
  color: var(--slate);
  border-color: var(--hair);
}

.tab-btn.active {
  background: var(--sky);
  color: var(--slate);
  font-weight: 700;
  border-color: var(--dawn-deep);
  box-shadow: 0 1px 3px rgba(var(--slate-rgb), 0.04);
}

.tab-badge {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--mist);
  border: 1px solid var(--hair);
  color: var(--dawn-deep);
  font-weight: 700;
}

.tab-panels-wrapper {
  position: relative;
  min-height: 400px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Kanban Filter Bar & Panoramic Layout
   ========================================================= */
.kanban-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.kanban-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--sky-hi);
  border: 1px solid var(--hair);
  border-radius: 12px;
  flex-wrap: wrap;
}

.filter-pills-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-pill {
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-family: var(--fa);
  font-size: 0.78rem;
  color: var(--slate-dim);
  cursor: pointer;
  transition: all var(--motion-fast);
}

.filter-pill:hover {
  border-color: var(--slate-dim);
  color: var(--slate);
}

.filter-pill.active {
  background: var(--slate);
  color: #fff;
  border-color: var(--slate);
  font-weight: 600;
}

.filter-controls-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-select {
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 6px 12px;
  font-family: var(--fa);
  font-size: 0.78rem;
  color: var(--slate);
  outline: none;
  cursor: pointer;
}

.filter-select:focus {
  border-color: var(--dawn-deep);
}

.filter-search-box {
  position: relative;
}

.filter-input {
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 6px 12px;
  font-family: var(--fa);
  font-size: 0.78rem;
  color: var(--slate);
  width: 180px;
  outline: none;
  transition: border-color var(--motion-fast), width var(--motion-fast);
}

.filter-input:focus {
  border-color: var(--dawn-deep);
  width: 220px;
}

.lane-dimmed {
  opacity: 0.35;
  filter: grayscale(0.5);
  transition: opacity var(--motion-med);
}

.clickable-item, .clickable-rows tbody tr {
  cursor: pointer;
  transition: all var(--motion-fast);
}

.clickable-rows tbody tr:hover td {
  background: rgba(var(--dawn-rgb), 0.08) !important;
}

.kanban-task-card {
  cursor: pointer;
}

/* =========================================================
   Rich Entity Detail Modal System
   ========================================================= */
body.modal-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(47, 58, 69, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal-container {
  position: relative;
  z-index: 10;
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: var(--radius-card);
  box-shadow: 0 16px 48px rgba(47, 58, 69, 0.16);
  width: 100%;
  max-width: 860px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { transform: scale(0.96) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  padding: 18px 24px;
  background: var(--sky-hi);
  border-bottom: 1px solid var(--hair);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.modal-header-titles {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.modal-header-titles h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--slate);
  line-height: 1.5;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

.modal-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-pill {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--sky);
  border: 1px solid var(--hair);
  color: var(--slate);
}

.badge-creator {
  font-size: 0.72rem;
  color: var(--slate-dim);
}

.modal-close-btn {
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--slate);
  font-size: 1rem;
  transition: all var(--motion-fast);
}

.modal-close-btn:hover {
  background: var(--coral);
  color: #fff;
  border-color: var(--coral);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  background: var(--sky-hi);
  border: 1px solid var(--hair);
  border-radius: 12px;
  padding: 14px 16px;
}

.modal-meta-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: visible;
}

.cell-val {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--slate);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

.modal-section-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-section-h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--slate);
  border-bottom: 1.5px solid var(--hair);
  padding-bottom: 6px;
}

.modal-body-content {
  background: var(--sky);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 16px 20px;
  font-size: 0.88rem;
  line-height: 1.85;
  color: var(--slate);
  word-break: break-word;
  direction: rtl;
  text-align: right;
  unicode-bidi: plaintext;
}

/* Bi-directional & Markdown Typography within Modals */
.modal-body-content.markdown-rendered {
  white-space: normal;
}

.modal-body-content p.md-p {
  margin: 0 0 12px 0;
  line-height: 1.85;
  unicode-bidi: plaintext;
}

.modal-body-content p.md-p:last-child {
  margin-bottom: 0;
}

.modal-body-content h2.md-h2,
.modal-body-content h3.md-h3,
.modal-body-content h4.md-h4,
.modal-body-content h5.md-h5 {
  color: var(--slate);
  margin: 16px 0 8px 0;
  font-weight: 700;
  line-height: 1.4;
  unicode-bidi: plaintext;
}

.modal-body-content h2.md-h2 { font-size: 1.1rem; }
.modal-body-content h3.md-h3 { font-size: 1.0rem; }
.modal-body-content h4.md-h4 { font-size: 0.92rem; }
.modal-body-content h5.md-h5 { font-size: 0.86rem; }

.modal-body-content ul.md-ul,
.modal-body-content ol.md-ol {
  margin: 8px 0 14px 0;
  padding-right: 22px;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-body-content li.md-li,
.modal-body-content li.md-oli {
  line-height: 1.7;
  unicode-bidi: plaintext;
}

.modal-body-content .md-inline-code {
  background: rgba(47, 58, 69, 0.08);
  border: 1px solid rgba(47, 58, 69, 0.12);
  color: #1e293b;
  font-family: var(--mono);
  font-size: 0.82em;
  padding: 2px 6px;
  border-radius: 5px;
  direction: ltr;
  display: inline-block;
  unicode-bidi: embed;
}

.modal-body-content .md-code-block {
  background: #1e242b;
  color: #e2e8f0;
  border-radius: 8px;
  margin: 14px 0;
  overflow: hidden;
  direction: ltr;
  text-align: left;
}

.modal-body-content .md-code-lang {
  background: #14181d;
  color: #94a3b8;
  font-size: 0.72rem;
  padding: 4px 12px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #2d3748;
}

.modal-body-content .md-code-block pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
}

.modal-body-content blockquote.md-quote {
  border-right: 3px solid var(--dawn);
  border-left: none;
  background: rgba(240, 169, 133, 0.08);
  margin: 12px 0;
  padding: 8px 14px;
  border-radius: 0 6px 6px 0;
  color: var(--slate);
  font-style: normal;
  unicode-bidi: plaintext;
}

.modal-body-content hr.md-hr {
  border: none;
  border-top: 1px solid var(--hair);
  margin: 16px 0;
}

.modal-body-content.message-highlight {
  background: #fff8f5;
  border-color: #fde2d7;
  color: #3b281f;
  font-weight: 500;
}

.modal-code-box {
  background: #1e242b;
  color: #d1d9e0;
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  direction: ltr;
  text-align: left;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.modal-alert-box {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-alert-box.blocked {
  background: #fff8f5;
  border: 1px solid #fde2d7;
  color: var(--dawn-deep);
}

.modal-alert-box.error {
  background: #fdf2f2;
  border: 1px solid #f8d7da;
  color: var(--coral);
}

.modal-result-box {
  background: #f0f7f3;
  border: 1px solid #cce5d6;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.82rem;
  color: #2b6e42;
}

/* =========================================================
   CRM & Neural Network Components Styling
   ========================================================= */

/* Neural Network Map */
.neural-map-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.neural-intro {
  background: var(--sky);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 12px 16px;
}

.neural-desc {
  font-size: 0.88rem;
  color: var(--slate);
  line-height: 1.6;
}

.neural-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 1024px) {
  .neural-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .neural-grid {
    grid-template-columns: 1fr;
  }
}

.neural-node-card {
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(47, 58, 69, 0.03);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.neural-node-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(47, 58, 69, 0.06);
}

.node-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.node-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.node-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--slate);
  flex: 1;
}

.node-level {
  font-size: 0.7rem;
  background: var(--sky);
  color: var(--slate-dim);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.node-role {
  font-size: 0.8rem;
  color: var(--slate-dim);
  line-height: 1.5;
  flex: 1;
}

.node-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--hair);
  padding-top: 8px;
  font-size: 0.72rem;
}

.node-status {
  color: #047857;
  font-weight: 600;
}

.node-id {
  color: var(--placeholder);
}

.neural-flow-banner {
  display: none;
}

.flow-step {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.step-num {
  width: 22px;
  height: 22px;
  background: var(--slate);
  color: var(--mist);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--mono);
}

.step-txt {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate);
}

.flow-arrow {
  color: var(--placeholder);
  font-weight: bold;
}

/* --- Neural Section Heading & Heartbeats --- */
.neural-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--hair);
  padding-bottom: 8px;
  margin-top: 8px;
}

.sec-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--slate);
}

.sec-sub {
  font-size: 0.75rem;
  color: var(--slate-dim);
}

.heartbeats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 1024px) {
  .heartbeats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .heartbeats-grid {
    grid-template-columns: 1fr;
  }
}

.heartbeat-pulse-card {
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(47, 58, 69, 0.03);
  position: relative;
  overflow: hidden;
}

.hb-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hb-dot-pulse {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
  animation: pulse-ring 2s infinite ease-out;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.hb-title {
  font-size: 0.84rem;
  flex: 1;
}

.hb-interval {
  font-size: 0.72rem;
  color: var(--slate-dim);
  background: var(--sky);
  padding: 2px 6px;
  border-radius: 4px;
}

.hb-mission {
  font-size: 0.78rem;
  color: var(--slate-dim);
  line-height: 1.4;
  flex: 1;
}

.hb-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed var(--hair);
  padding-top: 6px;
  font-size: 0.72rem;
}

/* CRM View Styling */
.crm-view-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.crm-subtabs-nav {
  display: flex;
  gap: 8px;
  background: var(--sky);
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--hair);
  overflow-x: auto;
}

.crm-subtab-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 16px;
  font-family: var(--fa);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate-dim);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.crm-subtab-btn:hover {
  background: var(--sky-hi);
  color: var(--slate);
}

.crm-subtab-btn.active {
  background: var(--mist);
  color: var(--slate);
  border-color: var(--hair);
  box-shadow: 0 2px 6px rgba(47, 58, 69, 0.05);
}

.crm-pane-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.crm-pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pane-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--slate);
}

.crm-table {
  table-layout: auto;
  width: 100%;
}

.crm-table th {
  background: var(--sky);
  padding: 10px 14px;
  font-weight: 700;
  color: var(--slate);
  border-bottom: 2px solid var(--hair);
  white-space: nowrap;
}

.crm-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--hair);
  vertical-align: middle;
  line-height: 1.6;
}

.crm-table tbody tr:hover {
  background: var(--sky-hi);
}

/* Patient Relation Tags */
.patient-relation-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.rel-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.rel-clinical {
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

.rel-finance {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.rel-inventory {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.rel-schedule {
  background: #f0fdfa;
  color: #0f766e;
  border: 1px solid #99f6e4;
}

/* Treatment Distribution Bars */
.treatment-bars-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 16px 20px;
}

.treatment-bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.t-bar-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.t-bar-label {
  font-weight: 600;
  color: var(--slate);
}

.t-bar-val {
  color: var(--slate-dim);
  font-size: 0.78rem;
}

.t-bar-track {
  width: 100%;
  height: 10px;
  background: var(--sky);
  border-radius: 5px;
  overflow: hidden;
}

.t-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.4s ease;
}
.records-browser-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.records-summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 1024px) {
  .records-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .records-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.records-sum-card {
  background: var(--sky);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.records-sum-card .sum-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--slate-dim);
}

.records-sum-card .sum-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--slate);
  font-family: var(--mono);
}

.records-sum-card .sum-sub {
  font-size: 0.68rem;
  color: var(--placeholder);
}

.records-filter-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--sky);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--hair);
}

.records-data-table th,
.records-data-table td {
  vertical-align: middle;
}

.records-text-cell {
  font-size: 0.82rem;
  color: var(--slate);
  line-height: 1.5;
  unicode-bidi: plaintext;
}

.clickable-row {
  cursor: pointer;
  transition: background 0.15s ease;
}

.clickable-row:hover {
  background: var(--sky-hi) !important;
}

.records-domain-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
}

.domain-clinical { background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; }
.domain-finance { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.domain-patients { background: #fdf2f8; color: #be185d; border: 1px solid #fbcfe8; }
.domain-inventory { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.domain-schedule { background: #f0fdfa; color: #0f766e; border: 1px solid #99f6e4; }
.domain-context { background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; }

.records-status-pill {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-family: var(--mono);
}

.records-status-pill.status-observed { background: #e0f2fe; color: #0369a1; }
.records-status-pill.status-inferred { background: #fef3c7; color: #92400e; }
.records-status-pill.status-unconfirmed { background: #fee2e2; color: #b91c1c; }

/* --- Pagination Bar --- */
.records-pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--sky);
  border: 1px solid var(--hair);
  border-radius: 10px;
  margin-top: 12px;
}

.pagination-info {
  font-size: 0.8rem;
  color: var(--slate-dim);
}

.pagination-buttons {
  display: flex;
  gap: 8px;
}

.btn-pagination {
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: 6px;
  padding: 6px 14px;
  font-family: var(--fa);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--slate);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-pagination:hover:not(:disabled) {
  background: var(--sky-hi);
  border-color: var(--slate-dim);
}

.btn-pagination:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.modal-data-table th {
  background: var(--sky-hi);
  padding: 8px 12px;
  color: var(--slate);
  border-bottom: 1px solid var(--hair);
}

.modal-data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--hair);
}

.comments-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comment-item {
  background: var(--sky-hi);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.comment-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.comment-author {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--slate);
  font-family: var(--mono);
}

.comment-time {
  font-size: 0.72rem;
  color: var(--slate-dim);
}

.comment-body {
  font-size: 0.84rem;
  color: var(--slate);
  line-height: 1.7;
  white-space: pre-wrap;
  direction: rtl;
  text-align: right;
  unicode-bidi: plaintext;
}

.comment-body.markdown-rendered {
  white-space: normal;
}

.comment-body .md-inline-code {
  background: rgba(47, 58, 69, 0.08);
  border: 1px solid rgba(47, 58, 69, 0.12);
  color: #1e293b;
  font-family: var(--mono);
  font-size: 0.85em;
  padding: 1px 5px;
  border-radius: 4px;
  direction: ltr;
  display: inline-block;
  unicode-bidi: embed;
}

.events-mini-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mini-event-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  padding: 6px 10px;
  background: var(--sky-hi);
  border-radius: 6px;
  border: 1px solid var(--hair);
}

.mini-event-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dawn-deep);
}

.mini-event-kind {
  font-weight: 600;
  font-family: var(--mono);
  color: var(--slate);
}

.mini-event-time {
  color: var(--slate-dim);
  font-size: 0.72rem;
}

.mini-event-payload {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--slate-dim);
  margin-right: auto;
  direction: ltr;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-link {
  background: none;
  border: none;
  color: var(--dawn-deep);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.8rem;
}

.modal-loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px 20px;
  color: var(--slate-dim);
}

.modal-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--hair);
  border-top-color: var(--dawn-deep);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.modal-empty-note {
  font-size: 0.8rem;
  color: var(--slate-dim);
  font-style: italic;
  padding: 8px 0;
}

.mono {
  font-family: var(--mono);
}

.small-text {
  font-size: 0.76rem;
  color: var(--slate-dim);
}

/* Recent Completed List */
.recent-completed-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.completed-task-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--sky-hi);
  border: 1px solid var(--hair);
  transition: all var(--motion-fast);
}

.completed-task-item:hover {
  background: var(--sky);
  border-color: var(--dawn);
  transform: translateY(-1px);
}

.completed-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.completed-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--slate);
}

.completed-sub {
  font-size: 0.72rem;
  color: var(--slate-dim);
  display: flex;
  gap: 6px;
  align-items: center;
}

.host-info-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--hair);
  font-size: 0.76rem;
  color: var(--slate-dim);
}

.cron-mode-tag {
  font-size: 0.68rem;
  color: var(--slate-dim);
}

/* ========================================================= */
/* Centered Top Dual-Mode Switcher (Clean Editorial)         */
/* ========================================================= */
.header-mode-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--sky);
  border: 1px solid var(--hair);
  border-radius: var(--radius-pill);
  padding: 4px;
  gap: 4px;
}

.mode-switch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 24px;
  border: none;
  background: transparent;
  border-radius: var(--radius-pill);
  color: var(--slate-dim);
  font-family: 'Vazirmatn', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  white-space: nowrap;
}

.mode-switch-btn .mode-title {
  font-family: 'Vazirmatn', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
}

.mode-switch-btn:hover {
  color: var(--slate);
  background: rgba(255, 255, 255, 0.6);
}

.mode-switch-btn.active {
  background: #ffffff;
  color: var(--slate);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(47, 58, 69, 0.08), 0 1px 2px rgba(47, 58, 69, 0.04);
}

.mode-badge {
  font-size: 0.72rem;
  font-family: ui-monospace, monospace;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--sky-hi);
  color: var(--slate);
  border: 1px solid var(--hair);
}

.status-pill-clean {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--sky-hi);
  border: 1px solid var(--hair);
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  color: var(--slate);
}

.status-label-clean {
  font-weight: 600;
}

.status-time-clean {
  font-size: 0.75rem;
  color: var(--slate-dim);
}

/* ========================================================= */
/* Clean Real Architectural Flow (Zero Clichés)              */
/* ========================================================= */
.agent-arch-wrapper {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.arch-flow-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #ffffff;
  border: 1px solid var(--hair);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: 0 2px 10px rgba(47, 58, 69, 0.03);
}

.arch-tier {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tier-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--slate-dim);
}

.arch-card {
  background: var(--sky-hi);
  border: 1px solid var(--hair);
  border-radius: var(--radius-input);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}

.arch-card:hover {
  background: var(--mist);
  border-color: var(--dawn);
  box-shadow: 0 2px 8px rgba(47, 58, 69, 0.05);
}

.card-gateway {
  border: 1px solid var(--hair);
}

.card-sentinel {
  border: 1px solid var(--hair);
}

.card-worker {
  background: #ffffff;
}

.card-supervisor {
  background: var(--sky-hi);
  border-color: #dce4ea;
}

.ac-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ac-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-blue { background: #0ea5e9; }
.dot-indigo { background: #6366f1; }
.dot-purple { background: #8b5cf6; }
.dot-amber { background: #f59e0b; }
.dot-emerald { background: #10b981; }
.dot-pink { background: #ec4899; }

.ac-name {
  font-size: 0.98rem;
  color: var(--slate);
}

.ac-id {
  font-size: 0.76rem;
  color: var(--slate-dim);
  background: var(--sky);
  padding: 2px 6px;
  border-radius: 4px;
}

.ac-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  margin-right: auto;
}

.badge-active {
  background: #ecfdf5;
  color: #10b981;
  border: 1px solid #a7f3d0;
}

.badge-audit {
  background: #f5f3ff;
  color: #8b5cf6;
  border: 1px solid #ddd6fe;
}

.ac-desc {
  font-size: 0.84rem;
  color: var(--slate-dim);
  line-height: 1.5;
  margin: 0;
}

.ac-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--slate-dim);
  padding-top: 6px;
  border-top: 1px dashed var(--hair);
}

.ac-meta .sep {
  color: var(--hair);
}

.ac-submeta {
  font-size: 0.76rem;
  padding-top: 4px;
}

.arch-flow-arrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
}

.arrow-line {
  flex: 1;
  height: 1px;
  background: var(--hair);
}

.arrow-label {
  font-size: 0.74rem;
  color: var(--slate-dim);
  font-weight: 500;
}

.arch-tier-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.arch-stream-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stream-connector-arrow {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--slate-dim);
  padding: 2px 0;
}

/* Sentinels Table Clean Section */
.sentinels-table-section {
  background: #ffffff;
  border: 1px solid var(--hair);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: 0 2px 8px rgba(47, 58, 69, 0.03);
}

.st-header {
  margin-bottom: 14px;
}

.st-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--slate);
  display: block;
}

.st-sub {
  font-size: 0.8rem;
  color: var(--slate-dim);
}

.hb-table-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  margin-left: 6px;
}

/* ========================================================= */
/* Priority Pills for Clinical Schedule */
.priority-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 600;
  text-align: center;
}

.prio-surgery {
  background: #fef2f2;
  color: #ef4444;
  border: 1px solid #fecaca;
}

.prio-high {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.prio-final {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.prio-prep {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.prio-normal {
  background: var(--sky);
  color: var(--slate);
  border: 1px solid var(--hair);
}

.schedule-stats-badge {
  font-size: 0.8rem;
  background: var(--sky);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--hair);
  color: var(--slate);
}

/* Master-Detail Clinical Workstation */
/* ========================================================= */
.crm-master-detail-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: start;
}

.crm-master-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #ffffff;
  border: 1px solid var(--hair);
  border-radius: var(--radius-card);
  padding: 14px;
  box-shadow: 0 2px 8px rgba(47, 58, 69, 0.04);
  max-height: 820px;
}

.master-search-bar {
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 10;
}

.master-filter-input {
  width: 100%;
}

.master-patient-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  max-height: 750px;
}

/* Master-Detail Clinical Workstation Cards (Clean, Bespoke, Editorial) */
.master-patient-card {
  padding: 14px 16px;
  background: #ffffff;
  border: 1px solid var(--hair);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.master-patient-card:hover {
  background: var(--sky);
  border-color: var(--dawn);
}

.master-patient-card.active {
  background: #ffffff;
  border: 1.5px solid var(--slate);
  box-shadow: 0 3px 12px rgba(47, 58, 69, 0.08);
}

.mp-head-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mp-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--slate);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.mp-file {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--slate-dim);
  background: var(--sky);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  white-space: nowrap;
}

.mp-status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  min-width: 0;
}

.mp-triage-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
}

.mp-act-text {
  font-size: 0.78rem;
  color: var(--slate-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.mp-meta-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  color: var(--slate-dim);
  padding-top: 2px;
  gap: 8px;
  min-width: 0;
}

.mp-phone,
.mp-balance {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Detail Column: Patient Clinical Chart */
.crm-detail-col {
  background: #ffffff;
  border: 1px solid var(--hair);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: 0 2px 10px rgba(47, 58, 69, 0.04);
}

.patient-detail-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.pd-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--hair);
  gap: 16px;
}

.pd-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.pd-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--slate);
  letter-spacing: -0.01em;
}

.pd-file-badge {
  font-size: 0.85rem;
  background: var(--sky);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--hair);
  color: var(--slate);
  font-weight: 700;
}

.pd-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 18px;
  font-size: 0.85rem;
  color: var(--slate);
}

.pd-meta-item .meta-label {
  color: var(--slate-dim);
  font-weight: 500;
  margin-left: 4px;
}

.pd-header-actions {
  flex-shrink: 0;
}

.btn-inspect-doc-orig {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--sky);
  border: 1px solid var(--hair);
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-inspect-doc-orig:hover {
  background: #ffffff;
  border-color: var(--dawn);
  box-shadow: 0 2px 8px rgba(47, 58, 69, 0.08);
}

/* Doctor Priority Notice Banner */
.doctor-priority-banner {
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dpb-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--slate);
}

.dpb-text {
  font-size: 0.84rem;
  color: var(--slate);
  line-height: 1.6;
}

/* 4 Clinical Panels Grid */
.pd-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.pd-chart-section {
  background: var(--mist);
  border: 1px solid var(--hair);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}

.pd-sec-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hair);
}

.pd-sec-title {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--slate);
}

.pd-sec-count {
  font-size: 0.75rem;
  background: var(--sky);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--hair);
  color: var(--slate-dim);
  font-family: ui-monospace, monospace;
}

.pd-sec-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 2px;
}

.pd-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  background: #ffffff;
  border: 1px solid rgba(220, 228, 234, 0.7);
  border-radius: 10px;
  gap: 10px;
  transition: border-color 0.15s ease;
}

.pd-item-row:hover {
  border-color: var(--dawn);
}

.pd-item-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.pd-item-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--slate);
}

.pd-item-desc {
  font-size: 0.78rem;
  color: var(--slate-dim);
  line-height: 1.45;
  margin: 0;
}

.empty-item-text {
  font-size: 0.82rem;
  padding: 12px 0;
  text-align: center;
}

.badge-status-neutral {
  font-size: 0.72rem;
  color: var(--slate-dim);
  background: var(--sky);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

@media (max-width: 992px) {
  .crm-master-detail-layout {
    grid-template-columns: 1fr;
  }
  .pd-chart-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   Dignified Clinical Patient Detail Modal
   ========================================================= */
.modal-patient-hero {
  background: var(--sky-hi);
  border: 1px solid var(--hair);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

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

.mph-names {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.mph-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--slate);
}

.mph-file {
  font-size: 0.92rem;
  color: var(--blue);
  font-weight: 700;
  background: var(--sky);
  padding: 2px 10px;
  border-radius: var(--radius-pill);
}

.mph-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.mph-meta-item {
  font-size: 0.86rem;
  color: var(--slate);
}

.meta-label {
  color: var(--slate-dim);
  font-weight: 600;
  margin-left: 4px;
}

.modal-section-block {
  margin-bottom: 22px;
}

.msb-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--hair);
}

.msb-title {
  font-size: 0.96rem;
  color: var(--slate);
}

.modal-dual-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.mdc-item {
  background: var(--sky-hi);
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 12px 14px;
}

.mdc-label {
  font-size: 0.8rem;
  color: var(--slate-dim);
  margin-bottom: 4px;
  display: block;
}

.mdc-val {
  font-size: 0.88rem;
  color: var(--slate);
  margin: 0;
  line-height: 1.5;
}

.modal-cumulative-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* =========================================================
   Authentic Neural Brain Topology
   ========================================================= */
.neural-brain-view {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brain-canvas-container {
  background: #ffffff;
  border: 1px solid var(--hair);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.brain-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.bh-title {
  font-size: 1.1rem;
  color: var(--slate);
}

.bh-sub {
  font-size: 0.82rem;
  margin: 4px 0 0 0;
}

.bh-live-pills {
  display: flex;
  gap: 8px;
}

.bh-pill {
  background: var(--sky);
  border: 1px solid var(--hair);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--slate);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pulse-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.brain-svg-wrap {
  width: 100%;
  overflow: hidden;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--hair);
}

.brain-svg-canvas {
  width: 100%;
  height: auto;
  max-height: 480px;
  display: block;
}

.brain-node-group {
  transition: transform 0.2s ease;
}

.brain-node-group:hover circle:first-child {
  filter: drop-shadow(0 0 10px rgba(14, 165, 233, 0.5));
}

.brain-node-group.selected circle:first-child {
  filter: drop-shadow(0 0 14px rgba(14, 165, 233, 0.75));
}

.brain-telemetry-console {
  background: #ffffff;
  border: 1px solid var(--hair);
  border-radius: 12px;
  padding: 18px 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.btc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.btc-badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btc-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.btc-title {
  font-size: 1.05rem;
  color: var(--slate);
}

.btc-hint {
  font-size: 0.76rem;
  color: var(--slate-dim);
}

.btc-mission {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--slate-dim);
  margin: 0 0 14px 0;
}

.btc-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.btc-meta-cell {
  background: var(--sky);
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 10px 14px;
}

.btc-meta-cell .cell-label {
  font-size: 0.74rem;
  color: var(--slate-dim);
  margin-bottom: 3px;
  display: block;
}

.btc-meta-cell .cell-val {
  font-size: 0.84rem;
  color: var(--slate);
}

/* =========================================================
   Doctor's Clinical Priority Filters & Triage Cards
   ========================================================= */
.patient-priority-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hair);
}

.triage-filter-btn {
  background: var(--sky);
  border: 1px solid var(--hair);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--slate);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.triage-filter-btn:hover {
  background: var(--sky-hi);
  border-color: var(--slate-dim);
}

.triage-filter-btn.active {
  background: var(--slate);
  color: #ffffff;
  border-color: var(--slate);
}

.triage-filter-btn.active .prio-dot {
  box-shadow: 0 0 6px #ffffff;
}

.prio-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-red { background: #ef4444; }
.dot-amber { background: #f59e0b; }
.dot-green { background: #10b981; }
.dot-blue { background: #0ea5e9; }

/* Calm Sagittal Brain SVG Styling */
.cortex-sagittal-contour path {
  transition: stroke 0.2s ease;
}

.brain-node-group circle.node-halo {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.brain-node-group:hover circle.node-halo,
.brain-node-group.selected circle.node-halo {
  opacity: 1;
}

.brain-node-group.selected circle:nth-child(2) {
  stroke-width: 3.5px;
}

/* =========================================================
   Unified Responsive Breakpoints & Cascade Polish (<= 768px & <= 480px)
   Positioned definitively at the end of the stylesheet to guarantee
   cascade precedence over all preceding base component rules.
   ========================================================= */

@media (max-width: 768px) {
  /* Site Header & Centered Dual-Mode Switcher */
  .site-header,
  .header-main {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 14px 16px;
    width: 100%;
    box-sizing: border-box;
  }
  .brand-section {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .header-mode-switcher {
    display: flex;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    justify-content: center;
    padding: 4px;
    gap: 4px;
  }
  .mode-switch-btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
    padding: 8px 14px;
    font-size: 0.92rem;
    white-space: nowrap;
  }
  .mode-switch-btn .mode-title {
    font-size: 0.92rem;
  }
  .header-status-area {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Clinical CRM Master-Detail Layout */
  .crm-master-detail-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .crm-master-col {
    max-height: none;
  }
  .master-patient-list {
    max-height: 380px;
    overflow-y: auto;
  }
  .pd-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .pd-header-actions {
    width: 100%;
  }
  .btn-inspect-doc-orig {
    width: 100%;
    justify-content: center;
  }
  .mph-meta-grid,
  .modal-dual-cards {
    grid-template-columns: 1fr;
  }

  /* Active Neural Sagittal Brain & Telemetry Console */
  .brain-canvas-container {
    padding: 12px 10px;
  }
  .brain-header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .bh-live-pills {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
  }
  .btc-meta-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .modal-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  /* Ultra-Compact Mobile Refinements (<= 480px) */
  .site-header,
  .header-main {
    padding: 12px 14px;
    gap: 10px;
  }
  .brand-logo-badge {
    width: 40px;
    height: 40px;
    padding: 3px;
  }
  .brand-titles h1 {
    font-size: 1.1rem;
  }
  .brand-titles p {
    font-size: 0.74rem;
  }
  .header-mode-switcher {
    padding: 3px;
    gap: 3px;
  }
  .mode-switch-btn {
    padding: 6px 8px;
    font-size: 0.86rem;
  }
  .mode-switch-btn .mode-title {
    font-size: 0.86rem;
  }
  .status-pill-clean {
    padding: 4px 10px;
    font-size: 0.74rem;
  }
  .crm-master-col {
    padding: 12px;
  }
  .master-patient-list {
    max-height: 320px;
  }
  .master-patient-card {
    padding: 10px 12px;
  }
  .pd-card {
    padding: 14px;
  }
  .brain-canvas-container {
    padding: 10px 8px;
  }
  .btc-meta-cell {
    padding: 8px 10px;
  }
  .triage-filter-btn {
    padding: 4px 8px;
    font-size: 0.74rem;
  }
}


