/* BuildToValue Trust OS — Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface-2: #21262d;
  --border:    rgba(255,255,255,0.08);
  --allow:     #3fb950;
  --block:     #f85149;
  --educate:   #d29922;
  --log:       #58a6ff;
  --redact:    #bc8cff;
  --inspect:   #79c0ff;
  --report:    #e3b341;
  --refuse:    #f85149;

  /* Identidade BTV — Teal Forense (substitui azul GitHub genérico #388bfd) */
  --accent:            #4f98a3;
  --accent-hover:      #3b7b85;
  --accent-focus-ring: rgba(79,152,163,.20);

  --text:      #e6edf3;
  --muted:     #7d8590;
  --green:     #3fb950;
  --red:       #f85149;
  --yellow:    #d29922;
  --purple:    #bc8cff;
  --blue:      #58a6ff;
  --mono:      'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  --sans:      'Inter', system-ui, sans-serif;
  --radius:    6px;
  --radius-lg: 10px;
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);

  /* ── República Algorítmica — Aliases Estruturais ────────────────────────
     Conway's Law visual: interface espelha o Monolito Modular (ADR-009).
     Aliases puros sobre tokens técnicos auditados. Zero novos seletores.
     WCAG: contraste herdado de cada token base (validado em theme.css).    */
  --legislative: var(--accent);   /* Policy-as-Code, Fatos Técnicos (Rust)  */
  --executive:   var(--educate);  /* Contestability, Execução / SLA 24h      */
  --judicial:    var(--allow);    /* Homologação Ética, explain_decision()    */
  --audit:       var(--redact);   /* Ledger Imutável, HMAC-SHA256            */

  /* Legacy aliases for backwards compat */
  --bg2: var(--surface);
  --bg3: var(--surface-2);
}

/* Light theme */
[data-theme="light"] {
  --bg:        #f6f8fa;
  --surface:   #ffffff;
  --surface-2: #f0f2f4;
  --border:    rgba(0,0,0,0.08);
  --text:      #24292f;
  --muted:     #57606a;
  --shadow:    0 4px 24px rgba(0,0,0,0.12);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* ── Layout ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}
.header .logo {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
}
.header .subtitle { color: var(--muted); font-size: 12px; white-space: nowrap; }
.header nav {
  margin-left: auto;
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
}
.header nav a {
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.header nav a:hover,
.header nav a.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
  text-decoration: none;
}
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: 8px; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.container-wide { max-width: 1400px; margin: 0 auto; padding: 24px; }

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

@media(max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2,1fr); } }
@media(max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .container, .container-wide { padding: 16px; }
  .header { padding: 10px 16px; gap: 10px; }
  .header .subtitle { display: none; }
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 600;
}
.card-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.card-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

/* Action badges */
.badge-allow   { background: rgba(63,185,80,.15);   color: var(--allow);   border: 1px solid rgba(63,185,80,.3); }
.badge-block   { background: rgba(248,81,73,.15);   color: var(--block);   border: 1px solid rgba(248,81,73,.3); }
.badge-educate { background: rgba(210,153,34,.15);  color: var(--educate); border: 1px solid rgba(210,153,34,.3); }
.badge-log     { background: rgba(88,166,255,.15);  color: var(--log);     border: 1px solid rgba(88,166,255,.3); }
.badge-redact  { background: rgba(188,140,255,.15); color: var(--redact);  border: 1px solid rgba(188,140,255,.3); }
.badge-inspect { background: rgba(121,192,255,.15); color: var(--inspect); border: 1px solid rgba(121,192,255,.3); }
.badge-report  { background: rgba(227,179,65,.15);  color: var(--report);  border: 1px solid rgba(227,179,65,.3); }
.badge-refuse  { background: rgba(248,81,73,.15);   color: var(--refuse);  border: 1px solid rgba(248,81,73,.3); }

/* Semantic badges */
.badge-green   { background: rgba(63,185,80,.15);   color: var(--green);   border: 1px solid rgba(63,185,80,.3); }
.badge-red     { background: rgba(248,81,73,.15);   color: var(--red);     border: 1px solid rgba(248,81,73,.3); }
.badge-yellow  { background: rgba(210,153,34,.15);  color: var(--yellow);  border: 1px solid rgba(210,153,34,.3); }
.badge-blue    { background: rgba(88,166,255,.15);  color: var(--blue);    border: 1px solid rgba(88,166,255,.3); }
.badge-purple  { background: rgba(188,140,255,.15); color: var(--purple);  border: 1px solid rgba(188,140,255,.3); }
.badge-muted   { background: rgba(125,133,144,.15); color: var(--muted);   border: 1px solid rgba(125,133,144,.3); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  font-family: var(--sans);
  min-height: 36px;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-2); text-decoration: none; }
.btn-danger  { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #e03b35; }
.btn-ghost   { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; min-height: 28px; }
.btn-lg { padding: 11px 22px; font-size: 15px; min-height: 44px; }
.btn-icon { padding: 7px; min-width: 36px; }

/* ── Forms ── */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--sans);
  outline: none;
  transition: border-color .15s;
  min-height: 36px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-focus-ring); }
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; min-height: 80px; line-height: 1.5; }
select option { background: var(--surface); }
input[type="checkbox"] { width: auto; min-height: auto; cursor: pointer; }
.form-group { margin-bottom: 14px; }

/* ── Table ── */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; padding: 8px 12px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); font-weight: 600; }
td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.mono { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tbl-scroll { overflow-x: auto; }

/* ── Code / JSON ── */
.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: #a5f3fc;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow-y: auto;
  line-height: 1.6;
}

/* ── Verdict blocks ── */
.verdict-block {
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1.5px solid;
}
.verdict-ALLOW   { border-color: var(--allow);   background: rgba(63,185,80,.07); }
.verdict-BLOCK   { border-color: var(--block);   background: rgba(248,81,73,.07); }
.verdict-REVIEW  { border-color: var(--yellow);  background: rgba(210,153,34,.07); }
.verdict-EDUCATE { border-color: var(--educate); background: rgba(210,153,34,.07); }
.verdict-LOG     { border-color: var(--log);     background: rgba(88,166,255,.07); }
.verdict-REDACT  { border-color: var(--redact);  background: rgba(188,140,255,.07); }
.verdict-INSPECT { border-color: var(--inspect); background: rgba(121,192,255,.07); }
.verdict-REPORT  { border-color: var(--report);  background: rgba(227,179,65,.07); }
.verdict-REFUSE  { border-color: var(--refuse);  background: rgba(248,81,73,.07); }
.verdict-UNKNOWN { border-color: var(--border);  background: var(--surface-2); }

.verdict-action {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: .04em;
  line-height: 1;
}
.verdict-ALLOW   .verdict-action, .verdict-ALLOW   { color: var(--allow);   }
.verdict-BLOCK   .verdict-action, .verdict-BLOCK   { color: var(--block);   }
.verdict-REVIEW  .verdict-action, .verdict-REVIEW  { color: var(--yellow);  }
.verdict-EDUCATE .verdict-action { color: var(--educate); }
.verdict-LOG     .verdict-action { color: var(--log);     }
.verdict-REDACT  .verdict-action { color: var(--redact);  }
.verdict-INSPECT .verdict-action { color: var(--inspect); }
.verdict-REPORT  .verdict-action { color: var(--report);  }
.verdict-REFUSE  .verdict-action { color: var(--refuse);  }

/* ── Progress bars ── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .5s cubic-bezier(.4,0,.2,1);
}
.progress-green  { background: var(--green); }
.progress-yellow { background: var(--yellow); }
.progress-red    { background: var(--red); }
.progress-blue   { background: var(--blue); }
.progress-purple { background: var(--purple); }

/* ── Dot indicator ── */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-green  { background: var(--green);  box-shadow: 0 0 6px var(--green); }
.dot-red    { background: var(--red);    box-shadow: 0 0 6px var(--red); }
.dot-yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.dot-blue   { background: var(--blue);   box-shadow: 0 0 6px var(--blue); }
.dot-muted  { background: var(--muted); }
.dot-pulse  { animation: pulse-dot 2s infinite; }

@keyframes pulse-dot {
  0%,100% { opacity:1; box-shadow: 0 0 6px currentColor; }
  50%      { opacity:.5; box-shadow: 0 0 12px currentColor; }
}

/* ── Persona cards (landing) ── */
.persona-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  display: block;
  color: var(--text);
}
.persona-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px var(--accent-focus-ring);
  text-decoration: none;
  color: var(--text);
}
.persona-icon { font-size: 36px; margin-bottom: 12px; display: block; }
.persona-role { font-size: 10px; text-transform: uppercase; letter-spacing:.12em; color: var(--muted); margin-bottom: 5px; }
.persona-name { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.persona-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ── Section title ── */
.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 13px;
  z-index: 9999;
  display: none;
  max-width: 320px;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-warning { border-left: 3px solid var(--yellow); }
.toast-info    { border-left: 3px solid var(--blue); }

/* ── Tabs ── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 16px; gap: 0; overflow-x: auto; }
.tab-btn {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  font-family: var(--sans);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 20px; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { color: var(--text); background: var(--surface-2); }

/* ── Skeleton loader ── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius);
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Offline badge ── */
.offline-badge {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--yellow);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  z-index: 200;
  display: none;
}
.offline-badge.visible { display: block; }

/* ── KPI row ── */
.kpi-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.kpi-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 18px; flex: 1; min-width: 120px; }
.kpi-label { font-size: 10px; text-transform: uppercase; letter-spacing:.08em; color: var(--muted); margin-bottom: 4px; }
.kpi-value { font-family: var(--mono); font-size: 22px; font-weight: 700; }

/* ── Utility ── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.text-muted { color: var(--muted); }
.text-small { font-size: 12px; }
.text-mono  { font-family: var(--mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-break { word-break: break-all; }
.hidden { display: none !important; }
.full-width { width: 100%; }

@media print {
  .header, .btn, nav, .modal-overlay { display: none !important; }
  body { background: white; color: black; }
}
