:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1d2330; --muted: #6b7280; --line: #dde1e7;
  --accent: #1f6feb; --accent-text: #fff; --ok: #137333; --warn: #b26a00; --err: #b3261e;
  --new: #137333; --changed: #1f6feb; --deleted: #b3261e; --sel: #e8f0fe;
  font-family: "Segoe UI", system-ui, Arial, sans-serif; font-size: 13px; color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
a { color: var(--accent); }
button { font: inherit; padding: 4px 10px; border: 1px solid var(--line); background: var(--panel); border-radius: 4px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary, #btnSnapshot:not(:disabled) { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
input, select { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.spacer { flex: 1; }
form.inline { display: inline; margin: 0; }

/* simple pages */
body.simple { display: flex; justify-content: center; align-items: flex-start; padding: 40px 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 20px 24px; width: 100%; max-width: 380px; }
.card.wide { max-width: 980px; }
.card h1 { font-size: 18px; margin: 0 0 14px; }
.login label { display: block; margin: 10px 0; }
.login input { display: block; width: 100%; margin-top: 4px; }
.login button { margin-top: 8px; width: 100%; padding: 8px; background: var(--accent); color: #fff; border-color: var(--accent); }
.err { background: #fdecea; color: var(--err); padding: 8px; border-radius: 4px; margin-bottom: 8px; }
.ok { background: #e6f4ea; color: var(--ok); padding: 8px; border-radius: 4px; margin-bottom: 8px; }
table.grid { border-collapse: collapse; width: 100%; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: left; vertical-align: middle; }
table.grid th { font-weight: 600; background: #fafbfc; position: sticky; top: 0; }
table.grid.small { font-size: 12px; }

/* app */
body.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.top { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-size: 15px; }
.badge { padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #eee; color: var(--muted); }
.badge.on { background: #e6f4ea; color: var(--ok); }
.layout { flex: 1; display: flex; min-height: 0; }
.side { width: 330px; min-width: 240px; display: flex; flex-direction: column; gap: 6px; padding: 8px; border-right: 1px solid var(--line); background: var(--panel); }
.side label { font-size: 12px; }
.list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; border-top: 1px solid var(--line); }
.list .grp { position: sticky; top: 0; background: #f0f2f5; font-weight: 600; padding: 4px 6px; font-size: 12px; z-index: 1; }
.list .it { padding: 4px 6px 4px 14px; cursor: pointer; display: flex; gap: 6px; align-items: baseline; border-bottom: 1px solid #f1f3f5; }
.list .it:hover { background: #f5f8ff; }
.list .it.sel { background: var(--sel); }
.list .it .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .it .sub { color: var(--muted); font-size: 11px; }
.list .it.del .nm { text-decoration: line-through; color: var(--deleted); }
.tag { font-size: 10px; padding: 0 5px; border-radius: 8px; border: 1px solid currentColor; white-space: nowrap; }
.tag.new { color: var(--new); } .tag.changed, .tag.restored { color: var(--changed); } .tag.deleted { color: var(--deleted); }
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.itemhead { padding: 8px 12px 4px; }
.itemhead .title { font-size: 15px; font-weight: 600; }
.toolbar { display: flex; gap: 6px; align-items: center; padding: 4px 12px 8px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.includes { display: flex; gap: 4px; flex-wrap: wrap; }
.includes button { font-size: 11px; padding: 1px 6px; border-radius: 10px; }
.workarea { flex: 1; display: flex; min-height: 0; }
.editorwrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.viewlabel { padding: 3px 12px; font-size: 12px; color: var(--muted); background: #fafbfc; border-bottom: 1px solid var(--line); min-height: 22px; }
.editor { flex: 1; min-height: 0; }
.versions { width: 400px; overflow: auto; border-left: 1px solid var(--line); background: var(--panel); }
.versions td.c { text-align: center; }
.versions tr.cur td { background: #fbfcfe; }
.logpanel { position: fixed; right: 16px; bottom: 16px; width: min(640px, calc(100vw - 32px)); max-height: 50vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); z-index: 10; }
.loghead { display: flex; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.logpanel pre { margin: 0; padding: 8px 10px; overflow: auto; font-size: 12px; white-space: pre-wrap; }
.logpanel .e { color: var(--err); } .logpanel .w { color: var(--warn); } .logpanel .s { color: var(--ok); }

@media (max-width: 900px) {
  .side { width: 240px; }
  .versions { width: 300px; }
}
