/* ═══════════════════════════════════════════════
   INTERLINX PORTAL APPLICATION
   Navy #001533 / Teal #00B0AD / Green #7EC8A0
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --ix-navy: #001533;
  --ix-teal: #00B0AD;
  --ix-teal-dark: #009E9B;
  --ix-green: #7EC8A0;
  --ix-mint-bg: #EFF7F6;
  --ix-mint-light: #DBF0EE;
  --ix-gray-50: #F8FAFA;
  --ix-gray-100: #EDF0F4;
  --ix-gray-300: #C9C7C7;
  --ix-gray-500: #63656A;
  --ix-gray-700: #3A3C40;
  --ix-bg: #F8FAFA;
  --ix-surface: #FFFFFF;
  --ix-text: #001533;
  --ix-text-muted: #63656A;
  --ix-border: #EDF0F4;
  --ix-success: #4caf50;
  --ix-warning: #ff9800;
  --ix-error: #f44336;
  --ix-info: #2196f3;
  --ix-radius: 8px;
  --ix-shadow-sm: 0 1px 3px rgba(0, 21, 51, 0.06);
  --ix-shadow: 0 2px 8px rgba(0, 21, 51, 0.08);
  --ix-shadow-lg: 0 4px 16px rgba(0, 21, 51, 0.1);
  --ix-font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Global ── */
body {
  font-family: var(--ix-font);
  font-size: 14px;
  background: var(--ix-bg);
  color: var(--ix-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--ix-teal); }
a:hover { color: var(--ix-teal-dark); }

::selection {
  background: var(--ix-mint-light);
  color: var(--ix-navy);
}

/* ── Bootstrap overrides ── */
.btn-primary {
  background: var(--ix-teal);
  border-color: var(--ix-teal);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--ix-teal-dark);
  border-color: var(--ix-teal-dark);
}
.btn-outline-primary {
  color: var(--ix-teal);
  border-color: var(--ix-teal);
}
.btn-outline-primary:hover {
  background: var(--ix-teal);
  border-color: var(--ix-teal);
  color: #fff;
}
.btn-outline-danger { color: var(--ix-error); border-color: var(--ix-error); }
.btn-outline-danger:hover { background: var(--ix-error); border-color: var(--ix-error); color: #fff; }
.btn-outline-warning { color: var(--ix-warning); border-color: var(--ix-warning); }
.btn-outline-warning:hover { background: var(--ix-warning); border-color: var(--ix-warning); color: #fff; }
.btn-outline-info { color: var(--ix-info); border-color: var(--ix-info); }
.btn-outline-info:hover { background: var(--ix-info); border-color: var(--ix-info); color: #fff; }

.btn {
  border-radius: 6px;
  font-family: var(--ix-font);
  font-weight: 500;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}
.btn-sm { border-radius: 6px; font-size: 0.8rem; padding: 0.3rem 0.65rem; }

.badge { font-weight: 600; font-size: 0.72rem; border-radius: 4px; letter-spacing: 0.02em; }
.bg-success { background-color: var(--ix-success) !important; }
.bg-danger { background-color: var(--ix-error) !important; }
.bg-warning { background-color: var(--ix-warning) !important; color: #fff !important; }
.bg-info { background-color: var(--ix-info) !important; }
.bg-primary { background-color: var(--ix-teal) !important; }
.bg-secondary { background-color: var(--ix-gray-500) !important; }

.form-control, .form-select {
  font-family: var(--ix-font);
  font-size: 0.85rem;
  border-color: var(--ix-border);
  border-radius: 6px;
}
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: var(--ix-teal);
  box-shadow: 0 0 0 3px rgba(0, 176, 173, 0.1);
}
.form-check-input:checked {
  background-color: var(--ix-teal);
  border-color: var(--ix-teal);
}

/* ── Navbar — White, matching portal ── */
.navbar-ix {
  background: var(--ix-surface);
  box-shadow: none;
  border-bottom: 1px solid var(--ix-border);
  padding: 0.55rem 2.5rem;
  min-height: 3.5rem;
  z-index: 1030;
}
.navbar-ix .container-fluid {
  max-width: 1400px;
  margin: 0 auto;
}
.navbar-ix .navbar-brand {
  display: flex;
  align-items: center;
  margin-right: 1.2rem;
  padding-right: 1.2rem;
  border-right: 1px solid var(--ix-border);
  text-decoration: none;
}
.navbar-ix .navbar-brand:hover {
  opacity: 0.85;
}
.navbar-ix .navbar-brand .brand-logo {
  height: 28px;
}
.navbar-ix .nav-link {
  color: var(--ix-gray-500);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.navbar-ix .nav-link:hover {
  color: var(--ix-teal);
  background: rgba(0, 176, 173, 0.06);
}
.navbar-ix .nav-link.active {
  color: var(--ix-teal);
  background: rgba(0, 176, 173, 0.08);
  font-weight: 600;
}
.navbar-ix .nav-link i {
  font-size: 0.82rem;
  opacity: 0.7;
}
.navbar-ix .dropdown-menu {
  border: 1px solid var(--ix-border);
  box-shadow: 0 8px 24px rgba(0, 21, 51, 0.1);
  border-radius: 8px;
  padding: 0.35rem;
  min-width: 180px;
}
.navbar-ix .dropdown-item {
  font-family: var(--ix-font);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 5px;
  padding: 0.4rem 0.75rem;
  color: var(--ix-gray-700);
  transition: all 0.12s ease;
}
.navbar-ix .dropdown-item:hover {
  background: var(--ix-mint-bg);
  color: var(--ix-teal);
}
.navbar-ix .dropdown-item i {
  font-size: 0.82rem;
  opacity: 0.6;
}
.navbar-ix .user-badge {
  background: var(--ix-gray-50);
  border: 1px solid var(--ix-border);
  border-radius: 20px;
  padding: 0.25rem 0.7rem;
  color: var(--ix-navy);
  font-size: 0.78rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.navbar-ix .user-badge i {
  color: var(--ix-teal);
}

/* User section divider */
.navbar-ix .d-flex.align-items-center {
  padding-left: 0.8rem;
  border-left: 1px solid var(--ix-border);
  margin-left: 0.4rem;
}

/* Sign out button — matches portal logout */
.navbar-ix .btn-outline-light {
  background: none;
  border: 1px solid var(--ix-border);
  color: var(--ix-gray-500);
  font-family: var(--ix-font);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 6px;
  padding: 0.2rem 0.65rem;
  transition: all 0.15s ease;
}
.navbar-ix .btn-outline-light:hover {
  border-color: var(--ix-gray-300);
  color: var(--ix-navy);
  background: var(--ix-gray-50);
}

/* Sign in link */
.navbar-ix .nav-link[href="/auth/login"] {
  background: var(--ix-teal);
  color: #fff !important;
  font-weight: 600;
  padding: 0.32rem 1rem;
  border-radius: 6px;
}
.navbar-ix .nav-link[href="/auth/login"]:hover {
  background: var(--ix-teal-dark);
  color: #fff !important;
}

/* Navbar toggler for mobile */
.navbar-ix .navbar-toggler {
  border-color: var(--ix-border);
  padding: 0.25rem 0.5rem;
}
.navbar-ix .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23001533' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ── Cards — Matching portal style ── */
.card {
  border: 1px solid var(--ix-border);
  border-radius: 10px;
  box-shadow: var(--ix-shadow-sm);
  overflow: hidden;
}
.card-header {
  background: var(--ix-surface);
  border-bottom: 1px solid var(--ix-border);
  padding: 0.85rem 1.2rem;
  font-weight: 600;
}
.card-body {
  padding: 1rem 1.2rem;
}

.site-card {
  border-left: 3px solid var(--ix-gray-300);
  transition: all 0.15s ease;
}
.site-card:hover {
  box-shadow: var(--ix-shadow);
  border-color: rgba(0, 176, 173, 0.2);
}
.site-card[data-status="completed"] { border-left-color: var(--ix-success); }
.site-card[data-status="in_progress"] { border-left-color: var(--ix-warning); }
.site-card[data-status="issues_found"] { border-left-color: var(--ix-error); }

/* ── Status indicators ── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-pending { background-color: var(--ix-gray-300); }
.status-in_progress { background-color: var(--ix-warning); }
.status-completed { background-color: var(--ix-success); }
.status-issues_found { background-color: var(--ix-error); }

/* ── Tables — Clean, portal-inspired ── */
.table {
  font-size: 0.85rem;
  font-family: var(--ix-font);
}
.table th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ix-text-muted);
  border-bottom: 2px solid var(--ix-border);
  padding: 0.6rem 0.75rem;
}
.table td {
  vertical-align: middle;
  border-color: var(--ix-border);
  padding: 0.6rem 0.75rem;
  color: var(--ix-text);
}
.table-hover tbody tr:hover { background: rgba(0, 176, 173, 0.03); }

.checks-table th { font-size: 0.72rem; }
.checks-table td { vertical-align: middle; padding: 0.5rem 0.75rem; }
.check-row { transition: background-color 0.15s ease; }
.table-success { background-color: rgba(76, 175, 80, 0.08) !important; }
.table-danger { background-color: rgba(244, 67, 54, 0.06) !important; }
.table-secondary { background-color: var(--ix-gray-50) !important; }

/* ── Comment inputs ── */
.comment-input {
  border: 1.5px solid transparent;
  background: transparent;
  border-radius: 6px;
  font-family: var(--ix-font);
  font-size: 0.85rem;
  transition: all 0.15s ease;
}
.comment-input:focus {
  border-color: var(--ix-teal);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 176, 173, 0.1);
}
.comment-input:hover { background: rgba(0, 176, 173, 0.03); }

/* ── Alert overrides ── */
.alert {
  font-family: var(--ix-font);
  font-size: 0.85rem;
  border-radius: var(--ix-radius);
}
.alert-info {
  background: var(--ix-mint-light);
  border-color: var(--ix-teal);
  color: var(--ix-teal-dark);
}
.alert-warning {
  background: #fff8e1;
  border-color: var(--ix-warning);
  color: #e65100;
}

/* ── Page headers — Navy text with teal accents ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--ix-font);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ix-navy);
}

h2 {
  font-size: 1.3rem;
  font-weight: 700;
}
h2 i { color: var(--ix-teal); }
h5 {
  font-size: 0.95rem;
  font-weight: 600;
}

/* ── Date picker bar ── */
.date-nav {
  background: var(--ix-surface);
  border: 1px solid var(--ix-border);
  border-radius: var(--ix-radius);
  box-shadow: none;
  padding: 0.6rem 1rem;
}
.date-nav .btn-outline-secondary {
  border-color: var(--ix-border);
  color: var(--ix-gray-500);
  font-family: var(--ix-font);
}
.date-nav .btn-outline-secondary:hover {
  background: rgba(0, 176, 173, 0.06);
  border-color: var(--ix-teal);
  color: var(--ix-teal-dark);
}

/* ── Modal ── */
.modal-content {
  border: none;
  border-radius: 10px;
  box-shadow: var(--ix-shadow-lg);
  font-family: var(--ix-font);
}
.modal-header {
  border-bottom: 1px solid var(--ix-border);
  background: var(--ix-mint-bg);
  padding: 1rem 1.2rem;
}
.modal-header .modal-title {
  color: var(--ix-navy);
  font-weight: 700;
  font-size: 1rem;
}
.modal-body { padding: 1rem 1.2rem; }
.modal-footer {
  border-top: 1px solid var(--ix-border);
  padding: 0.75rem 1.2rem;
}

/* ── Check items page ── */
.form-check-label strong { font-size: 0.88rem; }
.form-check-label small { line-height: 1.4; color: var(--ix-text-muted); }

/* ── Login page ── */
.login-card {
  border-radius: 10px;
  box-shadow: var(--ix-shadow-lg);
  max-width: 420px;
  border: 1px solid var(--ix-border);
}
.login-card .btn-primary {
  padding: 0.55rem 1.5rem;
  font-size: 0.92rem;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #E0E0E0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ix-gray-300); }

/* ── Grafana alerts page ── */
.alert-summary-card {
  box-shadow: var(--ix-shadow-sm);
  border-radius: 10px;
  border: 1px solid var(--ix-border);
}
.alert-summary-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

/* ── Grafana alerts panel ── */
.grafana-alerts-card {
  border-left: 3px solid var(--ix-error);
}
.grafana-alerts-card .card-header h5 {
  color: var(--ix-navy);
}
.grafana-alerts-card .card-header .bi-bell-fill {
  font-size: 1rem;
  color: var(--ix-error);
}
.alerts-table th { font-size: 0.72rem; }
.alerts-table td { vertical-align: middle; padding: 0.5rem 0.75rem; }
.alert-row { transition: background-color 0.15s ease; }
.alert-severity-critical { border-left: 3px solid var(--ix-error); }
.alert-severity-warning { border-left: 3px solid var(--ix-warning); }
.alert-state-firing { background-color: rgba(244, 67, 54, 0.06) !important; }
.alert-state-pending { background-color: rgba(255, 152, 0, 0.06) !important; }
.alert-state-error, .alert-state-nodata { background-color: rgba(244, 67, 54, 0.04) !important; }

#refreshAlerts .spinner-border {
  width: 0.85rem;
  height: 0.85rem;
  border-width: 0.15em;
}

/* No alerts state */
.grafana-alerts-card .bi-check-circle { color: var(--ix-success); }

/* Pulse animation for firing alert count */
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.grafana-alerts-card .badge.bg-danger-pulse {
  animation: pulse-badge 2s infinite;
}

/* ── Collapse toggle ── */
.collapse-toggle {
  padding: 0.2rem 0.45rem;
  line-height: 1;
}
.collapse-toggle i {
  transition: transform 0.2s ease;
  font-size: 0.85rem;
}

/* ── Main content area ── */
main.container-fluid {
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .navbar-ix { padding: 0.5rem 1rem; }
  .checks-table { font-size: 0.8rem; }
  .comment-input { min-width: 100px; }
  .card-header { padding: 0.75rem 1rem; }

  /* Reduce main content padding */
  main.container-fluid { padding: 1rem !important; }

  /* Alert tables — hide Summary and Since columns */
  .alerts-table th:nth-child(5),
  .alerts-table td:nth-child(5),
  .alerts-table th:nth-child(6),
  .alerts-table td:nth-child(6) { display: none; }
  .alerts-table th,
  .alerts-table td { padding: 0.35rem 0.5rem; }

  /* Touch-friendly form elements */
  .form-control, .form-select { min-height: 44px; font-size: 0.9rem; }
  .btn { min-height: 40px; }

  /* Alert summary cards */
  .alert-summary-card .card-body { padding: 0.75rem; gap: 0.5rem !important; }
  .alert-summary-icon { width: 36px; height: 36px; font-size: 1rem; }

  /* Modals — near full-width */
  .modal-dialog { margin: 0.5rem; }

  /* User badge */
  .user-badge { font-size: 0.78rem; }

  /* Embed body padding override */
  .embed-body { padding: 1rem !important; }

  /* Stack user section below nav links in collapsed menu */
  .navbar-ix .d-flex.align-items-center {
    border-left: none;
    margin-left: 0;
    padding-left: 0;
    padding-top: 0.5rem;
    border-top: 1px solid var(--ix-border);
    margin-top: 0.5rem;
    width: 100%;
  }

  /* Dropdown menus visible above page content */
  .navbar-ix .dropdown-menu { z-index: 1050; }
}

/* ── Small phones ── */
@media (max-width: 480px) {
  main.container-fluid { padding: 0.75rem !important; }

  /* Hide Cluster/Environment column too */
  .alerts-table th:nth-child(4),
  .alerts-table td:nth-child(4) { display: none; }

  h2 { font-size: 1.1rem; }
  .card-header h5 { font-size: 0.85rem; }

  .embed-body { padding: 0.75rem !important; }
}

/* ── Embed body base padding ── */
.embed-body { padding: 1.5rem; }

/* ═══════════════════════════════════════════════
   SERVER CALCULATOR — Infra Planner styles
   Scoped to .calculator-layout to avoid conflicts
   ═══════════════════════════════════════════════ */

/* ── Layout ── */
.calculator-layout {
  display: grid;
  grid-template-columns: 260px 420px 1fr;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}

@media (max-width: 960px) {
  .calculator-layout {
    grid-template-columns: 1fr;
  }
}

/* ── Mode Toggle ── */
.calculator-layout .mode-toggle {
  display: flex;
  background: var(--ix-surface);
  border: 1px solid var(--ix-border);
  border-radius: var(--ix-radius);
  padding: 0.25rem;
  box-shadow: var(--ix-shadow-sm);
  gap: 0.25rem;
}

.calculator-layout .mode-btn {
  flex: 1;
  padding: 0.45rem 1rem;
  border: none;
  border-radius: calc(var(--ix-radius) - 2px);
  background: transparent;
  font-family: var(--ix-font);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ix-gray-500);
  cursor: pointer;
  transition: all 0.15s ease;
}

.calculator-layout .mode-btn:hover {
  color: var(--ix-navy);
  background: var(--ix-gray-50);
}

.calculator-layout .mode-btn.active {
  background: var(--ix-teal);
  color: white;
  box-shadow: var(--ix-shadow-sm);
}

/* ── Config Panel ── */
.calculator-layout .config-panel {
  position: sticky;
  top: 5rem;
}

.calculator-layout .config-panel form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Fieldsets & Legends (scoped) ── */
.calculator-layout fieldset {
  background: var(--ix-surface);
  border: 1px solid var(--ix-border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin: 0;
  box-shadow: var(--ix-shadow-sm);
}

.calculator-layout legend {
  font-family: var(--ix-font);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ix-teal);
  padding: 0 0.5rem;
}

/* ── Form Controls (scoped) ── */
.calculator-layout .form-row {
  display: flex;
  gap: 1rem;
}

.calculator-layout .form-row .form-group {
  flex: 1;
}

.calculator-layout .form-group {
  margin-bottom: 0.75rem;
}

.calculator-layout .form-group:last-child {
  margin-bottom: 0;
}

.calculator-layout .form-group > label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ix-gray-500);
  margin-bottom: 0.25rem;
}

.calculator-layout select,
.calculator-layout input[type="number"] {
  width: 100%;
  padding: 0.45rem 0.7rem;
  border: 1.5px solid var(--ix-border);
  border-radius: 6px;
  font-family: var(--ix-font);
  font-size: 0.85rem;
  background: var(--ix-surface);
  color: var(--ix-text);
  transition: all 0.15s ease;
}

.calculator-layout select:focus,
.calculator-layout input[type="number"]:focus {
  outline: none;
  border-color: var(--ix-teal);
  box-shadow: 0 0 0 3px rgba(0, 176, 173, 0.1);
}

.calculator-layout input[type="number"] {
  width: 80px;
}

.calculator-layout input[type="checkbox"],
.calculator-layout input[type="radio"] {
  accent-color: var(--ix-teal);
}

.calculator-layout .checkbox-label,
.calculator-layout .radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--ix-text);
}

.calculator-layout .radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-top: 0.25rem;
}

.calculator-layout .radio-group-inline {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.calculator-layout .edge-tier-row {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--ix-border);
}

.calculator-layout .edge-tier-row:last-child {
  border-bottom: none;
}

.calculator-layout .hint {
  display: block;
  font-size: 0.72rem;
  color: var(--ix-gray-500);
  margin-top: 0.125rem;
  margin-left: 1.5rem;
  line-height: 1.4;
}

.calculator-layout .sub-options {
  margin-top: 0.75rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--ix-mint-light);
}

.calculator-layout .hidden {
  display: none;
}

/* ── HL7 Interface Controls ── */
.calculator-layout .hl7-interface-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.375rem 0;
  font-size: 0.85rem;
}

.calculator-layout .hl7-interface-row label {
  min-width: 90px;
  font-weight: 500;
  color: var(--ix-gray-500);
}

.calculator-layout .hl7-interface-row select {
  flex: 1;
  padding: 0.375rem 0.5rem;
  font-size: 0.82rem;
  border: 1px solid var(--ix-border);
  border-radius: 6px;
  background: var(--ix-gray-50);
}

/* ── Results Panel ── */
.calculator-layout .results-panel {
  min-width: 0;
}

.calculator-layout .result-section {
  background: var(--ix-surface);
  border: 1px solid var(--ix-border);
  border-radius: 10px;
  box-shadow: var(--ix-shadow-sm);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.calculator-layout .result-section-header {
  padding: 0.75rem 1.2rem;
  background: var(--ix-gray-50);
  border-bottom: 1px solid var(--ix-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calculator-layout .result-section-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ix-navy);
  letter-spacing: -0.02em;
}

/* ── Topology Badge ── */
.calculator-layout .topology-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calculator-layout .topology-badge.single {
  background: rgba(0, 176, 173, 0.12);
  color: var(--ix-teal-dark);
}

.calculator-layout .topology-badge.multi {
  background: rgba(255, 152, 0, 0.12);
  color: #e65100;
}

.calculator-layout .topology-badge.addon {
  background: rgba(126, 200, 160, 0.15);
  color: #2e7d4f;
}

/* ── Results Table ── */
.calculator-layout .results-table-wrapper {
  overflow-x: auto;
}

.calculator-layout .results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-family: var(--ix-font);
}

.calculator-layout .results-table th {
  text-align: left;
  padding: 0.6rem 1rem;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ix-text-muted);
  border-bottom: 2px solid var(--ix-border);
  white-space: nowrap;
}

.calculator-layout .results-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--ix-border);
  vertical-align: top;
  color: var(--ix-text);
}

.calculator-layout .results-table tbody tr:nth-child(even) {
  background: var(--ix-gray-50);
}

.calculator-layout .results-table tbody tr:hover {
  background: rgba(0, 176, 173, 0.03);
}

.calculator-layout .results-table tr.totals-row {
  background: var(--ix-mint-bg) !important;
  font-weight: 700;
}

.calculator-layout .results-table tr.totals-row td {
  border-top: 2px solid var(--ix-teal);
  border-bottom: none;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  color: var(--ix-navy);
}

.calculator-layout .results-table tr.nfs-row {
  background: #fffbeb !important;
  font-style: italic;
}

/* ── Profile Badge ── */
.calculator-layout .profile-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.calculator-layout .profile-badge.a1 { background: rgba(0, 176, 173, 0.12); color: var(--ix-teal-dark); }
.calculator-layout .profile-badge.a2 { background: rgba(33, 150, 243, 0.12); color: #1565c0; }
.calculator-layout .profile-badge.a3 { background: rgba(126, 200, 160, 0.15); color: #2e7d4f; }
.calculator-layout .profile-badge.a4 { background: rgba(255, 152, 0, 0.12); color: #e65100; }
.calculator-layout .profile-badge.a5 { background: rgba(255, 152, 0, 0.08); color: #bf360c; }
.calculator-layout .profile-badge.b1 { background: rgba(126, 200, 160, 0.2); color: #1b5e20; }
.calculator-layout .profile-badge.d1 { background: rgba(244, 67, 54, 0.1); color: #c62828; }

.calculator-layout .services-list {
  font-size: 0.72rem;
  color: var(--ix-text-muted);
  max-width: 280px;
  line-height: 1.5;
}

/* ── Warnings ── */
.calculator-layout .warnings {
  padding: 0.75rem 1.25rem;
  background: #fffbeb;
  border-top: 1px solid #fde68a;
  font-size: 0.82rem;
  color: var(--ix-warning);
}

.calculator-layout .warnings ul {
  margin: 0;
  padding-left: 1.25rem;
}

.calculator-layout .warnings li {
  margin-bottom: 0.25rem;
}

/* ── Both Options Layout ── */
.calculator-layout .both-options-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ix-gray-500);
  margin-bottom: 0.5rem;
  padding: 0.5rem 1.25rem;
  background: var(--ix-gray-50);
  border-bottom: 1px solid var(--ix-border);
}

/* ── Empty State ── */
.calculator-layout .empty-state {
  background: var(--ix-surface);
  border: 1px solid var(--ix-border);
  border-radius: 10px;
  padding: 3rem 2rem;
  text-align: center;
  color: var(--ix-text-muted);
  box-shadow: var(--ix-shadow-sm);
}

.calculator-layout .empty-state h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  color: var(--ix-navy);
  font-weight: 700;
}

.calculator-layout .empty-state p {
  margin: 0;
  font-size: 0.85rem;
}

/* ── Profile Reference ── */
.calculator-layout .profile-reference {
  margin-top: 1.5rem;
  background: var(--ix-surface);
  border: 1px solid var(--ix-border);
  border-radius: 10px;
  box-shadow: var(--ix-shadow-sm);
  overflow: hidden;
}

.calculator-layout .profile-reference summary {
  padding: 0.75rem 1.2rem;
  font-family: var(--ix-font);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--ix-teal);
  background: var(--ix-gray-50);
  border-bottom: 1px solid var(--ix-border);
  user-select: none;
  transition: all 0.15s ease;
}

.calculator-layout .profile-reference summary:hover {
  background: var(--ix-mint-bg);
}

.calculator-layout .profile-reference[open] summary {
  border-bottom: 1px solid var(--ix-border);
}

.calculator-layout .reference-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-family: var(--ix-font);
}

.calculator-layout .reference-table th {
  text-align: left;
  padding: 0.5rem 1rem;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ix-text-muted);
  border-bottom: 2px solid var(--ix-border);
}

.calculator-layout .reference-table td {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--ix-border);
}

.calculator-layout .reference-table tbody tr:nth-child(even) {
  background: var(--ix-gray-50);
}

.calculator-layout .reference-table tbody tr:hover {
  background: rgba(0, 176, 173, 0.03);
}

/* ── Header Actions (badges + export) ── */
.calculator-layout .header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ── Header Badges ── */
.calculator-layout .header-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.calculator-layout .env-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calculator-layout .env-badge.test {
  background: rgba(124, 58, 237, 0.12);
  color: #5b21b6;
}

/* ── Test Environment Visual Distinction ── */
.calculator-layout .result-section.test-env {
  border: 1.5px dashed #a78bfa;
  background: #faf5ff;
}

.calculator-layout .result-section.test-env .result-section-header {
  background: #f3f0ff;
  border-bottom-color: #c4b5fd;
}

.calculator-layout .result-section.test-env .result-section-header h2 {
  color: #5b21b6;
}

.calculator-layout .result-section.test-env .results-table tr.totals-row {
  background: #f3f0ff !important;
}

.calculator-layout .result-section.test-env .results-table tr.totals-row td {
  border-top-color: #7c3aed;
}

/* ── Help Panel (always visible) ── */
.calculator-layout .help-panel {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 6rem);
  overflow: hidden;
}

.calculator-layout .help-panel__content {
  display: block;
  overflow-y: auto;
  padding: 1rem;
  background: var(--ix-surface);
  border: 1px solid var(--ix-border);
  border-radius: 10px;
  box-shadow: var(--ix-shadow-sm);
  flex: 1;
  min-height: 0;
}

.calculator-layout .help-panel__content h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ix-navy);
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--ix-teal);
}

.calculator-layout .help-section {
  margin-bottom: 1.25rem;
}

.calculator-layout .help-section:last-child {
  margin-bottom: 0;
}

.calculator-layout .help-section h4 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ix-teal);
  margin: 0 0 0.5rem;
}

.calculator-layout .help-section dl {
  margin: 0;
}

.calculator-layout .help-section dt {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ix-navy);
  margin-top: 0.5rem;
}

.calculator-layout .help-section dt:first-child {
  margin-top: 0;
}

.calculator-layout .help-section dd {
  font-size: 0.75rem;
  color: var(--ix-gray-500);
  margin: 0.125rem 0 0 0;
  line-height: 1.5;
}

@media (max-width: 1200px) {
  .calculator-layout {
    grid-template-columns: 220px 380px 1fr;
  }
}

@media (max-width: 960px) {
  .calculator-layout .help-panel {
    position: static;
    max-height: none;
  }
  .calculator-layout .help-panel__content {
    max-height: 300px;
  }
}

/* ── Export Button ── */
.calculator-layout .export-btn {
  background: transparent;
  border: 1.5px solid var(--ix-teal);
  color: var(--ix-teal);
  border-radius: 6px;
  padding: 0.2rem 0.65rem;
  font-family: var(--ix-font);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.calculator-layout .export-btn:hover {
  background: var(--ix-teal);
  color: white;
}

/* ═══════════════════════════════════════════════
   SITE OVERVIEW — Native dashboard styles
   Scoped to .so-* to avoid conflicts
   ═══════════════════════════════════════════════ */

/* ── Header (embed) ── */
.so-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--ix-border);
  background: var(--ix-gray-50);
}
.so-header__left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.so-header__right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.so-cluster-select {
  font-size: 0.78rem;
  padding: 0.3rem 2rem 0.3rem 0.6rem;
  border: 1px solid var(--ix-gray-300);
  border-radius: 6px;
  color: var(--ix-navy);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2363656A' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 0.6rem center / 10px no-repeat;
  appearance: none;
  min-width: 180px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.so-cluster-select:focus {
  outline: none;
  border-color: var(--ix-teal);
  box-shadow: 0 0 0 2px rgba(0, 176, 173, 0.15);
}

.so-refresh-btn {
  background: none;
  border: 1px solid var(--ix-gray-300);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  color: var(--ix-gray-500);
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.15s;
}
.so-refresh-btn:hover {
  border-color: var(--ix-teal);
  color: var(--ix-teal);
}

.so-updated-at {
  font-size: 0.72rem;
  color: var(--ix-gray-500);
  white-space: nowrap;
}

.so-open-grafana {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ix-teal);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--ix-teal);
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.so-open-grafana:hover {
  background: var(--ix-teal);
  color: #fff;
}

/* ── Dashboard container ── */
.so-dashboard {
  padding: 1rem;
}

/* ── Loading & error states ── */
.so-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 3rem;
  color: var(--ix-gray-500);
  font-size: 0.85rem;
}

.so-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--ix-gray-500);
  text-align: center;
}
.so-error i { font-size: 2rem; margin-bottom: 0.5rem; color: var(--ix-gray-300); }

/* ── Sections ── */
.so-section {
  margin-bottom: 1.25rem;
}
.so-section:last-child {
  margin-bottom: 0;
}
.so-section__header {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ix-teal);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.so-section__header i {
  font-size: 0.82rem;
}

/* ── Stat grid ── */
.so-stat-grid {
  display: grid;
  gap: 0.65rem;
}
.so-stat-grid--6 { grid-template-columns: repeat(6, 1fr); }
.so-stat-grid--5 { grid-template-columns: repeat(5, 1fr); }
.so-stat-grid--2 { grid-template-columns: repeat(2, 1fr); }
.so-stat-grid--auto { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

/* ── Individual stat card ── */
.so-stat {
  background: var(--ix-surface);
  border: 1px solid var(--ix-border);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  text-align: center;
  box-shadow: var(--ix-shadow-sm);
  transition: box-shadow 0.15s;
}
.so-stat:hover {
  box-shadow: var(--ix-shadow);
}
.so-stat__value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.so-stat__label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ix-gray-500);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ── Performance layout (charts side by side) ── */
.so-perf-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-top: 0.65rem;
}

/* ── Chart card ── */
.so-chart-card {
  background: var(--ix-surface);
  border: 1px solid var(--ix-border);
  border-radius: 8px;
  padding: 0.75rem;
  box-shadow: var(--ix-shadow-sm);
}
.so-chart-card__title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ix-navy);
  margin-bottom: 0.5rem;
}
.so-chart-card canvas {
  height: 220px !important;
}

/* ── Responsive breakpoints ── */
@media (max-width: 960px) {
  .so-stat-grid--6 { grid-template-columns: repeat(3, 1fr); }
  .so-stat-grid--5 { grid-template-columns: repeat(3, 1fr); }
  .so-perf-layout { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .so-header { flex-direction: column; align-items: stretch; gap: 0.4rem; padding: 0.5rem 0.75rem; }
  .so-header__left { flex-wrap: wrap; gap: 0.35rem; }
  .so-cluster-select { min-width: 0; flex: 1 1 auto; font-size: 0.72rem; padding: 0.25rem 1.8rem 0.25rem 0.5rem; }
  .so-refresh-btn { padding: 0.25rem 0.4rem; font-size: 0.75rem; }
  .so-updated-at { font-size: 0.65rem; width: 100%; }
  .so-stat-grid--6 { grid-template-columns: repeat(3, 1fr); }
  .so-stat-grid--5 { grid-template-columns: repeat(3, 1fr); }
  .so-stat-grid--2 { grid-template-columns: repeat(2, 1fr); }
  .so-stat { padding: 0.5rem 0.4rem; }
  .so-stat__value { font-size: 1.1rem; }
  .so-stat__label { font-size: 0.6rem; }
  .so-dashboard { padding: 0.5rem; }
  .so-section { margin-bottom: 1rem; }
  .so-section__header { font-size: 0.65rem; margin-bottom: 0.4rem; }
  .so-stat-grid { gap: 0.4rem; }
  .so-perf-layout { gap: 0.4rem; }
  .so-chart-card { padding: 0.5rem; }
  .so-chart-card__title { font-size: 0.65rem; }
  .so-chart-card canvas { height: 180px !important; }
}

/* ═══════════════════════════════════════════════
   DASHBOARDS — Tab bar + Grafana iframe embed
   Scoped to .db-* to avoid conflicts
   ═══════════════════════════════════════════════ */

/* ── Tab bar ── */
.db-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--ix-border);
  padding: 0 1rem;
  background: var(--ix-gray-50);
  overflow-x: auto;
}
.db-tab {
  padding: 0.55rem 1rem;
  border: none;
  background: none;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ix-gray-500);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.db-tab:hover {
  color: var(--ix-teal);
}
.db-tab.active {
  color: var(--ix-teal);
  border-bottom-color: var(--ix-teal);
}

/* ── Tab panes ── */
.db-tab-pane {
  display: none;
}
.db-tab-pane.active {
  display: block;
}

/* ── Grafana iframe container ── */
.db-iframe-wrap {
  width: 100%;
  min-height: 600px;
}
.db-grafana-iframe {
  width: 100%;
  min-height: 600px;
  height: 700px;
  border: none;
  display: block;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .db-tabs { padding: 0 0.5rem; }
  .db-tab { padding: 0.4rem 0.6rem; font-size: 0.7rem; }
  .db-iframe-wrap { min-height: 400px; }
  .db-grafana-iframe { min-height: 400px; height: 500px; }
}

/* ═══════════════════════════════════════════════
   HIERARCHY & MANAGEMENT CARD GRID
   Shared hd-* classes + mgmt-* extensions
   ═══════════════════════════════════════════════ */

/* ── Header / Tabs / Breadcrumb (hierarchy-specific) ── */
.hd-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem; }
.hd-header h2 { margin: 0; }
.hd-tabs { display: flex; gap: 0; }
.hd-tab {
  padding: 0.5rem 1.25rem; border: 1px solid var(--ix-border); background: var(--ix-surface);
  cursor: pointer; font-weight: 500; font-size: 0.9rem; color: var(--ix-text-muted); transition: all 0.15s;
}
.hd-tab:first-child { border-radius: var(--ix-radius) 0 0 var(--ix-radius); }
.hd-tab:last-child  { border-radius: 0 var(--ix-radius) var(--ix-radius) 0; border-left: none; }
.hd-tab.active { background: var(--ix-teal); color: #fff; border-color: var(--ix-teal); }
.hd-tab:not(.active):hover { background: var(--ix-mint-light); }
.hd-tab i { margin-right: 0.35rem; }

.hd-breadcrumb {
  display: flex; align-items: center; gap: 0.35rem; padding: 0.5rem 0.75rem; margin-bottom: 1rem;
  background: var(--ix-gray-50); border-radius: var(--ix-radius); font-size: 0.85rem; flex-wrap: wrap;
}
.hd-breadcrumb-item { color: var(--ix-teal); cursor: pointer; font-weight: 500; }
.hd-breadcrumb-item:hover { text-decoration: underline; }
.hd-breadcrumb-current { color: var(--ix-text); font-weight: 600; }
.hd-breadcrumb-sep { color: var(--ix-gray-300); }

.hd-section-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ix-text-muted); font-weight: 600; margin: 1.25rem 0 0.5rem; }

/* ── Card Grid ── */
.hd-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem;
}

.hd-card {
  background: var(--ix-surface); border: 1px solid var(--ix-border); border-radius: var(--ix-radius);
  padding: 1.25rem; cursor: pointer; transition: all 0.15s; box-shadow: var(--ix-shadow-sm);
  display: flex; flex-direction: column; gap: 0.5rem;
}
.hd-card:hover { transform: translateY(-2px); box-shadow: var(--ix-shadow); border-color: var(--ix-teal); }
.hd-card.hd-muted { opacity: 0.55; }
.hd-card.hd-muted:hover { opacity: 1; }

/* ── Card Parts ── */
.hd-card-top { display: flex; align-items: center; gap: 0.75rem; }
.hd-icon {
  width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.hd-icon-vendor   { background: #e0f7f6; color: #00897b; }
.hd-icon-customer { background: #e3f2fd; color: #1565c0; }
.hd-icon-site     { background: #e8f5e9; color: #2e7d32; }
.hd-icon-env      { background: #f3e5f5; color: #7b1fa2; }
.hd-icon-host     { background: #e8eaf6; color: #3949ab; }

.hd-card-name { font-weight: 600; font-size: 0.95rem; color: var(--ix-text); line-height: 1.2; }
.hd-card-id   { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.78rem; color: var(--ix-text-muted); }

.hd-card-badges { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.hd-badge {
  font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 999px; font-weight: 500;
  background: var(--ix-gray-100); color: var(--ix-gray-700);
}
.hd-badge-vendor   { background: #e0f7f6; color: #00695c; }
.hd-badge-customer { background: #e3f2fd; color: #1565c0; }
.hd-badge-site     { background: #e8f5e9; color: #2e7d32; }
.hd-badge-env      { background: #f3e5f5; color: #7b1fa2; }
.hd-badge-host     { background: #e8eaf6; color: #3949ab; }

.hd-card-count { font-size: 0.8rem; color: var(--ix-text-muted); margin-top: auto; }

/* ── Environment border colors ── */
.hd-env-Production  { border-top: 3px solid #e53935; }
.hd-env-DR          { border-top: 3px solid #f57c00; }
.hd-env-Test        { border-top: 3px solid #1e88e5; }
.hd-env-Development { border-top: 3px solid #43a047; }

/* ── Environment badge colors ── */
.hd-badge-Production  { background: rgba(229,57,53,0.12); color: #c62828; }
.hd-badge-DR          { background: rgba(245,124,0,0.12); color: #e65100; }
.hd-badge-Test        { background: rgba(30,136,229,0.12); color: #1565c0; }
.hd-badge-Development { background: rgba(67,160,71,0.12); color: #2e7d32; }

/* ── Onboarding Progress Tooltip (Bootstrap Popover overrides) ── */
.ob-popover {
  --bs-popover-max-width: none;
  --bs-popover-bg: transparent;
  --bs-popover-border-color: transparent;
  --bs-popover-body-padding-x: 0;
  --bs-popover-body-padding-y: 0;
  --bs-popover-border-width: 0;
  --bs-popover-border-radius: 14px;
  --bs-popover-box-shadow: none;
  z-index: 99999;
  pointer-events: none;
}
.ob-popover .popover-arrow { display: none; }
.ob-popover .popover-body {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,21,51,0.18), 0 2px 10px rgba(0,0,0,0.08);
  color: #1e293b;
  font-family: Inter, system-ui, sans-serif;
  padding: 0;
}

.ob-tooltip-inner { padding: 1rem 1.25rem 1.1rem; }

.ob-tooltip-title {
  font-weight: 700; font-size: 0.82rem; color: #00B0AD;
  display: flex; align-items: center; gap: 0.4rem;
  margin: 0 0 0.9rem 0; letter-spacing: 0.02em;
}
.ob-tooltip-title i { font-size: 1rem; }

.ob-stepper {
  display: flex; align-items: flex-start;
  position: relative; padding: 0 4px;
}
.ob-step {
  display: flex; flex-direction: column; align-items: center;
  position: relative; z-index: 2; flex: 0 0 auto;
}
.ob-step-circle {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700;
  border: 3px solid #e2e8f0; flex-shrink: 0;
}
.ob-step.ob-s-done .ob-step-circle    { background: #00B0AD; color: #fff; border-color: #00B0AD; }
.ob-step.ob-s-pending .ob-step-circle { background: #f1f5f9; color: #94a3b8; border-color: #e2e8f0; }
.ob-step.ob-s-na .ob-step-circle      { background: #f8fafc; color: #cbd5e1; border-color: #e2e8f0; }

.ob-step-label {
  font-size: 0.62rem; font-weight: 600;
  margin-top: 6px; text-align: center;
  max-width: 64px; line-height: 1.2;
  word-wrap: break-word; overflow-wrap: break-word;
}
.ob-step.ob-s-done .ob-step-label    { color: #0f172a; }
.ob-step.ob-s-pending .ob-step-label { color: #94a3b8; }
.ob-step.ob-s-na .ob-step-label      { color: #cbd5e1; text-decoration: line-through; }

.ob-connector {
  flex: 1; height: 3px;
  margin-top: 15px;
  border-radius: 2px; min-width: 16px;
}
.ob-connector.ob-c-done    { background: #00B0AD; }
.ob-connector.ob-c-pending { background: #e2e8f0; }

.ob-summary {
  margin-top: 0.85rem; padding-top: 0.6rem;
  border-top: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.72rem; font-weight: 600; color: #64748b;
}
.ob-summary-pct {
  background: #00B0AD; border-radius: 99px;
  padding: 0.15rem 0.6rem; font-weight: 700;
  color: #fff; font-size: 0.72rem;
}

.ob-empty {
  font-size: 0.8rem; color: #94a3b8;
  padding: 1rem 1.25rem; text-align: center;
}

/* ── Host table (hierarchy drill-down) ── */
.hd-host-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.hd-host-table th {
  text-align: left; padding: 0.5rem 0.75rem; background: var(--ix-gray-50);
  color: var(--ix-text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.03em; border-bottom: 2px solid var(--ix-border);
}
.hd-host-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--ix-border); vertical-align: top; }
.hd-host-table tr:hover td { background: var(--ix-gray-50); }
.hd-host-table .hd-ip { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.82rem; }
.hd-host-table .hd-ip-desc { color: var(--ix-text-muted); font-size: 0.78rem; }

.hd-empty { padding: 2rem; text-align: center; color: var(--ix-text-muted); font-style: italic; }

/* ── Management Header ── */
.mgmt-header {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.mgmt-header h2 { margin: 0; flex-shrink: 0; }
.mgmt-search {
  flex: 1; min-width: 180px; max-width: 320px;
  padding: 0.45rem 0.75rem 0.45rem 2.2rem;
  border: 1px solid var(--ix-border); border-radius: 6px;
  font-family: var(--ix-font); font-size: 0.85rem;
  background: var(--ix-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%2363656A' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E") 0.65rem center no-repeat;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mgmt-search:focus {
  outline: none; border-color: var(--ix-teal);
  box-shadow: 0 0 0 3px rgba(0, 176, 173, 0.1);
}
.mgmt-header .btn { flex-shrink: 0; }

/* ── Management Card Extensions ── */
.mgmt-card-actions {
  display: flex; align-items: center; gap: 0.5rem; margin-top: auto; padding-top: 0.5rem;
  border-top: 1px solid var(--ix-border);
}
.mgmt-card-actions .btn { font-size: 0.75rem; padding: 0.2rem 0.55rem; }

.mgmt-card-notes {
  font-size: 0.78rem; color: var(--ix-text-muted); line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}

.mgmt-card-detail {
  font-size: 0.78rem; color: var(--ix-text-muted); line-height: 1.4;
}
.mgmt-card-detail strong { color: var(--ix-gray-700); font-weight: 600; }

.mgmt-status {
  display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.72rem; font-weight: 600;
}
.mgmt-status-dot {
  width: 7px; height: 7px; border-radius: 50%; display: inline-block;
}
.mgmt-status-active .mgmt-status-dot { background: var(--ix-success); }
.mgmt-status-inactive .mgmt-status-dot { background: var(--ix-gray-300); }
.mgmt-status-active { color: var(--ix-success); }
.mgmt-status-inactive { color: var(--ix-gray-500); }

.mgmt-card-link {
  font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mgmt-card-link a { color: var(--ix-teal); text-decoration: none; }
.mgmt-card-link a:hover { text-decoration: underline; }

.mgmt-no-results {
  display: none; padding: 2rem; text-align: center; color: var(--ix-text-muted); font-style: italic;
}

@media (max-width: 576px) {
  .hd-grid { grid-template-columns: 1fr; }
  .hd-header { flex-direction: column; align-items: flex-start; }
  .mgmt-header { flex-direction: column; align-items: stretch; }
  .mgmt-search { max-width: none; }
}

/* ═══════════════════════════════════════════════
   SYSTEM ISSUES — Site Health issue cards
   Scoped to .si-* to avoid conflicts
   ═══════════════════════════════════════════════ */

.si-card {
  border-radius: 0.5rem;
  overflow: hidden;
  border-color: var(--ix-border);
}
.si-card .card-header {
  background: var(--ix-gray-50);
  border-bottom: 1px solid var(--ix-border);
}

.si-table {
  font-size: 0.82rem;
}
.si-table thead th {
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ix-gray-600, #63656A);
  border-bottom-width: 1px;
  padding: 0.5rem 0.75rem;
  position: sticky;
  top: 0;
  background: #fff;
}
.si-table tbody td {
  padding: 0.4rem 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--ix-border);
}
.si-table tbody tr:last-child td {
  border-bottom: none;
}

.si-scroll {
  max-height: 380px;  /* ~10 rows + header */
  overflow-y: auto;
}


/* ═══════════════════════════════════════════════
   CRM PIPELINE — Toolbar, pills, table, groups
   ═══════════════════════════════════════════════ */

/* ── Action buttons ── */
.crm-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.crm-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  font-family: var(--ix-font);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ix-teal);
  background: var(--ix-surface);
  border: 1px solid var(--ix-teal);
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.crm-add-btn:hover {
  background: var(--ix-teal);
  color: #fff;
}
.crm-add-btn--filled {
  background: var(--ix-teal);
  color: #fff;
  border-color: var(--ix-teal);
}
.crm-add-btn--filled:hover {
  background: var(--ix-teal-dark);
  border-color: var(--ix-teal-dark);
  color: #fff;
}
.crm-add-btn i {
  font-size: 0.75rem;
}

/* ── Edit button (inline table action) ── */
.crm-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--ix-border);
  border-radius: 6px;
  color: var(--ix-teal);
  text-decoration: none;
  transition: all 0.15s ease;
  font-size: 0.8rem;
}
.crm-edit-btn:hover {
  background: var(--ix-teal);
  border-color: var(--ix-teal);
  color: #fff;
}

/* ── Toolbar ── */
.crm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding: 0.65rem 0.85rem;
  background: var(--ix-surface);
  border: 1px solid var(--ix-border);
  border-radius: var(--ix-radius);
  box-shadow: var(--ix-shadow-sm);
}
.crm-filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Multi-select dropdown ── */
.crm-dropdown {
  position: relative;
  user-select: none;
}
.crm-dropdown__trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--ix-border);
  border-radius: var(--ix-radius);
  background: var(--ix-surface);
  cursor: pointer;
  min-width: 200px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.crm-dropdown__trigger:hover {
  border-color: var(--ix-gray-300);
}
.crm-dropdown.open .crm-dropdown__trigger {
  border-color: var(--ix-teal);
  box-shadow: 0 0 0 2px rgba(0, 176, 173, 0.1);
}
.crm-dropdown__trigger > .bi-funnel {
  font-size: 0.82rem;
  color: var(--ix-teal);
}
.crm-dropdown__label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ix-gray-500);
  white-space: nowrap;
}
.crm-dropdown__tags {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  flex: 1;
}
.crm-dropdown__chevron {
  font-size: 0.7rem;
  color: var(--ix-gray-500);
  transition: transform 0.2s;
  margin-left: auto;
}
.crm-dropdown.open .crm-dropdown__chevron {
  transform: rotate(180deg);
}

/* Tags inside trigger */
.crm-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  background: var(--ix-gray-100);
  color: var(--ix-gray-700);
}
.crm-tag i { font-size: 0.65rem; }
.crm-tag__count {
  font-size: 0.62rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.08);
  padding: 0 0.3rem;
  border-radius: 999px;
  line-height: 1.4;
}
.crm-tag--all { background: rgba(0, 176, 173, 0.1); color: var(--ix-teal-dark); }
.crm-tag--all .crm-tag__count { background: rgba(0, 176, 173, 0.15); }
.crm-tag--secondary { background: rgba(99, 101, 106, 0.1); color: var(--ix-gray-700); }
.crm-tag--info { background: rgba(33, 150, 243, 0.1); color: #1565c0; }
.crm-tag--warning { background: rgba(255, 152, 0, 0.1); color: #e65100; }
.crm-tag--success { background: rgba(76, 175, 80, 0.1); color: #2e7d32; }
.crm-tag--primary { background: rgba(0, 176, 173, 0.1); color: var(--ix-teal-dark); }

/* Dropdown menu */
.crm-dropdown__menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  min-width: 240px;
  background: var(--ix-surface);
  border: 1px solid var(--ix-border);
  border-radius: var(--ix-radius);
  box-shadow: var(--ix-shadow-lg);
  padding: 0.35rem 0;
}
.crm-dropdown.open .crm-dropdown__menu {
  display: block;
}
.crm-dropdown__item label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--ix-text);
  transition: background 0.1s;
  margin: 0;
}
.crm-dropdown__item label:hover {
  background: var(--ix-gray-50);
}
.crm-dropdown__item input[type="checkbox"] {
  accent-color: var(--ix-teal);
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex-shrink: 0;
}
.crm-dropdown__item--all label {
  font-weight: 600;
}
.crm-dropdown__icon {
  font-size: 0.82rem;
  flex-shrink: 0;
}
.crm-dropdown__icon--secondary { color: var(--ix-gray-500); }
.crm-dropdown__icon--info { color: var(--ix-info); }
.crm-dropdown__icon--warning { color: var(--ix-warning); }
.crm-dropdown__icon--success { color: var(--ix-success); }
.crm-dropdown__icon--primary { color: var(--ix-teal); }
.crm-dropdown__count {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ix-text-muted);
  background: var(--ix-gray-100);
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  min-width: 1.4em;
  text-align: center;
}
.crm-dropdown__divider {
  height: 1px;
  background: var(--ix-border);
  margin: 0.25rem 0;
}
.crm-dropdown__actions {
  padding: 0.35rem 0.75rem 0.25rem;
  display: flex;
  justify-content: flex-end;
}
.crm-dropdown__apply {
  font-family: var(--ix-font);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 1rem;
  background: var(--ix-teal);
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s;
}
.crm-dropdown__apply:hover {
  background: var(--ix-teal-dark);
}

/* ── View toggle ── */
.crm-view-toggle {
  display: flex;
  border: 1px solid var(--ix-border);
  border-radius: 6px;
  overflow: hidden;
}
.crm-view-btn {
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--ix-gray-500);
  background: var(--ix-surface);
  border-right: 1px solid var(--ix-border);
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}
.crm-view-btn:last-child { border-right: none; }
.crm-view-btn:hover { background: var(--ix-gray-50); color: var(--ix-text); }
.crm-view-btn.active { background: var(--ix-teal); color: #fff; border-color: var(--ix-teal); }
.crm-view-btn i { font-size: 0.75rem; }

/* ── Table ── */
.crm-list { margin-bottom: 1rem; }
.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-family: var(--ix-font);
  background: var(--ix-surface);
  border: 1px solid var(--ix-border);
  border-radius: var(--ix-radius);
  overflow: hidden;
}
.crm-table thead th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ix-text-muted);
  padding: 0.55rem 0.75rem;
  border-bottom: 2px solid var(--ix-border);
  background: var(--ix-gray-50);
  white-space: nowrap;
}
.crm-table tbody td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--ix-border);
  vertical-align: middle;
}
.crm-table tbody tr:last-child td { border-bottom: none; }
.crm-table tbody tr:hover td { background: rgba(0, 176, 173, 0.025); }
.crm-cell-name { font-weight: 600; color: var(--ix-text); font-size: 0.88rem; line-height: 1.3; }
.crm-cell-id { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.75rem; color: var(--ix-text-muted); }
.crm-cell-url { font-size: 0.72rem; color: var(--ix-teal); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.crm-cell-notes {
  font-size: 0.78rem;
  color: var(--ix-text-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Inline stage select ── */
.crm-stage-form { display: flex; }
.crm-stage-select {
  font-family: var(--ix-font);
  font-size: 0.78rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--ix-border);
  border-radius: 5px;
  background: var(--ix-gray-50);
  color: var(--ix-text);
  cursor: pointer;
  width: 100%;
}
.crm-stage-select:focus {
  outline: none;
  border-color: var(--ix-teal);
  box-shadow: 0 0 0 2px rgba(0, 176, 173, 0.1);
}

/* ── Group headers (vendor view) ── */
.crm-group { margin-bottom: 1.25rem; }
.crm-group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.88rem;
  color: var(--ix-navy);
  background: var(--ix-mint-bg);
  border: 1px solid var(--ix-border);
  border-bottom: none;
  border-radius: var(--ix-radius) var(--ix-radius) 0 0;
}
.crm-group-header i { color: var(--ix-teal); font-size: 0.9rem; }
.crm-group-header--muted { background: var(--ix-gray-50); }
.crm-group-header--muted i { color: var(--ix-gray-300); }
.crm-group .crm-table { border-top: none; border-radius: 0 0 var(--ix-radius) var(--ix-radius); }

/* ── Contact row repeater (mirrors .ip-row) ── */
.contact-row {
  border-bottom: 1px solid var(--ix-border);
  padding-bottom: 0.25rem;
}
.contact-row:last-child { border-bottom: none; }

/* ── Renewal badges ── */
.crm-renewal-soon {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(220, 53, 69, 0.12);
  color: #dc3545;
}
.crm-renewal-warning {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(255, 152, 0, 0.12);
  color: #e65100;
}
.crm-renewal-muted {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ix-text-muted);
}

/* ── Value column ── */
.crm-cell-value {
  font-size: 0.82rem;
  font-weight: 600;
  font-family: 'SFMono-Regular', Consolas, monospace;
  white-space: nowrap;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .crm-toolbar { flex-direction: column; align-items: stretch; }
  .crm-view-toggle { justify-content: stretch; }
  .crm-view-btn { flex: 1; justify-content: center; }
  .crm-table { font-size: 0.8rem; }
  .crm-table thead th,
  .crm-table tbody td { padding: 0.4rem 0.5rem; }
  /* Hide notes column on mobile */
  .crm-table th:nth-last-child(2),
  .crm-table td:nth-last-child(2) { display: none; }
}
@media (max-width: 576px) {
  .crm-dropdown__trigger { min-width: 0; }
  .crm-dropdown__tags { display: none; }
}

.hd-icon-employee { background: #e8f5e9; color: #2e7d32; }

/* ═══════════════════════════════════════════════
   CRM NOTES — Conversation-style timeline
   ═══════════════════════════════════════════════ */

.crm-notes-container {
  padding: 1rem 0;
}

.crm-notes-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.crm-note-bubble {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--ix-border);
}
.crm-note-bubble:last-child {
  border-bottom: none;
}

.crm-note-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ix-teal);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.crm-note-content {
  flex: 1;
  min-width: 0;
}

.crm-note-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.crm-note-author {
  font-size: 0.85rem;
  color: var(--ix-navy);
}

.crm-note-time {
  font-size: 0.72rem;
  color: var(--ix-gray-500);
  margin-left: auto;
  white-space: nowrap;
}

.crm-note-text {
  font-size: 0.85rem;
  color: var(--ix-text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.crm-notes-input {
  border-top: 1px solid var(--ix-border);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

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

@media (max-width: 991px) {
  .si-card { margin-bottom: 0.5rem; }
}

/* ── Pagination ── */
.pgn-hidden { display: none !important; }
.pgn-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  gap: 1rem;
  flex-wrap: wrap;
}
.pgn-info {
  font-size: 0.85rem;
  color: var(--ix-text-muted, #6c757d);
}

/* ═══════════════════════════════════════════════
   SOW / Requirements Chat
   ═══════════════════════════════════════════════ */

.sow-chat-layout {
  display: flex;
  gap: 1rem;
  height: calc(100vh - 3rem);
  min-height: 400px;
  overflow: hidden;
}

.sow-chat-col {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.sow-docs-panel {
  flex: 0 0 260px;
  background: var(--ix-surface);
  border: 1px solid var(--ix-border);
  border-radius: var(--ix-radius);
  padding: 1rem;
  overflow-y: auto;
}

/* ── Messages area ── */
.sow-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sow-msg {
  max-width: 75%;
  word-wrap: break-word;
  animation: sow-msg-in 0.2s ease-out;
}

@keyframes sow-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sow-msg--user {
  align-self: flex-end;
}

.sow-msg--user .sow-msg-content {
  background: var(--ix-teal);
  color: #fff;
  padding: 0.6rem 0.9rem;
  border-radius: 18px 18px 4px 18px;
  font-size: 0.875rem;
  line-height: 1.45;
}

.sow-msg--assistant {
  align-self: flex-start;
}

.sow-msg--assistant .sow-msg-content {
  background: #f0f2f5;
  color: var(--ix-navy);
  padding: 0.6rem 0.9rem;
  border-radius: 18px 18px 18px 4px;
  font-size: 0.875rem;
  line-height: 1.55;
}

.sow-msg-time {
  font-size: 0.65rem;
  color: var(--ix-gray-400, #adb5bd);
  margin-top: 2px;
  padding: 0 0.5rem;
}

.sow-msg--user .sow-msg-time {
  text-align: right;
}

/* ── Assistant content markdown ── */
.sow-msg--assistant .sow-msg-content h1,
.sow-msg--assistant .sow-msg-content h2,
.sow-msg--assistant .sow-msg-content h3,
.sow-msg--assistant .sow-msg-content h4 {
  margin-top: 0.6rem;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}
.sow-msg--assistant .sow-msg-content h1 { font-size: 1.05rem; }
.sow-msg--assistant .sow-msg-content h2 { font-size: 1rem; }

.sow-msg--assistant .sow-msg-content ul,
.sow-msg--assistant .sow-msg-content ol {
  padding-left: 1.25rem;
  margin-bottom: 0.4rem;
}

.sow-msg--assistant .sow-msg-content p {
  margin-bottom: 0.4rem;
}
.sow-msg--assistant .sow-msg-content p:last-child {
  margin-bottom: 0;
}

.sow-msg--assistant .sow-msg-content code {
  background: rgba(0, 0, 0, 0.06);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.82em;
}

.sow-msg--assistant .sow-msg-content pre {
  background: rgba(0, 0, 0, 0.06);
  padding: 0.6rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.82rem;
}

.sow-msg--assistant .sow-msg-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.4rem 0;
  font-size: 0.82rem;
}

.sow-msg--assistant .sow-msg-content th,
.sow-msg--assistant .sow-msg-content td {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--ix-border);
}

.sow-msg--assistant .sow-msg-content th {
  background: rgba(0, 0, 0, 0.04);
  font-weight: 600;
}

/* ── Typing indicator (three bouncing dots) ── */
.sow-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.5rem;
  color: var(--ix-gray-500, #6c757d);
  font-size: 0.8rem;
}

.sow-typing-dots {
  display: flex;
  gap: 3px;
}

.sow-typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--ix-teal);
  border-radius: 50%;
  animation: sow-bounce 1.4s ease-in-out infinite;
}
.sow-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.sow-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sow-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Status bar ── */
.sow-status {
  font-size: 0.75rem;
  padding: 0.3rem 0.5rem;
  color: var(--ix-gray-500, #6c757d);
  text-align: center;
  min-height: 1.5rem;
  transition: color 0.3s;
}
.sow-status--error {
  color: var(--bs-danger, #dc3545);
  font-weight: 500;
}

/* ── Streaming content area ── */
.sow-streaming {
  align-self: flex-start;
  max-width: 75%;
}

.sow-streaming .sow-msg-content {
  background: #f0f2f5;
  color: var(--ix-navy);
  padding: 0.6rem 0.9rem;
  border-radius: 18px 18px 18px 4px;
  font-size: 0.875rem;
  line-height: 1.55;
}

/* ── Action buttons ── */
.sow-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.35rem 0;
}

/* ── Input area ── */
.sow-input-area {
  padding-top: 0.5rem;
  border-top: 1px solid var(--ix-border);
  flex-shrink: 0;
}

.sow-input-group {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.sow-input-group textarea {
  resize: none;
  flex: 1;
  border-radius: 20px;
  padding: 0.5rem 0.9rem;
  font-size: 0.875rem;
  max-height: 120px;
}

.sow-input-group .btn-send {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

/* ── Documents panel ── */
.sow-doc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--ix-border);
  gap: 0.5rem;
}

.sow-doc-item:last-child {
  border-bottom: none;
}

.sow-doc-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.sow-doc-name {
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sow-doc-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.sow-upload-area {
  margin-top: 0.5rem;
}

/* ── Responsive: stack on small screens ── */
@media (max-width: 768px) {
  .sow-chat-layout {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 3rem);
  }
  .sow-docs-panel {
    flex: none;
    max-height: 250px;
  }
  .sow-msg {
    max-width: 90%;
  }
}

/* ═══════════════════════════════════════════════
   SOW Document Viewer / Editor / History
   ═══════════════════════════════════════════════ */

/* ── Viewer layout (auto-height for iframe resize) ── */
.sow-doc-layout {
  display: flex;
  gap: 1rem;
  min-height: 400px;
}

.sow-doc-main {
  flex: 1;
  min-width: 0;
}

/* ── Rendered markdown content ── */
.sow-doc-content {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--ix-navy, #001533);
}

.sow-doc-content h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ix-navy, #001533);
  border-bottom: 3px solid var(--ix-teal, #00B0AD);
  padding-bottom: 0.4rem;
  margin-top: 1.5rem;
  margin-bottom: 0.8rem;
}

.sow-doc-content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ix-navy, #001533);
  border-bottom: 1px solid var(--ix-border, #dee2e6);
  padding-bottom: 0.3rem;
  margin-top: 1.3rem;
  margin-bottom: 0.6rem;
}

.sow-doc-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ix-navy, #001533);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.sow-doc-content h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.8rem;
  margin-bottom: 0.4rem;
}

.sow-doc-content p {
  margin-bottom: 0.6rem;
}

.sow-doc-content ul,
.sow-doc-content ol {
  padding-left: 1.5rem;
  margin-bottom: 0.6rem;
}

/* Section-style numbering for nested ordered lists (2.1, 2.2, etc.) */
.sow-doc-content > ol {
  counter-reset: section;
  list-style: none;
  padding-left: 0;
}

.sow-doc-content > ol > li {
  counter-increment: section;
}

.sow-doc-content > ol > li::before {
  content: counter(section) ". ";
  font-weight: 600;
}

.sow-doc-content > ol > li > ol {
  counter-reset: subsection;
  list-style: none;
  padding-left: 1.5rem;
}

.sow-doc-content > ol > li > ol > li {
  counter-increment: subsection;
}

.sow-doc-content > ol > li > ol > li::before {
  content: counter(section) "." counter(subsection) ". ";
  font-weight: 400;
}

.sow-doc-content li {
  margin-bottom: 0.2rem;
}

.sow-doc-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8rem 0;
  font-size: 0.85rem;
}

.sow-doc-content th,
.sow-doc-content td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--ix-border, #dee2e6);
}

.sow-doc-content th {
  background: var(--ix-surface, #f8f9fa);
  font-weight: 600;
}

.sow-doc-content code {
  background: rgba(0, 0, 0, 0.05);
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  font-size: 0.85em;
}

.sow-doc-content pre {
  background: #f5f6f8;
  padding: 0.8rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.82rem;
}

.sow-doc-content pre code {
  background: none;
  padding: 0;
}

.sow-doc-content hr {
  border: none;
  border-top: 1px solid var(--ix-border, #dee2e6);
  margin: 1.2rem 0;
}

.sow-doc-content blockquote {
  border-left: 3px solid var(--ix-teal, #00B0AD);
  padding: 0.5rem 1rem;
  margin: 0.8rem 0;
  background: rgba(0, 176, 173, 0.04);
  color: var(--ix-gray-600, #495057);
}

/* ── Comments sidebar ── */
.sow-comments-panel {
  flex: 0 0 280px;
  background: var(--ix-surface, #f8f9fa);
  border: 1px solid var(--ix-border, #dee2e6);
  border-radius: var(--ix-radius, 0.375rem);
  padding: 1rem;
  overflow-y: auto;
  max-height: calc(100vh - 6rem);
}

.sow-comment {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--ix-border, #dee2e6);
}

.sow-comment:last-child {
  border-bottom: none;
}

.sow-comment--resolved {
  opacity: 0.55;
}

.sow-comment-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.2rem;
  font-size: 0.78rem;
}

.sow-comment-section {
  font-size: 0.72rem;
  color: var(--ix-teal, #00B0AD);
  font-weight: 500;
  margin-bottom: 0.15rem;
}

.sow-comment-body {
  font-size: 0.82rem;
  line-height: 1.45;
}

/* ── Editor layout ── */
.sow-editor-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 3rem);
  min-height: 400px;
}

#md-editor {
  flex: 1;
  min-height: 0;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.55;
  resize: none;
  border: 1px solid var(--ix-border, #dee2e6);
  border-top: none;
  border-radius: 0 0 var(--ix-radius, 0.375rem) var(--ix-radius, 0.375rem);
  padding: 1rem;
}

/* ── Diff highlighting ── */
.sow-diff-add {
  background: #e6ffed;
  color: #22863a;
}

.sow-diff-remove {
  background: #ffeef0;
  color: #cb2431;
}

/* ── Responsive: viewer stacks on mobile ── */
@media (max-width: 768px) {
  .sow-doc-layout {
    flex-direction: column;
  }
  .sow-comments-panel {
    flex: none;
    max-height: 300px;
  }
}
