/* IRG Invoicing - laptop-first, forced light, sidebar layout */
:root {
  color-scheme: light only;
  --ink: #1A1A1A;
  --paper: #FAF9F7;
  --card: #FFFFFF;
  --accent: #FF4E00;
  --accent-soft: #FFF0E9;
  --rule: #BFBFBF;
  --muted: #6B6B6B;
  --ok: #1E7F3C;
  --ok-soft: #E8F4EC;
  --warn: #B45309;
  --warn-soft: #FDF3E3;
  --bad: #B3261E;
  --bad-soft: #FBEAE9;
  --display: "Cormorant Garamond", Georgia, serif;
  --body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { background: var(--paper); color: var(--ink); }
body { margin: 0; font-family: var(--body); font-size: 15px; line-height: 1.45; }

.hidden { display: none !important; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }
.boot-inner { text-align: center; }
.boot-feather { display: block; height: 68px; margin: 0 auto 12px; animation: featherpulse 1.5s ease-in-out infinite alternate; }
@keyframes featherpulse { from { opacity: .3; } to { opacity: 1; } }

/* Sign-in */
.signin { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.signin-card { background: var(--card); border: 1px solid var(--rule); padding: 48px 56px; text-align: center; max-width: 420px; }
.signin-logo { display: block; width: 215px; max-width: 75%; margin: 0 auto 4px; }
.signin-card h1 { font-family: var(--display); font-weight: 500; font-size: 2.2rem; margin: 8px 0 0; }
.signin-card p { color: var(--muted); }
.mark { font-size: .72rem; letter-spacing: .22em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.rule { width: 48px; height: 2px; background: var(--rule); margin: 16px auto; }
.error { color: var(--bad); font-size: .85rem; }

/* Shell: sidebar + content */
.app { display: grid; grid-template-columns: 164px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--ink); color: #CFCFCF; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; align-items: center; gap: 8px; padding: 16px 14px 14px; }
.side-logo { display: block; height: 34px; }
.brand-mark { font-weight: 700; color: var(--accent); letter-spacing: .06em; }
.brand-name { font-family: var(--display); font-size: 1.05rem; color: #fff; }
.side-nav { flex: 1; overflow-y: auto; padding-bottom: 12px; }
.nav-group { padding: 10px 0; }
.nav-group + .nav-group { border-top: 1px solid #3A3A3A; }
.side-nav button { display: block; width: 100%; text-align: left; background: none; border: none; border-left: 3px solid transparent; color: #CFCFCF; font: 600 .85rem var(--body); padding: 8px 13px; cursor: pointer; }
.side-nav button:hover { color: #fff; background: rgba(255,255,255,.05); }
.side-nav button.active { color: #fff; border-left-color: var(--accent); background: rgba(255,255,255,.07); }
.side-foot { border-top: 1px solid #3A3A3A; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-user { font-size: .82rem; color: #CFCFCF; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { display: flex; flex-direction: column; min-height: 100vh; }
.banner { padding: 10px 32px; font-size: .9rem; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--rule); display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }

.main { flex: 1; width: 100%; max-width: 1560px; padding: 28px 22px 60px; }
.footer { display: flex; justify-content: space-between; padding: 12px 32px; color: var(--muted); font-size: .78rem; border-top: 1px solid var(--rule); }

h2.screen-title { font-family: var(--display); font-weight: 500; font-size: 1.9rem; margin: 0 0 4px; }
.screen-sub { color: var(--muted); margin: 0 0 24px; max-width: 70ch; }

.card { background: var(--card); border: 1px solid var(--rule); margin-bottom: 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--rule); }
.card-head h3 { margin: 0; font-size: 1rem; font-weight: 700; letter-spacing: .01em; }
.card-head .hint { color: var(--muted); font-size: .8rem; font-weight: 400; }
.card-body { padding: 0; overflow-x: auto; }
.card-body.pad { padding: 16px 18px; }

table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th { text-align: left; font-weight: 700; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
td { padding: 9px 14px; border-bottom: 1px solid #E7E5E1; vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; white-space: nowrap; }
td.wrap { white-space: normal; min-width: 200px; max-width: 360px; }

/* Audit detail */
.audit-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.audit-person { font-family: var(--display); font-size: 1.55rem; font-weight: 600; line-height: 1.15; }
.audit-meta { color: var(--muted); font-size: .86rem; margin-top: 3px; }
.audit-status { display: flex; gap: 6px; flex-wrap: wrap; }
.stats { display: flex; gap: 34px; flex-wrap: wrap; margin-top: 16px; }
.stat-label { display: block; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 1px; }
.stat-val { font-size: 1.02rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.find-row { display: block; width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid #E7E5E1; padding: 8px 18px; font: .86rem var(--body); color: var(--ink); line-height: 1.45; }
.find-row:last-child { border-bottom: none; }
button.find-row { cursor: pointer; }
button.find-row:hover { background: var(--accent-soft); }
.find-where { display: inline-block; min-width: 58px; color: var(--muted); font-size: .78rem; margin: 0 8px 0 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 9px; }
.day-dot.ok { background: var(--ok); }
.day-dot.warn { background: var(--warn); }
.day-dot.bad { background: var(--bad); }
.day-iso { color: var(--muted); font-weight: 400; font-size: .76rem; margin-left: 9px; font-family: ui-monospace, Menlo, Consolas, monospace; }
td.cell-bad { background: var(--bad-soft); }
td.cell-warn { background: var(--warn-soft); }
td.dim { color: #B8B5B0; }
tr.flash > td { animation: flashbg 1.8s ease-out; }
@keyframes flashbg { 0%, 35% { background: var(--accent-soft); } 100% { background: transparent; } }
.audit-below { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.audit-below .card { margin-bottom: 0; }
.rail-pad { padding: 12px 16px; }
.rail-actions { display: flex; gap: 8px; margin: 6px 0 8px; }
.audit-below .ref-strip { display: flex; flex-direction: column; gap: 0; }
.ref-strip > div { display: grid; grid-template-columns: 86px 1fr; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid #E7E5E1; }
.ref-strip > div:last-child { border-bottom: none; }
.ref-strip .ref-label { margin-bottom: 0; }
.ref-strip .mono { font-size: .76rem; line-height: 1.55; overflow-wrap: anywhere; }
.audit-below .find-row { padding: 7px 14px; font-size: .82rem; }
.audit-below .find-where { min-width: 0; }
.pd-ok { display: inline-flex; align-items: center; gap: 5px; margin-left: 10px; font-size: .78rem; color: var(--muted); white-space: nowrap; cursor: pointer; font-weight: 600; }
.pd-ok input { accent-color: var(--accent); cursor: pointer; }
.audit-below .find-row .btn { margin-left: 10px; }
.find-flex { display: flex; align-items: baseline; gap: 8px; }
.find-flex .find-main { flex: 1 1 auto; min-width: 0; }
.find-flex .pd-ok { flex: 0 0 auto; }
.find-link { cursor: pointer; }
.find-link:hover { background: var(--accent-soft); }
.lines-scroll { overflow-x: auto; }
.lines-scroll table { font-size: .78rem; }
.lines-scroll td { padding: 3px 6px; line-height: 1.3; white-space: nowrap; }
.lines-scroll td + td { border-left: 1px solid #F0EDE7; }
.lines-scroll tr.day-alt td { background-image: linear-gradient(rgba(31,30,28,.03), rgba(31,30,28,.03)); }
.lines-scroll tbody tr:hover td { background-image: linear-gradient(rgba(31,30,28,.06), rgba(31,30,28,.06)); }
.lines-scroll tbody tr.day-row td, .lines-scroll tbody tr.finding-inline td { background-image: none; }
.lines-scroll tr.day-row td { position: sticky; top: 25px; z-index: 2; }
.lines-scroll td[data-cell] { cursor: cell; }
.lines-scroll.grid-edit { user-select: none; }
.lines-scroll tbody tr td.cell-range { background-image: linear-gradient(color-mix(in srgb, var(--accent) 12%, transparent), color-mix(in srgb, var(--accent) 12%, transparent)); }
.lines-scroll td.cell-sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.lines-scroll td.cell-editing { padding: 0; }
.lines-scroll td.cell-editing input { width: 100%; min-width: 70px; border: 2px solid var(--accent); padding: 2px 5px; font: inherit; background: #fff; outline: none; box-sizing: border-box; user-select: text; }
.lines-scroll td.wrap { white-space: normal; min-width: 130px; }
.lines-scroll td.f-projectName { min-width: 190px; }
.lines-scroll td.f-task { min-width: 150px; }
.lines-scroll td.f-region, .lines-scroll td.f-cls { min-width: 100px; max-width: 150px; }
.lines-scroll td.f-structures { min-width: 170px; max-width: 280px; overflow-wrap: anywhere; }
.lines-scroll th { padding: 6px 7px; font-size: .68rem; }
.lines-scroll .day-row td { padding: 3px 10px; white-space: normal; }
.lines-scroll thead th { position: sticky; top: 0; background: var(--card); z-index: 3; box-shadow: 0 1px 0 var(--rule); }
td.cell-edited { box-shadow: inset 0 -2px 0 var(--accent); }
.duplist { margin: 6px 0 10px; padding-left: 20px; color: var(--bad); font-size: .86rem; }
.duplist li { margin: 2px 0; }
.chg { font-size: .8rem; padding: 3px 0; border-bottom: 1px solid #E7E5E1; }
.chg:last-child { border-bottom: none; }
.rcpt { font-size: .84rem; padding: 2px 0; }
.rcpt-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: .78rem; margin-left: 8px; padding: 0 2px; }
.rcpt-del.btn-danger { background: none; color: var(--bad); font-weight: 700; }
details.notes summary { cursor: pointer; color: var(--muted); font-size: .82rem; padding: 8px 14px; border-top: 1px solid #E7E5E1; }
@media (max-width: 1100px) {
  .audit-below { grid-template-columns: 1fr; }
}

/* Audit day grouping and inline findings */
tr.day-row td { background: #F1EFEB; font-weight: 700; border-top: 2px solid var(--rule); border-left: 3px solid var(--accent); padding-top: 8px; padding-bottom: 8px; }
.day-sub { color: var(--muted); font-weight: 400; font-size: .8rem; margin-left: 10px; font-variant-numeric: tabular-nums; }
tr.finding-inline td { font-size: .84rem; padding-top: 5px; padding-bottom: 7px; }
tr.finding-inline.check td { background: var(--warn-soft); color: var(--warn); }
tr.finding-inline.stop td { background: var(--bad-soft); color: var(--bad); }
tr.finding-inline.info td { background: #F5F4F1; color: var(--muted); }
.match-ok { color: var(--ok); white-space: nowrap; }
.match-bad { color: var(--bad); font-weight: 700; white-space: nowrap; }

.ref-strip { display: flex; flex-wrap: wrap; gap: 10px 36px; font-size: .86rem; }
.ref-strip .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }
.ref-label { display: block; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 2px; }
tr.editing { background: var(--accent-soft); }
td input, td select, td textarea { width: 100%; min-width: 70px; font: .85rem var(--body); padding: 4px 6px; border: 1px solid var(--rule); background: #fff; color: var(--ink); }
td textarea { min-height: 50px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .03em; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.neutral { background: #EFEDE9; color: var(--muted); }

.meter { background: #EFEDE9; height: 8px; min-width: 120px; position: relative; display: inline-block; vertical-align: middle; margin-right: 8px; }
.meter > span { position: absolute; inset: 0 auto 0 0; background: var(--ok); }
.meter.warn > span { background: var(--warn); }
.meter.bad > span { background: var(--bad); }
.meter-label { font-size: .78rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.meter-label.bad { color: var(--bad); font-weight: 700; }

.btn { font: 600 .85rem var(--body); padding: 8px 16px; border: 1px solid var(--ink); background: var(--card); color: var(--ink); cursor: pointer; }
.btn:hover { background: #F1EFEB; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #333; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #E04500; }
.btn-ghost { background: none; border: 1px solid #555; color: #CFCFCF; }
.btn-ghost:hover { color: #fff; border-color: #fff; background: none; }
.btn-small { padding: 4px 10px; font-size: .78rem; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: #991F18; }
.btn[disabled] { opacity: .5; cursor: default; }

.cell-select { font: .85rem var(--body); padding: 3px 6px; border: 1px solid var(--rule); background: #fff; color: var(--ink); }
.sel-match { max-width: 300px; }
td input[type="checkbox"], th input[type="checkbox"] { width: auto; min-width: 0; }
.card-body.scrolly { max-height: 42vh; overflow-y: auto; }
table.compact th { padding: 6px 10px; }
table.compact td { padding: 5px 10px; }
.trunc { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-bar { display: flex; gap: 12px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--rule); font-size: .85rem; }
.copy-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0 4px; }
th.dimhead { color: #C4C1BC; }
.hidden { display: none; }
.card-head .tools { display: flex; gap: 8px; align-items: center; }
.search-box { font: .85rem var(--body); padding: 5px 9px; border: 1px solid var(--rule); background: #fff; color: var(--ink); width: 200px; max-width: 100%; }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #D4D1CC; border-radius: 999px; transition: background .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { left: 18px; }

.placeholder { border: 1px dashed var(--rule); background: var(--card); padding: 42px; text-align: center; color: var(--muted); }
.placeholder .phase { font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.placeholder h3 { font-family: var(--display); font-weight: 500; font-size: 1.5rem; margin: 10px 0 8px; color: var(--ink); }
.placeholder p { max-width: 56ch; margin: 0 auto; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 22px; font-size: .88rem; z-index: 50; box-shadow: 0 4px 18px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }

/* Intake */
.drop { border: 2px dashed var(--rule); padding: 34px; text-align: center; color: var(--muted); }
.drop.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.filelink { color: var(--accent); cursor: pointer; text-decoration: underline; }
.muted { color: var(--muted); }
tr.muted td { color: var(--muted); }
#sub-fields input, #sub-fields select, #sub-fields textarea { font: .88rem var(--body); padding: 4px 7px; border: 1px solid var(--rule); background: #fff; color: var(--ink); min-width: 220px; }
#sub-fields textarea { width: 100%; min-height: 60px; }
#sub-fields > div { min-width: 240px; }
.parse-file { border: 1px solid var(--rule); margin-top: 16px; padding: 14px 16px; background: #FCFBFA; }
.parse-file-name { font-weight: 700; font-size: .9rem; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.parse-tools { display: inline-flex; gap: 6px; flex-shrink: 0; }
.preview { border-top: 1px solid #E7E5E1; padding: 12px 0 14px; }
.preview-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.flaglist { margin: 6px 0 10px; padding-left: 20px; color: var(--warn); font-size: .86rem; }
.flaglist li { margin: 2px 0; }
.okline { color: var(--ok); font-size: .86rem; margin: 4px 0 10px; }

@media (max-width: 840px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side-nav { display: flex; overflow-x: auto; padding: 0 8px 10px; }
  .nav-group { margin-top: 0; display: flex; }
  .nav-group-label { display: none; }
  .side-nav button { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .side-nav button.active { border-bottom-color: var(--accent); }
  .main { padding: 18px 16px 50px; }
  .signin-card { padding: 32px 22px; }
}

/* Files screen */
.ftiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 12px; }
.ftile { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px; background: var(--card); text-decoration: none; color: var(--ink); }
.ftile:hover { border-color: var(--accent); background: var(--accent-soft); }
.ftile .fi { width: 24px; height: 24px; flex: none; }
.ftile-text { min-width: 0; display: flex; flex-direction: column; }
.ftile-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ftile-sub { font-size: .76rem; color: var(--muted); }
.fi { width: 16px; height: 16px; }
.files-table .fi { vertical-align: -3px; margin-right: 7px; }
.files-table tbody tr:hover td { background: #F4F2EE; }
.files-sum { margin: 0 0 8px; }
#files-crumbs a { color: var(--muted); text-decoration: none; font-weight: 400; }
#files-crumbs a:hover { color: var(--accent); text-decoration: underline; }

/* Audit grid crosshair: hovered cell lights its row and column, selection keeps an accent wash */
.lines-scroll td.hl:not(.cell-range):not(.cell-sel), .lines-scroll th.hl { background-image: linear-gradient(rgba(31,30,28,.07), rgba(31,30,28,.07)); }
.lines-scroll td.sl:not(.cell-range):not(.cell-sel), .lines-scroll th.sl { background-image: linear-gradient(rgba(255,78,0,.08), rgba(255,78,0,.08)); }
.lines-scroll tbody tr:not(.day-row):not(.finding-inline) td:hover { background-image: linear-gradient(rgba(31,30,28,.14), rgba(31,30,28,.14)); }

/* Verify flags clear in place */
.cell-ack { display: inline-block; width: 16px; height: 16px; padding: 0; margin-left: 5px; border: 1px solid var(--warn); border-radius: 50%; background: #fff; color: var(--warn); font-size: 10px; line-height: 14px; text-align: center; cursor: pointer; opacity: .6; vertical-align: 1px; }
.cell-ack:hover { opacity: 1; border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
tr.finding-inline .cell-ack-row { padding: 0 8px; font-size: .72rem; margin-left: 8px; }
