:root {
  --navy: #0b1e3f;
  --navy-2: #102a54;
  --navy-3: #173a70;
  --gold: #c9a24a;
  --gold-2: #e8c97a;
  --gold-soft: #f6ecd2;
  --bg: #f4f2ec;
  --card: #ffffff;
  --text: #16223a;
  --muted: #6b7486;
  --line: #e4e0d5;
  --ok: #1f8a5b;
  --warn: #c27a00;
  --bad: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(11, 30, 63, .06), 0 6px 18px rgba(11, 30, 63, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
@font-face { font-family: 'Poppins'; src: url('/fonts/Poppins-Regular.ttf'); font-weight: 400; }
@font-face { font-family: 'Poppins'; src: url('/fonts/Poppins-Bold.ttf'); font-weight: 700; }
a { color: var(--navy-3); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { align-self: start; background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%); color: #dfe6f3; padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { padding: 4px 10px 22px; border-bottom: 1px solid rgba(232, 201, 122, .25); margin-bottom: 14px; }
.brand b { display: block; font-size: 19px; color: #fff; letter-spacing: .3px; }
.brand small { color: var(--gold-2); font-size: 12px; }
.brand img { max-width: 150px; max-height: 46px; display: block; margin-bottom: 6px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #c9d3e6; text-decoration: none; margin-bottom: 2px; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.on { background: linear-gradient(90deg, rgba(201, 162, 74, .28), rgba(201, 162, 74, .08)); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav .ic { width: 20px; text-align: center; opacity: .9; }
.nav .badge { margin-left: auto; }
.side .foot { margin-top: auto; font-size: 12px; color: #9fb0cc; padding: 10px; }
.side .foot button { background: none; border: 1px solid rgba(255,255,255,.2); color: #dfe6f3; border-radius: 8px; padding: 6px 10px; margin-top: 8px; }

main { padding: 26px 30px 90px; max-width: 1280px; width: 100%; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.top h1 { font-size: 22px; margin: 0; }
.top .sp { flex: 1; }
.sim { background: var(--gold-soft); border: 1px solid var(--gold); color: #6d5313; padding: 10px 14px; border-radius: 12px; margin-bottom: 16px; font-size: 13px; }

.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; border: 1px solid var(--line); min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card h3 .sp { flex: 1; }
.kpi .v { font-size: 26px; font-weight: 700; color: var(--navy); }
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi { border-top: 3px solid var(--gold); }

.btn { border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--gold); }
.btn.pri { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.pri:hover { background: var(--navy-3); }
.btn.gold { background: linear-gradient(135deg, var(--gold), var(--gold-2)); border-color: var(--gold); color: var(--navy); }
.btn.bad { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; background: #eef0f5; color: var(--muted); white-space: nowrap; }
.pill.ok { background: #e3f4ec; color: var(--ok); }
.pill.warn { background: #fdf1dc; color: var(--warn); }
.pill.bad { background: #fbe5e2; color: var(--bad); }
.pill.navy { background: var(--navy); color: #fff; }
.pill.gold { background: var(--gold-soft); color: #7a5b12; }
.badge { background: var(--gold); color: var(--navy); border-radius: 99px; font-size: 11px; font-weight: 700; padding: 1px 7px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
.tbl-wrap { overflow-x: auto; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field input, .field select, .field textarea, .inp { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fff; }
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .inp:focus { outline: 2px solid rgba(201,162,74,.35); border-color: var(--gold); }
.check { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.hint { font-size: 12px; color: var(--muted); }

.list-item { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.list-item:last-child { border-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pre { white-space: pre-wrap; font-size: 13px; line-height: 1.55; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

/* Konten */
.content-card { display: grid; grid-template-columns: 260px 1fr; gap: 18px; }
.phone { background: #000; border-radius: 22px; padding: 8px; aspect-ratio: 9/16; display: flex; align-items: center; justify-content: center; color: #889; font-size: 12px; text-align: center; overflow: hidden; }
.phone video { width: 100%; height: 100%; object-fit: cover; border-radius: 16px; }
.scenes td { font-size: 12.5px; }
.copy { cursor: pointer; }

/* Chat */
.chat-layout { display: grid; grid-template-columns: 330px 1fr; gap: 14px; height: calc(100vh - 120px); }
.chat-list { overflow-y: auto; padding: 8px; }
.chat-row { padding: 10px; border-radius: 10px; cursor: pointer; display: flex; gap: 10px; }
.chat-row:hover { background: #f7f4ec; }
.chat-row.on { background: var(--gold-soft); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--navy); color: var(--gold-2); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.chat-main { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; background: #efeae0; }
.msg { max-width: 72%; padding: 8px 12px; border-radius: 12px; margin-bottom: 8px; white-space: pre-wrap; line-height: 1.45; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.msg.in { background: #fff; border-top-left-radius: 3px; }
.msg.out { background: #dfeefe; margin-left: auto; border-top-right-radius: 3px; }
.msg.out.bos { background: var(--gold-soft); }
.msg.out.sistem { background: #ececec; }
.msg .meta { font-size: 10.5px; color: var(--muted); margin-top: 3px; text-align: right; }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: #fff; }
.composer textarea { flex: 1; resize: none; height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.lead-info { padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fbfaf6; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.lead-info .inp { padding: 6px 8px; font-size: 12.5px; }

/* Pipeline */
.pipeline { display: grid; grid-template-columns: repeat(6, minmax(190px, 1fr)); gap: 10px; overflow-x: auto; }
.col { background: #ebe7dc; border-radius: 12px; padding: 10px; min-height: 200px; }
.col h4 { margin: 0 0 8px; font-size: 13px; text-transform: capitalize; display: flex; justify-content: space-between; }
.lead-card { background: #fff; border-radius: 10px; padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; font-size: 12.5px; }

/* Media */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-item { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.media-item .th { aspect-ratio: 1; background: #111; display: flex; align-items: center; justify-content: center; color: #ccc; }
.media-item .th img, .media-item .th video { width: 100%; height: 100%; object-fit: cover; }
.media-item .b { padding: 8px; font-size: 11.5px; }

/* Grafik mini */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 110px; padding-top: 6px; }
.bars .bar { flex: 1; background: linear-gradient(180deg, var(--gold-2), var(--gold)); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars .bar.c { background: var(--navy-3); }
.bars-x { display: flex; gap: 4px; font-size: 10px; color: var(--muted); }
.bars-x span { flex: 1; text-align: center; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 30% 20%, var(--navy-3), var(--navy) 60%); padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login h2 { margin: 0 0 4px; color: var(--navy); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 99; max-width: 90vw; font-size: 13px; }
.toast.err { background: var(--bad); }
.modal-bg { position: fixed; inset: 0; background: rgba(11, 30, 63, .45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; max-width: 760px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 22px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 14px; font-weight: 600; font-size: 12.5px; }
.tabs button.on { background: var(--navy); color: #fff; border-color: var(--navy); }

.mob-nav { display: none; }
.mob-only { display: none !important; }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sim { font-size: 12px; padding: 8px 12px; }
  .side { display: none; }
  main { padding: 16px 14px 90px; }
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g3, .g2 { grid-template-columns: 1fr; }
  .content-card { grid-template-columns: 1fr; }
  .phone { max-width: 240px; margin: 0 auto; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-layout.has-chat .chat-list-card { display: none; }
  .chat-layout:not(.has-chat) .chat-main { display: none; }
  .msgs { height: 55vh; }
  .lead-info { grid-template-columns: 1fr 1fr; }
  .msg { max-width: 88%; }
  .mob-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--navy); z-index: 40; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .mob-nav a { color: #b9c5dc; text-decoration: none; font-size: 10.5px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 6px; border-radius: 8px; position: relative; }
  .mob-nav a.on { color: var(--gold-2); }
  .mob-nav .ic { font-size: 18px; }
  .mob-nav .badge { position: absolute; top: -2px; right: 0; font-size: 9px; }
  .top h1 { font-size: 19px; }
  .mob-only { display: inline-flex !important; }
}
