:root {
  --ink: #1d2433;
  --muted: #5b6475;
  --line: #d8dde6;
  --head: #eef1f6;
  --accent: #1f5fbf;
  --comment: #fff6d6;
  --contradicts: #ffdcb8;
  --warn: #a33b00;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; display: flex; flex-direction: column; background: #fff; }
header { padding: 8px 16px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; }
h1 { font-size: 18px; margin: 0; }
h1 span { color: var(--muted); font-weight: normal; }
nav { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
nav a { color: var(--accent); text-decoration: none; padding: 4px 8px; border-radius: 6px; }
nav a.active { background: var(--head); color: var(--ink); font-weight: 600; }
#updated { margin-left: auto; color: var(--muted); font-size: 13px; }
a { color: var(--accent); }

#layout { flex: 1; display: flex; min-height: 0; }
#content { flex: 1; overflow: auto; min-width: 0; }
#viewer { flex: 0 0 48%; display: flex; flex-direction: column; border-left: 2px solid var(--line); min-width: 0; }
#viewer[hidden] { display: none; }

.sheet { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.sheet th, .sheet td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 6px; vertical-align: top; }
.sheet thead th { position: sticky; top: 0; background: var(--head); z-index: 2; font-size: 12px; min-width: 70px; text-align: left; }
.sheet th.plan { position: sticky; left: 0; background: #fff; z-index: 1; text-align: left; font-weight: normal; min-width: 240px; max-width: 280px; }
.sheet thead th.plan { z-index: 3; background: var(--head); }
.sheet th.plan small { display: block; color: var(--muted); }
.sheet tr.section th { position: sticky; left: 0; background: var(--ink); color: #fff; text-align: left; font-size: 13px; }
td { cursor: pointer; }
td:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
td.dot { text-align: center; }
td.commented { background: var(--comment); }
td.commented.contradicts { background: var(--contradicts); }
tr.open-plan > :not(.commented) { background: #e1ecfb; }
td.selected { outline: 3px solid var(--ink); outline-offset: -3px; }

.ambiguities-page { padding: 8px 16px 24px; }
.ambiguities-page h2 { margin: 8px 0; }
.ambiguities tbody th { text-align: left; font-weight: normal; min-width: 180px; }
.ambiguities tbody th small { display: block; color: var(--muted); }
.ambiguities td.text { cursor: default; }
.ambiguities td.text:hover { outline: none; }
.ambiguities td.comment-text { min-width: 320px; width: 50%; }
.ambiguities td[data-col] { width: 12%; overflow-wrap: anywhere; }

.plan-page { padding: 8px 16px 24px; max-width: 900px; }
.plan-page h2 { margin: 8px 0; }
.plan-page dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 16px; }
.plan-page dt { color: var(--muted); }
.plan-page dd { margin: 0; }
.plan-page table { border-collapse: collapse; width: 100%; }
.plan-page th, .plan-page td { border-bottom: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
.benefits th { width: 40%; font-weight: normal; color: var(--muted); }
.docs td { cursor: default; }
.docs td:hover { outline: none; }

.toolbar { display: flex; gap: 6px; align-items: center; padding: 6px 8px; background: var(--head); flex-wrap: wrap; }
.toolbar strong { flex: 1 1 100%; font-size: 13px; }
.toolbar input { width: 56px; }
.toolbar #close { margin-left: auto; }
#source-note { padding: 4px 10px; font-size: 13px; border-bottom: 1px solid var(--line); max-height: 30vh; overflow: auto; }
#source-note p { margin: 4px 0; }
#source-note .comment { background: var(--comment); padding: 4px 6px; }
#source-note .comment.contradicts { background: var(--contradicts); }
.pbp { color: var(--muted); }
.warn { color: var(--warn); }
#page-area { flex: 1; overflow: auto; position: relative; padding: 12px; background: #e6e8ec; }
.page { position: relative; margin: 0 auto 12px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); background: #fff; }
.page canvas { display: block; }
.textLayer mark { background: rgba(255, 196, 0, 0.5); color: transparent; border-radius: 2px; box-shadow: 0 0 0 2px rgba(230, 120, 0, 0.8); }
.notice { background: #fff; padding: 16px; }
