/* Florea WhatsApp CRM */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&family=Fraunces:opsz,wght@9..144,600&display=swap');

:root {
  --teal: #1F4D46;
  --teal-2: #2A6359;
  --teal-soft: #E5EFEC;
  --sand: #F6F2EA;
  --card: #FFFFFF;
  --line: #E6DFD2;
  --ink: #1E2B28;
  --muted: #6B746F;
  --gold: #B38A4D;
  --wa: #25D366;
  --wa-dark: #128C4A;
  --err: #B0544A;
  --warn: #C98A3B;
  --ok: #3E8E5A;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(30,43,40,.06), 0 4px 14px rgba(30,43,40,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 14px; color: var(--ink); background: var(--sand); line-height: 1.45; }
a { color: var(--teal-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font-family: 'Fraunces', Georgia, serif; font-size: 26px; font-weight: 600; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 1.2em; }
code { background: var(--teal-soft); padding: 1px 6px; border-radius: 4px; font-size: 12.5px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--teal); color: #DCE8E4; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side .logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #fff; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--gold); color: #fff; display: grid; place-items: center; font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600; flex: none; }
.side .logo b { display: block; font-size: 15px; font-weight: 600; }
.side .logo span { font-size: 11px; opacity: .7; letter-spacing: .08em; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; color: #DCE8E4; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.on { background: rgba(255,255,255,.14); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.side .me { margin-top: auto; padding: 12px; font-size: 12px; opacity: .85; border-top: 1px solid rgba(255,255,255,.12); }
.side .me a { color: #fff; }
.main { padding: 26px 30px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.topbar h1 { margin: 0; margin-right: auto; }

/* ---------- elements */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 500; padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #cfc5b3; text-decoration: none; }
.btn.primary { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn.primary:hover { background: var(--teal-2); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #073B1F; }
.btn.wa:hover { background: #1fbe5b; }
.btn.danger { color: var(--err); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.badge { display: inline-block; min-width: 20px; padding: 1px 7px; border-radius: 99px; background: var(--wa); color: #073B1F; font-size: 11px; font-weight: 600; text-align: center; }
.badge.grey { background: #ECE7DD; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 500; background: #F1ECE2; color: var(--ink); white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.pill.due { background: #F8E4E1; color: var(--err); }
.pill.soon { background: #FBEFDD; color: #8A5A17; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.card h2 { display: flex; align-items: center; gap: 8px; }
.card h2 .btn { margin-left: auto; }
.alert { padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; font-weight: 500; }
.alert.ok { background: #E3F1E7; color: #24563A; }
.alert.err { background: #F8E4E1; color: #7E2F27; }
.alert.warn { background: #FBEFDD; color: #7A4E12; }
.alert.info { background: var(--teal-soft); color: var(--teal); }
.empty { padding: 28px 10px; text-align: center; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; font-weight: 600; font-size: 12.5px; flex: none; }

/* ---------- forms */
.form label { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(42,99,89,.25); border-color: var(--teal-2); }
textarea { resize: vertical; min-height: 80px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.inline-search { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-search input, .inline-search select { margin: 0; width: auto; min-width: 160px; }

/* ---------- stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 600; line-height: 1.1; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 3px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.two > *, .lead-grid > * { min-width: 0; }
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel .row { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: 10px; font-size: 13px; }
.funnel .bar { height: 10px; border-radius: 99px; background: #F1ECE2; overflow: hidden; }
.funnel .bar i { display: block; height: 100%; border-radius: 99px; }

/* ---------- list rows */
.rows { display: flex; flex-direction: column; }
.rowlink { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid #F0EBE1; color: inherit; }
.rowlink:last-child { border-bottom: 0; }
.rowlink:hover { background: #FBF9F5; text-decoration: none; }
.rowlink .grow { flex: 1; min-width: 0; }
.rowlink .t { font-weight: 500; }
.rowlink .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

table.tbl { width: 100%; border-collapse: collapse; background: #fff; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #FBF9F5; }
.tbl th.right { text-align: right; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid #F0EBE1; vertical-align: middle; }
.tbl tr:hover td { background: #FBF9F5; }
.tbl-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }

/* ---------- pipeline */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(205px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: #EFE9DE; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.col-h { display: flex; align-items: center; gap: 8px; padding: 4px 4px 10px; font-weight: 600; font-size: 13px; }
.col-h .dot { width: 9px; height: 9px; border-radius: 50%; }
.col-h .badge { margin-left: auto; }
.col.drop { outline: 2px dashed var(--teal-2); outline-offset: -4px; }
.lc { display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin-bottom: 8px; color: inherit; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.lc:hover { text-decoration: none; border-color: #cfc5b3; }
.lc.dragging { opacity: .45; }
.lc .top { display: flex; align-items: center; gap: 6px; }
.lc .name { color: var(--ink); font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.lc .msg { font-size: 12.5px; color: #4b5552; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lc .tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.lc.unread { border-left: 3px solid var(--wa); }
.stage-select { display: none; }

/* ---------- lead page */
.lead-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.chat { display: flex; flex-direction: column; height: 560px; padding: 0; overflow: hidden; }
.chat-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-h .grow { flex: 1; min-width: 0; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; background: #EFEAE2 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Ccircle cx='2' cy='2' r='1' fill='%23e0d9cc'/%3E%3C/svg%3E"); display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 78%; padding: 7px 10px 5px; border-radius: 9px; font-size: 13.5px; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px .5px rgba(0,0,0,.13); }
.bubble.in { align-self: flex-start; background: #fff; border-top-left-radius: 2px; }
.bubble.out { align-self: flex-end; background: #D9FDD3; border-top-right-radius: 2px; }
.bubble .tm { display: block; text-align: right; font-size: 10.5px; color: #667781; margin-top: 2px; }
.day-sep { align-self: center; background: #fff; color: #54656F; font-size: 11.5px; padding: 3px 10px; border-radius: 7px; margin: 6px 0; box-shadow: 0 1px .5px rgba(0,0,0,.1); }
.composer { border-top: 1px solid var(--line); padding: 10px; background: #F7F5F1; }
.composer textarea { min-height: 64px; margin: 0 0 8px; }
.composer .acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.composer select { width: auto; margin: 0; flex: 1; min-width: 150px; }
.window-note { font-size: 11.5px; color: var(--muted); padding: 0 2px 8px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; font-size: 13px; }
.timeline li:before { content: ''; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.timeline li.note:before { background: var(--gold); }
.timeline li.stage:before { background: var(--teal-2); }
.timeline li.ai:before { background: #7A4E8A; }
.timeline li:after { content: ''; position: absolute; left: 7.5px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child:after { display: none; }
.timeline .when { font-size: 11.5px; color: var(--muted); }
.timeline .txt { white-space: pre-wrap; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.ai-box { background: #F4EEF7; border: 1px solid #E3D5EA; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }

/* ---------- auth */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--teal); }
.auth-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 30px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-card.wide { max-width: 520px; }
.auth-card .brand-mark { margin-bottom: 16px; }
.steps li { margin-bottom: 8px; }

/* ---------- mobile */
.mob-nav { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 14px 90px; }
  h1 { font-size: 22px; }
  .two, .lead-grid { grid-template-columns: 1fr; }
  .chat { height: 70vh; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .mob-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: var(--teal); z-index: 50; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .mob-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: #CFE0DB; font-size: 10.5px; padding: 4px 0; position: relative; }
  .mob-nav a.on { color: #fff; }
  .mob-nav a:hover { text-decoration: none; }
  .mob-nav svg { width: 21px; height: 21px; }
  .mob-nav .badge { position: absolute; top: 0; left: 55%; font-size: 9.5px; min-width: 16px; padding: 0 4px; }
  .board { grid-auto-columns: 82vw; scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .stage-select { display: block; margin: 8px 0 0; padding: 5px 8px; font-size: 12px; }
  .inline-search input, .inline-search select { flex: 1; min-width: 0; }
  .hide-m { display: none; }
}
