/* Nghtshft Office — iPad-first, one committed dark look (same brand as the website).
   Layout: fixed side rail on iPad landscape; bottom tab bar under 900px. */
:root {
  --bg: #0B0C0F;
  --panel: #14151A;
  --panel-2: #1B1D23;
  --raise: #22252D;
  --ink: #F4F5F3;
  --mute: rgba(244,245,243,.62);
  --faint: rgba(244,245,243,.38);
  --line: rgba(244,245,243,.10);
  --line-2: rgba(244,245,243,.18);
  --amber: #FF9A3C;
  --amber-hot: #FFC983;
  --amber-soft: rgba(255,154,60,.14);
  --ok: #4CC38A; --ok-soft: rgba(76,195,138,.14);
  --warn: #F2B544; --warn-soft: rgba(242,181,68,.14);
  --bad: #EE6B62; --bad-soft: rgba(238,107,98,.14);
  --info: #8FB4FF; --info-soft: rgba(143,180,255,.14);

  --f-x: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-head: "Funnel Display", -apple-system, "Segoe UI", sans-serif;
  --f-body: "Funnel Sans", -apple-system, "Segoe UI", sans-serif;

  --rail: 220px;
  --r: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 6px; }

.logo { font-family: var(--f-x); font-stretch: 125%; font-weight: 800; letter-spacing: -0.03em; font-size: 17px; display: inline-flex; gap: 2px; align-items: flex-start; }
.logo sup { font-family: var(--f-body); font-size: 8px; font-weight: 500; margin-top: 2px; }
.boot { height: 100%; display: grid; place-items: center; }
.boot-mark { font-family: var(--f-x); font-stretch: 125%; font-weight: 800; font-size: 22px; letter-spacing: -0.03em; opacity: .5; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .2; } }

/* ---------- Shell ---------- */
#app { height: 100%; }
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.rail { display: flex; flex-direction: column; gap: 22px; padding: calc(22px + env(safe-area-inset-top, 0px)) 14px calc(18px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px)); border-right: 1px solid var(--line); background: #08090B; overflow-y: auto; }
.rail-brand { padding: 0 10px; display: flex; flex-direction: column; gap: 4px; }
.rail-brand small { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; text-decoration: none; color: var(--mute); font-weight: 500; font-size: 15px; transition: background .15s, color .15s; }
.nav a svg { width: 19px; height: 19px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: var(--panel); color: var(--ink); }
.nav a.on { background: var(--panel-2); color: var(--ink); }
.nav a .count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--amber); color: #1A1305; font-size: 12px; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 10px; font-size: 12.5px; color: var(--faint); }
.rail-foot button { background: none; border: 0; padding: 0; text-align: left; color: var(--mute); font-size: 13px; }
.rail-foot button:hover { color: var(--ink); }

.main { min-width: 0; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(22px + env(safe-area-inset-top, 0px)) calc(28px + env(safe-area-inset-right, 0px)) calc(40px + env(safe-area-inset-bottom, 0px)) 28px; }
.main.split { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.top h1 { font-family: var(--f-head); font-weight: 500; font-size: 30px; letter-spacing: -0.025em; line-height: 1.1; margin-right: auto; }
.top .sub { width: 100%; color: var(--mute); margin-top: -14px; font-size: 14px; }
.demo { background: var(--amber-soft); border: 1px solid rgba(255,154,60,.35); color: var(--amber-hot); border-radius: 12px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 18px; }

/* ---------- Controls ---------- */
.btn { text-decoration: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; }
.btn:hover { border-color: rgba(244,245,243,.35); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.amber { background: var(--amber); color: #1A1305; border-color: var(--amber); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.input, .select, .textarea { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; font-size: 15px; transition: border-color .15s; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--amber); }
.textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--mute) 50%), linear-gradient(135deg, var(--mute) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.select.sm { padding: 6px 30px 6px 10px; font-size: 13px; border-radius: 10px; width: auto; }
.label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.field { display: flex; flex-direction: column; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 500; color: var(--mute); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.search { max-width: 280px; }

/* status pills: meaning in colour AND words */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--raise); color: var(--mute); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.book, .pill.call, .pill.replied, .pill.retainer { background: var(--ok-soft); color: var(--ok); }
.pill.nurture, .pill.contacted { background: var(--info-soft); color: var(--info); }
.pill.new, .pill.assessment, .pill.todo { background: var(--amber-soft); color: var(--amber-hot); }
.pill.build { background: var(--warn-soft); color: var(--warn); }
.pill.lost, .pill.not-now { background: var(--raise); color: var(--faint); }

/* ---------- Today ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; transition: border-color .15s; }
.stat:hover { border-color: var(--line-2); }
.stat b { font-family: var(--f-head); font-weight: 500; font-size: 34px; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--mute); font-size: 13.5px; }
.stat.hot b { color: var(--amber-hot); }
.bar { height: 5px; border-radius: 3px; background: var(--raise); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--amber); border-radius: 3px; transition: width .5s; }
.cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; min-width: 0; }
.card h2 { font-family: var(--f-head); font-weight: 500; font-size: 18px; letter-spacing: -0.015em; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.card h2 small { font-family: var(--f-body); color: var(--faint); font-size: 13px; font-weight: 500; margin-left: auto; }
.empty { color: var(--faint); font-size: 14px; padding: 10px 0 4px; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { border-top: 1px solid var(--line); }
.rows > li:first-child { border-top: 0; }
.row { display: flex; align-items: center; gap: 10px; padding: 11px 0; text-decoration: none; min-width: 0; width: 100%; background: none; border: 0; text-align: left; }
.row .who { min-width: 0; flex: 1; }
.row .who b { display: block; font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .who span { display: block; color: var(--mute); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row time { color: var(--faint); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.week { margin-top: 14px; }

/* ---------- Tables (leads, outreach, scorecard) ---------- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; transition: background .12s; }
tbody tr.click:hover { background: var(--panel-2); }
td.name b { display: block; font-weight: 600; }
td.name span { color: var(--mute); font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.muted { color: var(--mute); }
.score { font-variant-numeric: tabular-nums; font-weight: 600; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.links { display: flex; gap: 8px; }
.links a { color: var(--mute); font-size: 13px; }

/* ---------- Pipeline ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.lane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; min-height: 140px; }
.lane h2 { font-family: var(--f-head); font-weight: 500; font-size: 15px; display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 10px; }
.lane h2 span { color: var(--faint); font-family: var(--f-body); font-size: 13px; }
.deal { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.deal button.open { background: none; border: 0; padding: 0; text-align: left; }
.deal b { font-weight: 600; font-size: 14px; }
.deal span { color: var(--mute); font-size: 12.5px; }
.deal .move { display: flex; gap: 6px; justify-content: space-between; align-items: center; }
.deal .move button { background: var(--raise); border: 0; border-radius: 8px; width: 30px; height: 28px; color: var(--mute); }
.deal .move button:hover { color: var(--ink); }
.deal .move em { font-style: normal; font-size: 12.5px; color: var(--amber-hot); font-variant-numeric: tabular-nums; }

/* ---------- Inbox ---------- */
.inbox { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); }
.threads { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.threads-head { padding: calc(20px + env(safe-area-inset-top, 0px)) 16px 12px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--line); }
.threads-head .t { display: flex; align-items: center; gap: 10px; }
.threads-head h1 { font-family: var(--f-head); font-weight: 500; font-size: 26px; letter-spacing: -0.025em; margin-right: auto; }
.tlist { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.thread { display: block; width: 100%; text-align: left; background: none; border: 0; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); padding: 13px 16px; position: relative; }
.thread:hover { background: var(--panel); }
.thread.on { background: var(--panel-2); }
.thread .l1 { display: flex; gap: 8px; align-items: baseline; }
.thread .l1 b { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread .l1 time { color: var(--faint); font-size: 12px; flex: none; }
.thread .l2 { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.thread .l3 { font-size: 13px; color: var(--mute); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.thread.unread::before { content: ""; position: absolute; left: 6px; top: 20px; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.thread.unread .l1 b, .thread.unread .l2 { color: var(--ink); font-weight: 700; }
.convo { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.convo-head { padding: calc(18px + env(safe-area-inset-top, 0px)) 22px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.convo-head .who { flex: 1; min-width: 0; }
.convo-head h2 { font-family: var(--f-head); font-weight: 500; font-size: 20px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-head span { color: var(--mute); font-size: 13.5px; }
.back { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch; }
.msg { max-width: min(640px, 86%); border-radius: 16px; padding: 12px 15px; background: var(--panel); border: 1px solid var(--line); }
.msg.out { align-self: flex-end; background: #232019; border-color: rgba(255,154,60,.22); }
.msg header { display: flex; gap: 10px; justify-content: space-between; font-size: 12px; color: var(--faint); margin-bottom: 6px; }
.msg .body { white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; }
.reply { border-top: 1px solid var(--line); padding: 12px 22px calc(14px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 10px; align-items: flex-end; background: var(--bg); }
.reply .textarea { min-height: 52px; max-height: 40vh; }
.pick { flex: 1; display: grid; place-items: center; color: var(--faint); text-align: center; padding: 30px; }

/* ---------- Sheets (lead detail, compose, forms) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; animation: fade .2s; }
.sheet { position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--panel); border-left: 1px solid var(--line-2); display: flex; flex-direction: column; animation: slide .28s cubic-bezier(.2,.8,.2,1); }
.sheet.center { top: 50%; left: 50%; right: auto; bottom: auto; transform: translate(-50%, -50%); width: min(560px, calc(100% - 32px)); max-height: calc(100% - 48px); border: 1px solid var(--line-2); border-radius: 20px; animation: pop .22s cubic-bezier(.2,.8,.2,1); }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes pop { from { transform: translate(-50%, -46%); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: calc(18px + env(safe-area-inset-top, 0px)) 20px 14px; border-bottom: 1px solid var(--line); }
.sheet.center .sheet-head { padding-top: 18px; }
.sheet-head h2 { font-family: var(--f-head); font-weight: 500; font-size: 21px; letter-spacing: -0.02em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.x-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line-2); background: none; display: grid; place-items: center; }
.x-btn svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }
.sheet-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 14px 20px calc(16px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.answers { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 14px; font-size: 14px; }
.answers dt { color: var(--faint); }
.answers dd { margin: 0; word-wrap: break-word; }
.err { color: var(--bad); font-size: 13.5px; }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.4); animation: pop2 .25s; max-width: calc(100% - 32px); }
#toast.bad { background: var(--bad); color: #fff; }
@keyframes pop2 { from { transform: translate(-50%, 10px); opacity: 0; } }

/* ---------- Login ---------- */
.login { height: 100%; display: grid; place-items: center; padding: 24px; }
.login form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login .logo { font-size: 26px; }
.login p { color: var(--mute); margin-bottom: 8px; }
.setup { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13.5px; color: var(--mute); display: flex; flex-direction: column; gap: 6px; }
.setup li::before { content: "\2717\FE0E"; color: var(--bad); margin-right: 8px; }
.setup li.ok::before { content: "\2713\FE0E"; color: var(--ok); }

/* ---------- Narrow: iPad portrait split / phones ---------- */
@media (max-width: 1100px) {
  .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .rail { flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); border-right: 0; border-top: 1px solid var(--line); order: 2; overflow: visible; gap: 0; }
  .rail-brand, .rail-foot { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 3px; padding: 7px 4px; font-size: 11px; flex: 1; align-items: center; position: relative; }
  .nav a .count { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; min-width: 18px; height: 18px; font-size: 10.5px; padding: 0 5px; }
  .main { padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 24px; }
  .cols { grid-template-columns: minmax(0, 1fr); }
  .inbox { grid-template-columns: minmax(0, 1fr); }
  .inbox.has-convo .threads { display: none; }
  .inbox:not(.has-convo) .convo { display: none; }
  .back { display: inline-flex; }
  .convo-head .who { order: -1; flex-basis: 100%; }
  .convo-head h2 { white-space: normal; }
  .msgs, .reply, .convo-head { padding-left: 16px; padding-right: 16px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
