:root {
  --navy: #152c42; --bg: #f3f6f8; --surface: #fff; --text: #16202b; --muted: #5b6875; --border: #dce4e8;
  --primary: #00685c; --primary-text: #fff; --sel: #e3f3ee; --sel-line: #00685c;
  --ok-bg: #dff3ea; --ok: #0b5a41; --warn-bg: #fdf0d4; --warn: #7a4a00; --err-bg: #fde5e3; --err: #a02419;
  --info-bg: #e3edf8; --info: #1d4a80; --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 "Noto Sans Thai", "Leelawadee UI", "Sarabun", Tahoma, system-ui, sans-serif; }
h1 { font-size: 32px; line-height: 1.25; margin: 0; font-weight: 700; }
h2 { font-size: 20px; margin: 0 0 8px; }
h3 { font-size: 16px; margin: 18px 0 6px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.error-text { color: var(--err); min-height: 1.2em; margin: 6px 0; }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 14px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: #b3c0c8; }
button.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
button.primary:hover { background: #00574d; }
button.danger { color: var(--err); }
button.wide { width: 100%; padding: 10px; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; min-width: 0; }
input:disabled, select:disabled, textarea:disabled { background: #f1f4f6; color: #45525e; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
input.warn, select.warn, td.warn input { border-color: #d0921a; background: #fffaf0; }

.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.auth { width: 100%; max-width: 380px; padding: 24px; border-top: 4px solid var(--navy); }
.auth h1 { font-size: 26px; margin-bottom: 4px; }
.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 3px; }
.field > input, .field > select { width: 100%; }
.field small { display: block; color: var(--warn); font-size: 13.5px; }
.field small.hint { color: var(--muted); }
.inline { display: inline-flex; align-items: center; gap: 6px; }
.inline > span { color: var(--muted); font-size: 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.row.end { justify-content: flex-end; margin-top: 16px; }
.row > .grow { flex: 1 1 160px; }

/* ---- shell: navy menu on the left, white bar on top */
.app { display: grid; grid-template-columns: 202px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--navy); color: #dbe5ee; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-brand { font-size: 19px; font-weight: 700; color: #fff; padding: 20px 18px 18px; line-height: 1.3; }
.side-nav { display: flex; flex-direction: column; flex: 1; overflow-y: auto; }
.side button { background: none; border: 0; border-left: 4px solid transparent; border-radius: 0; color: inherit; text-align: left; padding: 11px 14px; display: flex; align-items: center; gap: 8px; }
.side button:hover { background: rgba(255, 255, 255, .07); }
.side button:focus-visible { outline: 2px solid #9ee3d0; outline-offset: -2px; }
.side-nav button.active { border-left-color: #9ee3d0; background: rgba(255, 255, 255, .13); color: #fff; font-weight: 600; }
.side-sep { font-size: 13px; color: #9fb1c1; padding: 18px 18px 6px; }
.side-foot { border-top: 1px solid rgba(255, 255, 255, .14); padding: 8px 0 10px; display: flex; flex-direction: column; }
#user-label { font-size: 14px; color: #9fb1c1; padding: 6px 18px 2px; overflow-wrap: anywhere; }
.pill { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 99px; background: #f4c869; color: #3d2a00; font-size: 13px; font-weight: 600; text-align: center; margin-left: auto; }

.main { min-width: 0; padding-bottom: 32px; }
.topbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; min-height: 64px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
#company { max-width: 280px; }
.period-pick { gap: 4px; }
.period-pick .lbl { color: var(--muted); font-size: 14px; margin-right: 2px; }
.month-pick { display: inline-flex; gap: 4px; }
.date-pick { display: inline-block; }
.field > span.date-pick, .field > span.month-pick, .inline > span.date-pick { font-size: 16px; color: var(--text); margin-bottom: 0; }
.field .date-pick, td .date-pick { display: block; }
.date-btn { width: 100%; text-align: left; font-variant-numeric: tabular-nums; }
.inline > .date-pick .date-btn { font-size: 16px; color: var(--text); }
.date-btn.blank { color: var(--muted); }
.date-btn.warn { border-color: #d0921a; background: #fffaf0; }
table.edit td .date-btn { min-width: 118px; padding: 5px 7px; }
.cal { position: fixed; z-index: 60; width: 292px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 28px rgba(21, 44, 66, .3); padding: 10px; }
.cal-head { display: flex; gap: 4px; align-items: center; margin-bottom: 8px; }
.cal-head select { flex: 1; min-width: 0; padding: 5px 6px; }
.cal-head button { padding: 4px 10px; font-size: 18px; line-height: 1; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-grid b { text-align: center; font-size: 13px; color: var(--muted); font-weight: 600; padding: 2px 0; }
.cal-grid button { border: 0; background: none; padding: 0; height: 36px; min-height: 0; border-radius: 50%; font-variant-numeric: tabular-nums; }
.cal-grid button:hover:not(:disabled) { background: var(--sel); }
.cal-grid button.today { box-shadow: inset 0 0 0 1.5px var(--primary); }
.cal-grid button.sel { background: var(--primary); color: #fff; font-weight: 700; }
.cal-foot { display: flex; gap: 6px; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.cal-foot button { font-size: 14px; padding: 4px 10px; min-height: 0; }
.inline > .month-pick { font-size: 16px; color: var(--text); }
.field .month-pick { display: flex; }
.field .month-pick select { flex: 1; min-width: 0; }
.period-pick button { padding: 6px 11px; font-size: 18px; line-height: 1; }
input[type="month"], input[type="date"] { cursor: pointer; }
.banner { margin: 14px 24px 0; padding: 10px 14px; border-radius: var(--radius); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.info { background: var(--info-bg); color: var(--info); }
.pagehead { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 22px 24px 14px; }
.pagehead p { margin: 2px 0 0; }
.pagehead .primary { padding: 9px 20px; }

.strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 24px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; min-height: 90px; }
.strip > div { padding: 14px 20px; border-left: 1px solid var(--border); display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.strip > div:first-child { border-left: 0; }
.strip span { color: var(--muted); font-size: 14px; }
.strip b { font-size: 26px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.strip b i { font-style: normal; font-size: 16px; font-weight: 400; color: var(--muted); }
.strip small { color: var(--muted); font-size: 13.5px; }

/* ---- table on the left, the selected row's detail on the right */
.work { display: grid; grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); gap: 16px; padding: 0 24px; align-items: start; }
.reg { overflow: hidden; }
.reg-tools { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.reg-tools input { flex: 1 1 180px; }
.reg-tools select { flex: 0 1 180px; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-weight: 600; font-size: 14px; color: var(--muted); padding: 8px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 4px 6px; vertical-align: top; }
.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.reg-table th { padding: 10px 12px; background: #f8fafb; }
.reg-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.reg-table tbody tr { cursor: pointer; box-shadow: inset 4px 0 0 transparent; }
.reg-table tbody tr:hover { background: #f6f9fa; }
.reg-table tbody tr.sel { background: var(--sel); box-shadow: inset 4px 0 0 var(--sel-line); }
.reg-table tbody tr.note { cursor: default; background: none; }
.reg-table tbody tr.note td { padding: 32px 16px; text-align: center; color: var(--muted); }
.reg-table td.nowrap { white-space: nowrap; }
.reg-table .sub, table.grid .sub, .detail .sub { color: var(--muted); font-size: 14px; }
.docno { border: 0; background: none; padding: 0; font-weight: 600; color: var(--text); text-align: left; white-space: normal; overflow-wrap: anywhere; cursor: pointer; }
.docno:hover { text-decoration: underline; }
.reg-note { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; background: var(--info-bg); color: var(--info); border-bottom: 1px solid var(--border); }
.reg-note span { flex: 1 1 240px; }
th[data-sort] button { border: 0; background: none; padding: 0; font-weight: 600; color: inherit; }
th[data-sort] button::after { content: " ↕"; opacity: .45; }
th[aria-sort="ascending"] button, th[aria-sort="descending"] button { color: var(--text); }
th[aria-sort="ascending"] button::after { content: " ▲"; opacity: 1; }
th[aria-sort="descending"] button::after { content: " ▼"; opacity: 1; }
.reg-table tbody tr.grp { cursor: default; background: #eef2f5; }
.reg-table tbody tr.grp:hover { background: #eef2f5; }
.reg-table tbody tr.grp td { padding: 7px 12px; font-size: 14px; color: var(--muted); }
.reg-table tbody tr.grp b { color: var(--text); font-size: 16px; }
.reg-table .sub.outside { color: var(--info); }
.online { padding: 0 0 8px; max-height: 34vh; overflow-y: auto; }
.online ul { list-style: none; margin: 0; padding: 0 18px; }
.online li { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; font-size: 14px; }
.online li i { flex: none; width: 9px; height: 9px; margin-top: 7px; border-radius: 50%; background: #4fd69c; }
.online li.idle i { background: none; border: 2px solid #7f93a5; }
.online li.idle { color: #9fb1c1; }
.online li b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.online li small { display: block; color: #9fb1c1; font-size: 13px; overflow-wrap: anywhere; }
.reg-foot { padding: 12px; border-top: 1px solid var(--border); background: #f8fafb; display: flex; flex-wrap: wrap; gap: 6px 28px; }
.reg-foot b { font-variant-numeric: tabular-nums; }
.reg-foot .sub { flex-basis: 100%; color: var(--muted); font-size: 14px; }

.badge { display: inline-block; font-size: 14px; padding: 2px 10px; border-radius: 99px; white-space: nowrap; background: #e9eef1; color: #3f4c58; }
.badge.ready, .badge.confirmed, .badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.review, .badge.wait { background: var(--warn-bg); color: var(--warn); }
.badge.error { background: var(--err-bg); color: var(--err); }
.badge.queued, .badge.processing, .badge.info { background: var(--info-bg); color: var(--info); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

.detail { padding: 16px; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; min-height: 220px; }
.detail-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-bottom: 12px; }
.detail-head h2 { margin: 0; overflow-wrap: anywhere; }
.detail-head .grow { min-width: 120px; }
.paper { border: 1px solid var(--border); border-radius: var(--radius); background: #e6ebee; padding: 12px; max-height: 48vh; overflow: auto; }
.paper img { display: block; width: 100%; background: #fff; box-shadow: 0 1px 4px rgba(21, 44, 66, .25); cursor: zoom-in; }
.paper-note { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.formtitle { margin: 18px 0 8px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 18px; }
.fieldgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 12px; }
.fieldgrid .field { margin: 6px 0; }
.fieldgrid .field.wide { grid-column: 1 / -1; }
.issues { background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); padding: 9px 12px; margin: 0 0 10px; }
.issues.err { background: var(--err-bg); color: var(--err); }
.lockbox { background: var(--info-bg); color: var(--info); border-radius: var(--radius); padding: 9px 12px; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lockbox span { flex: 1 1 220px; }
table.edit td input { width: 100%; min-width: 84px; padding: 5px 7px; }
table.edit td.desc input { min-width: 200px; }
table.edit td.x { width: 1%; }
table.edit td.x button { padding: 2px 9px; }
details.raw { margin-top: 14px; }
details.raw summary { cursor: pointer; font-weight: 600; }
details.raw pre { white-space: pre-wrap; background: #f5f7f9; border-radius: var(--radius); padding: 10px; font: 14px/1.5 ui-monospace, Consolas, monospace; max-height: 320px; overflow: auto; }
fieldset.group { border: 1px solid var(--border); border-radius: var(--radius); margin: 10px 0 0; padding: 4px 12px 8px; min-width: 0; }
fieldset.group legend { font-weight: 600; padding: 0 6px; }
.top-fields { margin-top: 8px; }
.hide-empty .empty-field { display: none; }
.checkbox { border-radius: var(--radius); padding: 9px 12px; }
.checkbox.ok { background: var(--ok-bg); color: var(--ok); }
.checkbox.warn { background: var(--warn-bg); color: var(--warn); }
.checkbox ul { margin: 4px 0 0; padding-left: 18px; }
.checkbox .sub { margin-top: 4px; font-size: 14px; color: inherit; opacity: .9; }
.checkbox .linkbtn { color: inherit; font-weight: 600; text-decoration: underline; }
.savebar { position: sticky; bottom: -16px; margin: 16px -16px -16px; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.savebar .primary { padding: 9px 22px; }
.savebar span { flex: 1 1 160px; color: var(--muted); font-size: 14px; }

/* documents page with the table tucked away: paper and form side by side */
.work.wide { grid-template-columns: minmax(0, 1fr); }
.work.wide .reg { display: none; }
.work.wide .detail { position: static; max-height: none; }
.work.wide .detail-body { display: grid; grid-template-columns: minmax(260px, 44%) minmax(0, 1fr); gap: 18px; align-items: start; }
.work.wide .paper { position: sticky; top: 12px; max-height: calc(100vh - 60px); }
.work.wide .formtitle { margin-top: 0; padding-top: 0; border-top: 0; }
.work.wide .savebar { bottom: 0; }

/* ---- bank reconciliation panel */
.bankbox { background: #f5f8fa; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.bankbox span { color: var(--muted); font-size: 14px; display: block; }
.bankbox b { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bankbox b i { font-style: normal; font-size: 16px; font-weight: 400; color: var(--muted); }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) minmax(0, 1fr); gap: 6px 12px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv dd.r { text-align: left; }
.diff { border-radius: var(--radius); padding: 10px 12px; font-weight: 600; margin: 10px 0; }
.diff.zero { background: var(--ok-bg); color: var(--ok); }
.diff.off { background: var(--warn-bg); color: var(--warn); }
.more { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.more p { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
#recon-extra { padding: 16px 24px 0; }

/* ---- report page */
.page { padding: 0 24px 28px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 14px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.stat b { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 14px; }
.stat small { display: block; color: var(--muted); font-size: 13.5px; }
.todo { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.todo li { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.todo li:last-child { border-bottom: 0; }
.todo li span { flex: 1; }
.todo li::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #93a1ad; flex: none; }
.todo li.warn::before { background: #d0921a; }
.todo li.ok::before { background: #1f9a6b; }
#home-todo h3 { margin-top: 0; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; }
.panel h3 { margin: 0 0 6px; }
table.grid td, table.grid th { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--primary); text-align: left; white-space: normal; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }

/* ---- chat */
.chat { padding: 0 24px 24px; max-width: 1000px; }
.chat-log { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-height: 240px; max-height: 56vh; overflow-y: auto; }
.msg { margin: 0 0 12px; max-width: 88%; padding: 9px 13px; border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { margin-left: auto; background: var(--sel); }
.msg.assistant { background: #f1f4f6; }
.msg.pending { color: var(--muted); }
.msg.assistant:has(.chat-table) { max-width: 100%; }
.chat-table { white-space: normal; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin: 2px 0 8px; }
.chat-table table.grid td, .chat-table table.grid th { padding: 5px 8px; white-space: nowrap; }
.chat-table tr.sum td { font-weight: 700; border-top: 2px solid var(--border); }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chat-suggest button { font-size: 14px; border-radius: 99px; white-space: normal; text-align: left; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.chat-form textarea { flex: 1 1 260px; resize: vertical; }
.btnlike { display: inline-block; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 13px; color: var(--text); text-decoration: none; background: var(--surface); white-space: nowrap; }
.btnlike:hover { border-color: #b3c0c8; }
.filecard { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; margin: 6px 0; white-space: normal; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--info-bg); color: var(--info); border-radius: 99px; padding: 2px 4px 2px 10px; font-size: 14px; }
.chip button { border: 0; background: none; padding: 0 6px; color: inherit; }

/* ---- task board */
.board { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; padding-bottom: 6px; }
.col { background: #e9eef2; border-radius: 10px; padding: 10px; min-height: 160px; border: 2px solid transparent; }
.col.over { border-color: var(--primary); background: var(--sel); }
.col h3 { margin: 0 4px 8px; display: flex; justify-content: space-between; }
.col h3 span { color: var(--muted); font-weight: 400; }
.col .sub { color: var(--muted); font-size: 14px; margin: 4px; }
.task { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; cursor: grab; }
.task p { margin: 4px 0 0; color: var(--muted); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 14px; color: var(--muted); margin-top: 6px; }
.task-meta .late { color: var(--err); font-weight: 600; }
.task-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; margin-top: 8px; }
.task-foot select, .task-foot button { font-size: 14px; padding: 4px 8px; }
.who { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }

/* ---- team chat: profile pictures, room rows and message bubbles shared by the full page and the floating window */
.ava { position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 17px; line-height: 1; }
.ava.sm { width: 28px; height: 28px; font-size: 13px; }
.ava.lg { width: 52px; height: 52px; font-size: 21px; }
.ava.grp { background: var(--navy); }
.ava svg { width: 60%; height: 60%; }
.ava i { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; border: 2px solid #fff; background: #b4bfc7; }
.ava i.on { background: #31a24c; }
.ava i.idle { background: #fff; box-shadow: inset 0 0 0 2.5px #31a24c; }
.who i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #b4bfc7; background: #b4bfc7; flex: none; }
.who.on i { background: #1f9a6b; border-color: #1f9a6b; }
.room-text { min-width: 0; flex: 1; display: block; text-align: left; }
.room-text b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-text small { display: block; color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; padding: 0 24px 24px; align-items: start; }
.team-rooms { max-height: 72vh; overflow-y: auto; padding: 6px; }
.room { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; border-radius: 10px; padding: 8px; background: none; white-space: normal; }
.room:hover { background: #f1f4f6; }
.room.active { background: var(--sel); }
.room.unread b, .room.unread small { font-weight: 700; color: var(--text); }
.room .pill { margin-left: 0; background: var(--primary); color: #fff; }
.team-main { padding: 0; overflow: hidden; }
.team-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.team-head b { font-size: 17px; }
.team-main #team-attach { margin: 0; padding: 0 14px; }
.team-main .chat-form { padding: 10px 14px 14px; }
.team-log { min-height: 260px; height: 52vh; overflow-y: auto; padding: 10px 14px; }
.tday { text-align: center; color: var(--muted); font-size: 12.5px; margin: 12px 0 6px; }
.tday button { font-size: 13px; padding: 4px 12px; border-radius: 99px; }
.tmsg { display: flex; align-items: flex-end; gap: 6px; margin-top: 2px; }
.tmsg.first, .tmsg.solo { margin-top: 8px; }
.tmsg.mine { flex-direction: row-reverse; }
.tava { flex: none; width: 28px; }
.tcol { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; max-width: 72%; min-width: 0; }
.tmsg.mine .tcol { align-items: flex-end; }
.tname { font-size: 12.5px; color: var(--muted); margin: 0 0 1px 12px; }
.bubble { background: #eef1f4; border-radius: 18px; padding: 7px 12px; max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; text-align: left; }
.bubble.gone { color: var(--muted); font-size: 14px; }
.tmsg.mine .bubble { background: var(--primary); color: #fff; }
/* corners between messages of one group are squared off on the side they hang from */
.tmsg.first:not(.mine) .bubble, .tmsg.mid:not(.mine) .bubble { border-bottom-left-radius: 5px; }
.tmsg.mid:not(.mine) .bubble, .tmsg.last:not(.mine) .bubble { border-top-left-radius: 5px; }
.tmsg.mine.first .bubble, .tmsg.mine.mid .bubble { border-bottom-right-radius: 5px; }
.tmsg.mine.mid .bubble, .tmsg.mine.last .bubble { border-top-right-radius: 5px; }
.timg { display: block; }
.timg img { display: block; max-width: min(320px, 100%); max-height: 280px; border-radius: 16px; border: 1px solid var(--border); background: #fff; }
.tfile, .tdoc { display: block; max-width: 100%; text-align: left; white-space: normal; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 8px 12px; text-decoration: none; }
.tfile:hover, .tdoc:hover { border-color: var(--primary); }
.tfile b, .tdoc b { display: block; overflow-wrap: anywhere; }
.tfile span, .tdoc span { display: block; color: var(--muted); font-size: 13px; }
.tdel { align-self: center; visibility: hidden; border: 0; background: none; padding: 2px 6px; font-size: 12.5px; color: var(--muted); text-decoration: underline; }
.tmsg:hover .tdel, .tdel:focus-visible { visibility: visible; }
.tseen { text-align: right; color: var(--muted); font-size: 12px; margin: 2px 4px 0; }
.link-card { max-width: 960px; }
.link-card table.grid select { max-width: 320px; width: 100%; }
.choice { display: grid; gap: 10px; }
.choice button { text-align: left; white-space: normal; padding: 12px 14px; }
.choice button b { display: block; font-size: 17px; }
.choice button span { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.choice button:hover { border-color: var(--primary); background: var(--sel); }
.paper.nopaper { padding: 18px; background: var(--info-bg); color: var(--info); }
.paper.nopaper b { display: block; margin-bottom: 4px; }

/* ---- the chat that follows the user: bottom right corner of every page */
.dock { position: fixed; right: 18px; bottom: 0; z-index: 30; display: flex; align-items: flex-end; gap: 12px; pointer-events: none; }
.dock > * { pointer-events: auto; }
.dock-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; padding-bottom: 16px; }
.dock-btn { position: relative; width: 56px; height: 56px; border-radius: 50%; background: var(--primary); border: 0; padding: 0; box-shadow: 0 4px 14px rgba(21, 44, 66, .35); }
.dock-btn:hover { background: #00574d; }
.dock-btn svg { display: block; width: 32px; height: 32px; margin: 0 auto; }
.dock-btn svg circle { fill: var(--primary); }
.dock-btn:hover svg circle { fill: #00574d; }
.dock-btn .pill, .head .pill { position: absolute; top: -4px; right: -4px; margin: 0; background: #e41e3f; color: #fff; border: 2px solid #fff; }
.dock-heads { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.head { position: relative; border: 0; background: none; padding: 0; border-radius: 50%; box-shadow: 0 3px 12px rgba(21, 44, 66, .3); }
.head:hover { transform: scale(1.06); }
.icon-btn { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: none; }
.icon-btn:hover { background: #eef1f4; }
.icon-btn svg, .dock-win header button svg { width: 22px; height: 22px; fill: var(--primary); display: block; }
.icon-btn.off svg { fill: #9aa7b2; }
.dock-win { width: 338px; max-width: calc(100vw - 100px); background: var(--surface); border: 1px solid var(--border); border-bottom: 0; border-radius: 12px 12px 0 0; box-shadow: 0 6px 24px rgba(21, 44, 66, .28); display: flex; flex-direction: column; overflow: hidden; }
.dock-win header { display: flex; align-items: center; gap: 2px; padding: 8px 6px 8px 10px; border-bottom: 1px solid var(--border); box-shadow: 0 1px 3px rgba(21, 44, 66, .08); }
.dock-win header button { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: none; }
.dock-win header button:hover { background: #eef1f4; }
.dock-head { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.dock-head .ava { width: 34px; height: 34px; font-size: 15px; }
.dock-head small { font-size: 12.5px; }
.dock-win .team-log { height: 360px; max-height: 52vh; min-height: 0; padding: 8px 10px; }
.dock-win .tcol { max-width: 78%; }
.dock-win .timg img { max-width: 100%; max-height: 220px; }
.dock-win #dock-attach { margin: 0; padding: 0 10px; }
.dock-form { display: flex; gap: 4px; align-items: flex-end; padding: 8px 6px; }
.dock-form textarea { flex: 1; resize: none; height: 36px; max-height: 110px; line-height: 1.35; border: 0; border-radius: 18px; background: #eef1f4; padding: 7px 12px; overflow-y: hidden; }
.dock-list { width: 330px; max-width: calc(100vw - 36px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 6px 24px rgba(21, 44, 66, .28); overflow: hidden; }
.dock-list header { display: flex; align-items: center; padding: 10px 10px 4px 14px; font-size: 22px; }
.dock-list #dock-search { display: block; width: calc(100% - 24px); margin: 4px 12px 6px; border: 0; border-radius: 99px; background: #eef1f4; padding: 7px 14px; }
.dock-list #dock-rooms { max-height: 48vh; overflow-y: auto; padding: 0 6px 6px; }
.dock-list footer { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--border); }
.dock-list footer:empty { display: none; }
.dock-list footer button { font-size: 14px; padding: 5px 10px; white-space: normal; }
.dock-list footer small { color: var(--muted); font-size: 13px; }
.peek { width: 280px; max-width: calc(100vw - 36px); text-align: left; white-space: normal; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 9px 12px; box-shadow: 0 6px 20px rgba(21, 44, 66, .28); }
.peek b { display: block; }
.peek span { display: block; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- dialogs */
dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(540px, calc(100vw - 24px)); color: var(--text); }
dialog::backdrop { background: rgba(21, 44, 66, .5); }
.dlg { padding: 20px 22px; }
dialog:has(.wide-dlg) { width: min(720px, calc(100vw - 24px)); }
.model-table { border: 1px solid var(--border); border-radius: var(--radius); max-height: 300px; overflow: auto; }
.model-table table td, .model-table table th { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.model-table thead th { position: sticky; top: 0; background: var(--surface); }
.model-table td:first-child { overflow-wrap: anywhere; }
.share-item, .user-item { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); }
.share-item input { flex: 1 1 240px; font-size: 14px; }
.user-item span:first-child { flex: 1; }
dialog.viewer { width: min(1200px, calc(100vw - 16px)); height: calc(100vh - 16px); max-height: none; padding: 0; }
dialog.viewer[open] { display: flex; flex-direction: column; }
.viewer-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); }
#viewer-title, #file-title { font-weight: 600; overflow-wrap: anywhere; }
.viewer-body { flex: 1; overflow: auto; background: #e6ebee; text-align: center; }
.viewer-body img { display: block; margin: 0 auto; max-width: none; transform-origin: center center; }
.file-body { text-align: left; padding: 10px; }
.file-body iframe { width: 100%; height: 100%; min-height: 70vh; border: 1px solid var(--border); background: #fff; }
.file-body pre { white-space: pre-wrap; background: #fff; padding: 12px; margin: 0; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: var(--radius); max-width: calc(100vw - 32px); z-index: 50; }
.toast.err { background: var(--err); }
.dropveil { position: fixed; inset: 0; z-index: 40; background: rgba(0, 104, 92, .88); color: #fff; font-size: 28px; font-weight: 700; display: flex; align-items: center; justify-content: center; pointer-events: none; }

/* ---- public share page */
.sharebar { background: var(--navy); color: #dbe5ee; display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline; padding: 14px 20px; }
.sharebar .brand { color: #fff; font-size: 19px; }
#share .card { padding: 20px; }
#share h1 { font-size: 28px; }

/* ---- camera for shooting many bills in a row */
dialog.camera { background: #0f1a24; color: #fff; }
dialog.camera .viewer-bar { border-bottom-color: rgba(255, 255, 255, .15); }
dialog.camera .viewer-bar .muted { color: #b7c4cf; }
dialog.camera .viewer-bar button { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .35); }
dialog.camera .viewer-bar button:hover { background: rgba(255, 255, 255, .26); }
.camera-body { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; background: #000; }
.camera-body video { max-width: 100%; max-height: 100%; }
.camera-body video.flash { opacity: .35; }
.camera-msg { position: absolute; left: 12px; right: 12px; bottom: 12px; margin: 0; text-align: center; color: #fff; text-shadow: 0 1px 3px #000; }
.camera-shots { display: flex; gap: 6px; overflow-x: auto; padding: 6px 10px; min-height: 70px; }
.camera-shots span { position: relative; flex: none; }
.camera-shots img { display: block; height: 58px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .4); }
.camera-shots button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; min-height: 0; padding: 0; border-radius: 50%; border: 0; background: #e41e3f; color: #fff; line-height: 1; }
.camera-bar { display: flex; gap: 16px; align-items: center; justify-content: center; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); }
.shutter { width: 68px; height: 68px; min-height: 0; border-radius: 50%; border: 5px solid #fff; background: #e9eef2; box-shadow: inset 0 0 0 3px #0f1a24; }
.shutter:active { background: #b7c4cf; }
.shutter:disabled { opacity: .4; }

/* ---- task card dialog, groups, daily summary */
dialog.big { width: min(760px, calc(100vw - 24px)); }
.task-notes { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.note { background: #f1f4f6; border-radius: 10px; padding: 8px 12px; }
.note small { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 2px; }
.note div { white-space: pre-wrap; overflow-wrap: anywhere; }
.note.ai { background: var(--sel); border-left: 4px solid var(--primary); }
.note.ask { background: var(--info-bg); }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); vertical-align: middle; }
.members { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 12px; max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.team-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
dialog { max-height: calc(100dvh - 24px); overflow-y: auto; }

@media (max-width: 1180px) {
  .strip b { font-size: 22px; }
  .work { gap: 14px; }
}
@media (max-width: 730px) {
  h1 { font-size: 28px; }
  .app { display: block; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-brand { padding: 12px 14px; font-size: 17px; }
  .side-nav { flex-direction: row; flex: 1 1 100%; order: 3; overflow-x: auto; }
  .side-nav button { border-left: 0; border-bottom: 4px solid transparent; padding: 10px 14px; }
  .side-nav button.active { border-bottom-color: #9ee3d0; }
  .side-sep { display: none; }
  .online { display: none; }
  .dock { right: 10px; left: 10px; justify-content: flex-end; }
  .dock-win { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-width: none; border-radius: 12px 12px 0 0; z-index: 31; }
  .dock-btn { width: 52px; height: 52px; }
  .team { grid-template-columns: minmax(0, 1fr); padding: 0 14px 24px; }
  .team-rooms { max-height: 30vh; }
  .tmsg { max-width: 92%; }
  .board { grid-template-columns: repeat(4, minmax(240px, 1fr)); }
  .side-foot { flex-direction: row; border-top: 0; margin-left: auto; padding: 0 6px 0 0; align-items: center; }
  .side-foot button { padding: 8px 10px; border-left: 0; }
  #user-label { display: none; }
  .pill { margin-left: 0; }
  .topbar { padding: 10px 14px; }
  .topbar .grow { display: none; }
  .banner { margin: 12px 14px 0; }
  .pagehead { padding: 16px 14px 12px; }
  .pagehead > .grow { flex-basis: 100%; }
  .strip { margin: 0 14px 14px; grid-template-columns: minmax(0, 1fr); }
  .strip > div { border-left: 0; border-top: 1px solid var(--border); padding: 10px 14px; }
  .strip > div:first-child { border-top: 0; }
  .work, .work.wide { grid-template-columns: minmax(0, 1fr); padding: 0 14px; }
  .work.wide .reg { display: block; }
  .work.wide .detail-body { display: block; }
  .detail, .work.wide .paper { position: static; max-height: none; }
  .paper { max-height: 60vh; }
  .savebar { position: static; }
  .page, .chat { padding: 0 14px 24px; }
  #recon-extra { padding: 14px 14px 0; }
  .reg-tools { flex-wrap: wrap; }
  .reg-tools select { flex: 1 1 100%; }
  .wide-toggle { display: none; }
}

/* ---- tablets and touch screens */
.mk-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.mk-tabs button { border-radius: 99px; }
.mk-tabs button.active { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
#tab-market .panel, #tab-market .checkbox { margin-bottom: 14px; }
#tab-market .panel table.grid { width: 100%; border-collapse: collapse; }
#tab-market .panel table.grid th { text-align: left; font-weight: 600; white-space: nowrap; }
#tab-market .panel table.grid th.r { text-align: right; }
.mk-table .linkbtn { font-weight: 600; }
.barcell { width: 40%; min-width: 90px; vertical-align: middle; }
.barcell progress { display: block; width: 100%; height: 14px; border: 0; border-radius: 4px; background: #e9eef1; overflow: hidden; appearance: none; -webkit-appearance: none; }
.barcell progress::-webkit-progress-bar { background: #e9eef1; }
.barcell progress::-webkit-progress-value { background: var(--primary); border-radius: 4px; }
.barcell progress::-moz-progress-bar { background: var(--primary); border-radius: 4px; }
.mail-body { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; max-height: 240px; overflow: auto; margin: 8px 0 12px; }
#camp-result .model-table table { width: 100%; border-collapse: collapse; }
#camp-result .model-table th { text-align: left; }
@media (max-width: 1100px) {
  .app { grid-template-columns: 172px minmax(0, 1fr); }
  .work { grid-template-columns: minmax(0, 1fr); }
  .detail { position: static; max-height: none; }
  .savebar { position: sticky; bottom: 0; }
  .team { grid-template-columns: 240px minmax(0, 1fr); }
  .board { grid-template-columns: repeat(4, minmax(220px, 1fr)); }
  .topbar, .pagehead { padding-left: 16px; padding-right: 16px; }
  .strip, .banner { margin-left: 16px; margin-right: 16px; }
  .work, .page, .team, #recon-extra { padding-left: 16px; padding-right: 16px; }
}
@media (pointer: coarse) {
  button, .btnlike, input, select { min-height: 42px; }
  input[type="checkbox"], input[type="radio"] { min-height: 0; width: 20px; height: 20px; }
  .icon-btn, .dock-win header button { width: 42px; height: 42px; }
  .tdel { visibility: visible; }
  .docno { min-height: 0; }
  .reg-table td { padding-top: 12px; padding-bottom: 12px; }
}
@media (max-width: 730px) {
  .team { grid-template-columns: minmax(0, 1fr); padding: 0 14px 24px; }
  .team-rooms { max-height: 34vh; }
  .board { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; }
  .board .col { flex: 0 0 84vw; scroll-snap-align: start; }
  .dock { right: 10px; left: auto; }
  .dock-side { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .dock-win { position: fixed; inset: 0; width: auto; max-width: none; height: 100dvh; border: 0; border-radius: 0; z-index: 31; }
  .dock-win .team-log { flex: 1; height: auto; max-height: none; }
  .dock-form { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .dock-list { position: fixed; left: 8px; right: 8px; bottom: 84px; width: auto; max-width: none; }
  .dock-list #dock-rooms { max-height: 56vh; }
  .peek { position: fixed; left: 8px; right: 76px; bottom: 20px; width: auto; max-width: none; }
  dialog, dialog.big, dialog:has(.wide-dlg) { width: calc(100vw - 12px); }
  .dlg { padding: 16px 14px; }
  .fieldgrid { grid-template-columns: minmax(0, 1fr); }
  .tcol { max-width: 82%; }
  .pagehead button { flex: 1 1 auto; }
  .mk-tabs button { flex: 1 1 auto; }
  .barcell { display: none; }
  #mk-q { flex-basis: 100%; }
}
