/* ==========================================================================
   Asan Umrah Kameti — WhatsApp AI Admin · v5 "Emerald & Gold"
   Deep emerald sidebar + warm gold accents + warm ivory pages.
   Fonts: Marcellus (brand/headings) + Plus Jakarta Sans (UI).
   Mobile-first: desktop sidebar, mobile topbar + bottom quick nav.
   ========================================================================== */
* { box-sizing: border-box; }
:root {
  --emerald-950: #07271D;
  --emerald-900: #0B3D2E;
  --emerald-800: #0E4A37;
  --emerald-700: #065F46;
  --emerald-600: #047857;
  --emerald-100: #D1FAE5;
  --gold: #C9A227;
  --gold-soft: #E9D9A6;
  --gold-dark: #9A7B14;
  --ivory: #F8F4EA;
  --ivory-2: #F1EBDA;
  --card: #FFFFFF;
  --ink: #1E2A24;
  --muted: #6B7A70;
  --line: #E7DFCB;
  --red: #B91C1C;
  --red-bg: #FDECEC;
  --green: #15803D;
  --amber: #B45309;
  --shadow: 0 2px 10px rgba(11, 61, 46, 0.08);
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--ivory);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3, .brand-name { font-family: "Marcellus", Georgia, serif; letter-spacing: 0.01em; }
a { color: var(--emerald-700); }

/* ---------- layout: sidebar + main ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: 0 0 248px;
  background: linear-gradient(180deg, var(--emerald-950), var(--emerald-900) 55%, var(--emerald-800));
  color: #EDEBE2;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; border-bottom: 1px solid rgba(201, 162, 39, 0.35); margin-bottom: 14px; }
.brand-mark { font-size: 30px; line-height: 1; }
.brand-name { font-size: 19px; line-height: 1.25; color: #F5EFD8; }
.brand-name small { display: block; font-family: "Plus Jakarta Sans", sans-serif; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); margin-top: 2px; }
.sidenav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidenav a {
  display: block; padding: 10px 12px; border-radius: 10px;
  color: #CFE3D6; text-decoration: none; font-weight: 600; font-size: 14.5px;
  border-left: 3px solid transparent;
}
.sidenav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.sidenav a.active { background: rgba(201, 162, 39, 0.16); color: var(--gold-soft); border-left-color: var(--gold); }
.sidenav a.logout { margin-top: auto; color: #F0B4B4; }
.main { flex: 1; min-width: 0; padding: 22px 22px 30px; }
.mobilebar { display: none; }
.pagehead { margin-bottom: 16px; }
.pagehead h2 { margin: 0; font-size: 28px; color: var(--emerald-900); }
.pagehead p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.content { max-width: 1120px; }

/* ---------- cards, stats ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 10px; font-size: 19px; color: var(--emerald-900); }
.card.stat { border-top: 3px solid var(--gold); }
.card.stat b { font-size: 30px; display: block; line-height: 1.1; color: var(--emerald-900); }
.card.stat span { color: var(--muted); font-size: 13px; }
.card.stat.hot { border-top-color: var(--red); }
.card.stat.hot b { color: var(--red); }
.card.stat.ok { border-top-color: var(--emerald-600); }
.card.stat.ok b { color: var(--emerald-700); }
.card.stat.warn { border-top-color: var(--amber); }
.card.stat.warn b { color: var(--amber); }
.muted { color: var(--muted); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; align-items: start; }
.grid2 > .card { margin-bottom: 0; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- forms & buttons ---------- */
label { display: block; font-weight: 700; font-size: 13.5px; margin-bottom: 12px; color: var(--ink); }
input, select, textarea {
  width: 100%; padding: 11px 12px; margin-top: 5px;
  border: 1px solid #D8CFB6; border-radius: 10px; font-size: 15px; font-family: inherit;
  background: #FFFDF6; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
input[type=checkbox] { width: auto; }
.btn {
  display: inline-block; background: #EFE9D6; color: var(--emerald-900);
  border: 1px solid #D8CFB6; padding: 10px 16px; border-radius: 10px;
  font-size: 14.5px; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #E6DDC2; }
.btn.primary { background: var(--gold); border-color: var(--gold-dark); color: #241D02; }
.btn.primary:hover { background: #D9B53A; }
.btn.emerald { background: var(--emerald-700); border-color: var(--emerald-700); color: #fff; }
.btn.emerald:hover { background: var(--emerald-600); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.danger { background: var(--red-bg); color: var(--red); border-color: #F3C2C2; }
.alert { background: var(--emerald-100); border: 1px solid #86C9A8; padding: 11px 13px; border-radius: 10px; margin-bottom: 14px; }
.alert.err { background: var(--red-bg); border-color: #F3C2C2; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- tables, pills, dots ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 8px 6px; color: var(--emerald-900); border-bottom: 2px solid var(--line); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em; }
td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: #FBF8EF; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; background: #EFE9D6; color: var(--emerald-900); }
.pill.st-new { background: #DCEFE4; color: var(--emerald-700); }
.pill.st-replied { background: #E4E7F7; color: #3730A3; }
.pill.st-interested { background: #FDF0CE; color: #92400E; }
.pill.st-joined, .pill.st-paid { background: #D1FAE5; color: #166534; }
.pill.st-closed { background: #F1F5F9; color: #64748B; }
.pill.sc-hot { background: var(--red-bg); color: var(--red); }
.pill.sc-warm { background: #FDF0CE; color: #92400E; }
.pill.sc-cold { background: #F1F5F9; color: #64748B; }
.pill.off { background: var(--red-bg); color: var(--red); }
.pill.gold { background: var(--gold); color: #241D02; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: middle; }
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }
.dot.warn { background: var(--amber); }
.dot.live { background: var(--green); box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.5); animation: livepulse 2s infinite; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.45); } 70% { box-shadow: 0 0 0 7px rgba(21, 128, 61, 0); } 100% { box-shadow: 0 0 0 0 rgba(21, 128, 61, 0); } }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select, .filters input { width: auto; flex: 1; min-width: 140px; margin: 0; }
.codebox { background: var(--emerald-950); color: #EDEBE2; padding: 11px 12px; border-radius: 10px; font-family: monospace; font-size: 13px; word-break: break-all; }
.health td:first-child { width: 240px; font-weight: 600; }

/* ---------- inbox / chat ---------- */
.inbox { display: grid; grid-template-columns: 330px 1fr; gap: 14px; align-items: start; }
.chatlist a.item { display: block; padding: 11px 12px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; border-radius: 10px; }
.chatlist a.item:hover { background: #FBF8EF; }
.chatlist a.item.active { background: #F3EEDB; border-left: 3px solid var(--gold); }
.chatlist a.item .unread { float: right; background: var(--red); color: #fff; border-radius: 12px; padding: 1px 9px; font-size: 11px; font-weight: 700; }
.chatlist a.item .unread.pulse { animation: livepulse 2s infinite; }
.backbtn { display: none; }
.chatbox { max-height: 55vh; overflow-y: auto; padding: 8px 4px; }
.bubble { max-width: 85%; padding: 10px 13px; border-radius: 14px; margin: 9px 0; white-space: pre-wrap; word-break: break-word; box-shadow: var(--shadow); }
.bubble.in { background: #fff; border: 1px solid var(--line); margin-right: auto; border-bottom-left-radius: 4px; }
.bubble.out { background: var(--emerald-700); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.bubble.out .meta { color: #BFE3CF; }
.bubble .meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.replybox textarea { margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 4px 0 10px; }
.chip {
  background: #F3EEDB; border: 1px solid var(--gold); color: var(--emerald-900);
  border-radius: 20px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.chip:hover { background: var(--gold-soft); }
.ai-pill { display: inline-block; padding: 6px 14px; border-radius: 20px; font-weight: 800; font-size: 13px; border: 0; cursor: pointer; }
.ai-pill.on { background: var(--emerald-700); color: #fff; }
.ai-pill.off { background: var(--red); color: #fff; }

/* ---------- dashboard chart ---------- */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding: 8px 4px 0; }
.chart .barwrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart .bar { width: 100%; max-width: 44px; min-height: 4px; border-radius: 7px 7px 0 0; background: linear-gradient(180deg, var(--gold), var(--emerald-600)); }
.chart .bar.zero { background: #E7DFCB; }
.chart .barval { font-size: 12px; font-weight: 800; color: var(--emerald-900); }
.chart .barlab { font-size: 11px; color: var(--muted); margin-top: 4px; }
.followup-row { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.followup-row:last-child { border-bottom: 0; }
.followup-row .who { flex: 1; min-width: 0; }
.followup-row .who b { display: block; }
.empty { text-align: center; padding: 26px 12px; color: var(--muted); }
.empty .big { font-size: 34px; display: block; margin-bottom: 6px; }

/* ---------- pipeline board ---------- */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: start; }
.pcol { background: var(--ivory-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px; min-height: 120px; }
.pcol h4 { margin: 2px 4px 10px; font-size: 15px; color: var(--emerald-900); display: flex; justify-content: space-between; align-items: center; }
.pcol h4 .count { background: var(--emerald-900); color: var(--gold-soft); border-radius: 12px; padding: 1px 9px; font-size: 12px; font-family: "Plus Jakarta Sans", sans-serif; }
.kcard { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 12px; padding: 11px 12px; margin-bottom: 9px; box-shadow: var(--shadow); }
.kcard.hot { border-left-color: var(--red); }
.kcard a.title { font-weight: 800; color: var(--emerald-900); text-decoration: none; font-size: 14.5px; }
.kcard .kmeta { font-size: 12.5px; color: var(--muted); margin: 3px 0 8px; }
.kcard select { padding: 7px 9px; font-size: 13.5px; margin: 0 0 6px; }
.kcard .btn { width: 100%; text-align: center; }

/* ---------- login ---------- */
.login-wrap { max-width: 430px; margin: 8vh auto 0; padding: 0 16px; }
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand .mark { font-size: 44px; }
.login-brand h1 { margin: 6px 0 2px; font-size: 30px; color: var(--emerald-900); }
.login-brand p { margin: 0; color: var(--muted); }
.login-card { background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }

/* ---------- mobile nav ---------- */
.mobilenav { display: none; }
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { padding: 0 0 84px; }
  .mobilebar {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--emerald-900); color: #F5EFD8; padding: 12px 16px;
    position: sticky; top: 0; z-index: 20;
  }
  .mobilebar .mbrand { font-family: "Marcellus", serif; font-size: 17px; }
  .mobilebar a { color: var(--gold-soft); font-weight: 700; font-size: 13px; text-decoration: none; }
  .pagehead { padding: 16px 16px 0; }
  .pagehead h2 { font-size: 23px; }
  .content { padding: 0 14px; }
  .inbox { grid-template-columns: 1fr; }
  .inbox.show-thread .chatlist { display: none; }
  .inbox:not(.show-thread) .thread { display: none; }
  .backbtn { display: inline-block; }
  .board { display: flex; overflow-x: auto; padding-bottom: 8px; }
  .pcol { flex: 0 0 262px; }
  .mobilenav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--emerald-950); border-top: 2px solid var(--gold);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobilenav a { flex: 1; text-align: center; color: #CFE3D6; text-decoration: none; font-size: 12.5px; font-weight: 700; padding: 7px 2px; border-radius: 8px; }
  .mobilenav a:active { background: rgba(201, 162, 39, 0.2); color: var(--gold-soft); }
}
@media (prefers-reduced-motion: reduce) {
  .dot.live, .chatlist a.item .unread.pulse { animation: none; }
}

/* ---------- v6: staff, waiting, ticks, notes/tags, summary, missed ---------- */
.pill.role-staff { background: #E4E7F7; color: #3730A3; }
.pill.esc-pill { background: #FDE68A; color: #92400E; }
.waiting-badge { display: inline-block; background: var(--red-bg); color: var(--red); font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 20px; margin-left: 4px; }
.tick { color: #94A3B8; font-size: 13px; letter-spacing: -2px; margin-left: 4px; }
.tick.read { color: #53BDEB; }
.tag-pill { display: inline-block; background: #FDF0CE; color: #92400E; border: 1px solid #F5D67B; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; margin: 2px 2px 2px 0; }
button.tag-pill.tag-del { cursor: pointer; background: #FDF0CE; }
button.tag-pill.tag-del:hover { background: #FDE68A; }
.note { background: #FFFBEB; border: 1px solid #F5D67B; border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; font-size: 14px; }
.missed-card { border: 2px solid var(--red); background: #FFF7F7; }
.summary-card { border: 2px solid var(--gold); }
.summary-nums { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0 12px; }
.summary-nums div { background: #F7F3E8; border: 1px solid var(--gold-soft); border-radius: 10px; padding: 10px 14px; text-align: center; min-width: 90px; }
.summary-nums b { display: block; font-size: 24px; color: var(--emerald-800); }
.summary-nums span { font-size: 12px; color: #6B7280; }
.summary-table { width: 100%; border-collapse: collapse; }
.summary-table th, .summary-table td { padding: 8px 10px; border-bottom: 1px solid #EFE9D6; text-align: left; }
.assign-inline { display: inline-flex; gap: 6px; align-items: center; }
.assign-inline select { padding: 6px 8px; border-radius: 8px; border: 1px solid #D9CFA8; font-size: 13px; max-width: 150px; }
.checkrow { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin: 10px 0; }
.checkrow input { margin-top: 3px; }
