:root {
  --paper: #f4f0e6;
  --paper-dim: #ece5d5;
  --ink: #2a2620;
  --ink-soft: #6b6455;
  --forest: #2f4a3d;
  --forest-dark: #223a2f;
  --brass: #a9762c;
  --brass-light: #e6d3ab;
  --red: #a13f3f;
  --line: #d9d0bb;
  --radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; margin: 0; }
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 8px 14px;
  background: var(--forest);
  color: #fff;
  font-size: 14px;
}
button:hover { background: var(--forest-dark); }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.ghost:hover { background: var(--paper-dim); }
button.secondary { background: var(--brass); }
button.secondary:hover { background: #8f611f; }
button.tiny { padding: 4px 9px; font-size: 12.5px; }
button.danger { background: var(--red); }
button.full { width: 100%; margin-top: 8px; }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  width: 100%;
}
label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--ink-soft); }
label.checkbox-label { display: flex; align-items: center; gap: 8px; }
label.checkbox-label input { width: auto; }
.muted { color: var(--ink-soft); }
.small { font-size: 12px; }
.error { color: var(--red); font-size: 13px; min-height: 18px; }

/* ---------------------------------------------------------- login ------ */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at top, var(--paper-dim), var(--paper));
}
.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 36px 34px;
  width: 340px;
  box-shadow: 0 12px 30px rgba(42,38,32,0.08);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand h1 { font-size: 22px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 8px;
  background: var(--forest); color: var(--brass-light);
  display: flex; align-items: center; justify-content: center;
  font-family: Georgia, serif; font-size: 20px; font-weight: bold;
}
.brand-mark.small { width: 26px; height: 26px; font-size: 14px; border-radius: 5px; }

/* ---------------------------------------------------------- shell ------ */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--forest);
  color: #fff;
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand-mini { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: 0.2px; }
.top-right { display: flex; align-items: center; gap: 10px; }
.top-right .who { font-size: 13px; opacity: 0.9; }
.top-right button.ghost { color: #fff; border-color: rgba(255,255,255,0.35); }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 20px; }
.badge.online { background: rgba(255,255,255,0.15); }
.badge.offline { background: var(--red); }
.badge.queued { background: var(--brass); display: none; }
.badge.unread { background: var(--red); margin-left: 6px; display: none; }
#chat-btn { position: relative; }

.chat-feed { max-height: 340px; overflow-y: auto; border: 1px solid rgba(0,0,0,0.12); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; background: #fff; }
.chat-msg, .chat-announcement, .chat-assignment { border-radius: 8px; padding: 8px 10px; position: relative; }
.chat-msg { background: var(--paper-dim); }
.chat-announcement { background: rgba(176,141,87,0.12); border: 1px solid rgba(176,141,87,0.35); }
.chat-assignment { background: rgba(61,139,253,0.08); border: 1px solid rgba(61,139,253,0.25); }
.chat-assignment.done { opacity: 0.6; }
.chat-del { position: absolute; top: 6px; right: 8px; background: none; border: none; width: auto; padding: 0 4px; font-size: 16px; line-height: 1; color: var(--ink-soft); cursor: pointer; }
.chat-del:hover { color: var(--red); }
.chat-meta { font-size: 13px; margin-bottom: 3px; }
.chat-body { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.chat-assignment-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.chat-composer { margin-top: 12px; }
.chat-composer textarea { resize: vertical; }
.chat-composer-row { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.chat-announce-toggle { font-size: 13px; display: flex; align-items: center; gap: 6px; }

.body { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 250px;
  background: var(--paper-dim);
  border-right: 1px solid var(--line);
  padding: 16px 10px;
  overflow-y: auto;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px 8px;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.sidebar-admin { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }

/* Folder tabs — the signature element: nested folders read like a
   physical filing-cabinet tab index, echoing the registry's real-world
   structure (Members -> County -> Location). */
.tree { list-style: none; margin: 0; padding-left: calc(var(--depth, 0) * 14px); }
.tree-item {
  display: block; width: 100%; text-align: left;
  background: transparent; color: var(--ink);
  border: 1px solid transparent;
  border-radius: 4px 10px 10px 4px;
  padding: 7px 10px; margin: 2px 0;
  font-size: 13.5px;
}
.tree-item:hover { background: #fff; border-color: var(--line); }
.tree-item.active {
  background: #fff;
  border-color: var(--brass);
  border-left: 4px solid var(--brass);
  font-weight: 600;
  color: var(--forest-dark);
}
.tree-item.root { margin-bottom: 6px; font-weight: 600; }

.content { flex: 1; padding: 22px 28px; overflow-y: auto; }
.crumbs { font-size: 13px; color: var(--ink-soft); margin-bottom: 10px; }
.crumb { cursor: pointer; }
.crumb:hover { color: var(--forest); text-decoration: underline; }
.sep { margin: 0 6px; }
.content-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.content-head .actions { display: flex; gap: 8px; }

.doc-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.doc-table th, .doc-table td { padding: 10px 12px; text-align: left; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.doc-table th { background: var(--paper-dim); font-weight: 600; color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.doc-table tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.perm-badges .pb { display: inline-block; font-size: 10.5px; padding: 2px 6px; border-radius: 8px; margin-right: 3px; }
.pb.view { background: #e4e9e6; color: var(--forest-dark); }
.pb.edit { background: var(--brass-light); color: #6b4c15; }
.pb.del { background: #f2dede; color: var(--red); }

/* ---------------------------------------------------------- modal ------ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(30,28,22,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
}
.modal {
  background: #fff; border-radius: 10px; padding: 26px 28px;
  width: 100%; max-width: 520px; max-height: 86vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.modal h3 { margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* --------------------------------------------------- Google edit diffs -- */
.diff-view { max-height: 320px; overflow-y: auto; font-family: monospace; font-size: 12.5px; background: rgba(0,0,0,0.03); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; }
.diff-line { padding: 1px 0; }
.diff-line.diff-added { background: rgba(60,160,90,0.15); color: #1d6b39; }
.diff-line.diff-removed { background: rgba(200,60,60,0.12); color: #a12f2f; text-decoration: line-through; }
.diff-line.diff-unchanged { opacity: 0.55; }

/* --------------------------------------------------- local sheet editor - */
.presence-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; min-height: 22px; }
.presence-chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; color: #fff; background: var(--pc, #888); }
.live-offline { margin-left: auto; }
.report-stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.stat-box { flex: 1 1 140px; border: 1px solid rgba(0,0,0,0.12); border-radius: 10px; padding: 12px 14px; text-align: center; }
.stat-num { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.doc-lines { max-height: 380px; overflow: auto; border: 1px solid rgba(0,0,0,0.12); border-radius: 8px; padding: 6px; }
.doc-line { display: flex; align-items: center; gap: 4px; margin: 2px 0; }
.doc-line input { flex: 1; font-family: inherit; font-size: 14px; padding: 7px 9px; border-radius: 6px; border: 1px solid var(--border, #ccc); }
.doc-line input:focus { outline: 2px solid var(--brass, #b08d57); outline-offset: -1px; }
.doc-line button.tiny { flex: 0 0 auto; padding: 4px 8px; }
.sheet-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.sheet-tab.active { background: var(--brass, #b08d57); color: #fff; }
.sheet-grid-wrap { max-height: 360px; overflow: auto; border: 1px solid rgba(0,0,0,0.12); border-radius: 8px; }
table.sheet-grid { border-collapse: collapse; }
table.sheet-grid td { border: 1px solid rgba(0,0,0,0.10); padding: 0; }
table.sheet-grid input { width: 110px; border: none; padding: 6px 8px; font-size: 13px; background: transparent; }
table.sheet-grid input:focus { outline: 2px solid var(--brass, #b08d57); outline-offset: -2px; background: rgba(176,141,87,0.08); }
.sheet-toolbar { display: flex; gap: 8px; margin-top: 10px; }

.kv-row { display: flex; gap: 8px; margin-bottom: 8px; }
.kv-row input { flex: 1; }

@media (max-width: 720px) {
  .body { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--line); }
  .content-head { flex-direction: column; align-items: flex-start; gap: 10px; }
}
