/* Tax Return Review. FactualIQ palette on light: navy structure, one orange accent, work on white under a warm head band. */
:root {
  --orange: #e36d19; --orange-deep: #a8520e; --orange-tint: #fbe9dc; --orange-line: #f0c9a8;
  --navy: #163554; --navy-dark: #0e1a2b;
  --ink: #1d2733; --ink-2: #4c5866; --line: #d5dae3; --line-soft: #e6e9ef;
  --band: #f4efe6; --surface: #fff; --row: #f8f9fb; --inset: #f6f2ec;
  --good: #23633a; --good-tint: #e3f1e7;
  --blue: #1d4f91; --blue-tint: #e4edf9;
  --warn: #7a5300; --warn-tint: #fbf0d3;
  --bad: #9c2226; --bad-tint: #fbe6e6;
  --neutral: #3f4b59; --neutral-tint: #edf0f4;
  --radius: 6px;
  --sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --serif: "Playfair Display", Georgia, serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font: 14px/1.45 var(--sans); color: var(--ink); background: var(--surface); }
a { color: var(--navy); }
button, input, select, textarea { font: inherit; color: inherit; }

/* Top bar */
.topbar { height: 52px; display: flex; align-items: center; gap: 28px; padding: 0 24px; background: var(--navy-dark); color: #fff; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; font-weight: 600; font-size: 15px; }
.topnav { display: flex; gap: 22px; }
.topnav a { color: #c9d3df; text-decoration: none; font-weight: 500; padding: 15px 0 13px; border-bottom: 3px solid transparent; }
.topnav a.on { color: #fff; border-bottom-color: var(--orange); }
.acct { position: relative; margin-left: auto; }
.acct-who { width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--orange); color: #fff; font-weight: 600; cursor: pointer; }
.acct-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 230px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; box-shadow: 0 8px 22px rgba(14,26,43,.14); display: grid; gap: 4px; }
.acct-label { margin: 0; color: var(--ink-2); text-transform: capitalize; font-size: 13px; }
.acct-mail { margin: 0 0 6px; font-weight: 500; }
.acct-item { color: var(--navy); text-decoration: none; font-weight: 500; padding: 4px 0; }
.acct-item:hover { text-decoration: underline; }

/* App mark: one periodic-table cell (oe-contract-manager AppTile), on a dark bar */
.apptile { --tile: 40px; position: relative; flex: 0 0 auto; user-select: none; width: calc(var(--tile) * 1.1); height: calc(var(--tile) * 1.3); display: grid; grid-template-rows: auto 1fr auto; justify-items: center; padding: calc(var(--tile) * .08) calc(var(--tile) * .07); border-radius: calc(var(--tile) * .05); border: 1px solid rgba(245,166,35,.55); background: rgba(245,166,35,.09); }
.apptile-no { font-size: calc(var(--tile) * .16); font-weight: 600; line-height: 1; letter-spacing: .06em; color: rgba(245,166,35,.9); justify-self: start; font-variant-numeric: tabular-nums; }
.apptile-code { align-self: center; line-height: 1; font-family: var(--serif); font-weight: 600; font-size: calc(var(--tile) * .48); color: #f6f0e4; }
.apptile-name { font-size: calc(var(--tile) * .13); font-weight: 600; line-height: 1.05; letter-spacing: .045em; text-transform: uppercase; color: rgba(246,240,228,.7); text-align: center; height: calc(var(--tile) * .273); display: flex; align-items: flex-start; }
.on-light .apptile { border-color: rgba(22,53,84,.25); background: #e9edf2; }
.on-light .apptile-no { color: var(--orange-deep); }
.on-light .apptile-code { color: var(--navy); }
.on-light .apptile-name { color: rgba(22,53,84,.7); }

/* Head band */
.band { background: var(--band); padding: 18px 24px 0; }
.crumbs { display: flex; gap: 8px; color: var(--ink-2); margin-bottom: 6px; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.head { display: flex; align-items: flex-start; gap: 18px; }
.head h1 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 26px; color: var(--navy-dark); line-height: 1.2; }
.head .grow { flex: 1; min-width: 0; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 8px; color: var(--ink-2); }
.facts b { color: var(--ink); font-weight: 600; }
.facts a { font-weight: 600; text-decoration: none; }
.facts a:hover { text-decoration: underline; }
.actions { display: flex; gap: 8px; align-items: center; flex: none; }
.stats { display: flex; gap: 36px; margin: 18px 0 2px; }
.stat .n { font-size: 24px; font-weight: 600; color: var(--navy-dark); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .l { color: var(--ink-2); }

/* Tabs: a strip of separate underlines, orange on the active one */
.tabs { display: flex; gap: 24px; margin-top: 18px; }
.tab { border: 0; background: none; padding: 8px 0 9px; cursor: pointer; font-weight: 500; color: var(--ink-2); border-bottom: 3px solid #c5ccd6; display: inline-flex; gap: 8px; align-items: baseline; }
.tab.on { color: var(--navy-dark); font-weight: 600; border-bottom-color: var(--orange); }
.tab .ct { font-weight: 600; color: var(--ink); }

/* Buttons */
.btn { height: 34px; padding: 0 14px; border-radius: var(--radius); border: 0; background: var(--navy); color: #fff; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--navy-dark); }
.btn.accent { background: var(--orange-deep); }
.btn.accent:hover { background: #8e450b; }
.btn.ghost { background: var(--surface); color: var(--navy); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--navy); }
.btn.sm { height: 30px; padding: 0 11px; }
.btn:disabled { background: var(--line-soft); color: var(--ink-2); cursor: not-allowed; border: 0; }
.tip { position: relative; display: inline-flex; }
.tip > button:disabled { pointer-events: none; }
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; left: 0; top: calc(100% + 6px); z-index: 40; background: var(--tipbg, var(--navy-dark)); color: var(--tipfg, #fff); border: 1px solid var(--tipline, transparent); font-weight: 500; padding: 6px 10px; border-radius: 5px; white-space: nowrap; }
.actions [data-tip]:hover::after { left: auto; right: 0; }
select.year { height: 34px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 0 10px; font-weight: 600; }

/* Page body */
.page { padding: 20px 24px 60px; }
.section + .section { margin-top: 30px; }
.section h2 { margin: 0 0 10px; font-size: 16px; font-weight: 600; color: var(--navy-dark); display: flex; gap: 10px; align-items: baseline; }
.section h2 .ct { color: var(--ink-2); font-weight: 500; }
.empty { color: var(--ink-2); padding: 14px 0; }

/* Tables: one size throughout, rule under the header only, faint banding */
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.grid th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 8px 12px; border-bottom: 1.5px solid var(--navy); white-space: nowrap; }
.grid td { padding: 9px 12px; vertical-align: top; }
.grid tbody tr:nth-child(even of :not(.open-row)) td { background: var(--row); }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid .nm { font-weight: 600; color: var(--navy); }
.grid .mu { color: var(--ink-2); }
.grid tr.link { cursor: pointer; }
.grid tr.link:hover td { background: var(--orange-tint); }
.grid a.pg { text-decoration: none; font-weight: 500; white-space: nowrap; }
.grid a.pg:hover { text-decoration: underline; }
.grid .act { text-align: right; white-space: nowrap; }
.grid .act .btn + .btn { margin-left: 6px; }

/* Chips: flat tints, small radius */
.chip { --tipbg: var(--neutral-tint); --tipfg: var(--neutral); display: inline-block; font-weight: 600; border-radius: 3px; padding: 1px 7px; white-space: nowrap; background: var(--neutral-tint); color: var(--neutral); }
.chip.good { background: var(--good-tint); color: var(--good); --tipbg: var(--good-tint); --tipfg: var(--good); }
.chip.blue { background: var(--blue-tint); color: var(--blue); --tipbg: var(--blue-tint); --tipfg: var(--blue); }
.chip.warn { background: var(--warn-tint); color: var(--warn); --tipbg: var(--warn-tint); --tipfg: var(--warn); }
.chip.bad { background: var(--bad-tint); color: var(--bad); --tipbg: var(--bad-tint); --tipfg: var(--bad); }
.chip.accent { background: var(--orange-tint); color: var(--orange-deep); --tipbg: var(--orange-tint); --tipfg: var(--orange-deep); }
.chip[data-tip]:hover::after { --tipline: currentColor; }

/* Upload drop */
.drop { border: 1.5px dashed var(--orange-line); background: #fffaf6; border-radius: 8px; padding: 26px 22px; display: flex; align-items: center; gap: 18px; }
.drop.over { border-color: var(--orange); background: var(--orange-tint); }
.drop .big { font-weight: 600; color: var(--navy-dark); font-size: 15px; }
.drop .mu { color: var(--ink-2); }

/* Return view: form list beside the form */
.reader { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; align-items: start; }
.formnav { position: sticky; top: 12px; display: grid; gap: 2px; }
.formnav button { text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 5px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; color: var(--ink); }
.formnav button:hover { background: var(--row); }
.formnav button.on { background: var(--orange-tint); color: var(--navy-dark); font-weight: 600; box-shadow: inset 3px 0 0 var(--orange); }
.formnav .n { color: var(--ink-2); font-weight: 500; }
.formnav .flag { color: var(--bad); font-weight: 600; }
.formhead { display: flex; align-items: baseline; gap: 14px; margin-bottom: 10px; }
.formhead h2 { margin: 0; font-size: 18px; color: var(--navy-dark); }
.formhead .src { color: var(--ink-2); }
.grid td.flagged, .grid tbody tr:nth-child(even of :not(.open-row)) td.flagged { background: var(--bad-tint); color: var(--bad); font-weight: 600; }
.grid td.ln { width: 56px; color: var(--ink-2); font-weight: 600; }
.grid td.desc { min-width: 260px; }
table.grid.narrow { max-width: 900px; }
.grid th.colh, .grid td.colv { text-align: right; }
.grid td.txt { color: var(--ink); }

/* Open items */
.items tr.open-row > td { background: var(--surface) !important; padding: 0 12px 20px; }
.items tr.on > td { background: var(--orange-tint) !important; }
.items tr.on > td:first-child { box-shadow: inset 3px 0 0 var(--orange); }
.itembody { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; padding-top: 14px; }
.detail { margin: 0 0 12px; font-size: 14px; }
.evidence { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.evidence th { text-align: left; color: var(--ink-2); font-weight: 600; padding: 6px 10px; border-bottom: 1.5px solid var(--navy); }
.evidence td { padding: 7px 10px; }
.evidence tr:nth-child(even) td { background: var(--row); }
.decide { background: var(--inset); border-radius: 8px; padding: 14px 16px; display: grid; gap: 10px; align-content: start; }
.decide .btn.accent { justify-content: flex-start; }
.decide .lbl { font-weight: 600; color: var(--navy-dark); }
.decide .row { display: flex; gap: 8px; flex-wrap: wrap; }
.decide textarea { width: 100%; min-height: 64px; border: 1px solid var(--line); border-radius: 5px; padding: 8px; background: #fff; resize: vertical; }
.decide .res { color: var(--ink); }
.decide .res b { font-weight: 600; }
.thread { grid-column: 1 / -1; display: grid; gap: 12px; padding: 4px 0 0 10px; max-width: 900px; }
.msg .who { font-weight: 600; color: var(--navy-dark); display: flex; gap: 10px; align-items: baseline; }
.msg .who .when { font-weight: 400; color: var(--ink-2); }
.msg .txt { white-space: pre-wrap; }
.msg.engine .who { color: var(--orange-deep); }
.compose { display: grid; gap: 8px; }
.compose .row { display: flex; gap: 8px; }
.compose textarea { width: 100%; min-height: 56px; border: 1px solid var(--line); border-radius: 5px; padding: 8px; resize: vertical; background: #fff; }
.disc { margin-top: 14px; }

/* Messages */
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--navy-dark); color: #fff; padding: 10px 14px; border-radius: 6px; z-index: 60; max-width: 420px; }
.toast.err { background: var(--bad); }

/* Sign-in */
body.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--band); }
.login-panel { width: 380px; background: var(--surface); border-radius: 10px; padding: 34px 32px 30px; box-shadow: 0 10px 30px rgba(14,26,43,.10); text-align: center; }
.login-panel .apptile { margin: 0 auto; }
.login-panel h1 { margin: 18px 0 0; font-family: var(--serif); font-size: 24px; color: var(--navy-dark); }
.login-brand { margin: 6px 0 0; text-transform: uppercase; letter-spacing: .1em; font-weight: 600; color: var(--orange-deep); font-size: 12px; }
.login-lede { margin: 20px auto 0; max-width: 31ch; color: var(--ink-2); }
.login-form { margin-top: 26px; display: grid; gap: 10px; text-align: left; }
.login-form input { height: 38px; border: 1px solid var(--line); border-radius: 6px; padding: 0 10px; }
.login-form .btn { justify-content: center; height: 38px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.login-msg { color: var(--ink-2); margin: 0; min-height: 0; }
.login-msg:empty { display: none; }

/* Users */
.user-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.user-add input, .user-add select, .grid select { height: 32px; border: 1px solid var(--line); border-radius: 5px; padding: 0 8px; background: #fff; }

.nw { white-space: nowrap; }
.formhead .src a { text-decoration: none; font-weight: 600; }
.formhead .src a:hover { text-decoration: underline; }
table.grid.parties { table-layout: fixed; }
.grid.parties td.ln { width: 56px; }
.grid.parties th:nth-child(1) { width: 56px; }
.grid.parties th:nth-child(2) { width: 260px; }
.grid.parties td.txt { text-align: right; }
.grid.parties th { white-space: normal; }
.grid .act .btn.sm { height: 26px; margin-top: -3px; margin-bottom: -3px; }
.filters { display: flex; gap: 6px; margin: 0 0 14px; }
.filter { border: 0; background: none; padding: 5px 10px; border-radius: 5px; cursor: pointer; color: var(--ink-2); font-weight: 500; display: inline-flex; gap: 6px; }
.filter:hover { background: var(--row); }
.filter.on { background: var(--orange-tint); color: var(--navy-dark); font-weight: 600; }
.filter .ct { font-weight: 600; color: var(--ink); }
select.inline { border: 0; background: transparent; font-weight: 600; color: var(--ink); padding: 0 2px; cursor: pointer; }
select.inline:hover { background: rgba(22,53,84,.06); border-radius: 4px; }
body.dropping #app { outline: 3px dashed var(--orange); outline-offset: -8px; }
