/* 1UP CRM · one stylesheet, phone and computer */
:root {
  --bg: #F4F5F7; --card: #FFFFFF; --ink: #111827; --ink2: #374151; --muted: #5B6372;
  --line: #E3E6EB; --line2: #EEF0F3; --field: #C9CFD8;
  --accent: #1F4FD8; --accent-ink: #173CA6; --accent-soft: #E8EEFC;
  --ok: #0F6B3C; --ok-soft: #E3F5EB; --warn: #9A4A06; --warn-soft: #FDF1E3;
  --bad: #B42318; --bad-soft: #FDECEA; --purple: #6B35C9; --purple-soft: #F1EAFE;
  --radius: 14px; --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
h1, h2, h3, p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 700; font-size: 16px; }
.logo { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--ink2); text-decoration: none; font-weight: 600; font-size: 14px; }
.nav-item:hover { background: var(--line2); color: var(--ink); }
.nav-item.on { background: var(--accent-soft); color: var(--accent); }
.nav-item .soon { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--muted); }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line2); display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 21px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .logo { display: none; }
.content { padding: 24px; width: 100%; max-width: 1240px; display: flex; flex-direction: column; gap: 20px; }
.tabbar { display: none; }
.demo-banner { background: var(--warn-soft); color: var(--warn); font-size: 13px; font-weight: 600; padding: 8px 24px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.demo-banner button { background: none; border: none; color: inherit; text-decoration: underline; cursor: pointer; padding: 0; font-weight: 600; }

/* ---------- Building blocks ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h2 { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.row { display: flex; gap: 12px; align-items: center; }
.wrap { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.wrap > * { flex: 1 1 340px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.stat b { font-size: 26px; font-weight: 700; }
.stat span { font-size: 13px; color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: #9AA3B2; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--field); background: var(--card); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #E4E7EC; border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { min-height: 36px; padding: 0 14px; border: none; border-radius: 8px; background: transparent; color: #4B5563; font-weight: 600; font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(17,24,39,.15); }
.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 999px; background: var(--line2); color: var(--ink2); white-space: nowrap; }
.pill.blue { background: var(--accent-soft); color: var(--accent); }
.pill.gray { background: #E4E7EC; color: var(--ink2); }
.pill.orange { background: var(--warn-soft); color: var(--warn); }
.pill.purple { background: var(--purple-soft); color: var(--purple); }
.pill.green { background: var(--ok-soft); color: var(--ok); }
.pill.red { background: var(--bad-soft); color: var(--bad); }
.avatar { width: 36px; height: 36px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar.lg { width: 52px; height: 52px; font-size: 17px; }
.banner { border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 600; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .flabel { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input { min-height: 44px; border: 1px solid var(--field); border-radius: 10px; padding: 0 12px; background: var(--card); color: var(--ink); width: 100%; }
textarea.input { padding: 10px 12px; min-height: 84px; resize: vertical; line-height: 1.4; }
.input:focus, .chip:focus-visible, .btn:focus-visible, .nav-item:focus-visible, .list-row:focus-visible, .board-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.list-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line2); border-radius: 10px; padding: 12px; cursor: pointer; color: var(--ink); text-decoration: none; }
.list-row:hover { border-color: var(--field); color: var(--ink); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line2); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty b { color: var(--ink); font-size: 17px; }

/* ---------- Leads table and board ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .input { max-width: 320px; }
.table { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table-inner { min-width: 820px; }
.trow { display: grid; grid-template-columns: 2fr 1.3fr .8fr .6fr 1.3fr 1.1fr 1.5fr; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--line2); font-size: 14px; }
.trow.head { font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); }
a.trow { color: var(--ink); text-decoration: none; }
a.trow:hover { background: #F8F9FB; color: var(--ink); }
.trow .name { display: flex; align-items: center; gap: 10px; font-weight: 600; min-width: 0; }
.trow .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.board-col { width: 250px; flex-shrink: 0; background: #EBEDF1; border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.board-col header { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 4px; font-size: 13px; font-weight: 700; color: var(--ink2); }
.board-card { display: flex; flex-direction: column; gap: 3px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink); text-decoration: none; }
.board-card:hover { border-color: var(--field); color: var(--ink); }
.board-card b { font-size: 14px; }
.board-card span { font-size: 12px; color: var(--muted); }
.more-btn { margin-top: 4px; }

/* ---------- Drawer, modal, toast ---------- */
.overlay { position: fixed; inset: 0; z-index: 30; display: flex; }
.scrim { position: absolute; inset: 0; background: rgba(17,24,39,.4); border: none; cursor: pointer; }
.drawer { position: relative; margin-left: auto; width: 480px; max-width: 100%; height: 100%; background: var(--bg); overflow-y: auto; box-shadow: -8px 0 24px rgba(17,24,39,.15); display: flex; flex-direction: column; }
.drawer-head { background: var(--card); border-bottom: 1px solid var(--line); padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; z-index: 2; }
.drawer-body { padding: 16px 20px 40px; display: flex; flex-direction: column; gap: 12px; }
.icon-btn { width: 44px; height: 44px; border: none; background: transparent; border-radius: 10px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.icon-btn:hover { background: var(--line2); color: var(--ink); }
.temp-pw { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 17px; letter-spacing: .04em; color: var(--ink); }
.btn.block.danger { border-color: var(--bad); }
.modal-wrap { align-items: center; justify-content: center; padding: 16px; z-index: 40; }
.modal { position: relative; width: 460px; max-width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--card); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 16px 40px rgba(17,24,39,.25); }
.modal.wide { width: 760px; }
.modal h2 { font-size: 18px; font-weight: 700; }
.opt { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 15px; cursor: pointer; text-align: left; }
.opt:hover { border-color: var(--field); }
.opt.on { border-color: var(--accent); background: var(--accent-soft); }
.toast { position: fixed; right: 24px; bottom: 24px; width: 380px; max-width: calc(100% - 32px); background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 14px; z-index: 60; box-shadow: 0 8px 24px rgba(17,24,39,.25); display: flex; flex-direction: column; gap: 2px; }
.toast b { font-size: 14px; }
.toast span { font-size: 13px; color: #D1D5DB; }
.toast.error { background: var(--bad); }
.toast.error span { color: #FDE2DF; }
.timeline-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line2); }
.timeline-item:last-child { border-bottom: none; }
.dot { width: 8px; height: 8px; border-radius: 999px; background: var(--accent); margin-top: 7px; flex-shrink: 0; }
.task { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line2); }
.task:last-child { border-bottom: none; }
.task input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.task label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }

/* ---------- Auth screens ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth .card { width: 420px; max-width: 100%; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.auth h1 { font-size: 22px; }

/* ---------- Phone ---------- */
@media (max-width: 899px) {
  .sidebar { display: none; }
  .topbar { padding: 10px 16px; }
  .topbar h1 { font-size: 18px; }
  .topbar .logo { display: flex; width: 32px; height: 32px; font-size: 12px; }
  .hide-phone, .topbar .hide-phone { display: none; }
  .content { padding: 16px 16px 96px; gap: 16px; }
  .demo-banner { padding: 8px 16px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); z-index: 20; }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; }
  .tab.on { color: var(--accent); }
  .drawer { width: 100%; }
  .modal-wrap { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-height: 88vh; border-radius: 20px 20px 0 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .toast { left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); width: auto; }
  .toolbar .input { max-width: none; flex: 1 1 100%; }
  .chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; }
  .table-inner { min-width: 0; }
  .trow.head { display: none; }
  .trow { grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px; }
  .trow > :nth-child(n+2):not(.stage-cell):not(.sub-phone) { display: none; }
  .trow .stage-cell { grid-column: 2; grid-row: 1; }
  .trow .sub-phone { display: block; }
}
.sub-phone { display: none; grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
