:root {
  --brand: #0d9488; --brand-d: #0f766e; --brand-l: #ccfbf1; --accent: #f59e0b;
  --bg: #f6f7f9; --panel: #ffffff; --line: #e5e7eb; --text: #111827; --muted: #6b7280;
  --in: #ffffff; --out: #d9fdd3; --note: #fef9c3; --danger: #dc2626;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--brand-d); }
button, input, select, textarea { font: inherit; }
.btn { border: 0; background: var(--brand); color: #fff; padding: 9px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.btn:hover { background: var(--brand-d); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f3f4f6; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.danger { background: var(--danger); }
.btn.ai { background: linear-gradient(135deg, #7c3aed, #0d9488); }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fff; width: 100%; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-l); border-color: var(--brand); }
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 5px; }
.muted { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.tag { display: inline-block; background: var(--brand-l); color: var(--brand-d); padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; margin: 1px 2px 1px 0; }
.tag.gray { background: #f3f4f6; color: var(--muted); }
.tag.ai { background: #ede9fe; color: #6d28d9; }
.badge { background: var(--brand); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.row { display: flex; gap: 10px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 99; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Layout aplikasi ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }
.side { background: #0b3b37; color: #d1fae5; display: flex; flex-direction: column; padding: 16px 10px; }
.logo { font-weight: 800; font-size: 20px; color: #fff; padding: 4px 10px 18px; letter-spacing: -.02em; }
.logo span { color: var(--accent); }
.nav a { display: flex; justify-content: space-between; align-items: center; color: #d1fae5; text-decoration: none; padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a.on { background: rgba(255,255,255,.14); color: #fff; }
.side .foot { margin-top: auto; font-size: 12px; padding: 10px; color: #99f6e4; }
.main { overflow: auto; }
.page { padding: 24px 28px; max-width: 1200px; }
.page h1 { margin: 0 0 4px; font-size: 22px; }
.page .sub { color: var(--muted); margin-bottom: 20px; }

/* ---------- Inbox ---------- */
.inbox { display: grid; grid-template-columns: 320px 1fr 300px; height: 100vh; }
.inbox .list { border-right: 1px solid var(--line); background: #fff; display: flex; flex-direction: column; min-height: 0; }
.inbox .list .head { padding: 14px; border-bottom: 1px solid var(--line); }
.filters { display: flex; gap: 6px; margin-top: 10px; }
.filters button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.filters button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.convs { overflow: auto; flex: 1; }
.conv { padding: 12px 14px; border-bottom: 1px solid #f3f4f6; cursor: pointer; display: flex; gap: 10px; }
.conv:hover { background: #f9fafb; }
.conv.on { background: #ecfdf5; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-l); color: var(--brand-d); display: grid; place-items: center; font-weight: 700; flex: none; }
.conv .meta { flex: 1; min-width: 0; }
.conv .name { font-weight: 600; display: flex; justify-content: space-between; }
.conv .last { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv time { font-size: 11px; color: var(--muted); font-weight: 400; }
.chat { display: flex; flex-direction: column; min-height: 0; 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='%23d6cfc4'/%3E%3C/svg%3E"); }
.chat .top { background: #fff; padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.msgs { flex: 1; overflow: auto; padding: 18px 6%; display: flex; flex-direction: column; gap: 4px; }
.bubble { max-width: 70%; padding: 7px 10px 5px; border-radius: 9px; box-shadow: 0 1px 1px rgba(0,0,0,.08); white-space: pre-wrap; word-wrap: break-word; line-height: 1.4; }
.bubble.in { background: var(--in); align-self: flex-start; }
.bubble.out { background: var(--out); align-self: flex-end; }
.bubble.note { background: var(--note); align-self: center; font-size: 13px; border: 1px dashed #eab308; }
.bubble .info { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 2px; }
.tick.read { color: #3b82f6; }
.tick.failed { color: var(--danger); }
.composer { background: #f0f2f5; padding: 10px 14px; position: relative; }
.composer .ai-box { background: #faf5ff; border: 1px solid #ddd6fe; border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.composer textarea { resize: none; min-height: 44px; max-height: 140px; }
.composer.note-mode textarea { background: var(--note); }
.qr-pop { position: absolute; bottom: 100%; left: 14px; right: 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 220px; overflow: auto; }
.qr-pop div { padding: 8px 12px; cursor: pointer; }
.qr-pop div:hover, .qr-pop div.on { background: #ecfdf5; }
.empty { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 20px; }
.detail { background: #fff; border-left: 1px solid var(--line); overflow: auto; padding: 16px; }
.detail h3 { margin: 6px 0 2px; }
.summary { white-space: pre-wrap; background: #faf5ff; border: 1px solid #ddd6fe; border-radius: 10px; padding: 10px; font-size: 13px; }

/* ---------- Pipeline ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; }
.col { background: #eef0f3; border-radius: 12px; padding: 10px; min-height: 300px; }
.col h4 { margin: 2px 4px 10px; display: flex; justify-content: space-between; font-size: 13px; }
.col.drag { outline: 2px dashed var(--brand); }
.deal { background: #fff; border-radius: 10px; padding: 10px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.06); cursor: grab; }
.deal b { display: block; }

/* ---------- Statistik ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat .v { font-size: 26px; font-weight: 800; margin-top: 4px; }
.stat .l { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; font-size: 10px; color: var(--muted); height: 100%; }
.bars .b i { display: block; width: 100%; border-radius: 4px 4px 0 0; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 14px; padding: 22px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.modal h2 { margin-top: 0; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { flex-direction: row; overflow-x: auto; padding: 8px; }
  .side .logo, .side .foot { display: none; }
  .nav { display: flex; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .detail { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .page { padding: 16px; }
}
.btn { white-space: nowrap; }
@media (max-width: 1280px) and (min-width: 901px) {
  .app { grid-template-columns: 190px 1fr; }
  .inbox { grid-template-columns: 260px 1fr 250px; }
}
