:root {
  --bg: #FBF7F8;
  --surface: #FFFFFF;
  --surface-2: #FDF3F6;
  --ink: #2A1F24;
  --ink-2: #5E4F56;
  --muted: #8C7B82;
  --line: #EEE1E6;
  --pink: #C2185B;
  --pink-ink: #A3144C;
  --pink-soft: #FCE7EF;
  --blue: #3F6EA8;
  --blue-soft: #E8EFF8;
  --amber: #C77A12;
  --amber-soft: #FBF0DE;
  --good: #2E7D4F;
  --good-soft: #E3F3E9;
  --bad: #B3261E;
  --bad-soft: #FBE6E4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(60, 20, 35, .05), 0 2px 8px rgba(60, 20, 35, .04);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--pink-ink); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }
.num { font-variant-numeric: tabular-nums; }

/* buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 8px; padding: 7px 12px; font: inherit; font-weight: 550; cursor: pointer;
  text-decoration: none; white-space: nowrap; min-height: 34px;
}
.btn:hover { border-color: #DCC6CF; background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--pink); border-color: var(--pink); color: #fff; }
.btn.primary:hover { background: var(--pink-ink); }
.btn.small { padding: 4px 9px; min-height: 28px; font-size: 12.5px; }
.btn.warn { color: var(--bad); }
.btn.ok { color: var(--good); }
input[type=text], input[type=password], input[type=number], input[type=search], textarea, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, textarea:focus, select:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid #E79AB6; outline-offset: 1px; }
textarea { resize: vertical; }
label { font-weight: 600; font-size: 12.5px; color: var(--ink-2); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px 24px; box-shadow: var(--shadow); display: grid; gap: 8px;
}
.login-card h1 { margin-top: 6px; }
.login-card p { margin: 0 0 8px; }
.login-card .btn { margin-top: 8px; min-height: 40px; }

/* layout */
.app { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.nav {
  position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px; padding: 14px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 8px 16px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-weight: 550; position: relative;
}
.nav a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--pink-soft); color: var(--pink-ink); }
.nav .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pink); margin-left: auto; }
.live { margin-top: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 8px 10px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: #C9BCC1; }
.live.on i { background: var(--good); }
.main { padding: 22px 26px 40px; min-width: 0; grid-column: 2; grid-row: 1; }
.reports-pane { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding-bottom: 22px; }
.reports-pane[hidden] { display: none; }
.reports-frame { flex: 1; width: 100%; min-height: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #FAF7F5; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* segmented range / filter controls */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; font: inherit; font-weight: 550; color: var(--ink-2); padding: 5px 11px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--pink-soft); color: var(--pink-ink); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 7px;
  padding: 4px 10px; font: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer;
}
.chip.on { border-color: #E9A9C0; background: var(--pink-soft); color: var(--pink-ink); }
.chip .n { color: var(--muted); margin-left: 4px; font-weight: 500; }

/* cards */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card > h2 { margin-bottom: 4px; }
.card > .desc { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }
.section { margin-top: 14px; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .foot { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.lead { border-color: #F0C3D3; background: linear-gradient(180deg, #FFF 0%, #FFF7FA 100%); }
.kpi.lead .value { color: var(--pink-ink); }
.chart-box { position: relative; height: 230px; }
.chart-box.short { height: 170px; }
.chart-box.tall { height: 280px; }

/* morning briefing */
.brief { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; }
.brief-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.brief-item {
  display: block; text-decoration: none; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.brief-item b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.brief-item span { font-size: 12px; color: var(--ink-2); }
.brief-item.hot { border-color: #F0C3D3; }
.brief-item.hot b { color: var(--pink-ink); }
.goal-bar { height: 10px; background: var(--pink-soft); border-radius: 6px; overflow: hidden; margin: 10px 0 6px; }
.goal-bar i { display: block; height: 100%; background: var(--pink); border-radius: 6px; transition: width .4s ease; }
.goal-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.goal-row .big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* lists and tables */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); min-width: 0; }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .s { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); padding: 14px 0; font-size: 13px; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 12px; color: var(--ink-2); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

/* badges */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 5px; background: #F2ECEE; color: var(--ink-2); white-space: nowrap; }
.badge.paid { background: var(--good-soft); color: var(--good); }
.badge.open { background: var(--amber-soft); color: #8A5208; }
.badge.lost { background: var(--bad-soft); color: var(--bad); }
.badge.pink { background: var(--pink-soft); color: var(--pink-ink); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 6px; border-radius: 5px; border: 1px solid #EBCBD7; color: var(--pink-ink); margin: 2px 4px 0 0; }

/* inbox */
.inbox { display: grid; grid-template-columns: 330px minmax(0, 1fr) 300px; height: calc(100vh - 44px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.inbox.no-detail { grid-template-columns: 330px minmax(0, 1fr); }
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane.people { border-right: 1px solid var(--line); }
.pane.detail { border-left: 1px solid var(--line); overflow-y: auto; padding: 16px; gap: 14px; }
.people-top { padding: 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.people-top .row { display: flex; gap: 6px; }
.people-list { overflow-y: auto; flex: 1; }
.person {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px;
  border-bottom: 1px solid var(--line); cursor: pointer; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; font: inherit; color: inherit;
}
.person:hover { background: var(--surface-2); }
.person.on { background: var(--pink-soft); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: var(--pink-ink); background: var(--pink-soft); border: 1px solid #F0C3D3; font-size: 13px; }
.person .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .last { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .when { font-size: 11.5px; color: var(--muted); text-align: right; display: grid; gap: 3px; justify-items: end; }
.person .unread { width: 8px; height: 8px; border-radius: 50%; background: var(--pink); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 58px; }
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .who span { font-size: 12px; color: var(--muted); }
.back { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 16px 14px; background: #FCF9FA; display: flex; flex-direction: column; gap: 6px; }
.day-sep { align-self: center; font-size: 11.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; margin: 8px 0; }
.bubble { max-width: min(78%, 560px); padding: 8px 11px 6px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; border: 1px solid var(--line); background: var(--surface); }
.bubble.customer { align-self: flex-start; border-top-left-radius: 4px; }
.bubble.kamala { align-self: flex-end; background: var(--pink-soft); border-color: #F3CEDC; border-top-right-radius: 4px; }
.bubble.owner { align-self: flex-end; background: var(--blue-soft); border-color: #CFDCEE; border-top-right-radius: 4px; }
.bubble .meta { font-size: 11px; color: var(--muted); margin-top: 3px; text-align: right; }
.bubble.customer .meta { text-align: left; }
.bubble .by { font-weight: 650; font-size: 11px; margin-right: 6px; }
.bubble.kamala .by { color: var(--pink-ink); }
.bubble.owner .by { color: var(--blue); }
.composer { border-top: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 6px; }
.composer .row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 160px; }
.closed-note { background: var(--amber-soft); color: #6E4206; border-radius: 8px; padding: 10px 12px; font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; user-select: none; font-weight: 550; }
.switch input { appearance: none; width: 32px; height: 18px; border-radius: 10px; background: #DDD0D5; position: relative; cursor: pointer; margin: 0; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--amber); }
.switch input:checked::after { transform: translateX(14px); }
.radio { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink); cursor: pointer; }
.radio input { accent-color: var(--pink); width: 16px; height: 16px; margin: 0; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 4px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.inv { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 6px; }
.inv .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.inv .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.no-chat { flex: 1; display: grid; place-items: center; color: var(--muted); padding: 20px; text-align: center; }

/* invoice rows */
.irow { display: grid; grid-template-columns: 1.6fr 1.3fr .8fr 1fr auto; gap: 12px; align-items: center; padding: 11px 4px; border-top: 1px solid var(--line); }
.irow:first-child { border-top: 0; }
.irow .t { font-weight: 600; }
.irow .s { font-size: 12.5px; color: var(--muted); }
.irow .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* alerts */
.alert { padding: 12px 0; border-top: 1px solid var(--line); }
.alert:first-child { border-top: 0; }
.alert .top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.alert .body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; color: var(--ink-2); margin-top: 4px; }

/* funnel */
.funnel { display: grid; gap: 8px; }
.fstep { display: grid; grid-template-columns: 150px 1fr 90px; gap: 10px; align-items: center; font-size: 13px; }
.fbar { height: 22px; background: #F6EEF1; border-radius: 4px; overflow: hidden; }
.fbar i { display: block; height: 100%; background: var(--pink); border-radius: 0 4px 4px 0; min-width: 2px; }
.fstep .drop { font-size: 12px; color: var(--bad); }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13px; transition: all .2s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--bad); }

.loading { color: var(--muted); padding: 30px 0; }

@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .inbox, .inbox.no-detail { grid-template-columns: 300px minmax(0, 1fr); }
  .inbox .pane.detail { display: none; }
  .inbox.show-detail .pane.detail { display: flex; position: fixed; right: 0; top: 0; bottom: 0; width: min(380px, 100vw); background: var(--surface); z-index: 30; box-shadow: -6px 0 24px rgba(40, 10, 20, .12); }
}
@media (max-width: 960px) {
  .g3 { grid-template-columns: 1fr; }
  .g2 { grid-template-columns: 1fr; }
  .brief { grid-template-columns: 1fr; }
  .irow { grid-template-columns: 1fr auto; }
  .irow .c3, .irow .c4 { grid-column: 1; }
  .irow .acts { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .nav {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; justify-content: space-around;
    border-right: 0; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 20; gap: 0;
  }
  .brand, .live { display: none; }
  .nav a { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 4px; flex: 1; text-align: center; }
  .nav .dot { position: absolute; top: 4px; right: calc(50% - 16px); margin: 0; }
  .main { padding: 16px 16px 90px; grid-column: 1; }
  .reports-pane { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .reports-pane .head .sub { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 21px; }
  .inbox, .inbox.no-detail { grid-template-columns: 1fr; height: calc(100vh - 150px); height: calc(100dvh - 150px); }
  .chat-head { flex-wrap: wrap; row-gap: 8px; }
  .chat-head .who { flex: 1 1 calc(100% - 130px); }
  .chat-head .switch { margin-left: auto; }
  .inbox .pane.chat { display: none; }
  .inbox.open-chat .pane.people { display: none; }
  .inbox.open-chat .pane.chat { display: flex; }
  .back { display: inline-flex; }
  .fstep { grid-template-columns: 110px 1fr 70px; }
  .bubble { max-width: 88%; }
}
