:root {
  --black: #0A0A0A; --ink: #111111; --grey: #5B5F66; --grey-2: #8A8F98;
  --line: #E6E7E9; --tint: #F6F7F8; --white: #FFFFFF;
  --blue: #1A56FF; --blue-dk: #0F43D9; --blue-soft: #EAF0FF;
  --green: #12805C; --green-soft: #E6F4EE; --red: #C4321C; --red-soft: #FBEAE7; --amber: #9A6200; --amber-soft: #FCF1DC;
  --font: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --r: 6px;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--white); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 400; color: var(--black); letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; letter-spacing: -0.02em; }
h3 { font-size: 1rem; font-weight: 500; }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--grey); }

.btn { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 14px; padding: 8px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--white); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--black); }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--blue-dk); border-color: var(--blue-dk); }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); }
.btn:disabled { opacity: .45; cursor: default; }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: center; gap: 32px; height: 56px; padding: 0 24px; max-width: 1440px; margin: 0 auto; }
.wordmark { font-size: 1.1rem; font-weight: 500; letter-spacing: -0.02em; color: var(--black); }
.wordmark span { color: var(--grey-2); font-weight: 400; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: var(--r); cursor: pointer; color: var(--grey); font-weight: 500; }
.tabs button:hover { color: var(--black); }
.tabs button.on { color: var(--black); background: var(--tint); }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--grey); }

main { max-width: 1440px; margin: 0 auto; padding: 28px 24px 64px; }
.head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* stat strip */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 20px; overflow: hidden; }
.stat { padding: 14px 16px; border-right: 1px solid var(--line); cursor: default; background: var(--white); text-align: left; border-top: 0; border-bottom: 0; border-left: 0; }
.stat:last-child { border-right: 0; }
button.stat { cursor: pointer; }
button.stat:hover { background: var(--tint); }
button.stat.on { background: var(--blue-soft); }
.stat .k { color: var(--grey); font-size: 12.5px; }
.stat .v { font-size: 1.45rem; color: var(--black); margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--grey-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* filters */
.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters input, .filters select { border: 1px solid var(--line); border-radius: var(--r); padding: 7px 10px; background: var(--white); }
.filters input[type=search] { min-width: 240px; }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--blue); }
.count { margin-left: auto; align-self: center; color: var(--grey); }

/* table */
.tbl-wrap { border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--grey); font-size: 12.5px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--tint); white-space: nowrap; cursor: pointer; user-select: none; }
th.nosort { cursor: default; }
th .arr { color: var(--blue); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: #FAFBFC; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num { text-align: right; }
td.nowrap { white-space: nowrap; }
td.chk, th.chk { width: 36px; cursor: default; }
.sub { color: var(--grey-2); font-size: 12.5px; }
.empty { padding: 48px 16px; text-align: center; color: var(--grey); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--tint); color: var(--grey); white-space: nowrap; }
.pill.New { background: var(--tint); color: var(--grey); }
.pill.Contacted { background: var(--blue-soft); color: var(--blue-dk); }
.pill.Call-booked { background: var(--amber-soft); color: var(--amber); }
.pill.Proposal-sent { background: #F0EAFF; color: #5B2FD0; }
.pill.Won, .pill.yes { background: var(--green-soft); color: var(--green); }
.pill.Lost, .pill.no { background: var(--red-soft); color: var(--red); }
.due { color: var(--red); }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(10,10,10,.25); z-index: 40; display: none; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--white); z-index: 41; border-left: 1px solid var(--line); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .18s ease; }
.open .scrim { display: block; }
.open .drawer { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 1.2rem; }
.drawer-head .x { margin-left: auto; border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--grey); }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer-foot { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.drawer-foot .grow { flex: 1; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.grid .full { grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--grey); }
label.f input, label.f select, label.f textarea { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; font-size: 14px; color: var(--ink); background: var(--white); }
label.f textarea { min-height: 80px; resize: vertical; }
label.f input:focus, label.f select:focus, label.f textarea:focus { outline: none; border-color: var(--blue); }
label.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.section-title { margin: 24px 0 10px; font-size: 13px; font-weight: 500; color: var(--black); }
.note-form { display: flex; gap: 8px; }
.note-form textarea { flex: 1; border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; min-height: 44px; resize: vertical; }
.notes { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.note { border-left: 2px solid var(--line); padding: 2px 0 2px 12px; white-space: pre-wrap; }
.note .meta { color: var(--grey-2); font-size: 12px; margin-bottom: 2px; }
.mini { margin-top: 6px; }
.mini td, .mini th { padding: 6px 8px; font-size: 13px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--black); color: #fff; padding: 10px 16px; border-radius: var(--r); z-index: 60; display: none; }
.toast.show { display: block; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--tint); }
.login form { width: 100%; max-width: 360px; background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 32px; display: flex; flex-direction: column; gap: 14px; }
.login .err { color: var(--red); min-height: 1.2em; font-size: 13px; }

@media (max-width: 760px) {
  .top-inner { gap: 12px; padding: 0 16px; overflow-x: auto; }
  .who span { display: none; }
  main { padding: 20px 16px 48px; }
  .filters input[type=search] { min-width: 0; flex: 1; }
  .grid { grid-template-columns: 1fr; }
}
