:root {
  --bg: #f4f6fa; --panel: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --side: #0b1324; --side-ink: #cbd5e1; --accent: #2563eb; --accent-soft: #dbeafe;
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --radius: 12px;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--accent); }
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* Sidebar */
.side { background: var(--side); color: var(--side-ink); padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { color: #fff; font-weight: 700; font-size: 16px; padding: 0 8px 4px; }
.brand small { display: block; color: #64748b; font-weight: 500; font-size: 12px; margin-top: 2px; }
.mode { margin: 12px 8px 18px; font-size: 11px; padding: 6px 8px; border-radius: 8px; }
.mode.live { background: #052e16; color: #86efac; }
.mode.demo { background: #422006; color: #fcd34d; }
.nav-h { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #475569; margin: 16px 8px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-ink); text-decoration: none; }
.nav a:hover { background: #111c33; }
.nav a.active { background: #1e293b; color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.user-box { margin: 24px 8px 0; padding-top: 14px; border-top: 1px solid #1e293b; font-size: 13px; }
.user-box button { background: #111c33; color: var(--side-ink); border-color: #1e293b; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--side); }
.login { width: min(400px, 100%); background: #fff; border-radius: 16px; padding: 30px 28px; }
.login h1 { font-size: 20px; }
.login .err-box { background: #fee2e2; color: #991b1b; border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 12px; display: none; }
.badge { margin-left: auto; background: var(--bad); color: #fff; font-size: 11px; border-radius: 999px; padding: 1px 7px; }

/* Main */
main { padding: 28px 32px 60px; max-width: 1400px; width: 100%; min-width: 0; }
td select { min-width: 110px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
h1 { font-size: 24px; margin: 0; }
.sub { color: var(--muted); margin-top: 4px; max-width: 760px; line-height: 1.5; }
h2 { font-size: 16px; margin: 0 0 12px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; }
.two { grid-template-columns: 1.6fr 1fr; align-items: start; }
.divs { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.div-card { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.div-card:hover { border-color: #94a3b8; box-shadow: 0 4px 14px rgba(15,23,42,.06); }
.div-top { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.code { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; flex: none; }
.div-top b { display: block; }
.div-top span { color: var(--muted); font-size: 12px; }
.bar { height: 8px; background: #eef2f7; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; }
.stats { display: flex; gap: 10px; font-size: 12px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.last { font-size: 12px; color: var(--muted); margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; line-height: 1.4; }

/* Lists */
.feed { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.feed li { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.4; display: flex; gap: 8px; }
.feed time { color: var(--muted); font-size: 11px; display: block; }
.task { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task .t { font-weight: 600; }
.task .m { color: var(--muted); font-size: 12px; margin-top: 3px; }
.task .actions { display: flex; gap: 6px; align-items: start; flex-wrap: wrap; justify-content: flex-end; }
.err { color: var(--bad); font-size: 12px; margin-top: 4px; }

.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #eef2f7; color: #334155; white-space: nowrap; }
.pill.todo { background: #eef2f7; }
.pill.running { background: #dbeafe; color: #1d4ed8; }
.pill.review, .pill.pending { background: #fef3c7; color: #92400e; }
.pill.done, .pill.approved, .pill.sent, .pill.menang, .pill.disetujui { background: #dcfce7; color: #166534; }
.pill.failed, .pill.rejected, .pill.kalah { background: #fee2e2; color: #991b1b; }
.pill.revision, .pill.ditunda { background: #fce7f3; color: #9d174d; }
.pill.tinggi { background: #fee2e2; color: #991b1b; }
.spin { display: inline-block; width: 10px; height: 10px; border: 2px solid #93c5fd; border-top-color: #1d4ed8; border-radius: 50%; animation: s 0.8s linear infinite; vertical-align: -1px; margin-right: 4px; }
@keyframes s { to { transform: rotate(360deg); } }

/* Buttons & forms */
button, .btn { font: inherit; font-size: 13px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 12px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover { border-color: #94a3b8; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #1d4ed8; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.danger { color: var(--bad); }
button.small { padding: 4px 9px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }
form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 10px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); }
.check input { width: auto; }

/* CRM board */
.board { display: grid; grid-template-columns: repeat(7, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #eef2f7; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.col h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; margin: 2px 4px 2px; display: flex; justify-content: space-between; }
.col .sum { font-size: 11px; color: var(--muted); margin: 0 4px 10px; }
.lead { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; font-size: 12px; }
.lead b { font-size: 13px; display: block; margin-bottom: 4px; }
.lead .val { font-weight: 600; margin-top: 6px; }
.lead select { margin-top: 8px; padding: 4px 6px; font-size: 12px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }

/* Ideas matrix */
.matrix { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quad { border-radius: var(--radius); padding: 12px; min-height: 120px; }
.quad h3 { font-size: 12px; margin: 0 0 8px; }
.quad .chip { background: #fff; border-radius: 8px; padding: 6px 8px; font-size: 12px; margin-bottom: 6px; border: 1px solid var(--line); }
.q1 { background: #dcfce7; } .q2 { background: #dbeafe; } .q3 { background: #fef9c3; } .q4 { background: #f1f5f9; }

/* Markdown */
.md { line-height: 1.6; font-size: 14px; overflow-wrap: anywhere; }
.md h1 { font-size: 20px; } .md h2 { font-size: 17px; margin-top: 20px; } .md h3 { font-size: 15px; }
.md table { margin: 10px 0; } .md td, .md th { border: 1px solid var(--line); }
.md blockquote { margin: 10px 0; padding: 8px 12px; background: #fffbeb; border-left: 3px solid var(--warn); border-radius: 6px; }
.md code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }
.md pre { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow-x: auto; }
.md pre code { background: none; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal.open { display: flex; }
.modal .box { background: #fff; border-radius: 14px; width: min(900px, 100%); padding: 24px 28px; position: relative; }
.modal .x { position: absolute; right: 14px; top: 12px; border: 0; font-size: 22px; background: none; }
.sources { font-size: 12px; margin-top: 18px; border-top: 1px solid var(--line); padding-top: 10px; }
.sources a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); padding: 20px 0; text-align: center; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; transition: opacity .2s; z-index: 60; }
.toast.show { opacity: 1; }
.muted { color: var(--muted); }
.mt { margin-top: 16px; }
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .two { grid-template-columns: 1fr; }
  main { padding: 20px 16px; }
}

/* Proyek */
.bar .ideal { position: absolute; top: -3px; width: 2px; height: 16px; background: #0f172a; border-radius: 1px; }
.bar { overflow: visible; }
.bar > i { max-width: 100%; }
.ms { padding: 14px 0; border-bottom: 1px solid var(--line); }
.ms:last-child { border-bottom: 0; }
.ms-task { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 13px; padding: 6px 0 6px 14px; border-left: 2px solid var(--line); margin-top: 6px; }

/* Gantt */
.gantt { overflow-x: auto; }
.g-row { display: grid; grid-template-columns: 220px 1fr; align-items: center; min-width: 640px; }
.g-row + .g-row { border-top: 1px dashed var(--line); }
.g-label { font-size: 12px; padding: 8px 10px 8px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-track { position: relative; height: 34px; }
.g-head .g-track { height: 22px; }
.g-head span { position: absolute; top: 2px; font-size: 11px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 4px; }
.g-bar { position: absolute; top: 9px; height: 16px; border: 1px solid; border-radius: 5px; overflow: hidden; }
.g-bar > i { display: block; height: 100%; }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: #dc2626; opacity: .7; z-index: 1; }
@media (max-width: 900px) { .g-row { grid-template-columns: 130px 1fr; } }
.pill.usulan { background: #ede9fe; color: #5b21b6; }
