/* ──────────────  Design tokens  ────────────── */
:root {
  /* Ported from the Compliance ARMOR design prototype (files 7). */
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f2f5;
  --border: #eceef1;
  --border-strong: #e2e5ea;
  --line: #eef0f3;

  --text: #171a1f;
  --text-2: #2b3038;
  --text-muted: #8b919b;
  --text-subtle: #a6abb4;
  --label: #a3a8b1;

  --primary: #3d6ef5;
  --primary-hover: #3361ec;
  --primary-soft: #eef2ff;
  --primary-soft-text: #3361ec;
  --primary-ic: #4f6ef7;

  --success: #16a34a;
  --success-dot: #22c55e;
  --success-soft: #ecfdf3;
  --warning: #e8920b;
  --warning-soft: #fff5e6;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --purple: #6d5ef0;
  --purple-soft: #f0eefe;

  --ring: 0 0 0 3px rgba(61, 110, 245, 0.12);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow:    0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 10px 26px rgba(16, 24, 40, 0.08);

  --radius:   14px;
  --radius-lg: 14px;
  --radius-sm: 9px;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }

h1, h2, h3 { letter-spacing: -0.01em; }
h2 { font-size: 22px; font-weight: 600; margin: 0; }
h3 { font-size: 17px; font-weight: 600; margin: 0; }

.muted { color: var(--text-muted); font-size: 13px; margin: 0; }
.opt   { color: var(--text-subtle); font-weight: 400; }

/* ──────────────  Login  ────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background:
    radial-gradient(circle at 20% 0%, rgba(79,70,229,0.08), transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(79,70,229,0.06), transparent 50%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.login-card h2 { margin-top: 8px; font-size: 20px; }
.login-sub { margin-bottom: 16px; }
.brand-lg {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.brand-lg h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.brand-lg p  { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }
.brand-mark {
  width: 44px; height: 44px;
  object-fit: contain;
  flex-shrink: 0;
}
.brand-mark.sm { width: 36px; height: 36px; }
.legal { color: var(--text-subtle); font-size: 12px; margin-top: 24px; text-align: center; }

/* ──────────────  App shell  ────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidenav {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidenav .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.sidenav .brand strong { display: block; font-size: 14px; font-weight: 600; }
.sidenav .brand small  { display: block; font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
/* Grouped sidebar sections (prototype: Main / Compliance / Administration). */
.nav-group { margin-bottom: 18px; }
.nav-group > h4 {
  margin: 0 0 6px;
  padding: 0 10px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--label);
}
.nav .tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 0;
  height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  text-align: left;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav .tab svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.9; }
.nav .tab:hover { background: #f5f6f8; color: var(--text-2); }
.nav .tab.active {
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  font-weight: 600;
}
.nav .tab.active svg { opacity: 1; color: var(--primary); }

.user-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-top: 12px;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0;
  flex-shrink: 0;
}
.user-meta { min-width: 0; }
.user-meta strong {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.role-pill {
  display: inline-block;
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.icon-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

/* ──────────────  Prototype components (panels, grids, ribbon)  ────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line);
}
.panel-head .pt { font-size: 15px; font-weight: 700; color: var(--text); }
.panel-head .ps { font-size: 12px; color: var(--text-subtle); margin-top: 3px; }
.panel-body { padding: 8px 20px 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 980px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.roadmap-ribbon {
  display: flex; align-items: center; gap: 10px;
  background: var(--purple-soft); color: #4a3fb0;
  border: 1px solid #ddd8fb; border-radius: var(--radius-sm);
  padding: 11px 14px; font-size: 13px; margin-bottom: 18px;
}
.roadmap-ribbon::before { content: "✦"; color: var(--purple); font-weight: 700; }

/* Preview form fields */
.fld { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.fld input {
  height: 40px; padding: 0 12px; font: inherit; font-size: 13px; font-weight: 400;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
}
.fld input:disabled { background: #fafbfc; color: var(--text-subtle); }

/* Timeline list (recent activity) */
.tl-item {
  display: flex; gap: 13px; padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.tl-item:last-child { border-bottom: 0; }
.tl-ic {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.tl-ic svg { width: 16px; height: 16px; }
.tl-ic.blue { background: var(--primary-soft); color: var(--primary); }
.tl-ic.green { background: var(--success-soft); color: var(--success); }
.tl-ic.amber { background: var(--warning-soft); color: var(--warning); }
.tl-ic.red { background: var(--danger-soft); color: var(--danger); }
.tl-body { min-width: 0; }
.tl-title { font-size: 13px; font-weight: 600; color: var(--text); }
.tl-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.tl-time { font-size: 11px; color: var(--text-subtle); margin-top: 2px; }

/* Status dot for monitor/dashboard rows */
.sdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.sdot.green { background: var(--success-dot); }
.sdot.amber { background: var(--warning); }
.sdot.red { background: var(--danger); }

/* ──────────────  Main content  ────────────── */
.main {
  padding: 28px 36px 64px;
  max-width: 1400px;
  width: 100%;
}
.tab-panel { display: none; animation: fade-in 0.18s ease-out; }
.tab-panel.active { display: block; }
@keyframes fade-in { from { opacity: 0; transform: translateY(2px);} to { opacity: 1; transform: none;} }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 22px;
}
.page-head h2 { font-size: 27px; font-weight: 800; letter-spacing: -0.6px; }
.page-head .muted { font-size: 13.5px; margin-top: 4px; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ──────────────  Card  ────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* ──────────────  Tables  ────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  background: var(--surface);
  color: #6b717b;
  text-align: left;
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th.num     { text-align: right; }
th.actions-col { text-align: right; }
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.mono, td .mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}
td.payload {
  max-width: 460px;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}
td.actions { text-align: right; white-space: nowrap; }

/* ──────────────  Buttons  ────────────── */
button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.05s;
  white-space: nowrap;
}
button:hover { background: var(--surface-2); border-color: var(--text-muted); }
button:active { transform: translateY(0.5px); }
button:focus-visible { box-shadow: var(--ring); outline: none; }
button svg { width: 14px; height: 14px; flex-shrink: 0; }

button.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 6px 14px rgba(61,110,245,.28);
}
button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
}
button.ghost:hover { background: #f6f7f9; color: var(--text); border-color: var(--border-strong); }
button.block { display: flex; width: 100%; justify-content: center; padding: 10px 14px; margin-top: 4px; }
button.danger { background: var(--danger); color: white; border-color: var(--danger); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

button.sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* table action buttons */
table button {
  padding: 4px 10px;
  font-size: 12px;
}

/* ──────────────  Form controls  ────────────── */
label {
  display: block;
  margin: 14px 0 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
input, select, textarea {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  margin-top: 6px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:hover, select:hover, textarea:hover { border-color: var(--text-muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
textarea { resize: vertical; min-height: 60px; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* ──────────────  Filter bar  ────────────── */
.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.filters label { margin: 0; min-width: 0; }
.filters input, .filters select { width: 200px; }
.filters .self-end { align-self: end; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ──────────────  Banners / alerts  ────────────── */
.error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 1em; }

#integrity-banner {
  margin: 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
}
#integrity-banner:not(:empty) { display: flex; }
#integrity-banner.ok  { background: var(--success-soft); color: #14532D; border-color: #BBF7D0; }
#integrity-banner.bad { background: var(--danger-soft); color: #7F1D1D; border-color: #FECACA; }

.callout {
  background: var(--warning-soft);
  border: 1px solid #FDE68A;
  color: #78350F;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 12.5px;
  margin: 16px 0 4px;
  line-height: 1.55;
}
.callout strong { display: block; margin-bottom: 2px; color: #92400E; }

/* ──────────────  Modal  ────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fade-in 0.15s ease-out;
}
.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px 28px 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  padding: 0 0 4px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ──────────────  Pills / status  ────────────── */
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.tier-2     { background: var(--primary-soft); color: var(--primary-soft-text); padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.tier-3     { background: var(--warning-soft); color: #92400E;                   padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.tier-none  { background: var(--surface-2);    color: var(--text-muted);         padding: 2px 9px; border-radius: 999px; font-size: 11px; }
.acl-on     { background: var(--danger-soft);  color: #7F1D1D;                   padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.acl-off    { background: var(--surface-2);    color: var(--text-muted);         padding: 2px 9px; border-radius: 999px; font-size: 11px; }

.sev-info     { color: var(--text-muted); font-weight: 500; }
.sev-warning  { color: var(--warning); font-weight: 600; }
.sev-critical { color: var(--danger); font-weight: 700; }

/* ──────────────  Audit: stats cards  ────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--text-subtle);
  opacity: 0;
  transition: opacity .15s;
}
.stat-card:hover::before { opacity: 0.7; }
.stat-card.stat-info::before    { background: var(--primary); opacity: 1; }
.stat-card.stat-warn::before    { background: var(--warning); opacity: 1; }
.stat-card.stat-success::before { background: var(--success); opacity: 1; }
.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.stat-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  margin: 8px 0 4px;
  color: var(--text);
  letter-spacing: -0.02em;
  font-feature-settings: "tnum";
}
.stat-card.stat-warn .stat-value    { color: var(--warning); }
.stat-card.stat-success .stat-value { color: var(--success); }
.stat-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ──────────────  Audit: filter chips  ────────────── */
.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 14px 16px 0;
}
.chip {
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.chip:hover { background: var(--border); color: var(--text); }
.chip.active {
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  border-color: var(--primary);
}

/* ──────────────  Audit: event-type chips  ────────────── */
.evt-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--mono);
  white-space: nowrap;
}
.evt-chip::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.evt-cat-auth      { background: #ECFEFF; color: #0E7490; }
.evt-cat-session   { background: #EEF2FF; color: #3730A3; }
.evt-cat-capture   { background: #F5F3FF; color: #5B21B6; }
.evt-cat-signature { background: #F0FDF4; color: #14532D; }
.evt-cat-admin     { background: #FFF7ED; color: #9A3412; }
.evt-cat-warn      { background: #FEF2F2; color: #7F1D1D; }
.evt-cat-default   { background: var(--surface-2); color: var(--text-muted); }

/* ──────────────  Audit: app tag in events table  ────────────── */
.app-tag {
  display: inline-block;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text);
  vertical-align: middle;
}
.muted-cell { color: var(--text-subtle); }

/* ──────────────  Audit: row expand  ────────────── */
.audit-table tbody tr.detail-row td {
  background: var(--surface-2);
  padding: 0;
}
.detail-card {
  padding: 16px 20px 18px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 24px;
}
.detail-card pre {
  margin: 6px 0 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
}
.detail-card .meta dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  font-size: 12px;
}
.detail-card .meta dt {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  align-self: center;
}
.detail-card .meta dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  word-break: break-all;
  color: var(--text);
}
.detail-card .section-h {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0;
}
.expand-btn {
  background: transparent;
  border: 0;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}
.expand-btn:hover { background: var(--surface-2); color: var(--text); }
.expand-btn svg {
  width: 14px; height: 14px;
  transition: transform .15s;
}
.audit-table tbody tr.expanded .expand-btn svg { transform: rotate(90deg); }

/* ──────────────  Agent fleet status dots  ────────────── */
.agent-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  background: var(--text-muted);
}
.agent-dot.agent-online  { background: #16A34A; box-shadow: 0 0 0 3px rgba(22,163,74,0.15); }
.agent-dot.agent-idle    { background: #D97706; box-shadow: 0 0 0 3px rgba(217,119,6,0.15); }
.agent-dot.agent-offline { background: #94A3B8; }

/* ──────────────  File-action buttons inside expanded audit row  ──────────── */
.file-actions { margin-top: 6px; }
.file-action-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-sm {
  font: inherit;
  font-size: 12.5px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
}
.btn-sm:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }
.diff-pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 360px;
  overflow: auto;
  white-space: pre;
  margin: 8px 0 0;
}

/* ──────────────  Mouse-stroke visualisation (Phase 3)  ────────────── */
.stroke-svg {
  display: block;
  max-width: 100%;
  margin: 6px 0 2px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ──────────────  Field-level semantic diff (D6)  ────────────── */
.field-changes {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 0;
  font-size: 13px;
}
.field-changes th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
}
.field-changes td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.field-changes .fc-field { font-weight: 600; color: var(--text); }
.field-changes .fc-chg { font-size: 11px; text-transform: uppercase; color: var(--text-muted); }
.field-changes tr.fc-changed { background: #FFFBEB; }
.field-changes tr.fc-added   { background: #F0FDF4; }
.field-changes tr.fc-removed { background: #FEF2F2; }
.field-changes .fc-old { color: #DC2626; text-decoration: line-through; font-family: ui-monospace, monospace; }
.field-changes .fc-new { color: #16A34A; font-weight: 600; font-family: ui-monospace, monospace; }

/* ──────────────  Inline toggle in page headers (Show inactive)  ────────────── */
.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  margin: 0;
}
.inline-toggle input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}
.inline-toggle:hover { background: var(--surface-2); color: var(--text); }

/* ──────────────  Row actions (Edit / Delete / Reactivate) ────────────── */
.row-actions {
  display: inline-flex;
  gap: 4px;
  white-space: nowrap;
}
.row-actions button {
  padding: 4px 9px;
  font-size: 11.5px;
}
.row-actions button.danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--border-strong);
}
.row-actions button.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}
.row-actions button.success {
  background: var(--surface);
  color: var(--success);
  border-color: var(--border-strong);
}
.row-actions button.success:hover {
  background: var(--success-soft);
  border-color: var(--success);
}

.row-inactive { opacity: 0.55; }
.row-inactive .app-tag,
.row-inactive td:first-child strong { text-decoration: line-through; }

/* ──────────────  Edit-app modal: watched folder list  ────────────── */
.folders-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.folder-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.folder-row .path {
  font-family: var(--mono);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-row .recursive-tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary-soft-text);
}
.folder-row .recursive-tag.flat {
  background: var(--surface);
  color: var(--text-muted);
}
.folder-row button {
  padding: 3px 8px;
  font-size: 11px;
}
.grid-3 {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}
.folder-add-row input { margin-top: 0; }

/* ──────────────  Vault diff pre block ────────────── */
.diff-pre {
  margin: 0;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 380px;
  overflow: auto;
}
.meta-inline {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  margin: 0;
}
.meta-inline dt { color: var(--text-muted); font-weight: 600; }
.meta-inline dd { margin: 0; }

/* severity row tinting */
.audit-table tbody tr.row-sev-warning td  { background: #FFFBEB; }
.audit-table tbody tr.row-sev-critical td { background: #FEF2F2; }

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

/* tighter on small screens */
@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidenav   { position: static; height: auto; flex-direction: row; flex-wrap: wrap; gap: 8px; padding: 12px; }
  .sidenav .brand { width: 100%; padding-bottom: 8px; margin-bottom: 8px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .user-card { width: 100%; margin-top: 4px; }
  .main { padding: 20px 16px 48px; }
  .filters input, .filters select { width: 100%; }
}

/* ── Audit Trail: search bar + shortcuts + match highlight ───────────────── */
.audit-searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 14px;
}
.audit-searchbar .search-ic {
  width: 18px; height: 18px; flex: 0 0 auto;
  color: var(--text-muted, #64748b);
}
#audit-search {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  font-size: 14px;
  background: var(--surface, #fff);
  color: var(--text, #0f172a);
  transition: border-color .12s, box-shadow .12s;
}
#audit-search::placeholder { color: var(--text-muted, #94a3b8); }
#audit-search:focus {
  outline: none;
  border-color: var(--indigo, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .16);
}
.icon-btn {
  flex: 0 0 auto;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface, #fff);
  border-radius: 8px;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 19px; line-height: 1;
  color: var(--text-muted, #64748b);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-2, #f1f5f9); color: var(--text, #0f172a); }
.audit-count {
  flex: 0 0 auto;
  font-size: 12.5px;
  color: var(--text-muted, #64748b);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.audit-table mark, .field-changes mark {
  background: #fde68a;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}
.chip-row { flex-wrap: wrap; align-items: center; }
.chip-sep { width: 1px; align-self: stretch; min-height: 18px; background: var(--border, #e2e8f0); margin: 0 4px; }
.audit-hint {
  margin: 8px 2px 14px;
  font-size: 12.5px;
  color: var(--text-muted, #64748b);
  line-height: 1.5;
}
.audit-hint b { color: var(--text, #0f172a); font-weight: 600; }
.sev-legend { margin: 0 2px 14px; font-size: 12.5px; color: var(--text-muted, #64748b); }
.sev-legend > summary { cursor: pointer; color: var(--indigo, #6366f1); font-weight: 600; }
.sev-legend-body { margin-top: 8px; padding: 10px 12px; background: var(--surface-2, #f1f5f9); border-radius: 8px; }
.sev-legend-body p { margin: 0 0 6px; line-height: 1.5; }
.sev-legend-body p:last-child { margin-bottom: 0; }
.reason-box {
  margin: 0 0 14px;
  padding: 8px 12px;
  background: var(--surface-2, #f1f5f9);
  border-left: 3px solid var(--indigo, #6366f1);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text, #0f172a);
  white-space: pre-wrap;
}

/* Plain-English fact list used in the audit and record drawers. The technical
   values are still there, one disclosure away; this is what a reviewer who does
   not know what SHA-256 means reads first. */
dl.plain-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}
dl.plain-facts dt {
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
}
dl.plain-facts dd { margin: 0; word-break: break-word; }
