/* ZeniX AI Vigilance — application styles (extracted from index.html in t38).
 * Colours, type and radii come from tokens.css; this file must not hard-code new colours. */


/* ━━━━━━━━━━━━━━━━  DARK MODE (component overrides; tokens live in tokens.css)  ━━━━━━━━━━━━━━━━ */
body.dark .sidebar { background: var(--surface-1); }
body.dark .topbar  { background: var(--surface-0); }
body.dark .login-card { background: var(--surface-0); color: var(--text); }
body.dark .login-field input { background: var(--surface-1); color: var(--text); border-color: var(--border2); }
body.dark .table-row:hover { background: var(--surface-2); }
body.dark select, body.dark input, body.dark textarea {
  background: var(--surface-1); color: var(--text); border-color: var(--border2);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  overflow: hidden;
  font-size: var(--fs-sm);
  line-height: var(--lh);
}

/* ━━━━━━━━━━━━━━━━  SIDEBAR  ━━━━━━━━━━━━━━━━ */

.sidebar {
  width: var(--sidebar);
  min-width: var(--sidebar);
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: width 0.2s ease;
  z-index: 100;
}

.sidebar.collapsed {
  width: 60px;
  min-width: 60px;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  min-height: 64px;
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  overflow: hidden;
}

.sidebar-logo .logo-text h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.sidebar-logo .logo-text span {
  font-size: 12px;
  color: var(--text3);
  white-space: nowrap;
}

.sidebar.collapsed .logo-text { display: none; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border2); border-radius: var(--r); }

.nav-section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 8px 4px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .nav-section-label { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-s);
  cursor: pointer;
  color: var(--text2);
  transition: all 0.15s;
  margin-bottom: 2px;
  text-decoration: none;
  overflow: hidden;
  white-space: nowrap;
}

.nav-item:hover {
  background: rgba(37,99,235,.07);
  color: var(--blue);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--blue);
  font-weight: 600;
  border-left: 3px solid var(--blue);
  padding-left: 7px;
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  font-size: 14px;
}

.nav-item .nav-label {
  font-size: 14px;
  font-weight: 500;
}

.sidebar.collapsed .nav-label { display: none; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.collapse-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  border-radius: var(--r-s);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 12px;
  font-family: inherit;
}

.collapse-btn:hover { background: var(--card); color: var(--text2); }

/* ━━━━━━━━━━━━━━━━  MAIN AREA  ━━━━━━━━━━━━━━━━ */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: 56px;
  min-height: 56px;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border);
  border-top: 3px solid transparent;
  background-clip: padding-box;
  box-shadow: none;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.topbar-sub {
  font-size: 12px;
  color: var(--text3);
  margin-left: 4px;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.badge-blue   { background: rgba(37,99,235,.1);   color: var(--blue); }
.badge-green  { background: rgba(5,150,105,.1);   color: var(--green); }
.badge-amber  { background: rgba(217,119,6,.1);   color: var(--amber); }
.badge-red    { background: rgba(220,38,38,.1);   color: var(--red); }
.badge-purple { background: rgba(138,43,226,.1);  color: var(--purple); }
.badge-teal   { background: rgba(13,148,136,.1);  color: var(--teal); }
.badge-gray   { background: rgba(75,85,119,.08);  color: var(--text2); }

/* ━━━━━━━━━━━━━━━━  VIEWS  ━━━━━━━━━━━━━━━━ */

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: var(--border2); border-radius: var(--r); }

.view {
  display: none;
  animation: fadeIn 0.18s ease;
}

.view.active { display: block; }

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

/* ━━━━━━━━━━━━━━━━  LOGIN OVERLAY  ━━━━━━━━━━━━━━━━ */
#login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--surface-1);
  display: flex; align-items: center; justify-content: center;
}
#login-overlay.hidden { display: none; }
.login-card {
  background: var(--surface-0); border-radius: var(--r);
  padding: 40px 36px; width: 400px; max-width: 92vw;
  box-shadow: none; border: 1px solid var(--border);
}
.login-card h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.login-card p  { font-size: 12px; color: var(--text3); margin-bottom: 24px; }
.login-field { margin-bottom: 16px; }
.login-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 5px; }
.login-field input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border2);
  border-radius: var(--r-s); font-size: 14px; font-family: inherit;
  color: var(--text); background: var(--bg); outline: none;
  transition: border-color 0.15s;
}
.login-field input:focus { border-color: var(--blue); }
.login-btn {
  width: 100%; padding: 11px; background: var(--blue); color: #fff;
  border: none; border-radius: var(--r-s); font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background 0.15s; margin-top: 4px;
}
.login-btn:hover { background: var(--blue-d); }
.login-btn:disabled { background: var(--text3); cursor: not-allowed; }
.login-error {
  font-size: 12px; color: var(--red); background: rgba(220,38,38,.06);
  border: 1px solid rgba(220,38,38,.2); border-radius: var(--r-s);
  padding: 8px 10px; margin-top: 10px; display: none;
}
.login-error.visible { display: block; }

/* ━━━━━━━━━━━━━━━━  USER BAR  ━━━━━━━━━━━━━━━━ */
.user-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 4px; font-size: 12px; color: var(--text2);
}
.user-bar .u-name { font-weight: 600; color: var(--text); }
.user-bar .u-sep  { color: var(--border2); }
.signout-btn {
  padding: 5px 12px; background: transparent; color: var(--text2);
  border: 1px solid var(--border); border-radius: var(--r);
  font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: all 0.15s;
}
.signout-btn:hover { background: rgba(220,38,38,.07); color: var(--red); border-color: rgba(220,38,38,.3); }
.session-warn {
  font-size: 12px; color: var(--amber); font-weight: 600;
  background: rgba(217,119,6,.08); border: 1px solid rgba(217,119,6,.2);
  border-radius: var(--r); padding: 3px 8px;
}

/* ━━━━━━━━━━━━━━━━  CARDS  ━━━━━━━━━━━━━━━━ */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
}

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-sub {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}

/* ━━━━━━━━━━━━━━━━  STAT CARDS  ━━━━━━━━━━━━━━━━ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: border-color 0.15s;
}

.stat-card:hover { border-color: var(--border2); }

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.stat-icon.blue   { background: rgba(37,99,235,.1);  color: var(--blue); }
.stat-icon.red    { background: rgba(220,38,38,.1);  color: var(--red); }
.stat-icon.amber  { background: rgba(217,119,6,.1);  color: var(--amber); }
.stat-icon.purple { background: rgba(138,43,226,.1); color: var(--purple); }

.stat-info { flex: 1; }
.stat-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text3);
  font-weight: 500;
}

/* ━━━━━━━━━━━━━━━━  PILLAR GRID  ━━━━━━━━━━━━━━━━ */

.pillars-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

@media (max-width: 1100px) {
  .pillars-grid { grid-template-columns: repeat(2, 1fr); }
}

.pillar-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, transform 0.15s;
}

.pillar-card:hover {
  border-color: var(--blue-l);
  
  box-shadow: none;
}

.pillar-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 2px;
}

.pillar-icon.teal   { background: rgba(13,148,136,.1);  color: var(--teal); }
.pillar-icon.amber  { background: rgba(217,119,6,.1);   color: var(--amber); }
.pillar-icon.blue   { background: rgba(37,99,235,.1);   color: var(--blue); }
.pillar-icon.purple { background: rgba(138,43,226,.1);  color: var(--purple); }
.pillar-icon.green  { background: rgba(16,185,129,.1);  color: var(--green); }

.pillar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.pillar-desc {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
  flex: 1;
}

/* ━━━━━━━━━━━━━━━━  BUTTONS  ━━━━━━━━━━━━━━━━ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-s);
  border: none;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

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

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-l); }

.btn-teal   { background: var(--teal); color: #fff; }
.btn-teal:hover:not(:disabled) { opacity: 0.88; }

.btn-amber  { background: var(--amber); color: #fff; }
.btn-amber:hover:not(:disabled) { opacity: 0.88; }

.btn-purple { background: var(--purple); color: #fff; }
.btn-purple:hover:not(:disabled) { opacity: 0.88; }

.btn-blue   { background: var(--blue); color: #fff; }
.btn-blue:hover:not(:disabled) { background: var(--blue-d); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text2);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); border-color: var(--blue-l); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.88; }

.btn-green { background: var(--green); color: #fff; }
.btn-green:hover:not(:disabled) { opacity: 0.88; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Privacy tab bar ── */
.priv-tab {
  padding: 7px 16px; font-size: 12px; font-weight: 600; border: none; border-bottom: 3px solid transparent;
  background: transparent; color: var(--text2); cursor: pointer; margin-bottom: -2px; border-radius: 0;
  transition: color 0.15s, border-color 0.15s;
}
.priv-tab:hover { color: var(--text); }
.priv-tab-active { color: var(--blue) !important; border-bottom-color: var(--blue) !important; }

/* ━━━━━━━━━━━━━━━━  FORMS  ━━━━━━━━━━━━━━━━ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-input, .form-select, .form-textarea {
  background: var(--surface-0);
  border: 1px solid var(--border2);
  border-radius: var(--r-s);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--accent-ring);
}

.form-select { cursor: pointer; }
.form-select option { background: var(--surface-0); }

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

/* ━━━━━━━━━━━━━━━━  TABLE  ━━━━━━━━━━━━━━━━ */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text3);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text2);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(37,99,235,0.03); }

/* ━━━━━━━━━━━━━━━━  RESULT CARD  ━━━━━━━━━━━━━━━━ */

.result-card {
  background: var(--card2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 20px;
  margin-top: 16px;
  animation: fadeIn 0.2s ease;
}

.result-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.result-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.result-icon.success { background: rgba(5,150,105,.1);  color: var(--green); }
.result-icon.warning { background: rgba(217,119,6,.1);  color: var(--amber); }
.result-icon.error   { background: rgba(220,38,38,.1);  color: var(--red); }
.result-icon.info    { background: rgba(37,99,235,.1);  color: var(--blue); }

.packet-box {
  background: rgba(138,43,226,.04);
  border: 1px solid rgba(138,43,226,.15);
  border-radius: var(--r-s);
  padding: 14px 16px;
  margin-top: 12px;
}

.packet-box .packet-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}

.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(138,43,226,.07);
  border: 1px solid rgba(138,43,226,.15);
  border-radius: var(--r);
  font-size: 12px;
  color: var(--purple);
}

/* ━━━━━━━━━━━━━━━━  SPINNER  ━━━━━━━━━━━━━━━━ */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(37,99,235,0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin  { to { transform: rotate(360deg); } }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

.loading-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px;
  color: var(--text2);
  font-size: 14px;
}

/* ━━━━━━━━━━━━━━━━  TOAST  ━━━━━━━━━━━━━━━━ */

#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  padding: 12px 16px;
  min-width: 280px;
  max-width: 360px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: slideIn 0.2s ease;
  pointer-events: all;
  font-size: 12px;
}

.toast.toast-error   { border-left: 3px solid var(--red); }
.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-info    { border-left: 3px solid var(--blue); }
.toast.toast-warning { border-left: 3px solid var(--amber); }
.toast-dismiss { opacity: 0; animation: fadeOut 0.2s ease 3.8s forwards; }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateX(20px); }
}

/* ━━━━━━━━━━━━━━━━  MODAL  ━━━━━━━━━━━━━━━━ */

.mdb-type, .mdb-level, .cu-tab {
  padding: 6px 14px; border: none; border-radius: var(--r); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; background: transparent; color: var(--text2);
}
.mdb-type.active, .mdb-level.active { background: var(--blue); color: #fff; }
.cu-tab { border-radius: var(--r) var(--r) 0 0; border-bottom: 2px solid transparent; }
.cu-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,34,53,.55);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  width: 100%;
  max-width: 720px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

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

.modal-title { font-size: 14px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

pre.json-view {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  padding: 14px;
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  color: var(--text2);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ━━━━━━━━━━━━━━━━  WORKFLOW STEPS  ━━━━━━━━━━━━━━━━ */

.wf-step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.wf-step:hover { background: var(--card2); color: var(--text); }
.wf-step.active { background: var(--blue-d); color: #fff; }
.wf-arrow {
  color: var(--text3);
  font-size: 14px;
  padding: 0 2px;
  user-select: none;
}

/* ━━━━━━━━━━━━━━━━  PROGRESS BAR  ━━━━━━━━━━━━━━━━ */

.progress-bar-wrap {
  background: var(--border);
  border-radius: var(--r);
  height: 8px;
  overflow: hidden;
  margin: 6px 0;
}

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

/* ━━━━━━━━━━━━━━━━  SIGNAL STRENGTH DOTS  ━━━━━━━━━━━━━━━━ */

.strength-strong  { color: var(--red); font-weight: 700; }
.strength-moderate { color: var(--amber); font-weight: 600; }
.strength-weak     { color: var(--text3); }

/* ━━━━━━━━━━━━━━━━  DIVIDER / SECTION  ━━━━━━━━━━━━━━━━ */

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 12px;
}

hr.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ━━━━━━━━━━━━━━━━  TWO COL GRID  ━━━━━━━━━━━━━━━━ */

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 760px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ━━━━━━━━━━━━━━━━  ACTIVITY FEED  ━━━━━━━━━━━━━━━━ */

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.activity-dot.blue   { background: var(--blue); }
.activity-dot.green  { background: var(--green); }
.activity-dot.amber  { background: var(--amber); }
.activity-dot.red    { background: var(--red); }
.activity-dot.purple { background: var(--purple); }

.activity-text {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.4;
}

.activity-time {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}

/* ━━━━━━━━━━━━━━━━  EXPANDABLE SECTION  ━━━━━━━━━━━━━━━━ */

.expand-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--blue);
  margin-top: 10px;
  user-select: none;
}

.expand-content { display: none; margin-top: 10px; }
.expand-content.open { display: block; }

/* ━━━━━━━━━━━━━━━━  DEADLINE COUNTDOWN  ━━━━━━━━━━━━━━━━ */

.deadline-urgent { color: var(--red); font-weight: 700; }
.deadline-warn   { color: var(--amber); font-weight: 600; }
.deadline-ok     { color: var(--green); }

/* ━━━━━━━━━━━━━━━━  EMPTY STATE  ━━━━━━━━━━━━━━━━ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text3);
  gap: 12px;
}

.empty-state i { font-size: 32px; opacity: 0.4; }
.empty-state p { font-size: 14px; max-width: 280px; line-height: 1.5; }

/* ━━━━━━━━━━━━━━━━  CASE FORM TABS  ━━━━━━━━━━━━━━━━ */

.cf-tabs {
  display: flex;
  gap: 2px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  padding: 3px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.cf-tab {
  flex: 1 1 auto;
  min-width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 10px;
  border-radius: var(--r);
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.cf-tab:hover { background: var(--surface-0); color: var(--text); }
.cf-tab.active { background: var(--blue); color: #fff; box-shadow: none; }

.cf-panel { display: none; }
.cf-panel.active { display: block; animation: fadeIn 0.15s ease; }

.cf-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 20px;
  margin-bottom: 14px;
}

.cf-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blue);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cf-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

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

@media (max-width: 900px) {
  .form-grid-3, .form-grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .form-grid-3, .form-grid-4, .form-grid-2 { grid-template-columns: 1fr; }
}

.form-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  margin-bottom: 8px;
}
.form-check input[type=checkbox] {
  width: 14px;
  height: 14px;
  accent-color: var(--blue);
  cursor: pointer;
}

.form-group.required .form-label::after { content: ' *'; color: var(--red); }

.cf-activity-row {
  display: grid;
  grid-template-columns: 140px 1fr 100px 120px auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.cf-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: rgba(37,99,235,.08);
  border: 1px dashed var(--blue-l);
  border-radius: var(--r-s);
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.cf-add-btn:hover { background: rgba(37,99,235,.14); }

.cf-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  position: sticky;
  bottom: 0;
  background: var(--bg);
}

.seriousness-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 6px;
}

/* ━━━━━━━━━━  CHAT MESSAGES  ━━━━━━━━━━ */
.chat-msg { display: flex; }
.chat-msg.chat-ai { justify-content: flex-start; }
.chat-msg.chat-user { justify-content: flex-end; }
.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--r);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-ai .chat-bubble {
  background: var(--card2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.chat-user .chat-bubble {
  background: var(--purple);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-evidence {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chat-evidence-chip {
  font-size: 12px;
  padding: 2px 7px;
  border-radius: var(--r);
  background: rgba(79,146,245,0.12);
  border: 1px solid rgba(79,146,245,0.25);
  color: var(--blue);
  cursor: default;
}
.chat-src-case      { background:rgba(20,184,166,.13);border:1px solid rgba(20,184,166,.3);color:var(--teal); }
.chat-src-faers     { background:rgba(245,158,11,.12);border:1px solid rgba(245,158,11,.3);color:var(--amber); }
.chat-src-literature{ background:rgba(34,197,94,.12); border:1px solid rgba(34,197,94,.3); color:#16a34a; }
.chat-src-rag       { background:rgba(99,102,241,.12);border:1px solid rgba(99,102,241,.3);color:#6366f1; }
.chat-src-badge { font-size:12px;border-radius:var(--r);padding:1px 4px;font-weight:700;margin-left:3px; }
.chat-conf-bar { height:4px;border-radius:var(--r);background:var(--border);margin-top:6px;overflow:hidden; }
.chat-conf-bar-fill { height:100%;border-radius:var(--r);transition:width .4s; }
.chat-reg-refs { margin-top:6px;display:flex;flex-wrap:wrap;gap:3px; }
.chat-reg-chip { font-size:12px;padding:1px 6px;border-radius:var(--r);background:rgba(99,102,241,.1);
                 border:1px solid rgba(99,102,241,.25);color:#6366f1; }
.chat-suggest-chip { font-size:12px;padding:5px 11px;border-radius:var(--r);cursor:pointer;
  background:var(--card2);border:1px solid var(--border2);color:var(--text2);
  transition:border-color .15s,color .15s; }
.chat-suggest-chip:hover { border-color:var(--purple);color:var(--purple); }
.chat-copy-btn { font-size:12px;padding:2px 7px;border:1px solid var(--border);border-radius:var(--r);
  background:transparent;color:var(--text3);cursor:pointer;margin-top:5px;float:right; }
.chat-copy-btn:hover { background:var(--card2); }
/* ━━━━━━━━━━  MARKDOWN RENDERING  ━━━━━━━━━━ */
.chat-bubble { white-space: normal; }
.chat-md h1,.chat-md h2,.chat-md h3 { font-weight:700;margin:.5em 0 .3em;line-height:1.3; }
.chat-md h1{font-size:1.15em;}.chat-md h2{font-size:1.05em;}.chat-md h3{font-size:.97em;}
.chat-md p{margin:.35em 0;}
.chat-md ul,.chat-md ol{padding-left:1.4em;margin:.35em 0;}.chat-md li{margin:.2em 0;}
.chat-md table{border-collapse:collapse;width:100%;margin:.5em 0;font-size:12px;}
.chat-md th,.chat-md td{border:1px solid var(--border);padding:4px 8px;text-align:left;}
.chat-md th{background:var(--card2);font-weight:600;}
.chat-md tr:nth-child(even){background:rgba(79,146,245,.04);}
.chat-md blockquote{border-left:3px solid var(--purple);margin:.4em 0;padding:.3em .7em;
  background:rgba(138,43,226,.04);color:var(--text2);font-style:italic;}
.chat-md code{font-family:var(--font-mono);font-size:12px;
  background:rgba(79,146,245,.1);border-radius:var(--r);padding:1px 5px;color:var(--blue);}
.chat-md pre{background:var(--surface-2);border-radius:var(--r-s);padding:10px 12px;overflow-x:auto;margin:.5em 0;}
.chat-md pre code{background:transparent;color:var(--text);font-size:12px;padding:0;}
.chat-md strong{font-weight:700;color:var(--text);}
.chat-md a{color:var(--blue);text-decoration:underline;}
.chat-md hr{border:none;border-top:1px solid var(--border);margin:.5em 0;}
.chat-md .chat-field-ref{font-size:12px;background:rgba(79,146,245,.1);border-radius:var(--r);padding:1px 4px;color:var(--blue);}
.chat-typing-dots{display:inline-flex;gap:3px;align-items:center;margin-left:5px;}
.chat-typing-dots span{width:5px;height:5px;border-radius:50%;background:var(--purple);
  animation:chat-dot-bounce .9s ease-in-out infinite;}
.chat-typing-dots span:nth-child(2){animation-delay:.15s;}
.chat-typing-dots span:nth-child(3){animation-delay:.30s;}
@keyframes chat-dot-bounce{0%,60%,100%{transform:translateY(0);}30%{transform:translateY(-5px);}}
/* ━━━━━━━━━━  STAGE PIPELINE INDICATORS  ━━━━━━━━━━ */
.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--r);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text2);
  transition: opacity 0.15s;
}
.stage-pill:hover { opacity: 0.8; }
.stage-pill.ok    { border-color: var(--green); color: var(--green); background: rgba(5,150,105,0.07); }
.stage-pill.warning { border-color: var(--amber); color: var(--amber); background: rgba(217,119,6,0.07); }
.stage-pill.error   { border-color: var(--red); color: var(--red); background: rgba(220,38,38,0.07); }
/* ━━━━━━━━━━  REVIEW COMMENT ITEMS  ━━━━━━━━━━ */
.comment-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  margin-bottom: 8px;
  background: var(--card2);
}
.comment-item.resolved { opacity: 0.55; }
.comment-section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text3);
  margin: 10px 0 4px;
}
.comment-unresolved-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--amber);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  margin-left: 4px;
  vertical-align: middle;
}

/* ━━━━━━━━━━━━━━━━  t38 — CLEAN ENTERPRISE LAYER  ━━━━━━━━━━━━━━━━
   Flat, compact, neutral. One accent; status colour only where it carries meaning. */

/* Shell */
.sidebar { background: var(--surface-1); }
.sidebar-logo { padding: 12px 12px; min-height: 56px; gap: 8px; }
.sidebar-logo .logo-icon { width: 28px; height: 28px; font-size: 14px; color: #fff; border-radius: var(--radius); }
.sidebar-logo .logo-text h2 { font-size: var(--fs-sm); font-weight: 700; }
.sidebar-logo .logo-text span { font-size: var(--fs-xs); }
.sidebar-nav { padding: 4px 8px 8px; }
.nav-section-label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .04em; color: var(--ink-3); padding: 14px 8px 4px; }
.nav-item { padding: 6px 8px; gap: 8px; margin-bottom: 1px; border-radius: var(--radius); color: var(--ink-2); transition: background .1s, color .1s; }
.nav-item .nav-label { font-size: var(--fs-sm); font-weight: 400; }
.nav-item .nav-icon { font-size: var(--fs-xs); width: 16px; color: var(--ink-3); }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; border-left: 0; padding-left: 8px; }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-item.active .nav-label { font-weight: 600; }
.topbar { height: 48px; min-height: 48px; padding: 0 20px; border-top: 0; background: var(--surface-0); }
.topbar-title { font-size: var(--fs-md); font-weight: 600; }
.topbar-sub { font-size: var(--fs-xs); }
.content { padding: 20px 24px; background: var(--surface-1); }
.view { animation: none; }

/* Workspace switcher (sidebar header) */
.ws-switch { display: flex; margin: 8px 12px 4px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface-0); overflow: hidden; }
.ws-switch button { flex: 1; border: 0; background: transparent; color: var(--ink-2); font: 600 var(--fs-xs)/1 var(--font-sans); padding: 7px 6px; cursor: pointer; white-space: nowrap; }
.ws-switch button + button { border-left: 1px solid var(--line-2); }
.ws-switch button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.ws-switch button:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: -2px; }
.sidebar.collapsed .ws-switch { display: none; }
.ws-tag { display: inline-block; margin-left: 8px; padding: 1px 6px; border: 1px solid var(--line-2); border-radius: var(--radius); font-size: var(--fs-xs); color: var(--ink-2); vertical-align: middle; }

/* Cards, stats */
.card { border-radius: var(--radius); padding: 16px; }
.card-title { font-size: var(--fs-sm); font-weight: 600; }
.card-sub { font-size: var(--fs-xs); }
.card-header { margin-bottom: 12px; }
.stats-grid { gap: 12px; margin-bottom: 20px; }
.stat-card { padding: 14px 16px; gap: 12px; }
.stat-icon { width: 32px; height: 32px; font-size: var(--fs-sm); border-radius: var(--radius); }
.stat-value { font-size: var(--fs-xl); font-weight: 600; }
.stat-label { font-size: var(--fs-xs); color: var(--ink-2); }
.pillar-card { padding: 16px; gap: 8px; }
.pillar-card:hover { border-color: var(--line-2); }
.pillar-icon { width: 32px; height: 32px; font-size: var(--fs-sm); border-radius: var(--radius); }
.pillar-title { font-size: var(--fs-sm); }
.pillar-desc { font-size: var(--fs-xs); }
.section-title { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }

/* Buttons: neutral by default, accent for primary; colour variants stay flat */
.btn { padding: 6px 12px; font-size: var(--fs-sm); font-weight: 600; border-radius: var(--radius); border: 1px solid transparent; line-height: 1.2; }
.btn-sm { padding: 4px 8px; font-size: var(--fs-xs); }
.btn-primary, .btn-blue { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover:not(:disabled), .btn-blue:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: var(--surface-0); border: 1px solid var(--line-2); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line-2); color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 1px; }

/* Badges: small, square-ish */
.badge { border-radius: var(--radius); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0; padding: 1px 6px; }

/* Forms */
.form-label { font-size: var(--fs-xs); text-transform: none; letter-spacing: 0; color: var(--ink-2); }
.form-input, .form-select, .form-textarea, .input { padding: 6px 10px; font-size: var(--fs-sm); background: var(--surface-0); border: 1px solid var(--line-2); border-radius: var(--radius); color: var(--ink); font-family: inherit; }
.input { width: 100%; box-sizing: border-box; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.form-group { gap: 4px; margin-bottom: 12px; }
.field-label { display: block; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field-hint { font-size: var(--fs-xs); color: var(--ink-3); margin-top: 4px; }

/* Tables: compact rows */
th, .th-cell { font-size: var(--fs-xs); font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--ink-2); background: var(--surface-1); padding: 6px 10px; text-align: left; }
td { padding: 6px 10px; font-size: var(--fs-sm); color: var(--ink); height: var(--row-h); }
tr:hover td { background: var(--surface-1); }

/* Page scaffolding (replaces repeated inline styles) */
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.page-title { font-size: var(--fs-lg); font-weight: 600; margin-bottom: 2px; color: var(--ink); }
.page-sub, .text-muted { color: var(--ink-2); font-size: var(--fs-xs); }
.text-meta { color: var(--ink-3); font-size: var(--fs-xs); }
.text-error { color: var(--danger); font-size: var(--fs-xs); }
.section-heading { font-size: var(--fs-sm); font-weight: 600; margin-bottom: 12px; color: var(--ink); }
.status-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.status-row--last { border-bottom: 0; }
.status-row .status-name { font-size: var(--fs-sm); color: var(--ink-2); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 8px; vertical-align: middle; }
.dash-head { margin-bottom: 16px; }
.dash-head h1 { font-size: var(--fs-lg); font-weight: 600; margin-bottom: 2px; }
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cell-id { color: var(--accent); font-weight: 600; font-family: var(--font-mono); font-size: var(--fs-xs); }
.cell-trunc { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* Empty state for placeholder (backend pending) screens */
.empty-state { color: var(--ink-3); }
.empty-state i { font-size: var(--fs-xl); opacity: .6; }
.empty-state p { font-size: var(--fs-sm); }
.placeholder-panel { background: var(--surface-0); border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 40px 24px; text-align: center; color: var(--ink-2); }
.placeholder-panel > i { font-size: var(--fs-xl); color: var(--ink-3); }
.placeholder-panel h3 { font-size: var(--fs-md); font-weight: 600; color: var(--ink); margin: 8px 0 4px; }
.placeholder-panel p { font-size: var(--fs-sm); max-width: 560px; margin: 0 auto 4px; }
.placeholder-panel .eta { display: inline-block; margin-top: 10px; padding: 2px 8px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); font-size: var(--fs-xs); font-weight: 600; }
.placeholder-panel code { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-2); }

/* Workspace visibility: items tagged for one workspace hide in the other */
body[data-workspace="pv"] [data-ws="clinical"],
body[data-workspace="clinical"] [data-ws="pv"] { display: none !important; }

/* Login: brand above one calm card, soft tint of the logo colours behind */
#login-overlay {
  flex-direction: column; gap: 28px; padding: 32px 16px 64px; overflow-y: auto;
  background:
    url("/ui/assets/brand/login-threads.svg") center / cover no-repeat,
    radial-gradient(900px 420px at 0% 30%, rgba(74, 176, 245, .06), transparent 70%),
    radial-gradient(900px 420px at 100% 75%, rgba(130, 96, 240, .06), transparent 70%),
    var(--surface-0);
}
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand img { width: 48px; height: 48px; display: block; }
.login-wordmark { font-size: 30px; font-weight: 400; letter-spacing: -.01em; color: var(--ink); line-height: 1; }
.login-wordmark b { font-weight: 600; }
.login-card {
  width: 440px; border-radius: 8px; padding: 36px 40px 32px;
  border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .04);
}
.login-card h2 { font-size: 24px; font-weight: 600; margin-bottom: 24px; }
.login-field { margin-bottom: 18px; }
.login-field label { font-size: var(--fs-sm); font-weight: 400; color: var(--ink-2); margin-bottom: 6px; }
.login-field input { border-radius: 6px; padding: 10px 12px; font-size: 14px; background: var(--surface-0); }
.login-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--blue20); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 40px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; background: none; cursor: pointer;
  color: var(--ink-3); border-radius: 4px;
}
.pw-toggle:hover { color: var(--ink); }
.login-btn { border-radius: 6px; font-size: 15px; font-weight: 600; padding: 11px; margin-top: 8px; }
.login-help { text-align: center; margin: 18px 0 0 !important; font-size: var(--fs-sm) !important; color: var(--ink-3) !important; }
.login-foot {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px; text-align: center;
  font-size: var(--fs-xs); color: var(--ink-3); background: var(--surface-1); border-top: 1px solid var(--line);
}
body.dark #login-overlay { background: var(--surface-1); }
body.dark .login-wordmark { color: var(--ink); }

/* Sidebar mark */
.sidebar-logo .logo-mark { width: 30px; height: 30px; flex: 0 0 auto; display: block; }

/* Floating surfaces: one subtle elevation only */
.modal { box-shadow: var(--shadow-pop); border-radius: var(--radius); }

/* Clinical Safety screens (t58) */
.clin-filter { width: auto; min-width: 120px; max-width: 240px; }
.clin-spacer { flex: 1 1 auto; }
.callout { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; margin-bottom: 12px; background: var(--accent-soft); border: 1px solid var(--line-2); border-radius: var(--radius); color: var(--ink); font-size: var(--fs-sm); }
.callout:empty { display: none; }
.callout-warn { background: #FEF6E7; border-color: #F3D9A4; }
body.dark .callout-warn { background: rgba(180, 83, 9, .15); border-color: rgba(180, 83, 9, .4); }
.callout ul { margin: 4px 0 0 16px; padding: 0; }
th.th-sort { cursor: pointer; user-select: none; }
th.th-sort:hover { color: var(--ink); }
th.th-sort::after { content: ""; display: inline-block; width: 10px; margin-left: 4px; color: var(--ink-3); }
th.th-sort[aria-sort="ascending"]::after { content: "\25B2"; font-size: 9px; }
th.th-sort[aria-sort="descending"]::after { content: "\25BC"; font-size: 9px; }
.clin-table td { padding: 6px 10px; }
.clin-table td.cell-wrap { white-space: normal; min-width: 180px; max-width: 360px; }
.clin-table td.cell-num { text-align: right; font-variant-numeric: tabular-nums; }
.clin-table .sod-note { display: block; margin-top: 2px; color: var(--warn); font-size: var(--fs-xs); white-space: normal; max-width: 280px; }
.clin-modal { max-width: 560px; width: calc(100% - 32px); }
.clin-modal.clin-modal-wide { max-width: 920px; }
.clin-modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.clin-modal-foot:empty { display: none; }
.clin-form-error { color: var(--danger); font-size: var(--fs-xs); margin-top: 8px; min-height: 16px; }
.clin-xml { background: var(--surface-1); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 10px; font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.5; max-height: 320px; overflow: auto; white-space: pre; color: var(--ink); }
.clin-kv { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; font-size: var(--fs-sm); }
.clin-kv b { color: var(--ink-2); font-weight: 600; }
.clin-list { margin: 4px 0 8px 16px; padding: 0; font-size: var(--fs-xs); color: var(--ink-2); }

/* ── Intake item detail (iqd) ─────────────────────────────────────────── */
.iqd { display: flex; flex-direction: column; gap: 14px; font-size: 14px; color: var(--ink); }
.iqd-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.iqd-head-l { display: flex; align-items: center; gap: 12px; min-width: 0; }
.iqd-ch { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.iqd-subject { font-weight: 600; font-size: 15px; }
.iqd-muted { color: var(--ink-3); font-size: 12.5px; }
.iqd-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-card, 10px); overflow: hidden; }
.iqd-tile { padding: 10px 14px; border-right: 1px solid var(--line); min-width: 0; }
.iqd-tile:last-child { border-right: 0; }
.iqd-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 3px; }
.iqd-value { font-weight: 500; overflow-wrap: anywhere; }
.iqd-callout { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius, 8px); line-height: 1.45; }
.iqd-callout > i { margin-top: 3px; }
.iqd-callout.warn { background: var(--warn-soft); }
.iqd-callout.warn > i { color: #B26B00; }
.iqd-callout.bad { background: var(--bad-soft); }
.iqd-callout.bad > i { color: #C53030; }
.iqd-callout.ok { background: var(--ok-soft); }
.iqd-callout.ok > i { color: #1F8A4C; }
.iqd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.iqd-card { border: 1px solid var(--line); border-radius: var(--r-card, 10px); padding: 12px 14px; background: var(--surface-1); }
.iqd-h { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--ink); }
.iqd-h-note { font-weight: 400; margin-left: 4px; }
.iqd-row { display: flex; gap: 12px; padding: 4px 0; }
.iqd-row .iqd-label { flex: 0 0 120px; margin: 2px 0 0; }
.iqd-note { margin: 8px 0 0; color: var(--ink-2); font-size: 12.5px; line-height: 1.45; }
.iqd-text { background: var(--soft); border-radius: var(--radius, 8px); padding: 10px 12px; white-space: pre-wrap; line-height: 1.55; max-height: 260px; overflow: auto; }
.iqd-file, .iqd-msg { padding: 8px 0; border-top: 1px solid var(--line); }
.iqd-file:first-of-type, .iqd-msg:first-of-type { border-top: 0; padding-top: 2px; }
.iqd-file, .iqd-msg-top { display: flex; align-items: flex-start; gap: 10px; }
.iqd-file-ic { color: var(--ink-3); width: 16px; text-align: center; margin-top: 3px; flex: none; }
.iqd-file-main { flex: 1; min-width: 0; }
.iqd-hash { font-size: 11px; color: var(--ink-3); background: var(--soft); padding: 2px 6px; border-radius: 4px; flex: none; }
.iqd-details { margin: 6px 0 0 26px; }
.iqd-details summary { cursor: pointer; color: var(--accent); font-size: 12.5px; }
.iqd-wording { margin-top: 6px; white-space: pre-wrap; background: var(--soft); border-radius: var(--radius, 8px); padding: 10px 12px; font-size: 13px; line-height: 1.5; }
.iqd-timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.iqd-timeline li { display: flex; gap: 10px; padding: 0 0 10px; position: relative; }
.iqd-timeline li:not(:last-child)::before { content: ""; position: absolute; left: 3px; top: 12px; bottom: -2px; width: 1px; background: var(--line-2); }
.iqd-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex: none; }
@media (max-width: 760px) {
  .iqd-tiles { grid-template-columns: 1fr 1fr; }
  .iqd-tile:nth-child(2) { border-right: 0; }
  .iqd-tile:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .iqd-grid { grid-template-columns: 1fr; }
}
