:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --surface2: #f3f1ee;
  --surface3: #ebe9e5;
  --border: #ddd9d3;
  --accent: #cc785c;
  --accent2: #c96a2e;
  --accent3: #2d7d52;
  --danger: #c0392b;
  --text: #1a1915;
  --muted: #8a857d;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Geist', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; font-size: 14px; -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; }

/* HEADER */
.top-bar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.top-bar .logo { width: 32px; height: 32px; background: var(--accent); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1rem; color: #fff; flex-shrink: 0; }
.top-bar h1 { font-size: 1rem; font-weight: 700; }
.top-bar p { font-size: 0.72rem; color: var(--muted); }
.back-link { margin-left: auto; font-size: 0.73rem; color: var(--accent); text-decoration: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 5px 12px; font-weight: 600; }
.back-link:hover { background: var(--surface2); }
.gear-btn { background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--muted); padding: 4px 6px; border-radius: 6px; }
.gear-btn:hover { background: var(--surface2); color: var(--text); }

/* CONFIG */
.config-panel { background: var(--surface2); border-bottom: 1px solid var(--border); padding: 12px 24px; display: none; }
.config-panel.open { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.cfg-field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 200px; }
.cfg-field label { font-size: 0.65rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.cfg-field input { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-family: 'Geist', sans-serif; font-size: 0.78rem; color: var(--text); outline: none; }
.cfg-field input:focus { border-color: var(--accent); }

/* STATUS */
.status-bar { padding: 8px 24px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; font-size: 0.73rem; color: var(--muted); flex-shrink: 0; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.status-dot.ok { background: var(--accent3); }
.status-dot.err { background: var(--danger); }

/* LAYOUT */
.main-layout { display: grid; grid-template-columns: 220px 1fr; flex: 1; min-height: 0; }

/* SIDEBAR */
.sidebar { background: var(--surface2); border-right: 1px solid var(--border); overflow-y: auto; padding: 10px 0 20px; }
.sb-section-hdr { padding: 10px 16px 4px; font-size: 0.62rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }
.sb-item { padding: 6px 16px; font-size: 0.78rem; color: var(--muted); cursor: pointer; display: flex; align-items: center; gap: 7px; user-select: none; border-right: 2px solid transparent; transition: background 0.1s; }
.sb-item:hover { background: var(--surface3); color: var(--text); }
.sb-item.active { background: var(--surface); color: var(--text); border-right-color: #185FA5; font-weight: 600; }
.sb-item.sub { padding-left: 30px; font-size: 0.73rem; }
.sb-item.sub.active { border-right-color: var(--accent); }
.sb-arrow { font-size: 0.6rem; margin-left: auto; transition: transform 0.15s; }
.sb-arrow.open { transform: rotate(90deg); }
.sb-count { font-size: 0.6rem; background: var(--surface3); border-radius: 20px; padding: 1px 6px; color: var(--muted); margin-left: auto; }
.sb-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.sb-divider { height: 1px; background: var(--border); margin: 8px 12px; }

/* MAIN PANEL */
.main-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.main-top { padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.main-top h2 { font-size: 0.88rem; font-weight: 700; flex: 1; }
.search-inp { flex: 1; max-width: 280px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 11px; font-family: 'Geist', sans-serif; font-size: 0.78rem; color: var(--text); outline: none; }
.search-inp:focus { border-color: var(--accent); }
.btn { padding: 6px 14px; border: none; border-radius: 8px; font-family: 'Geist', sans-serif; font-size: 0.75rem; font-weight: 700; cursor: pointer; transition: opacity 0.15s; }
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.notes-list { flex: 1; overflow-y: auto; padding: 14px 20px; }

/* NOTE CARD */
.note-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; }
.note-card-top { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.note-title { font-size: 0.82rem; font-weight: 600; color: var(--text); flex: 1; }
.note-tag { font-size: 0.62rem; padding: 2px 7px; border-radius: 20px; background: var(--surface2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.note-tag.gmail { background: #fff3ee; color: var(--accent2); border-color: #f0d4c8; }
.note-meta { font-size: 0.68rem; color: var(--muted); margin-bottom: 6px; font-family: 'Geist Mono', monospace; }
.note-text { font-size: 0.75rem; color: var(--text); line-height: 1.6; white-space: pre-wrap; }
.note-sub-tag { display: inline-block; font-size: 0.62rem; padding: 1px 7px; border-radius: 20px; background: var(--surface3); color: var(--muted); margin-bottom: 5px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); font-size: 0.78rem; }
.empty-icon { font-size: 2rem; margin-bottom: 10px; }

/* ADD NOTE MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 1000; display: none; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: 14px; padding: 24px; width: 100%; max-width: 500px; margin: 20px; box-shadow: 0 8px 32px rgba(0,0,0,0.12); }
.modal h3 { font-size: 0.92rem; font-weight: 700; margin-bottom: 18px; }
.field { margin-bottom: 14px; }
.field label { font-size: 0.68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; display: block; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 11px; font-family: 'Geist', sans-serif; font-size: 0.8rem; color: var(--text); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 90px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.datalist-hint { font-size: 0.65rem; color: var(--muted); margin-top: 3px; }

/* TOAST */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 0.78rem; font-weight: 600; z-index: 9999; transform: translateY(60px); opacity: 0; transition: transform 0.22s, opacity 0.22s; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.ok { background: var(--accent3); }
.toast.err { background: var(--danger); }

/* DEPT COLORS */
.dot-mgmt { background: #888780; }
.dot-prod { background: #639922; }
.dot-eng { background: #185FA5; }
.dot-purch { background: #BA7517; }
.dot-stores { background: #7F77DD; }
.dot-hr { background: #D4537E; }
.dot-acct { background: #1D9E75; }
.dot-pq { background: #D85A30; }
.dot-sq { background: #993556; }
.dot-mktg { background: #378ADD; }
.dot-rd { background: #534AB7; }
.dot-cust { background: #185FA5; }
.dot-vend { background: #D85A30; }
.dot-prosp { background: #1D9E75; }
.dot-misc { background: #888780; }


/* Stage 3.11e - shared visibility helper */
.is-hidden { display: none !important; }
