/* Compliance OS frontend — design system preset 11 Build.
   Luxury minimalism: generous whitespace, weight shifts 200–600, one accent. */

:root {
  --ink: #14171A;
  --ink2: #454C53;
  --muted: #8A9199;
  --line: #E8E5DF;
  --line2: #F2F0EB;
  --bg: #FCFBF9;
  --panel: #FFFFFF;
  --accent: #C2410C;
  --accent-soft: #FBF1EA;
  --accent-line: #EEBFA6;
  --ok: #1F7A3D;   --ok-soft: #EDF6EF;   --ok-line: #BFDCC8;
  --wn: #B45309;   --wn-soft: #FBF3E7;   --wn-line: #E6CDA6;
  --dn: #B3261E;   --dn-soft: #FBEDEC;   --dn-line: #E8C4C0;
  --nf: #38536E;   --nf-soft: #EDF1F5;   --nf-line: #C6D2DE;
  --shadow: 0 1px 2px rgba(20, 23, 26, .04), 0 10px 30px rgba(20, 23, 26, .05);
  --rail: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.5 "Inter", "Helvetica Neue", -apple-system, "SF Pro Text", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: .86em; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: #fff; padding: 8px; border: 1px solid var(--line); z-index: 20; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.nowrap { white-space: nowrap; }

.auth-wrap { max-width: 480px; margin: 6vh auto 0; }
.auth-wrap .card { padding: 26px 26px 22px; }

/* ---------------------------------------------------------------- chrome */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 26px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.mark { font-size: 14px; font-weight: 700; letter-spacing: .04em; }
.mark em { color: var(--accent); font-style: normal; }
.ws {
  color: var(--muted); font-size: 13.5px; min-width: 0;
  /* A long workspace name must truncate, not push the bar wider than the viewport. */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-actions { display: flex; align-items: center; gap: 14px; flex: none; }
.who { font-size: 13px; color: var(--muted); }

.shell { display: flex; align-items: flex-start; gap: 0; }
.rail {
  width: var(--rail); flex: none; padding: 20px 14px; position: sticky; top: 52px;
  display: flex; flex-direction: column; justify-content: space-between; min-height: calc(100vh - 52px);
}
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.nav {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 5px;
  color: var(--ink2); font-size: 13.5px; text-decoration: none; border: 1px solid transparent;
}
.nav:hover { background: #F4F2EE; text-decoration: none; }
.nav b { width: 7px; height: 7px; border-radius: 2px; background: #D8D4CC; }
.nav.on { background: #fff; border-color: var(--line); color: var(--ink); font-weight: 600; }
.nav.on b { background: var(--accent); }
.rail-foot { display: flex; flex-direction: column; gap: 6px; padding: 14px 11px 0; border-top: 1px solid var(--line2); }
.rail-foot .mini { font-size: 11.5px; color: var(--muted); }

main { flex: 1; min-width: 0; padding: 26px 30px 60px; max-width: 1180px; }
.foot {
  border-top: 1px solid var(--line2); padding: 14px 30px; color: var(--muted); font-size: 11.5px;
}

/* ---------------------------------------------------------------- headings */
.h1 { font-size: 24px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 2px; }
.sub { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
h3 { font-size: 13.5px; font-weight: 600; margin: 0 0 6px; }
.kicker { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.hdr { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card.p0 { padding: 0; overflow: hidden; }
.card.soft { background: var(--bg); box-shadow: none; }
.card.accent { background: var(--accent-soft); border-color: var(--accent-line); box-shadow: none; }
.card.empty, .card.error { text-align: center; padding: 40px 24px; }
.card.error { border-color: var(--dn-line); background: var(--dn-soft); }
.grid2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 16px 18px; }
.kpi .n { font-size: 27px; font-weight: 200; letter-spacing: -.02em; line-height: 1; }
.kpi .n em { color: var(--accent); font-style: normal; font-weight: 400; }
.kpi .l { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 9px; }

.banner {
  background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 6px;
  padding: 12px 15px; font-size: 13.5px; margin-bottom: 16px;
}
.banner.ok { background: var(--ok-soft); border-color: var(--ok-line); }
.banner.dn { background: var(--dn-soft); border-color: var(--dn-line); }

/* ---------------------------------------------------------------- tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; background: #fff; }
.tbl th {
  text-align: left; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.clickable:hover { background: #FCFBF8; cursor: pointer; }
.tbl .c { text-align: center; }
.tbl .r { text-align: right; }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink2);
  border-radius: 5px; padding: 9px 15px; font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: #D8D4CC; text-decoration: none; }
.btn.p { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.p:hover { background: #A8360A; }
.btn.g { background: transparent; border-color: transparent; color: var(--muted); }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .55; cursor: progress; }

.fld { margin-bottom: 14px; }
.fl { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 5px; padding: 10px 12px;
  font: inherit; font-size: 14px; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.invalid, select.invalid, textarea.invalid { border-color: var(--dn); }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.field-error { font-size: 12px; color: var(--dn); margin-top: 5px; min-height: 0; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink2); cursor: pointer; padding: 6px 0; }
.check input { width: auto; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 500;
  padding: 3px 9px; border-radius: 4px; border: 1px solid var(--line); background: #fff; color: var(--ink2);
}
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip[role="button"] { cursor: pointer; }
.pill { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 2.5px 9px; border-radius: 20px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.wn { background: var(--wn-soft); color: var(--wn); }
.pill.dn { background: var(--dn-soft); color: var(--dn); }
.pill.nf { background: var(--nf-soft); color: var(--nf); }
.pill.gy { background: #F1EFEA; color: var(--muted); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 8px 13px; font: inherit; font-size: 12.5px; color: var(--ink2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }

/* ---------------------------------------------------------------- states */
.skel {
  height: 12px; border-radius: 3px; margin-bottom: 10px;
  background: linear-gradient(90deg, #F1EFEA 0%, #E8E5DF 50%, #F1EFEA 100%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.loading-label { font-size: 11.5px; color: var(--muted); margin-bottom: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: #14171A; color: #fff; padding: 11px 18px; border-radius: 6px; font-size: 13.5px;
  opacity: 0; transition: opacity .2s, transform .2s; z-index: 40; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--ok); }
.toast.dn { background: var(--dn); }

/* ---------------------------------------------------------------- misc */
.stack { display: flex; flex-direction: column; gap: 10px; }
.ev { display: flex; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; }
.ev .tb { width: 34px; height: 34px; border-radius: 5px; background: #EDEAE4; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #6C7278; flex: none; }
.kv { display: grid; grid-template-columns: 165px 1fr; gap: 9px 16px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; padding-top: 3px; }
.kv dd { margin: 0; }
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: start; }
.col { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.col h3 { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.mini-card { border: 1px solid var(--line); border-radius: 5px; padding: 10px; margin-bottom: 8px; font-size: 13px; }
.cred { word-break: break-all; font-size: 11.5px; background: #14171A; color: #E9E7E2; padding: 12px; border-radius: 5px; max-height: 150px; overflow: auto; }

@media (max-width: 1100px) {
  .rail { display: none; }
  main { padding: 20px 18px 60px; }
  .kpis, .board, .grid4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .top { padding: 12px 16px; gap: 10px; }
  /* Keep the bar inside the viewport: drop the role list, cap the workspace name. */
  .who { display: none; }
  .ws { max-width: 30vw; }
  .mark { font-size: 13px; letter-spacing: .02em; }
  .foot { padding: 12px 16px; font-size: 11px; }
  .kpis, .board, .grid3, .grid4, .grid2 { grid-template-columns: 1fr; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .tbl td { border: 0; padding: 4px 14px; }
  .tbl td::before { content: attr(data-label); display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
}

/* --------------------------------------------------------------- the agent */

/* The agent panel is a live trace of work being done. It is deliberately
   quiet: a progress bar measured against the agent's own plan, one line saying
   what it is doing at this instant, and a step list that updates in place so
   nothing flickers while you read it. */
.agent { border-left: 3px solid var(--line); margin-bottom: 18px; overflow: hidden;
         transition: border-color .25s ease; }
.agent.live { border-left-color: var(--accent); }
.agent.succeeded { border-left-color: var(--ok); }
.agent.failed { border-left-color: var(--dn); }

.ag-hdr { display: flex; align-items: flex-start; gap: 10px; padding: 14px 18px 0; }
.ag-head { flex: 1; min-width: 0; }
.ag-line { display: flex; align-items: center; gap: 8px; }
.ag-line b { font-size: 13.5px; }

.ag-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; margin-top: 5px; }
.ag-dot.on { background: var(--accent); animation: ag-pulse 1.15s ease-in-out infinite; }
.ag-dot.succeeded { background: var(--ok); }
.ag-dot.failed { background: var(--dn); }
@keyframes ag-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--accent-soft); }
  50% { opacity: .55; box-shadow: 0 0 0 5px var(--accent-soft); }
}

/* Progress is steps done out of the plan the agent declared — a fact about the
   work, not a decoration. */
.ag-progress { padding: 10px 18px 12px; }
.ag-bar { height: 5px; border-radius: 3px; background: var(--line2); overflow: hidden; }
.ag-fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px;
           transition: width .5s cubic-bezier(.4, 0, .2, 1), background-color .3s ease; }
.agent.succeeded .ag-fill { background: var(--ok); }
.agent.failed .ag-fill { background: var(--dn); }
/* A run that is going nowhere is visible as a stalled bar rather than a
   spinner that looks the same either way. */
.agent.live .ag-fill { animation: ag-breathe 1.8s ease-in-out infinite; }
@keyframes ag-breathe { 0%, 100% { opacity: 1; } 50% { opacity: .72; } }

.ag-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px;
           font-variant-numeric: tabular-nums; }

.ag-steps { list-style: none; margin: 0; padding: 0 18px 4px; }
.ag-step { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line2); }
.ag-step:first-child { border-top: none; }
.ag-step.enter { animation: ag-in .3s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes ag-in { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

.ag-ico { width: 16px; flex: none; text-align: center; font-size: 11px; line-height: 18px; color: var(--ok); }
.ag-step.running .ag-ico::before {
  content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); animation: ag-pulse 1.15s ease-in-out infinite;
}
.ag-step.failed .ag-ico { color: var(--dn); }

.ag-body { flex: 1; min-width: 0; }
.ag-title { font-size: 12.5px; color: var(--ink); }
.ag-step.running .ag-title { color: var(--accent); font-weight: 600; }

/* The sweep says "working" without claiming a number the agent has not
   computed. It is deliberately indeterminate. */
.ag-sweep { height: 3px; border-radius: 2px; background: var(--accent-soft); overflow: hidden;
           margin-top: 6px; max-width: 240px; }
.ag-sweep span { display: block; height: 100%; width: 38%;
                 background: linear-gradient(90deg, transparent, var(--accent), transparent);
                 animation: ag-sweep 1.2s ease-in-out infinite; }
@keyframes ag-sweep { from { transform: translateX(-110%); } to { transform: translateX(320%); } }

.ag-finding { font-size: 11.5px; color: var(--ink2); margin-top: 3px;
              font-variant-numeric: tabular-nums; animation: ag-fade .35s ease-out both; }
@keyframes ag-fade { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }

.ag-sum { margin: 8px 18px 16px; padding-top: 10px; border-top: 1px solid var(--line);
          font-size: 12.5px; font-weight: 600; }
.ag-sum:empty { display: none; }
.ag-sum.bad { color: var(--dn); font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  .agent.live .ag-fill, .ag-dot.on, .ag-step.running .ag-ico::before,
  .ag-sweep span, .ag-step.enter, .ag-finding { animation: none; }
  .ag-fill { transition: none; }
}

/* ------------------------------------------------------------- scanning */

/* Reading a document is a convenience: the form still works by hand, and what
   becomes a record is what the person confirms afterwards. */
.scan { border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px;
        margin-bottom: 16px; background: var(--accent-soft); }
.scan-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.scan-head b { font-size: 12.5px; }

.scan-out { margin-top: 10px; font-size: 12px; }
.scan-out.pending { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.scan-out.bad { color: var(--dn); }
.scan-field { display: grid; grid-template-columns: 84px 1fr; gap: 2px 10px;
              padding: 6px 0; border-top: 1px solid var(--line2); }
.scan-field:first-of-type { border-top: none; }
.scan-field .scan-src { grid-column: 2; overflow-wrap: anywhere; }
.scan-field > span { color: var(--muted); }
.scan-text { max-height: 180px; overflow: auto; background: var(--panel); border: 1px solid var(--line);
             border-radius: 8px; padding: 10px; margin-top: 8px; font-size: 11px; line-height: 1.5;
             white-space: pre-wrap; overflow-wrap: anywhere; }
details summary { cursor: pointer; margin-top: 8px; }

@media (max-width: 560px) {
  .scan-field { grid-template-columns: 1fr; }
  .scan-field .scan-src { grid-column: 1; }
}
