:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f5f5f4;
  --border: #e5e5e3;
  --border-strong: #d4d4d2;
  --text: #1a1a1a;
  --text-2: #5a5a58;
  --text-3: #8a8a87;
  --accent: #1f2937;
  --accent-hover: #111827;
  --danger: #991b1b;
  --warn: #92400e;
  --good: #14532d;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 6px rgba(0,0,0,.05), 0 10px 25px rgba(0,0,0,.08);
  --radius: 6px;
  --radius-lg: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); }
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 7px 10px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31,41,55,.08);
}
textarea { resize: vertical; min-height: 60px; font-family: inherit; }

/* Login layout */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 28px 24px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.login-brand .logo {
  width: 34px; height: 34px; border: 1.5px solid var(--accent);
  border-radius: 7px; display: grid; place-items: center; font-weight: 700;
}
.login-brand .name { font-weight: 600; font-size: 15px; }
.login-brand .name small { color: var(--text-3); font-weight: 400; display: block; font-size: 12px; }
.login-card h1 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.login-card .sub { color: var(--text-2); font-size: 13px; margin-bottom: 22px; }
.login-card .field { margin-bottom: 12px; }
.login-card label { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; display: block; margin-bottom: 5px; }
.login-error { background: #fdf2f2; color: var(--danger); padding: 9px 11px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; display: none; border: 1px solid #fadcdc; }
.login-error.show { display: block; }
.login-divider { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; margin: 18px 0; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.google-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 9px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); font-weight: 500; font-size: 14px; }
.google-btn:hover { background: var(--surface-2); }
.google-btn svg { width: 16px; height: 16px; }
.login-foot { text-align: center; font-size: 11px; color: var(--text-3); margin-top: 18px; }

/* Buttons */
.btn {
  padding: 7px 13px; border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13px; font-weight: 500;
  color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary {
  background: var(--accent); color: white;
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: #f3d4d4; }
.btn.danger:hover { background: #fdf2f2; }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn .icon { font-size: 15px; line-height: 1; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; padding: 9px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* App layout */
.app { display: flex; flex-direction: column; height: 100vh; }
header.top {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.brand .logo {
  width: 26px; height: 26px;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.brand small { color: var(--text-3); font-weight: 400; font-size: 12px; }
nav.views { display: flex; gap: 2px; margin-left: 16px; }
nav.views button {
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-weight: 500;
  font-size: 13px;
}
nav.views button:hover { background: var(--surface-2); color: var(--text); }
nav.views button.active { background: var(--accent); color: white; }
.top-spacer { flex: 1; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.user-menu { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 18px; font-size: 12px; color: var(--text-2); }
.user-menu .uavatar { width: 22px; height: 22px; background: var(--accent); color: white; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 600; }
.user-menu .uname { font-weight: 500; color: var(--text); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu .ulogout { color: var(--text-3); padding: 2px 4px; font-size: 12px; }
.user-menu .ulogout:hover { color: var(--danger); }

main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

/* Subtoolbar */
.subtoolbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search { position: relative; width: 280px; }
.search input { padding-left: 30px; }
.search::before { content: "⌕"; position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 15px; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border-strong); border-radius: 20px; font-size: 12px; color: var(--text-2); background: var(--surface); }
.filter-chip select { border: none; padding: 0; width: auto; min-width: 60px; background: transparent; color: var(--text); font-weight: 500; }
.filter-chip select:focus { box-shadow: none; }
.stats-mini { margin-left: auto; display: flex; gap: 16px; color: var(--text-2); font-size: 12px; }
.stats-mini strong { color: var(--text); font-weight: 600; }

/* Kanban */
.kanban-scroll { flex: 1; overflow-x: auto; overflow-y: hidden; padding: 16px 20px; }
.kanban { display: flex; gap: 14px; height: 100%; min-width: max-content; }
.column { width: 290px; flex-shrink: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: 100%; }
.column-header { padding: 12px 14px 10px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.column-title { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.stage-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.stage-dot.s1 { background: #94a3b8; }
.stage-dot.s2 { background: #64748b; }
.stage-dot.s3 { background: #475569; }
.stage-dot.s4 { background: #334155; }
.stage-dot.s5 { background: #1e293b; }
.stage-dot.s6 { background: #14532d; }
.stage-dot.s7 { background: #166534; }
.stage-dot.s8 { background: #991b1b; }
.column-count { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-2); font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; }
.column-body { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.column-body::-webkit-scrollbar { width: 6px; }
.column-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.column-add { padding: 8px; border-top: 1px solid var(--border); }
.column-add button { width: 100%; padding: 6px; border-radius: var(--radius); color: var(--text-3); font-size: 12px; }
.column-add button:hover { background: var(--surface); color: var(--text); }

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; box-shadow: var(--shadow); transition: box-shadow .15s, border-color .15s; }
.card:hover { border-color: var(--border-strong); box-shadow: 0 2px 4px rgba(0,0,0,.06), 0 4px 8px rgba(0,0,0,.06); }
.card.dragging { opacity: 0.4; }
.column.drop-target { background: #eef2f7; border-color: var(--accent); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.card-title { font-weight: 600; font-size: 13px; line-height: 1.3; }
.card-type { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.card-contact { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.card-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 11px; color: var(--text-3); margin-top: 6px; }
.card-meta span { display: inline-flex; align-items: center; gap: 3px; }
.card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 11px; }
.conviction { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-weight: 500; }
.conviction .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.conviction.hot .dot { background: #b91c1c; }
.conviction.warm .dot { background: #b45309; }
.conviction.cold .dot { background: #64748b; }
.conviction.committed .dot { background: #15803d; }
.next-action { color: var(--text-2); font-size: 11px; display: inline-flex; align-items: center; gap: 4px; }
.next-action.overdue { color: var(--danger); font-weight: 500; }
.next-action.soon { color: var(--warn); }
.score-pill { display: inline-flex; align-items: center; gap: 2px; font-size: 10px; color: var(--text-2); background: var(--surface-2); padding: 1px 6px; border-radius: 10px; border: 1px solid var(--border); }

/* Empty */
.empty { color: var(--text-3); font-size: 12px; text-align: center; padding: 20px 10px; border: 1px dashed var(--border-strong); border-radius: var(--radius); margin: 4px; }

/* Table view */
.table-wrap { flex: 1; overflow: auto; }
table.investors { width: 100%; border-collapse: collapse; background: var(--surface); }
table.investors th, table.investors td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
table.investors th { background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.5px; position: sticky; top: 0; z-index: 1; }
table.investors tbody tr { cursor: pointer; }
table.investors tbody tr:hover { background: var(--surface-2); }
.empty-table { text-align: center; padding: 80px 20px; color: var(--text-3); }
.empty-table h3 { font-weight: 600; color: var(--text-2); margin-bottom: 8px; font-size: 16px; }
.empty-table p { margin-bottom: 16px; font-size: 13px; }

/* Dashboard */
.dashboard { flex: 1; overflow: auto; padding: 24px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; max-width: 1400px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; }
.kpi-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; margin-bottom: 6px; }
.kpi-value { font-size: 26px; font-weight: 600; line-height: 1.1; }
.kpi-sub { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.dash-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 1400px; margin-top: 16px; }
.dash-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; }
.dash-card h3 { font-size: 13px; font-weight: 600; margin-bottom: 14px; color: var(--text); display: flex; justify-content: space-between; align-items: center; }
.dash-card h3 small { color: var(--text-3); font-weight: 400; font-size: 12px; }
.funnel-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; }
.funnel-row .lbl { width: 110px; color: var(--text-2); flex-shrink: 0; }
.funnel-row .bar-wrap { flex: 1; background: var(--surface-2); height: 18px; border-radius: 3px; overflow: hidden; }
.funnel-row .bar { height: 100%; background: var(--accent); transition: width .3s; }
.funnel-row .val { width: 40px; text-align: right; font-weight: 600; color: var(--text); font-size: 12px; }
.action-row { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-size: 13px; }
.action-row:last-child { border-bottom: none; }
.action-row:hover { background: var(--surface-2); margin: 0 -20px; padding-left: 20px; padding-right: 20px; }
.action-row .name { font-weight: 500; }
.action-row .due { font-size: 12px; }
.due.overdue { color: var(--danger); font-weight: 500; }
.due.today { color: var(--warn); font-weight: 500; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,15,15,.32); display: none; align-items: center; justify-content: center; z-index: 100; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 720px; max-width: calc(100vw - 40px); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 16px; font-weight: 600; }
.modal-head .close { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--text-3); font-size: 20px; }
.modal-head .close:hover { background: var(--surface-2); color: var(--text); }
.modal-tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 12px; }
.modal-tabs button { padding: 11px 14px; color: var(--text-3); font-size: 13px; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.modal-tabs button:hover { color: var(--text); }
.modal-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.modal-body { flex: 1; overflow-y: auto; padding: 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal-foot .right { display: flex; gap: 8px; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.field .hint { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.star-input { display: flex; gap: 3px; font-size: 18px; }
.star-input button { padding: 0; }
.star-input .star { color: var(--border-strong); }
.star-input .star.filled { color: var(--accent); }
.chips-input { display: flex; flex-wrap: wrap; gap: 5px; padding: 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); min-height: 36px; align-items: center; }
.chips-input .chip { background: var(--surface-2); padding: 3px 8px; border-radius: 10px; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); }
.chips-input .chip button { color: var(--text-3); font-size: 13px; padding: 0 2px; }
.chips-input .chip button:hover { color: var(--danger); }
.chips-input input { border: none; padding: 4px; width: auto; min-width: 80px; flex: 1; }
.chips-input input:focus { box-shadow: none; }

/* Activity */
.activity-add { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 16px; padding: 12px; background: var(--surface-2); border-radius: var(--radius); }
.activity-add select { width: 110px; flex-shrink: 0; }
.activity-add input[type=text] { flex: 1; }
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 26px; height: 26px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 50%; display: grid; place-items: center; font-size: 13px; color: var(--text-2); flex-shrink: 0; }
.activity-body { flex: 1; }
.activity-meta { font-size: 11px; color: var(--text-3); display: flex; gap: 8px; }
.activity-text { font-size: 13px; margin-top: 2px; }
.activity-item .del { color: var(--text-3); font-size: 14px; opacity: 0; padding: 0 4px; }
.activity-item:hover .del { opacity: 1; }
.activity-item .del:hover { color: var(--danger); }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--accent); color: white; padding: 10px 18px; border-radius: 6px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 200; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* Detail header */
.detail-header { display: flex; gap: 12px; align-items: center; padding: 14px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.avatar { width: 40px; height: 40px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; display: grid; place-items: center; font-size: 14px; font-weight: 600; color: var(--text-2); }
.detail-title { font-weight: 600; font-size: 15px; }
.detail-sub { font-size: 12px; color: var(--text-2); }
.stage-pill { margin-left: auto; padding: 4px 10px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }

.confirm-text { padding: 8px 0 4px; color: var(--text-2); font-size: 14px; }

/* Users page */
.users-shell { padding: 24px; max-width: 980px; margin: 0 auto; }
.users-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px; }
.users-card h2 { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.users-add { display: grid; grid-template-columns: 1fr 1fr 1fr 130px 100px; gap: 8px; align-items: end; }
.role-badge { padding: 2px 8px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; }
.role-badge.admin { color: var(--accent); border-color: var(--accent); }
.disabled-row { opacity: 0.55; }
