/* Noe Varner Partnerships OS — Apple-inspired design system */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;

  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f0f0f2;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #9a9aa0;
  --border: rgba(0, 0, 0, 0.09);
  --border-strong: rgba(0, 0, 0, 0.16);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.14);

  --blue: #0071e3;
  --blue-soft: rgba(0, 113, 227, 0.1);
  --green: #1d9a4e;
  --green-soft: rgba(29, 154, 78, 0.12);
  --amber: #b25e09;
  --amber-soft: rgba(196, 116, 20, 0.13);
  --red: #d32029;
  --red-soft: rgba(211, 32, 41, 0.1);
  --purple: #6e56cf;
  --purple-soft: rgba(110, 86, 207, 0.11);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --sidebar-w: 236px;
  --inspector-w: 304px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

[data-theme="dark"] {
  --bg: #101012;
  --surface: #1b1b1e;
  --surface-2: #232327;
  --surface-3: #2b2b30;
  --text: #f5f5f7;
  --text-2: #a1a1a8;
  --text-3: #6e6e76;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.17);
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 4px 18px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 48px rgba(0,0,0,.55);
  --blue: #2997ff;
  --blue-soft: rgba(41, 151, 255, 0.14);
  --green: #30c85e;
  --green-soft: rgba(48, 200, 94, 0.14);
  --amber: #e8973a;
  --amber-soft: rgba(232, 151, 58, 0.15);
  --red: #ff5d63;
  --red-soft: rgba(255, 93, 99, 0.13);
  --purple: #a08fe8;
  --purple-soft: rgba(160, 143, 232, 0.14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  transition: background .25s var(--ease), color .25s var(--ease);
}
button { font-family: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.workspace { flex: 1; overflow-y: auto; padding: 24px 28px 56px; scroll-behavior: smooth; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: width .22s var(--ease);
  overflow: hidden;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .nav-label, .sidebar.collapsed .brand-text, .sidebar.collapsed .nav-count { display: none; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(160deg, var(--blue), #0a4f9e);
  color: #fff; font-weight: 700; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-weight: 600; font-size: 14px; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.nav-section { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 14px 8px 5px; white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 9px; margin: 1px 0;
  border: none; background: transparent; border-radius: var(--r-sm);
  font-size: 13.5px; cursor: pointer; text-align: left; color: var(--text);
  transition: background .14s var(--ease);
  white-space: nowrap;
}
.nav-item:hover { background: var(--surface-3); }
.nav-item.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.nav-ico { width: 20px; text-align: center; font-size: 14px; flex-shrink: 0; opacity: .85; }
.nav-count { margin-left: auto; font-size: 11px; color: var(--text-3); background: var(--surface-3); border-radius: 20px; padding: 1px 7px; font-variant-numeric: tabular-nums; }
.nav-item.active .nav-count { background: transparent; color: var(--blue); }
.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); }

/* ---------- Topbar ---------- */
.topbar {
  height: 54px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 5;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.crumbs { font-size: 13px; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.crumbs b { color: var(--text); font-weight: 600; }
.icon-btn { background: none; border: none; font-size: 17px; cursor: pointer; padding: 6px; border-radius: var(--r-sm); }
.icon-btn:hover { background: var(--surface-3); }
.mobile-menu { display: none; }
.searchbar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px 10px; min-width: 250px;
  cursor: pointer; font-size: 13px; color: var(--text-3);
  transition: border-color .15s var(--ease);
}
.searchbar:hover { border-color: var(--border-strong); }
.searchbar kbd { margin-left: auto; font-family: var(--font); font-size: 11px; background: var(--surface-3); border-radius: 5px; padding: 1px 6px; color: var(--text-2); }
.sync-pill { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); padding: 5px 11px; border-radius: 20px; white-space: nowrap; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

/* ---------- Generic components ---------- */
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0 2px; }
.page-sub { color: var(--text-2); font-size: 14px; margin-bottom: 22px; }
.section-title { font-size: 16px; font-weight: 650; margin: 26px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title .hint { font-size: 12px; font-weight: 400; color: var(--text-3); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card + .card { margin-top: 14px; }
.card h3 { margin: 0 0 10px; font-size: 14px; font-weight: 650; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; border-radius: 20px;
  padding: 2.5px 9px; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.purple { background: var(--purple-soft); color: var(--purple); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 10px; padding: 7px 14px; font-size: 13px; font-weight: 550;
  cursor: pointer; transition: all .15s var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn:active { transform: scale(.98); }

.kpi { padding: 16px 18px; }
.kpi .kpi-label { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi .kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .kpi-note { font-size: 11.5px; color: var(--text-3); margin-top: 4px; line-height: 1.35; }

/* ---------- Tables ---------- */
.tbl-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-3); padding: 11px 14px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); cursor: pointer; user-select: none; white-space: nowrap;
}
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr { cursor: pointer; transition: background .12s var(--ease); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .money { font-variant-numeric: tabular-nums; text-align: right; }
.tbl th.money { text-align: right; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input[type="text"] {
  font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 6px 10px;
}
.filters .count { font-size: 12.5px; color: var(--text-3); margin-left: auto; }

/* ---------- Pipeline board ---------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.board-col { min-width: 250px; width: 250px; flex-shrink: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px; }
.board-col h4 { margin: 2px 6px 10px; font-size: 12.5px; font-weight: 650; display: flex; justify-content: space-between; color: var(--text-2); }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow); transition: transform .14s var(--ease); }
.board-card:hover { transform: translateY(-1px); }
.board-card .bc-brand { font-weight: 600; font-size: 13px; }
.board-card .bc-meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.board-card .bc-val { font-size: 12px; color: var(--text-2); margin-top: 5px; font-variant-numeric: tabular-nums; }

/* ---------- Deal detail ---------- */
.deal-layout { display: grid; grid-template-columns: minmax(0, 1fr) var(--inspector-w); gap: 20px; align-items: start; }
.deal-header { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.avatar {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 19px; color: #fff;
  background: linear-gradient(150deg, #5e5ce6, #0071e3);
}
.deal-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.deal-subtitle { color: var(--text-2); font-size: 13.5px; margin-top: 2px; }
.deal-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }

.segmented {
  display: inline-flex; background: var(--surface-3); border-radius: 11px; padding: 3px; margin-bottom: 18px;
  overflow-x: auto; max-width: 100%;
}
.segmented button {
  border: none; background: transparent; padding: 6px 15px; border-radius: 8px;
  font-size: 13px; font-weight: 550; cursor: pointer; color: var(--text-2); white-space: nowrap;
  transition: all .16s var(--ease);
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.12); font-weight: 600; }

.inspector { position: sticky; top: 0; }
.inspector .card { padding: 16px; }
.ins-row { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.ins-row:last-child { border-bottom: none; }
.ins-row .k { color: var(--text-2); }
.ins-row .v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.prob-bar { height: 5px; border-radius: 4px; background: var(--surface-3); margin-top: 6px; overflow: hidden; }
.prob-bar > div { height: 100%; border-radius: 4px; background: var(--blue); transition: width .4s var(--ease); }

.kv-grid { display: grid; grid-template-columns: 160px 1fr; gap: 7px 16px; font-size: 13.5px; }
.kv-grid .k { color: var(--text-2); }
.kv-grid .v { min-width: 0; overflow-wrap: break-word; }

.banner { border-radius: var(--r-md); padding: 12px 15px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; border: 1px solid transparent; }
.banner.red { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.banner.amber { background: var(--amber-soft); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.banner.purple { background: var(--purple-soft); color: var(--purple); border-color: color-mix(in srgb, var(--purple) 25%, transparent); }
.banner.blue { background: var(--blue-soft); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 22%, transparent); }
.banner b { font-weight: 650; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 14px; position: relative; padding-bottom: 20px; }
.timeline li::before { content: ""; position: absolute; left: 14px; top: 30px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.tl-dot {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; z-index: 1;
  background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-size: 13px;
  border: 1px solid var(--border);
}
.tl-body { padding-top: 3px; min-width: 0; }
.tl-title { font-weight: 600; font-size: 13.5px; }
.tl-meta { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.tl-detail { font-size: 13px; color: var(--text-2); margin-top: 4px; overflow-wrap: break-word; }

/* ---------- Draft viewer ---------- */
.draft-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.draft-head { padding: 11px 15px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.draft-subject { font-weight: 600; font-size: 13.5px; }
.draft-body { padding: 15px; font-size: 13.5px; white-space: pre-wrap; line-height: 1.55; max-height: 420px; overflow-y: auto; }
.draft-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 11px 15px; border-top: 1px solid var(--border); background: var(--surface); }

/* ---------- Bars (analytics) ---------- */
.bar-row { display: grid; grid-template-columns: 190px 1fr 76px; align-items: center; gap: 12px; padding: 5px 0; font-size: 13px; }
.bar-row .bar-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--blue); transition: width .5s var(--ease); }
.bar-row .bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12.5px; }

/* ---------- Command menu ---------- */
.cmdk-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.22);
  display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh;
  animation: fade .16s var(--ease);
}
.cmdk {
  width: min(620px, 92vw); background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border); overflow: hidden;
  animation: pop .18s var(--ease);
}
.cmdk-input { width: 100%; border: none; outline: none; background: transparent; color: var(--text); font-family: inherit; font-size: 16px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.cmdk-results { max-height: 46vh; overflow-y: auto; padding: 6px; }
.cmdk-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; cursor: pointer; font-size: 13.5px; }
.cmdk-item.sel, .cmdk-item:hover { background: var(--blue-soft); }
.cmdk-item .ci-ico { width: 24px; text-align: center; opacity: .7; }
.cmdk-item .ci-sub { color: var(--text-3); font-size: 12px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.cmdk-section { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 9px 12px 3px; }
.cmdk-foot { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(-6px); } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 20px; border-radius: 24px;
  font-size: 13.5px; font-weight: 550; z-index: 200; box-shadow: var(--shadow-lg);
  animation: toast-in .22s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* ---------- Forms ---------- */
textarea, input[type="text"], select {
  font-family: inherit; font-size: 13.5px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px;
  width: 100%;
}
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
textarea { resize: vertical; min-height: 74px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }

.note-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.note-item:last-child { border-bottom: none; }
.note-meta { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }

.empty { text-align: center; color: var(--text-3); padding: 44px 20px; font-size: 13.5px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.list-item:hover { background: var(--surface-2); }
.list-item:last-child { border-bottom: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .deal-layout { grid-template-columns: 1fr; }
  .inspector { position: static; }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; z-index: 50; height: 100%; height: 100dvh; transform: translateX(-100%); transition: transform .22s var(--ease); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 49; background: rgba(0,0,0,.3); animation: fade .18s var(--ease); }
  .mobile-menu { display: block; padding: 8px 10px; }
  .searchbar { min-width: 0; padding: 8px 10px; }
  .search-hint { display: none; }
  .sync-pill { display: none; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .workspace { padding: 16px 14px 64px; }
  .kv-grid { grid-template-columns: 1fr; gap: 2px 0; }
  .kv-grid .k { margin-top: 8px; }
  .page-title { font-size: 22px; }
  .deal-header { flex-direction: row; gap: 12px; }
  .avatar { width: 44px; height: 44px; font-size: 16px; border-radius: 12px; }
  .deal-title { font-size: 19px; }
  /* touch targets */
  .btn { padding: 10px 16px; min-height: 42px; }
  .btn.sm { padding: 8px 12px; min-height: 38px; }
  .nav-item { padding: 11px 10px; font-size: 14.5px; }
  select, input[type="text"], textarea { font-size: 16px; } /* prevents iOS zoom-on-focus */
  .filters select, .filters input[type="text"] { flex: 1 1 44%; font-size: 15px; padding: 9px 10px; }
  .segmented button { padding: 9px 13px; }
  .tbl th, .tbl td { padding: 10px 10px; }
  .tbl-wrap { -webkit-overflow-scrolling: touch; }
  .board-col { min-width: 82vw; width: 82vw; }
  .draft-body { max-height: 50vh; }
  .draft-actions .btn { flex: 1 1 auto; justify-content: center; }
  .cmdk-overlay { padding-top: 6vh; }
  .cmdk-results { max-height: 55vh; }
  .bar-row { grid-template-columns: 110px 1fr 64px; }
  .list-item { padding: 12px 4px; }
  .topbar { padding: 0 12px; }
}
@media (max-width: 760px) and (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top); height: calc(54px + env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
