/* ============================================================
   Security & Maintenance Dashboard
   Azia Light Theme — white/aqua palette
   ============================================================ */

body.security-active #expanded-title,
body.security-active #detail-panel,
body.security-active #bg-layer,
body.security-active #c4-link { display: none !important; }

#security-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: #ECFEFF;
  color: #475569;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
}

#security-view::before { content: none; }

.sec-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  z-index: 250;
  flex-shrink: 0;
  border-bottom: 2px solid #0891B2;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.sec-header-left { display: flex; align-items: center; gap: 12px; }
.sec-title { font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; color: #172351; }
.sec-subtitle { font-size: 0.75rem; font-weight: 400; color: rgba(71,85,105,0.7); text-transform: uppercase; letter-spacing: 0.08em; margin-left: 4px; }

.sec-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

/* ---- Metrics ---- */
.sec-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.sec-metric-card {
  background: #fff;
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid #E5E7EB;
}

.sec-metric-card .metric-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: #94A3B8; margin-bottom: 6px;
}
.sec-metric-card .metric-value {
  font-size: 1.6rem; font-weight: 700; color: #172351;
}
.sec-metric-card .metric-sub {
  font-size: 0.72rem; color: #64748B; margin-top: 2px;
}

/* ---- Section nav pills ---- */
.sec-section-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.sec-section-pill {
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid #E5E7EB;
  background: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  color: #475569;
  transition: all 0.15s;
  text-decoration: none;
}

.sec-section-pill:hover { border-color: #0693E3; color: #0693E3; }

/* ---- Section headings ---- */
.sec-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #172351;
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid #E5E7EB;
}

/* ---- Tables ---- */
.sec-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
  margin-bottom: 24px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.sec-table th {
  background: #F1F5F9;
  color: #475569;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #E5E7EB;
  white-space: nowrap;
}

.sec-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #F1F5F9;
  color: #475569;
  vertical-align: middle;
}

.sec-table tr:last-child td { border-bottom: none; }
.sec-table tr:hover td { background: #F8FAFC; }

/* ---- Status badges ---- */
.sec-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.sec-badge-ok { background: #DCFCE7; color: #166534; }
.sec-badge-warning { background: #FEF3C7; color: #92400E; }
.sec-badge-critical { background: #FEE2E2; color: #991B1B; }
.sec-badge-info { background: #DBEAFE; color: #1E40AF; }
.sec-badge-na { background: #F3F4F6; color: #6B7280; }
.sec-badge-weak { background: #FEF3C7; color: #92400E; }
.sec-badge-at-risk { background: #FEE2E2; color: #991B1B; }

/* Compliance checkmarks */
.sec-check { color: #22C55E; font-weight: 700; }
.sec-cross { color: #EF4444; font-weight: 700; }

/* ---- Collapsible facts ---- */
.sec-facts {
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  margin-bottom: 20px;
  overflow: hidden;
}

.sec-facts-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: #172351;
  background: #F8FAFC;
  border: none;
  width: 100%;
  text-align: left;
}

.sec-facts-toggle:hover { background: #F1F5F9; }

.sec-facts-body {
  padding: 0 16px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s;
}

.sec-facts-body.open {
  max-height: 500px;
  padding: 12px 16px;
}

.sec-facts-body ul {
  margin: 0; padding: 0 0 0 18px; font-size: 0.82rem; line-height: 1.7; color: #475569;
}

/* ---- Severity badges ---- */
.sec-sev-info { background: #DBEAFE; color: #1E40AF; }
.sec-sev-warning { background: #FEF3C7; color: #92400E; }
.sec-sev-critical { background: #FEE2E2; color: #991B1B; }

/* ---- Digital Properties Overview cards ---- */
.sec-props-grid { margin-bottom: 24px; }

.sec-props-category { margin-bottom: 16px; }

.sec-props-cat-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94A3B8;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #E5E7EB;
}

.sec-props-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.sec-prop-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  border: 1px solid #E5E7EB;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow 0.15s;
}

.sec-prop-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Padlock — top-right */
.sec-prop-padlock {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 16px;
  cursor: help;
  z-index: 2;
}

.sec-padlock-ok {
  color: #D4A017;
  filter: drop-shadow(0 0 4px rgba(212, 160, 23, 0.5));
}

.sec-padlock-fail {
  color: #dc2626;
}

/* Top section — icon + name + desc */
.sec-prop-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.sec-prop-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
  line-height: 1;
}

.sec-prop-info {
  flex: 1;
  min-width: 0;
}

.sec-prop-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #172351;
  line-height: 1.3;
}

.sec-prop-id {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #0693E3;
  color: #0693E3;
  font-size: 0.65rem;
  font-weight: 600;
  font-family: monospace;
  margin-right: 4px;
  vertical-align: middle;
}

.sec-prop-desc {
  font-size: 0.78rem;
  color: #64748B;
  margin-top: 2px;
}

/* URL */
.sec-prop-url {
  font-size: 0.75rem;
}

.sec-prop-url a {
  color: #0693E3;
  text-decoration: none;
}

.sec-prop-url a:hover {
  text-decoration: underline;
}

/* Bottom section — status pill + plug + note */
.sec-prop-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
}

/* Status pills */
.sec-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 16px;
  white-space: nowrap;
}

.sec-status-api-connected {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.sec-status-in-progress {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}

.sec-status-manual {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.sec-status-not-connected {
  background: #f9fafb;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

.sec-status-deprecated {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Connection plug */
.sec-plug-live { font-size: 12px; color: #2563eb; }
.sec-plug-broken { font-size: 12px; color: #dc2626; }
.sec-plug-pending { font-size: 12px; color: #9ca3af; }

/* Note */
.sec-prop-note {
  font-size: 0.7rem;
  color: #94A3B8;
  font-style: italic;
  margin-left: auto;
}

/* ---- Startup Roster ---- */

.sec-startup-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.sec-startup-search {
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
  width: 220px;
  outline: none;
}
.sec-startup-search:focus {
  border-color: #0891B2;
  box-shadow: 0 0 0 2px rgba(8,145,178,0.15);
}

.sec-startup-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sec-startup-pill {
  padding: 4px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  font-size: 0.75rem;
  cursor: pointer;
  color: #475569;
  transition: all 0.15s;
}
.sec-startup-pill:hover { background: #e2e8f0; }
.sec-startup-pill.active {
  background: #0891B2;
  color: #fff;
  border-color: #0891B2;
}

.sec-startup-table td { vertical-align: middle; }

.sec-startup-cmd {
  font-family: monospace;
  font-size: 0.75rem;
  color: #64748b;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sec-startup-actions {
  white-space: nowrap;
  display: flex;
  gap: 4px;
}

.sec-startup-btn {
  padding: 3px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.sec-startup-btn:hover { background: #f1f5f9; }
.sec-startup-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.sec-startup-stop { color: #dc2626; border-color: #fca5a5; }
.sec-startup-stop:hover { background: #fef2f2; }

.sec-startup-restart { color: #d97706; border-color: #fcd34d; }
.sec-startup-restart:hover { background: #fffbeb; }

.sec-startup-start { color: #059669; border-color: #6ee7b7; }
.sec-startup-start:hover { background: #ecfdf5; }

.sec-startup-no-action {
  font-size: 0.72rem;
  color: #94a3b8;
  font-style: italic;
}

/* Source badges */
.sec-startup-src { font-size: 0.72rem; }
.sec-src-registry { background: #ede9fe; color: #7c3aed; }
.sec-src-folder { background: #fef3c7; color: #92400e; }
.sec-src-task { background: #dbeafe; color: #1d4ed8; }
.sec-src-service { background: #d1fae5; color: #065f46; }
.sec-src-other { background: #f1f5f9; color: #475569; }

/* ---- Software Updates Section ---- */

.sec-pill-software {
  background: rgba(8, 145, 178, 0.08);
  color: #0891B2;
  border-color: rgba(8, 145, 178, 0.25);
  font-weight: 600;
}
.sec-pill-software:hover {
  background: rgba(8, 145, 178, 0.15);
}

.sec-software-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.sec-software-refresh-all {
  padding: 6px 16px;
  border: 1px solid #0891B2;
  border-radius: 6px;
  background: #0891B2;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sec-software-refresh-all:hover { background: #0E7490; }
.sec-software-refresh-all:disabled { opacity: 0.6; cursor: not-allowed; }

.sec-software-timestamp {
  font-size: 0.75rem;
  color: #94a3b8;
}

.sec-software-grid { margin-bottom: 24px; }

.sec-sw-category { margin-bottom: 16px; }

.sec-sw-cat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #0891B2;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(8, 145, 178, 0.15);
}

.sec-sw-table th:first-child,
.sec-sw-table td:first-child { width: 36px; text-align: center; }

.sec-sw-icon-cell {
  font-size: 18px;
  color: #475569;
  text-align: center;
}

.sec-sw-actions { white-space: nowrap; }

.sec-sw-check-btn {
  padding: 3px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #0891B2;
}
.sec-sw-check-btn:hover { background: #ECFEFF; border-color: #0891B2; }
.sec-sw-check-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.sec-sw-tip {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #ECFDF5;
  color: #065F46;
  font-size: 0.7rem;
  font-weight: 500;
  animation: secSwFadeIn 0.2s ease;
}

@keyframes secSwFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Infrastructure Health ---- */

.sec-infra-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.sec-infra-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
}

.sec-infra-icon {
  font-size: 22px;
  color: #475569;
  width: 32px;
  text-align: center;
  flex-shrink: 0;
}

.sec-infra-info {
  flex: 1;
  min-width: 0;
}

.sec-infra-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e293b;
}

.sec-infra-detail {
  font-size: 0.75rem;
  color: #94a3b8;
  font-family: monospace;
}

.sec-infra-status {
  flex-shrink: 0;
}

.sec-infra-containers {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  color: #475569;
  padding: 8px 0;
}

.sec-infra-container {
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 2px 8px;
  font-family: monospace;
  font-size: 0.78rem;
  margin: 2px 4px 2px 0;
}

.sec-infra-monitors {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.sec-infra-monitor-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
}

.sec-infra-monitor-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 10px;
}

.sec-infra-monitor-title i {
  margin-right: 6px;
}

.sec-infra-monitor-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 8px;
}

.sec-infra-monitor-stats span {
  font-size: 0.92rem;
  color: #1e293b;
}

.sec-infra-monitor-stats small {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-left: 2px;
}

.sec-infra-monitor-stats strong {
  font-size: 1.2rem;
  font-weight: 700;
}

.sec-infra-monitor-footer {
  font-size: 0.75rem;
  color: #94a3b8;
}

/* ---- Security Routines Grid (ADR-095) ---- */
.sec-routines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 0 0 20px;
}
.sec-routine-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  transition: border-color 0.15s;
}
.sec-routine-card:hover { border-color: #94a3b8; }
.sec-rt-active { border-left: 3px solid #16a34a; }
.sec-rt-pending { border-left: 3px solid #f59e0b; }
.sec-rt-other { border-left: 3px solid #94a3b8; }
.sec-rt-ref { font-size: 10px; color: #7c3aed; font-family: 'SF Mono', 'Consolas', monospace; margin-bottom: 4px; }
.sec-rt-title { font-size: 13px; font-weight: 600; color: #1e293b; margin-bottom: 4px; }
.sec-rt-schedule { font-size: 11px; color: #64748b; margin-bottom: 8px; }
.sec-rt-meta { display: flex; justify-content: space-between; font-size: 10px; color: #94a3b8; }
.sec-rt-status { text-transform: uppercase; font-weight: 600; letter-spacing: 0.3px; }
.sec-rt-active .sec-rt-status { color: #16a34a; }
.sec-rt-pending .sec-rt-status { color: #f59e0b; }
.sec-no-routines, .sec-error { padding: 20px; text-align: center; color: #94a3b8; font-size: 13px; }

/* ---- Staff Ownerships ---- */
.sec-pill-ownership {
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;
  border-color: rgba(124, 58, 237, 0.25);
  font-weight: 600;
}
.sec-pill-ownership:hover {
  background: rgba(124, 58, 237, 0.15);
}

.sec-ownership-grid { margin-bottom: 24px; }

.so-tier-group { margin-bottom: 20px; }
.so-tier-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7c3aed;
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 2px solid rgba(124, 58, 237, 0.15);
}

.so-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}

.so-card {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  overflow: hidden;
  transition: box-shadow 0.15s ease;
}
.so-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.so-card-empty { opacity: 0.5; }

.so-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 14px 8px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  background: rgba(124, 58, 237, 0.03);
}

.so-worker-info { display: flex; flex-direction: column; gap: 2px; }
.so-worker-name { font-weight: 700; font-size: 0.9rem; color: #172351; }
.so-worker-role { font-size: 0.68rem; color: rgba(71, 85, 105, 0.6); }

.so-counts { display: flex; gap: 4px; flex-wrap: wrap; }
.so-count {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 8px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}
.so-count-project { background: #d1fae5; color: #065f46; }
.so-count-task { background: #fef3c7; color: #92400e; }
.so-count-routine { background: #dbeafe; color: #1e40af; }
.so-count-none { background: rgba(0,0,0,0.04); color: #94a3b8; }

.so-card-body { padding: 8px 14px 12px; }

.so-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(0,0,0,0.03);
  font-size: 0.78rem;
}
.so-item:last-child { border-bottom: none; }

.so-item-icon { font-size: 0.65rem; width: 16px; text-align: center; flex-shrink: 0; }
.so-item-ref {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.65rem;
  color: #7c3aed;
  font-weight: 500;
  flex-shrink: 0;
  min-width: 80px;
}
.so-item-title {
  color: rgba(71, 85, 105, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.so-deadline {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  background: rgba(0,0,0,0.04);
  color: #64748b;
}
.so-deadline-overdue { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.so-deadline-urgent { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.so-deadline-soon { background: rgba(59, 130, 246, 0.08); color: #2563eb; }

.so-item-more {
  color: rgba(71, 85, 105, 0.45);
  font-style: italic;
  font-size: 0.72rem;
  padding-top: 4px;
}

.so-empty {
  color: rgba(71, 85, 105, 0.35);
  font-size: 0.78rem;
  font-style: italic;
  padding: 8px 0;
}

@media (max-width: 900px) {
  .sec-metrics { grid-template-columns: repeat(2, 1fr); }
  .sec-props-card-grid { grid-template-columns: 1fr; }
  .sec-infra-grid { grid-template-columns: repeat(2, 1fr); }
  .sec-infra-monitors { grid-template-columns: 1fr; }
  .sec-routines-grid { grid-template-columns: repeat(2, 1fr); }
  .so-cards-grid { grid-template-columns: 1fr; }
}
