:root {
  --bg: #eef0f3; --chrome: #ffffff; --ink: #1d1f23; --muted: #5d6470; --line: #d9dde3; --accent: #1f5eff;
  --accent-ink: #fff; --band: #e9e9e9; --new: #2f7cf6; --sug: #12805c; --sug-bg: #e9f7f1; --warn: #a15c00;
  --cmt: #f6c445; --cmt-bg: #fff6d6; --danger: #b42318; --ok: #12805c; --shadow: 0 1px 3px rgba(20, 24, 31, .12);
  --card: #f6f7f9; --card-line: #c9ced6; --sel: #7c3aed; --sel-bg: #f1ebff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17191d; --chrome: #212328; --ink: #eceef1; --muted: #a2a9b4; --line: #343840; --accent: #6d97ff;
    --cmt-bg: #3a3218; --sug-bg: #15322a; --shadow: 0 1px 3px rgba(0, 0, 0, .5);
    --sug: #34c38f; --new: #5b9bff; --card: #2b2e35; --card-line: #4a505b; --sel: #b197fc; --sel-bg: #30264d;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; display: flex; flex-direction: column; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--chrome); color: var(--ink); border-radius: 8px; padding: 6px 12px; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.ghost { border-color: transparent; background: transparent; }
button.sm { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
input, textarea, select { font: inherit; color: var(--ink); background: var(--chrome); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; min-height: 64px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--chrome); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 800; letter-spacing: .14em; font-size: 13px; }
.titlebox { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.titlebox h1 { font-size: 16px; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { font-size: 12px; padding: 2px 10px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; color: var(--muted); }
.pill.aprovado, .pill.aprovado_ressalvas { color: var(--ok); border-color: var(--ok); }
.pill.alteracoes { color: var(--warn); border-color: var(--warn); }
.right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#people { display: flex; }
.av { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; margin-left: -6px; border: 2px solid var(--chrome); }
#saveState { font-size: 12px; color: var(--muted); min-width: 64px; text-align: right; }

.banner { padding: 8px 16px; font-size: 13px; color: var(--muted); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner b { color: var(--ink); }
.banner .newdot { color: var(--new); font-weight: 700; }
.banner .lock { color: var(--ok); font-weight: 600; }

.wrap { flex: 1; display: flex; min-height: 0; }
.scroll { flex: 1; overflow: auto; padding: 8px 16px 64px; }
.sheet { background: #fff; color: #000; margin: 0 auto; max-width: 1056px; min-width: 640px; padding: 48px 56px; box-shadow: var(--shadow); font: 11pt/1.35 Arial, Helvetica, sans-serif; }
.sheet h2 { font: 700 16pt Arial, sans-serif; margin: 0 0 18px; }
table.grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.grid th { text-align: left; font-size: 9pt; text-transform: uppercase; letter-spacing: .06em; color: #555; padding: 6px 8px; border-bottom: 2px solid #000; }
.grid th.n, .grid td.n { width: 34px; }
.grid th + th, .grid td + td { border-left: 1px solid #d0d0d0; }
.grid tr.band td { background: var(--band); font-weight: 700; padding: 5px 8px; border-top: 1px solid #bbb; }
.grid tr.band .mark { font-weight: 400; color: #444; margin-left: 12px; font-size: 9pt; }
.grid td { vertical-align: top; padding: 0; border-bottom: 1px solid #e3e3e3; }
.grid td.n { color: #777; font-size: 9pt; padding: 8px 4px; }
.cellwrap { position: relative; }
.cell { padding: 8px; min-height: 36px; outline: none; white-space: pre-wrap; word-break: break-word; border-left: 3px solid transparent; }
.cell p, .cell li { margin: 0; }
.cell ul, .cell ol { margin: 0; padding-left: 22px; }
.cell[contenteditable="true"]:hover { background: #f7f9fc; }
.cell[contenteditable="true"]:focus { background: #f2f6ff; box-shadow: inset 0 0 0 1px #9db7ff; }
.cell.new { border-left-color: var(--new); }
.cell.sel { box-shadow: inset 0 0 0 2px #7c3aed; background: #f6f2ff; }
::highlight(cmt) { background-color: #ffe58f; }
::highlight(cmtsel) { background-color: #d6c4ff; }
.cell.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: #fff1b3; } to { background: transparent; } }
.cell.busy { box-shadow: inset 0 0 0 2px var(--who, #f59f00); }
.tag { position: absolute; top: -9px; right: 6px; font: 600 10px/1 -apple-system, sans-serif; color: #fff; background: var(--who, #f59f00); padding: 3px 6px; border-radius: 4px; pointer-events: none; }
.cmtbtn { position: absolute; top: 4px; right: 4px; z-index: 1; font: 11px/1 -apple-system, sans-serif; padding: 3px 6px; border-radius: 6px; border: 1px solid #e0c46c; background: #fff8dc; color: #6b5200; opacity: 0; }
.cellwrap:hover .cmtbtn, .cmtbtn.has { opacity: 1; }
.sugbox { margin: 0 8px 8px; padding: 6px 8px; border-radius: 6px; background: #e9f7f1; border: 1px dashed #12805c; font: 10pt/1.35 Arial, sans-serif; color: #0b4d38; white-space: pre-wrap; }
.sugbox { cursor: pointer; }
.sugbox.sel { background: #f1ebff; border: 2px solid #7c3aed; color: #3b1a7a; }
.sugbox .who { font: 600 10px -apple-system, sans-serif; text-transform: uppercase; letter-spacing: .04em; display: block; margin-bottom: 2px; }
.float { position: fixed; z-index: 20; display: none; }
.scroll { position: relative; }
.bubble { position: absolute; z-index: 12; width: min(340px, calc(100% - 16px)); max-height: 60vh; overflow: auto; background: var(--chrome); color: var(--ink); border: 1px solid var(--card-line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .28); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.bubble .bhead { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.bubble .empty { padding: 8px; }

aside.panel { width: 360px; background: var(--chrome); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
aside.panel[hidden] { display: none; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; border-radius: 0; background: transparent; padding: 10px 4px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .count { font-size: 11px; margin-left: 4px; }
.pane { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.card { border: 1px solid var(--card-line); border-left: 4px solid var(--stripe, var(--card-line)); border-radius: 10px; padding: 10px 12px; background: var(--card); cursor: pointer; }
.card.c { --stripe: var(--cmt); } .card.s { --stripe: var(--sug); } .card.a { --stripe: var(--new); }
.card.sel { --stripe: var(--sel); border-color: var(--sel); background: var(--sel-bg); box-shadow: 0 0 0 1px var(--sel); }
.card textarea { cursor: text; }
.card.resolved { opacity: .6; }
.card .where { font-size: 11px; color: var(--muted); cursor: pointer; }
.card .quote { border-left: 3px solid var(--cmt); background: var(--cmt-bg); padding: 4px 8px; margin: 6px 0; font-size: 12px; border-radius: 0 6px 6px 0; }
.msg { margin-top: 6px; }
.msg .who { font-weight: 600; font-size: 12px; }
.msg .when { font-size: 11px; color: var(--muted); margin-left: 6px; }
.msg .body { white-space: pre-wrap; word-break: break-word; }
.msg.staff .who { color: var(--accent); }
.actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.diff del { color: var(--danger); background: rgba(180, 35, 24, .08); }
.diff ins { color: var(--ok); background: rgba(18, 128, 92, .1); text-decoration: none; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; font-size: 13px; }
.composer { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.composer[hidden] { display: none; }
.composer .ctx { font-size: 11px; color: var(--muted); }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px)); background: var(--chrome); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(10, 12, 16, .45); }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
dialog h3 { margin: 0; font-size: 17px; }
dialog label { font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
dialog .row { display: flex; gap: 8px; justify-content: flex-end; }
dialog .fine { font-size: 12px; color: var(--muted); margin: 0; }
dialog .err { color: var(--danger); font-size: 13px; min-height: 1em; margin: 0; }
.choice { display: flex; gap: 8px; }
.choice label { flex: 1; flex-direction: row; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.choice input { width: auto; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1d1f23; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 30; display: none; max-width: calc(100vw - 32px); }
.full { margin: 15vh auto; max-width: 420px; text-align: center; padding: 0 16px; }
.full h1 { font-size: 20px; }
footer { font-size: 11px; color: var(--muted); padding: 6px 16px; text-align: center; }

@media (max-width: 760px) {
  .bar { padding: 8px 16px; }
  .brand { width: 100%; }
  .right { width: 100%; justify-content: flex-end; }
  .scroll { padding: 8px 0 64px; }
  .sheet { min-width: 600px; padding: 24px 16px; }
  aside.panel { position: fixed; inset: auto 0 0 0; width: 100%; height: 70vh; z-index: 15; border-left: 0; border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(0, 0, 0, .2); }
}
