* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Calibri, system-ui, sans-serif;
       background: #f5f6f7; color: #1c1e21; font-size: 15px; }
header { background: #16211c; color: #fff; padding: 10px 24px;
         display: flex; align-items: center; justify-content: space-between;
         flex-wrap: wrap; gap: 8px; }
.brand { font-weight: 600; font-size: 17px; }
.logo { background: #2e7d5b; border-radius: 4px; padding: 2px 7px;
        font-weight: 700; margin-right: 6px; }
.proto { font-size: 11px; opacity: .65; border: 1px solid rgba(255,255,255,.4);
         border-radius: 3px; padding: 1px 6px; margin-left: 8px; vertical-align: middle; }
nav a { color: #cfe3da; text-decoration: none; margin-right: 18px; }
nav a:hover { color: #fff; }
nav .user { color: #8fa89d; font-size: 13px; }
nav .user a { margin: 0; }
main { max-width: 1400px; margin: 0 auto; padding: 22px 24px 60px; }
footer { text-align: center; color: #7a8580; font-size: 12px; padding: 18px; }
h1 { font-size: 22px; margin: 6px 0 2px; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 16px 0 6px; }
.meta-line { color: #5b6660; font-size: 13px; margin-top: 2px; }
.card { background: #fff; border: 1px solid #dfe3e1; border-radius: 8px;
        padding: 16px 18px; margin: 14px 0; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat { background: #fff; border: 1px solid #dfe3e1; border-radius: 8px;
        padding: 10px 16px; font-size: 13px; color: #5b6660; }
.stat b { display: block; font-size: 20px; color: #16211c; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: #5b6660; font-weight: 600; font-size: 12px;
     text-transform: uppercase; letter-spacing: .03em; }
th, td { padding: 7px 10px 7px 0; border-bottom: 1px solid #eceeed;
         vertical-align: top; }
.nowrap { white-space: nowrap; }
a { color: #1d6b4c; }
.muted { color: #8a938e; }
.hint { color: #5b6660; font-size: 13px; }
.error { color: #a5231d; }
.notice { background: #f0f4f2; border: 1px solid #cfe0d8; border-radius: 6px;
          padding: 8px 12px; font-size: 13px; margin: 8px 0; }
.notice.error { background: #fbeeed; border-color: #e5b8b5; }
input[type=text], input[type=search], input[type=password], input:not([type]),
textarea { width: 100%; padding: 8px 10px; border: 1px solid #c9cfcc;
           border-radius: 6px; font: inherit; margin: 4px 0 10px; }
input[type=file] { margin: 4px 0 10px; }
button { background: #1d6b4c; color: #fff; border: 0; border-radius: 6px;
         padding: 8px 16px; font: inherit; cursor: pointer; }
button:hover { background: #17573d; }
button:disabled { background: #9db3a9; cursor: default; }
button.mini { padding: 1px 8px; font-size: 12px; background: #eef1f0;
              color: #1d6b4c; border: 1px solid #c9d6d0; }
button.mini:hover { background: #e1e8e5; }
.upload-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.upload-form input[type=text] { flex: 1; min-width: 180px; margin: 0; }
.upload-form input[type=file] { margin: 0; }
details summary { cursor: pointer; color: #5b6660; font-size: 13px; margin: 6px 0; }

.badge { display: inline-block; font-size: 11px; border-radius: 10px;
         padding: 1px 8px; margin-left: 4px; white-space: nowrap; }
.s-ready { background: #e2f2ea; color: #17573d; }
.s-processing { background: #fdf3dc; color: #7a5c12; }
.s-error { background: #fbeeed; color: #a5231d; }
.s-none { background: #eef0ef; color: #6c7671; }
.s-stated { background: #e2f2ea; color: #17573d; }
.s-inferred { background: #e8ecfb; color: #2c4491; }
.s-notfound { background: #eef0ef; color: #6c7671; }
.conf-high { background: #eef0ef; color: #3c463f; }
.conf-medium { background: #fdf3dc; color: #7a5c12; }
.conf-low { background: #fbeeed; color: #a5231d; }
.badge.warn { background: #fbeeed; color: #a5231d; }
.badge.ok { background: #e2f2ea; color: #17573d; }
.badge.cat { background: #eef0ef; color: #3c463f; }
.sev-high { background: #fbeeed; color: #a5231d; }
.sev-medium { background: #fdf3dc; color: #7a5c12; }
.sev-low { background: #eef0ef; color: #3c463f; }

.columns { display: flex; gap: 16px; align-items: flex-start; }
.doc-col { flex: 1.1; min-width: 0; }
.side-col { flex: 1; min-width: 0; }
#doctext { white-space: pre-wrap; font-family: Georgia, "Times New Roman", serif;
           font-size: 13.5px; line-height: 1.55; max-height: 78vh; overflow-y: auto;
           background: #fcfcfb; border: 1px solid #eceeed; border-radius: 6px;
           padding: 14px 16px; margin: 0; }
mark { background: #ffe98f; border-radius: 2px; padding: 0 1px; }
.fields td { font-size: 13px; }
.flabel { color: #5b6660; width: 34%; }
.fieldval.anchored { border-bottom: 1px dashed #1d6b4c; }
.row-verified .fieldval { font-weight: 600; }

.finding { border: 1px solid #e4e7e5; border-left: 4px solid #c9cfcc;
           border-radius: 6px; padding: 10px 12px; margin: 10px 0;
           background: #fff; font-size: 13.5px; }
.finding.sev-high { border-left-color: #c0392b; background: #fff; color: inherit; }
.finding.sev-medium { border-left-color: #d9a012; background: #fff; color: inherit; }
.finding.sev-low { border-left-color: #9aa5a0; background: #fff; color: inherit; }
.finding p { margin: 6px 0; }
.fhead b { margin-left: 6px; }
.quote { color: #444; font-style: italic; }
.quote.anchored { cursor: pointer; border-bottom: 1px dashed #1d6b4c;
                  display: inline-block; }
.rule { color: #2c4491; font-size: 12.5px; }
.suggestion { color: #17573d; font-size: 12.5px; }
.rerun { float: right; }

.login-body { display: flex; align-items: center; justify-content: center;
              min-height: 100vh; background: #16211c; }
.login-box { background: #fff; border-radius: 10px; padding: 30px 34px;
             width: 340px; }
.login-box .brand { color: #16211c; margin-bottom: 18px; }
.login-box label { display: block; font-size: 13px; color: #5b6660; }
.login-box button { width: 100%; margin-top: 6px; }

@media (max-width: 980px) { .columns { flex-direction: column; } }

/* Stage-2 additions */
.repo-layout { display: flex; gap: 16px; align-items: flex-start; }
.views-panel { width: 240px; flex-shrink: 0; background: #fff; border: 1px solid #dfe3e1;
               border-radius: 8px; padding: 12px 14px; }
.views-panel h3 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase;
                  color: #5b6660; letter-spacing: .04em; }
.view-link { display: flex; justify-content: space-between; padding: 5px 8px;
             border-radius: 6px; text-decoration: none; color: #1c1e21; font-size: 13.5px; }
.view-link:hover { background: #eef1f0; }
.view-link.active { background: #e2f2ea; color: #17573d; font-weight: 600; }
.view-link .count { color: #5b6660; font-size: 12px; }
.newbtn { display: block; text-align: center; background: #1d6b4c; color: #fff;
          border-radius: 6px; padding: 8px; text-decoration: none; font-weight: 600; }
.newbtn:hover { background: #17573d; }
.up-date { display: block; font-size: 12px; padding: 4px 6px; border-radius: 4px;
           text-decoration: none; color: #1c1e21; }
.up-date:hover { background: #eef1f0; }
.repo-main { flex: 1; min-width: 0; }
.badge.big { font-size: 13px; padding: 3px 10px; }
.badge.lc { background: #e8ecfb; color: #2c4491; }
.sg-not_sent { background: #eef0ef; color: #6c7671; }
.sg-sent { background: #fdf3dc; color: #7a5c12; }
.sg-signed_by_counterparty, .sg-partially_signed { background: #e8ecfb; color: #2c4491; }
.sg-fully_executed { background: #e2f2ea; color: #17573d; }
.st-active { background: #e2f2ea; color: #17573d; }
.st-expiring { background: #fdf3dc; color: #7a5c12; }
.st-expired, .st-terminated { background: #fbeeed; color: #a5231d; }
.k-stated { background: #e2f2ea; color: #17573d; }
.k-calculated { background: #e8ecfb; color: #2c4491; }
.k-conditional { background: #fdf3dc; color: #7a5c12; }
.status-bar { display: flex; gap: 26px; align-items: center; flex-wrap: wrap; }
.status-bar select { padding: 5px 8px; border: 1px solid #c9cfcc; border-radius: 6px;
                     font: inherit; }
.progress { width: 130px; height: 7px; background: #eceeed; border-radius: 4px;
            margin-top: 4px; }
.progress div { height: 100%; background: #2e7d5b; border-radius: 4px; }
.tri-ignored .fieldval { text-decoration: line-through; color: #8a938e; }
.tri-btns { white-space: nowrap; }
.tri-btns .mini { padding: 1px 6px; }
.cal { table-layout: fixed; }
.cal td { height: 92px; vertical-align: top; border: 1px solid #eceeed; padding: 3px; }
.cal td.today { background: #f4faf7; outline: 2px solid #2e7d5b; }
.daynum { font-size: 11px; color: #5b6660; }
.cal-event { display: block; font-size: 11px; border-radius: 4px; padding: 2px 4px;
             margin: 2px 0; text-decoration: none; color: #1c1e21; background: #eef1f0; }
.cal-event:hover { background: #e1e8e5; }
.cal-nav { display: flex; gap: 18px; align-items: center; margin: 8px 0; }
#questions label { display: block; margin-top: 8px; font-weight: 600; }
#questions label .hint { font-weight: 400; }
.user-menu { position: relative; display: inline-block; }
#user-chip { background: rgba(255,255,255,.12); color: #cfe3da; border: 1px solid
             rgba(255,255,255,.25); border-radius: 6px; padding: 4px 12px; font-size: 13px; }
#user-chip:hover { background: rgba(255,255,255,.2); }
.user-dd { display: none; position: absolute; right: 0; top: 34px; background: #fff;
           border: 1px solid #dfe3e1; border-radius: 8px; min-width: 250px; z-index: 50;
           box-shadow: 0 6px 20px rgba(0,0,0,.15); padding: 6px; }
.user-dd.open { display: block; }
.dd-head { font-size: 11px; color: #5b6660; text-transform: uppercase;
           letter-spacing: .04em; padding: 6px 10px 4px; }
.dd-item { display: block; width: 100%; text-align: left; background: none; border: 0;
           color: #1c1e21; padding: 7px 10px; border-radius: 6px; font-size: 13.5px;
           cursor: pointer; text-decoration: none; }
.dd-item:hover { background: #eef1f0; }
.dd-item.active { background: #e2f2ea; color: #17573d; font-weight: 600; }

/* Stable header: same height and alignment in every role (no wrap-jumping
   when the role switcher changes the number of nav items). */
header { flex-wrap: nowrap; min-height: 54px; }
nav { display: flex; align-items: center; gap: 15px; flex-wrap: nowrap;
      white-space: nowrap; }
nav a { margin-right: 0; }
.user-menu { margin-left: 6px; flex-shrink: 0; }
@media (max-width: 1150px) {
  nav { gap: 9px; font-size: 13.5px; }
  .brand .proto { display: none; }
}

/* Containment: nothing escapes the white cards. Long unbroken values
   (addresses, URLs, quoted clauses) wrap instead of running past the
   card edge; a worst-case wide table scrolls inside its card. */
.card { overflow-x: auto; }
.card table { max-width: 100%; }
.fields td, .finding, .finding p, .quote, #answer, #refs li, .hint, .basis,
#doctext, .cal-event, .meta-line { overflow-wrap: anywhere; }
.badge { white-space: normal; }
td .badge { white-space: nowrap; }
.status-bar { overflow: visible; }
