:root {
  --navy: #1F2A44; --navy-2: #2C3A5C; --ink: #222; --muted: #6B7280; --line: #D8DEE8; --bg: #F3F5F8; --panel: #fff; --soft: #E9EDF3;
  --red: #B3261E; --amber: #B45309; --green: #1E7B45; --blue: #1D4ED8; --purple: #6D28D9;
  --radius: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.45; }
a { color: var(--navy); }
h1 { font-size: 1.55rem; margin: 0; color: var(--navy); }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; color: var(--navy); }
h3 { font-size: .98rem; margin: 1rem 0 .5rem; color: var(--navy); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .pre { white-space: pre-wrap; } .right { text-align: right; margin-bottom: .6rem; }
.hidden { display: none !important; } .mono { font-family: Consolas, monospace; font-size: .85rem; }
.loading { padding: 2rem; color: var(--muted); }
.empty { padding: 1.4rem; text-align: center; color: var(--muted); background: var(--bg); border-radius: var(--radius); }
.empty.err { color: var(--red); }
.ok-text { color: var(--green); font-weight: 600; } .err-text { color: var(--red); margin-top: .6rem; }

/* ---------- shell ---------- */
header.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem; height: 60px; padding: 0 1rem; background: #fff; border-bottom: 3px solid var(--navy); }
.brand img { height: 38px; display: block; }
.gsearch { flex: 1; max-width: 560px; position: relative; }
.gsearch input { width: 100%; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 20px; background: var(--bg); font: inherit; }
.who { position: relative; margin-left: auto; }
.icon-btn { background: none; border: 0; cursor: pointer; font-size: 1.1rem; padding: .3rem .45rem; border-radius: 6px; color: var(--navy); }
.icon-btn:hover { background: var(--soft); }
.menu { display: none; }
nav#nav { position: fixed; top: 63px; left: 0; bottom: 0; width: 220px; background: var(--navy); padding: .8rem .5rem; overflow-y: auto; z-index: 20; }
nav#nav a { display: flex; align-items: center; gap: .65rem; color: #C9D1E3; text-decoration: none; padding: .55rem .75rem; border-radius: 6px; margin-bottom: 2px; font-size: .93rem; }
nav#nav a:hover { background: var(--navy-2); color: #fff; }
nav#nav a.active { background: #fff; color: var(--navy); font-weight: 600; }
main#main { margin-left: 220px; padding: 1.3rem 1.6rem 4rem; max-width: 1500px; }
.dropdown { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.12); z-index: 50; max-height: 70vh; overflow: auto; }
.dropdown.right { left: auto; right: 0; min-width: 220px; }
.dropdown a { display: block; padding: .55rem .8rem; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--soft); }
.dropdown a:hover { background: var(--bg); }
.dd-head { padding: .6rem .8rem; border-bottom: 1px solid var(--line); font-size: .85rem; } .dd-empty { padding: .8rem; color: var(--muted); }
.tag { display: inline-block; font-size: .72rem; padding: .08rem .45rem; border-radius: 10px; background: var(--soft); color: var(--navy); font-weight: 600; vertical-align: middle; }
.tag.p1 { background: #FDE2E1; color: var(--red); } .tag.p2 { background: #FEF0D9; color: var(--amber); } .tag.p3 { background: #E3ECFD; color: var(--blue); } .tag.p4 { background: #E6F4EA; color: var(--green); }

/* ---------- common ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: .2rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.panel, .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.narrow { max-width: 640px; }
.btn { display: inline-flex; align-items: center; gap: .35rem; font: inherit; font-size: .9rem; padding: .5rem .9rem; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--navy); cursor: pointer; text-decoration: none; white-space: nowrap; font-weight: 500; }
.btn:hover { background: var(--bg); border-color: #b9c3d3; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); } .btn.primary:hover { background: var(--navy-2); }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; } .btn.ghost:hover { background: var(--soft); }
.btn.small { padding: .25rem .55rem; font-size: .8rem; } .btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: default; }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .12rem .5rem; border-radius: 10px; background: var(--soft); color: #475467; white-space: nowrap; }
.badge.green { background: #E6F4EA; color: var(--green); } .badge.amber { background: #FEF0D9; color: var(--amber); } .badge.red { background: #FDE2E1; color: var(--red); }
.badge.blue { background: #E3ECFD; color: var(--blue); } .badge.purple { background: #EEE7FD; color: var(--purple); } .badge.grey { background: var(--soft); color: #475467; }
.badge.risk-trivial { background: #D9EAD3; color: #245a2c; } .badge.risk-tolerable { background: #E2F0C9; color: #3d5e12; } .badge.risk-moderate { background: #FFE699; color: #6b5200; }
.badge.risk-substantial { background: #F8B26A; color: #6d3500; } .badge.risk-intolerable { background: #E06666; color: #fff; }
.alert { padding: .7rem .9rem; border-radius: var(--radius); background: #E3ECFD; color: #1e3a8a; margin-bottom: 1rem; }
.alert.warn { background: #FEF3C7; color: #7c4a03; }

/* forms */
.fld { display: block; margin-bottom: .75rem; }
.fld > span { display: block; font-size: .82rem; font-weight: 600; color: #344054; margin-bottom: .25rem; }
.fld input, .fld select, .fld textarea, .filters input, .filters select, textarea, input[type=search], select { width: 100%; font: inherit; font-size: .95rem; padding: .5rem .6rem; border: 1px solid #c5cedb; border-radius: 6px; background: #fff; color: var(--ink); }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid #8ea4d2; outline-offset: 0; border-color: #8ea4d2; }
input[readonly], textarea[readonly] { background: var(--bg); }
.fld.inline { display: inline-block; margin-right: .6rem; min-width: 120px; }
.fld.row { display: grid; grid-template-columns: minmax(200px, 45%) 1fr; gap: .8rem; align-items: center; }
.fld.row > span { font-weight: 400; font-size: .92rem; margin: 0; }
.check { display: flex; align-items: center; gap: .45rem; margin: .4rem 0; font-size: .92rem; cursor: pointer; }
.check input { width: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
.with-btn { display: flex; gap: .5rem; align-items: flex-end; } .with-btn .fld { flex: 1; margin: 0; }
.filters { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters .fld { margin: 0; min-width: 170px; flex: 0 1 220px; }
.filters .check { margin-bottom: .55rem; }
.upl { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; padding: .7rem; background: var(--bg); border-radius: var(--radius); }
.upl select { width: auto; }
dl { display: grid; grid-template-columns: 130px 1fr; gap: .35rem .8rem; margin: 0; } dt { color: var(--muted); font-size: .88rem; } dd { margin: 0; }
details summary { cursor: pointer; color: var(--navy); font-weight: 600; margin: .6rem 0; }
pre.code { background: #0f172a; color: #e2e8f0; padding: .8rem; border-radius: 6px; overflow-x: auto; font-size: .82rem; }

/* tables */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: .5rem .6rem; border-bottom: 2px solid var(--line); background: #FAFBFC; }
table.grid td { padding: .55rem .6rem; border-bottom: 1px solid var(--soft); vertical-align: top; }
table.grid tr.clickable { cursor: pointer; } table.grid tr.clickable:hover td { background: #F7F9FC; }
table.grid .num { text-align: right; } .nowrap { white-space: nowrap; }
table.grid.small td, table.grid.small th { font-size: .78rem; padding: .3rem .4rem; }
tr.muted-row td { opacity: .6; }
table.compare td:first-child { min-width: 260px; }

/* dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: var(--radius); padding: .8rem 1rem; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.7rem; color: var(--navy); line-height: 1.1; } .stat span { font-size: .84rem; color: var(--muted); }
.stat.amber { border-left-color: #F59E0B; } .stat.red { border-left-color: var(--red); } .stat.purple { border-left-color: var(--purple); }
.stat:hover { border-color: #b9c3d3; }

/* tabs */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin: -.2rem -.2rem 1rem; overflow-x: auto; }
.tab { font: inherit; font-size: .9rem; background: none; border: 0; border-bottom: 3px solid transparent; padding: .55rem .9rem; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab.active { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }

/* timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .55rem 0 .55rem 1rem; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: .9rem; width: 10px; height: 10px; border-radius: 50%; background: var(--navy); }
.t-when { font-size: .78rem; color: var(--muted); }

/* modal */
.modal-wrap { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 1rem; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 620px; box-shadow: 0 25px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 940px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 1rem 1.1rem; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: .8rem 1.1rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: .5rem; }
.problems { margin: .3rem 0 .6rem; padding-left: 1.2rem; } .problems li { margin: .15rem 0; }

/* toasts */
#toasts { position: fixed; bottom: 1rem; right: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: var(--navy); color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.2); opacity: 0; transform: translateY(10px); transition: .25s; max-width: 420px; white-space: pre-line; }
.toast.show { opacity: 1; transform: none; } .toast.err { background: var(--red); }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--navy), #3a4a70); padding: 1rem; }
.login { background: #fff; padding: 2rem; border-radius: 12px; width: 100%; max-width: 400px; box-shadow: 0 30px 60px rgba(0,0,0,.3); }
.login img { height: 54px; display: block; margin: 0 auto 1rem; } .login h2 { text-align: center; margin-bottom: 1.2rem; }

/* ---------- assessment editor ---------- */
.as-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; position: sticky; top: 63px; background: var(--bg); z-index: 10; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.as-head h1 { font-size: 1.35rem; } .as-head .sub { color: var(--muted); font-size: .9rem; }
.save-state { font-size: .82rem; padding: .25rem .6rem; border-radius: 10px; }
.save-state.ok { color: var(--green); } .save-state.busy { color: var(--blue); } .save-state.err { color: #fff; background: var(--red); }
.as-body { display: grid; grid-template-columns: 270px 1fr; gap: 1.2rem; align-items: start; }
.as-nav { position: sticky; top: 150px; max-height: calc(100vh - 170px); overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem; font-size: .86rem; }
.as-nav a { display: flex; align-items: center; gap: .45rem; padding: .35rem .5rem; border-radius: 5px; text-decoration: none; color: var(--ink); }
.as-nav a:hover { background: var(--bg); } .as-nav a.active { background: var(--navy); color: #fff; }
.as-nav a.top { font-weight: 600; color: var(--navy); } .as-nav a.top.active { color: #fff; }
.as-nav .n { width: 1.6rem; text-align: right; color: var(--muted); font-size: .78rem; flex-shrink: 0; } .as-nav a.active .n { color: #c9d1e3; }
.as-nav .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-nav .cnt { background: #FEF0D9; color: var(--amber); border-radius: 9px; font-size: .72rem; padding: 0 .4rem; font-weight: 700; }
.as-nav .cnt.warn { background: #FDE2E1; color: var(--red); } .as-nav .done { color: var(--green); font-weight: 700; } .as-nav a.active .done { color: #9ae6b4; }
.nav-part { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .7rem .5rem .2rem; font-weight: 700; }
.as-mobile-nav { display: none; }
.sec-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; gap: .6rem; flex-wrap: wrap; }
.sec-head h2 { margin: 0; font-size: 1.25rem; } .sec-tools { display: flex; gap: .5rem; align-items: center; }
.q-legend { margin-bottom: .6rem; }
.q { border-bottom: 1px solid var(--soft); padding: .55rem .2rem; }
.q:last-of-type { border-bottom: 0; }
.q.sub .q-label { padding-left: 1.3rem; }
.q-main { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.q-label { flex: 1; font-size: .93rem; } .q-label b { color: var(--navy); margin-right: .25rem; }
.q-head { padding: .6rem .2rem .2rem; color: var(--navy); font-size: .92rem; }
.q.exception { background: #FFFBEB; border-left: 3px solid #F59E0B; padding-left: .6rem; border-radius: 4px; }
.q-findings { margin-top: .3rem; } .add-qf { margin-top: .3rem; }
.seg { display: inline-flex; border: 1px solid #c5cedb; border-radius: 7px; overflow: hidden; flex-shrink: 0; }
.seg button { font: inherit; font-size: .84rem; border: 0; background: #fff; padding: .42rem .75rem; cursor: pointer; border-right: 1px solid #e3e8ef; color: #475467; min-width: 52px; position: relative; }
.seg button:last-child { border-right: 0; }
.seg button.normal::after { content: ''; position: absolute; bottom: 3px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: #9aa6bb; }
.seg button.on { background: var(--navy); color: #fff; } .seg button.on.normal::after { background: #9ae6b4; }
.q.exception .seg button.on { background: #C2410C; }
.seg button:disabled { cursor: default; } .seg.small button { padding: .22rem .55rem; font-size: .78rem; min-width: 0; }
.seg.big button { padding: .6rem 1.1rem; font-size: .95rem; }
.q-date { margin-top: .4rem; }
.finding { border: 1px solid #F5C28B; background: #fff; border-radius: 8px; padding: .7rem .8rem .3rem; margin: .5rem 0; box-shadow: var(--shadow); }
.finding.type-advisory { border-color: #a9c1f5; } .finding.type-note { border-color: var(--line); }
.f-top { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; flex-wrap: wrap; }
.f-tools { margin-left: auto; display: flex; gap: .2rem; } .f-tools label.icon-btn { display: inline-flex; }
.f-meta { display: flex; flex-wrap: wrap; gap: 0 .2rem; } .f-meta .fld select, .f-meta .fld input { font-size: .88rem; padding: .35rem .45rem; }
.f-photos { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.f-photos figure { margin: 0; width: 110px; } .f-photos img { width: 110px; height: 80px; object-fit: cover; border-radius: 5px; display: block; } .f-photos figcaption { font-size: .72rem; color: var(--muted); }
textarea.flash { animation: flash .9s; } @keyframes flash { 0% { background: #E6F4EA; } 100% { background: #fff; } }
.add-row { display: flex; gap: .5rem; margin-top: .4rem; }
.sec-foot { display: flex; justify-content: space-between; align-items: center; margin: 1rem 0 2rem; }
.cover-ph { min-height: 160px; background: var(--bg); border-radius: 6px; display: flex; align-items: center; justify-content: center; margin-bottom: .6rem; overflow: hidden; }
.cover-ph img { max-width: 100%; max-height: 320px; }
.matrix-mini { border-collapse: collapse; margin: .6rem 0; font-size: .85rem; }
.matrix-mini th, .matrix-mini td { border: 1px solid var(--line); padding: .35rem .7rem; text-align: center; }
.matrix-mini .hit { outline: 3px solid var(--navy); outline-offset: -3px; font-weight: 700; }
.rk-trivial { background: #D9EAD3; } .rk-tolerable { background: #E2F0C9; } .rk-moderate { background: #FFE699; } .rk-substantial { background: #F8B26A; } .rk-intolerable { background: #E06666; color: #fff; }
table.ap tr.grp td { background: var(--soft); font-weight: 700; color: var(--navy); } .clickable-f { cursor: pointer; } .clickable-f:hover td { background: #F7F9FC; }
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; }
.ph-card { border: 1px solid var(--line); border-radius: 8px; padding: .5rem; display: flex; flex-direction: column; gap: .4rem; }
.ph-card img { width: 100%; height: 150px; object-fit: cover; border-radius: 5px; background: var(--bg); }
.ph-card input, .ph-card select { font-size: .82rem; padding: .3rem .4rem; }

/* predictive text */
.pt-wrap { position: relative; background: #fff; border-radius: 6px; }
.pt-mirror { position: absolute; top: 0; left: 0; pointer-events: none; white-space: pre-wrap; word-wrap: break-word; overflow: hidden; border-style: solid; border-color: transparent; color: transparent; box-sizing: border-box; }
.pt-mirror .pt-ghost { color: #9aa3af; }
textarea.pt-input { position: relative; background: transparent; z-index: 1; display: block; }
.pt-drop { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid #b9c3d3; border-radius: 8px; box-shadow: 0 16px 40px rgba(16,24,40,.18); z-index: 60; max-height: 340px; overflow-y: auto; }
.pt-head { display: flex; justify-content: space-between; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .45rem .7rem; border-bottom: 1px solid var(--soft); background: #FAFBFC; position: sticky; top: 0; }
.pt-item { padding: .5rem .7rem; cursor: pointer; border-bottom: 1px solid var(--soft); }
.pt-item:hover, .pt-item.sel { background: #EEF2FA; }
.pt-item.sel { box-shadow: inset 3px 0 0 var(--navy); }
.pt-text { font-size: .9rem; } .pt-text mark { background: #FFF1B8; color: inherit; padding: 0 1px; border-radius: 2px; }
.pt-meta { display: flex; gap: .4rem; align-items: center; margin-top: .2rem; flex-wrap: wrap; font-size: .74rem; }
.pt-meta .uses { color: var(--amber); font-weight: 600; } .pt-meta .rec { color: var(--green); }
.pt-hint { position: absolute; right: 0; bottom: calc(100% + 2px); font-size: .7rem; color: var(--muted); background: #fff; padding: 0 .3rem; border-radius: 4px; z-index: 2; }
kbd { font-family: inherit; font-size: .68rem; border: 1px solid #c5cedb; border-bottom-width: 2px; border-radius: 3px; padding: 0 .25rem; background: #fff; }
.lib-results { margin-top: .7rem; max-height: 55vh; overflow-y: auto; }
.lib-item { display: block; width: 100%; text-align: left; font: inherit; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: .6rem .7rem; margin-bottom: .4rem; cursor: pointer; }
.lib-item:hover { border-color: var(--navy); background: #F7F9FC; }
.try textarea { margin-top: .3rem; }

/* historic */
.split { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1rem; align-items: start; }
.docview { width: 100%; height: 78vh; border: 0; border-radius: 6px; background: var(--bg); }
.believe { background: #EEF2FA; border-left: 4px solid var(--navy); padding: .6rem .8rem; border-radius: 6px; margin-bottom: .8rem; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .as-body { grid-template-columns: 1fr; } .as-nav { display: none; }
  .as-mobile-nav { display: block; position: fixed; bottom: 0; left: 0; right: 0; padding: .5rem 1rem; background: #fff; border-top: 1px solid var(--line); z-index: 25; }
  .split { grid-template-columns: 1fr; } .docview { height: 50vh; }
}
@media (max-width: 860px) {
  .menu { display: inline-block; }
  nav#nav { transform: translateX(-100%); transition: transform .2s; width: 250px; }
  body.nav-open nav#nav { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  main#main { margin-left: 0; padding: 1rem 1rem 5rem; }
  .brand img { height: 30px; } .gsearch { max-width: none; }
  .who .btn { font-size: 0; padding: .4rem; } .who .btn .muted { font-size: 1rem; }
  .grid2, .grid3 { grid-template-columns: 1fr; } .fld.row { grid-template-columns: 1fr; gap: .2rem; }
  .q-main { flex-direction: column; align-items: stretch; gap: .4rem; } .seg { align-self: flex-start; }
  .seg button { padding: .55rem .9rem; }
  .as-head { position: static; }
  table.grid thead { display: none; }
  table.grid tr { display: block; border-bottom: 1px solid var(--line); padding: .4rem 0; }
  table.grid td { display: flex; gap: .6rem; border: 0; padding: .2rem .3rem; }
  table.grid td::before { content: attr(data-label); flex: 0 0 38%; font-size: .75rem; color: var(--muted); text-transform: uppercase; }
  table.grid td:empty { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) { header.top { gap: .5rem; padding: 0 .6rem; } .brand { display: none; } }

/* AI rewrite */
.rw-bar { display: flex; justify-content: flex-end; margin: .15rem 0 -.2rem; }
.rw-btn { color: var(--purple); }
.rw-orig { background: var(--bg); border-radius: 6px; padding: .6rem .8rem; margin-bottom: .8rem; }
.rw-opts { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; }
.rw-opts input { flex: 1; min-width: 220px; }
.rw-out { min-height: 90px; }
.narrow-wide { max-width: 900px; }
.rw-result .pre { background: var(--bg); padding: .7rem .8rem; border-radius: 6px; margin-bottom: .4rem; }
.fld > span.has-rw { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.rw-bar { display: inline-flex; margin: 0; } .rw-bar .btn { padding: .1rem .45rem; }
.pt-head kbd { text-transform: none; }
.rw-opts input { font: inherit; font-size: .92rem; padding: .45rem .6rem; border: 1px solid #c5cedb; border-radius: 6px; }

/* bulk selection / always-include */
th.chk, td.chk { width: 34px; text-align: center; } td.chk input, th.chk input { width: 16px; height: 16px; cursor: pointer; }
.bulk-bar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding: .5rem .7rem; border-radius: 8px; background: var(--soft); margin-bottom: .8rem; opacity: .6; }
.bulk-bar.active { opacity: 1; background: #E3ECFD; }
.bulk-bar select { width: auto; min-width: 180px; }
.assign-bar .check { margin: 0 .3rem; }
.always-bar { background: #FAFBFC; } .always-bar > div { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; } .always-bar select { width: auto; }
.always-tick input { width: 18px; height: 18px; accent-color: var(--navy); cursor: pointer; }

/* ---------- quotes / invoices / diary ---------- */
tr.clickrow { cursor: pointer; } tr.clickrow:hover td { background: #F7F9FC; }
tr.qdetail > td { background: #F7F9FC; padding: 0; }
.qpanel { padding: 1rem 1.1rem; border-left: 4px solid var(--navy); }
.qpanel h3 { margin-top: 0; } .qactions { margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .8rem; }
ul.plain { list-style: none; padding: 0; margin: 0 0 .6rem; } ul.plain li { padding: .15rem 0; }
.with-btn textarea { flex: 1; }
.paybox { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; margin-top: .6rem; }
table.lines input { width: 100%; font: inherit; padding: .35rem .45rem; border: 1px solid #c5cedb; border-radius: 5px; }
table.lines input.short, input.short { width: 90px; }
.totals { display: flex; gap: 1.5rem; justify-content: flex-end; margin: .4rem 0; } .totals .grand { font-size: 1.1rem; color: var(--navy); }
.quick { max-width: 640px; margin: 0 auto; } .quick textarea { font-size: 1.05rem; }
.quick-btns { display: flex; gap: .6rem; margin: .8rem 0; } .btn.big { padding: .85rem 1.2rem; font-size: 1.05rem; flex: 1; justify-content: center; }
.btn.rec { background: var(--red); color: #fff; border-color: var(--red); animation: pulse 1.2s infinite; } @keyframes pulse { 50% { opacity: .7; } }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; font-size: .85rem; } .legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-h { background: #FAFBFC; font-size: .75rem; text-transform: uppercase; color: var(--muted); padding: .35rem .5rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-weight: 600; }
.cal-d { min-height: 104px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .25rem .3rem; font-size: .8rem; }
.cal-d.other { background: #FAFBFC; color: #aab; } .cal-d.today { background: #EEF2FA; } .cal-n { font-weight: 700; color: var(--navy); margin-bottom: .2rem; }
a.bk { display: block; text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: 4px; padding: .15rem .3rem; margin-bottom: .2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.bk:hover { background: #F3F5F8; }
.agenda-day h3 { margin: .8rem 0 .3rem; } .agenda-item { margin-bottom: .4rem; } .agenda-item a.bk { white-space: normal; }
.perm-table select { padding: .25rem .4rem; font-size: .85rem; }
.terms-table textarea, .terms-table input, .terms-table select { font-size: .85rem; padding: .3rem .4rem; }
.settings-form { max-width: 980px; } .big-check { font-size: 1rem; margin: .6rem 0; } .steps li { margin-bottom: .4rem; }
@media print { header.top, nav#nav, .filters, .actions, #toasts { display: none !important; } main#main { margin: 0; padding: 0; } .panel { box-shadow: none; } }
@media (max-width: 860px) { .cal-d { min-height: 70px; } .quick-btns { flex-direction: column; } }

/* Copy wording from a previous report */
.copy-search { display: flex; gap: .75rem; align-items: center; margin-bottom: .6rem; }
.copy-search input { flex: 1; }
.copy-list { max-height: 300px; overflow: auto; border: 1px solid var(--line, #dde3ec); border-radius: var(--radius); margin-bottom: .9rem; }
.copy-row { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .75rem; border-bottom: 1px solid var(--line, #eef1f5); cursor: pointer; }
.copy-row:last-child { border-bottom: 0; }
.copy-row.sel { background: var(--soft); }
.copy-row input { margin-top: .25rem; }
.copy-list > p { padding: .75rem; margin: 0; }
.copy-parts h4 { margin: 0 0 .4rem; }
.copy-parts .chk, .copy-mode .chk { display: block; margin: .25rem 0; }
.copy-mode { margin: .5rem 0 0 1.4rem; }
.alert-btns { margin-top: .5rem; }
.warn-list li { margin: .3rem 0; }
.copy-search input:not([type=checkbox]) { padding: .5rem .65rem; border: 1px solid var(--line, #cfd6e0); border-radius: var(--radius); font: inherit; }
