/* ============================================================
   CertLogIQ — Enterprise Suite CSS
   Shared styles for all 5 enterprise modules.
   Drop into public/ alongside the module JS files.
   Design language: sharp left-border tags, monospace dates,
   square avatars, uppercase section dividers.
   ============================================================ */

/* ─── CSS custom properties ─────────────────────────────────── */
:root {
  --ei-red:       #B71C1C;
  --ei-red-bg:    #FFEBEE;
  --ei-red-text:  #B71C1C;
  --ei-amber:     #E65100;
  --ei-amber-bg:  #FFF3E0;
  --ei-amber-text:#E65100;
  --ei-green:     #2E7D32;
  --ei-green-bg:  #E8F5E9;
  --ei-green-text:#27500A;
  --ei-blue:      #1565C0;
  --ei-blue-bg:   #E3F2FD;
  --ei-blue-text: #0C447C;
  --ei-border:    var(--color-border-tertiary, #e0e0e0);
  --ei-border2:   var(--color-border-secondary, #ccc);
  --ei-bg:        var(--color-background-primary, #fff);
  --ei-bg2:       var(--color-background-secondary, #f5f5f5);
  --ei-text:      var(--color-text-primary, #1a1a1a);
  --ei-text2:     var(--color-text-secondary, #666);
  --ei-radius:    var(--border-radius-md, 4px);
  --ei-mono:      'Courier New', 'Lucida Console', monospace;
}

/* ─── KPI grids ──────────────────────────────────────────────── */
.ei-kpi-grid {
  display: grid;
  gap: 1px;
  background: var(--ei-border);
  border: 0.5px solid var(--ei-border);
  border-radius: var(--ei-radius);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.ei-kpi-4  { grid-template-columns: repeat(4, 1fr); }
.ei-kpi-3  { grid-template-columns: repeat(3, 1fr); }
.ei-kpi-2  { grid-template-columns: repeat(2, 1fr); }
.ei-kpi-cell { background: var(--ei-bg); padding: 12px 14px; }
.ei-kpi-n { font-size: 24px; font-weight: 500; color: var(--ei-text); line-height: 1; }
.ei-kpi-n.ei-kpi-r { color: var(--ei-red); }
.ei-kpi-n.ei-kpi-a { color: var(--ei-amber); }
.ei-kpi-n.ei-kpi-g { color: var(--ei-green); }
.ei-kpi-l { font-size: 10px; color: var(--ei-text2); margin-top: 4px; letter-spacing: 0.3px; }

/* ─── Tab bar ────────────────────────────────────────────────── */
.ei-tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  border: 0.5px solid var(--ei-border);
  border-radius: var(--ei-radius);
  overflow: hidden;
}
.ei-tab {
  flex: 1;
  padding: 8px 4px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-align: center;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--ei-text2);
  border-right: 0.5px solid var(--ei-border);
  font-family: inherit;
  transition: background 0.1s;
}
.ei-tab:last-child { border-right: none; }
.ei-tab.ei-tab-on  { background: var(--ei-red); color: #fff; }
.ei-tab:hover:not(.ei-tab-on) { background: var(--ei-bg2); }

/* ─── Section dividers ───────────────────────────────────────── */
.ei-sect {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 2px;
  color: var(--ei-text2);
  text-transform: uppercase;
  margin: 1.25rem 0 8px;
  padding-bottom: 6px;
  border-bottom: 0.5px solid var(--ei-border);
}
.ei-sect:first-child { margin-top: 0; }

/* ─── Row / list items ───────────────────────────────────────── */
.ei-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 0.5px solid var(--ei-border);
}
.ei-row:last-child { border-bottom: none; }
.ei-row-main { flex: 1; min-width: 0; }
.ei-row-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ei-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ei-row-sub { font-size: 11px; color: var(--ei-text2); margin-top: 1px; }
.ei-row-end { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ─── Status tags ────────────────────────────────────────────── */
.ei-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}
.ei-tag-red    { background: var(--ei-red-bg);   color: var(--ei-red);   border-left: 2px solid var(--ei-red); }
.ei-tag-amber  { background: var(--ei-amber-bg); color: var(--ei-amber); border-left: 2px solid var(--ei-amber); }
.ei-tag-green  { background: var(--ei-green-bg); color: var(--ei-green); border-left: 2px solid var(--ei-green); }
.ei-tag-blue   { background: var(--ei-blue-bg);  color: var(--ei-blue);  border-left: 2px solid var(--ei-blue); }
.ei-tag-grey   { background: var(--ei-bg2); color: var(--ei-text2); border-left: 2px solid var(--ei-border2); }

/* ─── Alerts ─────────────────────────────────────────────────── */
.ei-alert {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: var(--ei-radius);
  border: 0.5px solid var(--ei-border);
  background: var(--ei-bg);
  align-items: center;
}
.ei-alert-accent { width: 3px; border-radius: 2px; align-self: stretch; flex-shrink: 0; }
.ei-alert-red .ei-alert-accent   { background: var(--ei-red); }
.ei-alert-amber .ei-alert-accent { background: var(--ei-amber); }
.ei-alert-green .ei-alert-accent { background: var(--ei-green); }
.ei-alert-blue .ei-alert-accent  { background: var(--ei-blue); }
.ei-alert-body { flex: 1; min-width: 0; }
.ei-alert-title { font-size: 13px; color: var(--ei-text); }
.ei-alert-sub   { font-size: 11px; color: var(--ei-text2); margin-top: 2px; }
.ei-alert-badge {
  font-size: 10px;
  font-weight: 500;
  font-family: var(--ei-mono);
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 2px;
}
.ei-alert-badge-red   { background: var(--ei-red-bg);   color: var(--ei-red); }
.ei-alert-badge-amber { background: var(--ei-amber-bg); color: var(--ei-amber); }
.ei-alert-badge-green { background: var(--ei-green-bg); color: var(--ei-green); }
.ei-alert-badge-blue  { background: var(--ei-blue-bg);  color: var(--ei-blue); }

/* ─── Cards ──────────────────────────────────────────────────── */
.ei-card {
  background: var(--ei-bg);
  border: 0.5px solid var(--ei-border);
  border-radius: var(--ei-radius);
  padding: 1rem;
}
.ei-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.ei-card-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--ei-text2);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.ei-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ─── Progress bars ──────────────────────────────────────────── */
.ei-progress-wrap { margin-bottom: 8px; }
.ei-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ei-text2);
  margin-bottom: 3px;
}
.ei-progress-track {
  background: var(--ei-bg2);
  height: 4px;
  overflow: hidden;
  border-radius: 0;
}
.ei-progress-fill { height: 4px; transition: width 0.3s; }
.ei-progress-r    { background: var(--ei-red); }
.ei-progress-a    { background: var(--ei-amber); }
.ei-progress-g    { background: var(--ei-green); }
.ei-progress-b    { background: var(--ei-blue); }

/* wider compliance bar variant */
.ei-compliance-bar { margin: 0.75rem 0; }
.ei-compliance-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ei-text2);
  margin-bottom: 4px;
}

/* ─── Risk meter (predictive AI) ─────────────────────────────── */
.ei-risk-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 0.5px solid var(--ei-border);
}
.ei-risk-row:last-child { border-bottom: none; }
.ei-risk-label { width: 140px; flex-shrink: 0; }
.ei-risk-meter { flex: 1; height: 6px; background: var(--ei-bg2); overflow: hidden; border-radius: 0; }
.ei-risk-fill  { height: 6px; transition: width 0.4s; }

/* ─── Avatars / initials ─────────────────────────────────────── */
.ei-avatar {
  width: 32px;
  height: 32px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
  font-family: var(--ei-mono);
}
.ei-avatar-r { background: var(--ei-red-bg);   color: var(--ei-red); }
.ei-avatar-b { background: var(--ei-blue-bg);  color: var(--ei-blue-text); }
.ei-avatar-g { background: var(--ei-green-bg); color: var(--ei-green-text); }
.ei-avatar-a { background: var(--ei-amber-bg); color: var(--ei-amber); }

/* doc icon variant */
.ei-doc-icon {
  width: 30px;
  height: 30px;
  background: var(--ei-bg2);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ei-text2);
  flex-shrink: 0;
  font-size: 14px;
}
.ei-doc-icon-g { background: var(--ei-green-bg); color: var(--ei-green-text); }
.ei-doc-icon-r { background: var(--ei-red-bg);   color: var(--ei-red); }
.ei-doc-icon-a { background: var(--ei-amber-bg); color: var(--ei-amber); }
.ei-doc-icon-b { background: var(--ei-blue-bg);  color: var(--ei-blue-text); }

/* ─── Timeline ───────────────────────────────────────────────── */
.ei-timeline { position: relative; padding-left: 20px; }
.ei-tl-item  { position: relative; padding-bottom: 14px; }
.ei-tl-item:last-child .ei-tl-line { display: none; }
.ei-tl-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 0;
  border: 2px solid;
}
.ei-tl-dot.r { border-color: var(--ei-red);   background: var(--ei-red); }
.ei-tl-dot.g { border-color: var(--ei-green); background: var(--ei-green); }
.ei-tl-dot.a { border-color: var(--ei-amber); background: transparent; }
.ei-tl-dot.n { border-color: var(--ei-border); background: transparent; }
.ei-tl-line {
  position: absolute;
  left: -17px;
  top: 12px;
  width: 2px;
  height: calc(100% + 8px);
  background: var(--ei-border);
}

/* ─── Chat bubbles ───────────────────────────────────────────── */
.ei-chat-bubble {
  padding: 10px 14px;
  border-radius: var(--ei-radius);
  margin-bottom: 8px;
  max-width: 85%;
  font-size: 12px;
  line-height: 1.5;
}
.ei-bubble-in  { background: var(--ei-bg2); color: var(--ei-text); border: 0.5px solid var(--ei-border); }
.ei-bubble-out { background: var(--ei-red); color: #fff; margin-left: auto; }
.ei-chat-meta  { font-size: 10px; color: var(--ei-text2); margin-bottom: 3px; }
.ei-chat-meta-out { text-align: right; }
.ei-chat-wrap { display: flex; flex-direction: column; gap: 0; }

/* ─── Buttons ────────────────────────────────────────────────── */
.ei-btn {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  padding: 5px 10px;
  border-radius: 2px;
  border: 0.5px solid var(--ei-border2);
  background: transparent;
  color: var(--ei-text2);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.ei-btn:hover { background: var(--ei-bg2); }
.ei-btn-primary {
  font-size: 11px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 2px;
  background: var(--ei-red);
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.ei-btn-primary:hover { background: #9b1717; }
.ei-btn-row { display: flex; gap: 8px; margin-top: 1rem; }

/* ─── Forms ──────────────────────────────────────────────────── */
.ei-label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ei-text2);
  margin-bottom: 4px;
}
.ei-input, .ei-select, .ei-textarea {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 0.5px solid var(--ei-border2);
  border-radius: 2px;
  background: var(--ei-bg);
  color: var(--ei-text);
  font-family: inherit;
  box-sizing: border-box;
}
.ei-input:focus, .ei-select:focus, .ei-textarea:focus {
  outline: none;
  border-color: var(--ei-red);
}
.ei-textarea { resize: vertical; }
.ei-file-input { font-size: 12px; color: var(--ei-text2); }
.ei-form-group { margin-bottom: 0.75rem; }
.ei-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.ei-toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--ei-border2);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.ei-toggle:checked { background: var(--ei-green); }
.ei-toggle::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: left 0.2s;
}
.ei-toggle:checked::after { left: 18px; }

/* ─── Modals ─────────────────────────────────────────────────── */
.ei-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.ei-modal {
  background: var(--ei-bg);
  border-radius: var(--ei-radius);
  border: 0.5px solid var(--ei-border);
  padding: 1.25rem;
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}
.ei-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 0.5px solid var(--ei-border);
}
.ei-modal-title { font-size: 14px; font-weight: 500; color: var(--ei-text); }
.ei-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 0.5px solid var(--ei-border);
}

/* ─── Utilities ──────────────────────────────────────────────── */
.ei-mono { font-family: var(--ei-mono); }
.ei-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ei-text2);
  font-size: 13px;
  border: 0.5px dashed var(--ei-border);
  border-radius: var(--ei-radius);
  margin-bottom: 1rem;
}
.ei-loading { padding: 2rem; text-align: center; color: var(--ei-text2); font-size: 13px; }
.ei-error   { padding: 1rem; color: var(--ei-red); font-size: 13px; }
.ei-badge-optional {
  font-size: 9px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ei-text2);
  margin-left: 4px;
  vertical-align: middle;
}
.ei-compliance-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 2px;
  font-family: var(--ei-mono);
}
.ei-register-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 0.75rem;
  gap: 12px;
}
.ei-register-actions { display: flex; gap: 8px; flex-shrink: 0; }
.ei-permission-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--ei-border);
}
.ei-permission-row:last-child { border-bottom: none; }
.ei-permission-label { flex: 1; font-size: 13px; color: var(--ei-text); }
.ei-permission-sub   { font-size: 11px; color: var(--ei-text2); margin-top: 1px; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ei-kpi-4 { grid-template-columns: repeat(2, 1fr); }
  .ei-two-col { grid-template-columns: 1fr; }
  .ei-form-row { grid-template-columns: 1fr; }
  .ei-register-header { flex-direction: column; align-items: flex-start; }
  .ei-modal { padding: 1rem; }
  .ei-tab { font-size: 9px; padding: 7px 2px; }
}
