:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --line: #e8edf5;
  --text: #061532;
  --muted: #7b8497;
  --orange: #ff5a3d;
  --orange-2: #ff7a45;
  --green: #00b979;
  --red: #ff4d6d;
  --blue: #2563eb;
  --shadow: 0 12px 30px rgba(18, 29, 58, 0.08);
  --radius: 22px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.sidebar {
  position: fixed;
  inset: 18px auto 18px 18px;
  width: 250px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 28px; font-weight: 900; margin-bottom: 42px; }
.brand-mark { color: var(--orange); transform: rotate(-12deg); display: inline-block; }
.menu-title { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: 1.4px; margin: 0 0 12px 12px; }
.menu-item {
  border: 0;
  background: transparent;
  color: #161d2f;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 14px;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
  text-align: left;
  margin-bottom: 8px;
}
.menu-item span { width: 34px; height: 34px; border-radius: 12px; background: #f0f2f7; display: grid; place-items: center; color: #7a8294; }
.menu-item.active { color: white; background: linear-gradient(135deg, var(--orange), var(--orange-2)); box-shadow: 0 12px 24px rgba(255, 90, 61, .25); }
.menu-item.active span { background: rgba(255,255,255,.22); color: white; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--line); padding-top: 18px; }
.menu-item.muted { color: #2d3446; }

.main { margin-left: 300px; padding: 36px 28px 60px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 26px; }
h1 { margin: 0; font-size: 28px; }
p { margin: 0; }
.topbar p { color: var(--muted); margin-top: 6px; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.select, input[type="date"], input[type="text"] {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  border-radius: 13px;
  padding: 13px 16px;
  font-weight: 700;
  outline: none;
}
.btn {
  border: 0;
  padding: 13px 18px;
  border-radius: 13px;
  font-weight: 900;
  cursor: pointer;
  background: white;
  color: var(--text);
  box-shadow: 0 4px 10px rgba(18,29,58,.08);
}
.btn.primary { background: linear-gradient(135deg, var(--orange), var(--orange-2)); color: white; }
.btn.ghost { background: white; border: 1px solid var(--line); box-shadow: none; }
.btn.danger { color: var(--red); background: #fff1f4; box-shadow: none; }
.btn.small { padding: 8px 12px; font-size: 12px; }
.btn.full { width: 100%; }

.grid { display: grid; gap: 22px; }
.grid.cards { grid-template-columns: 1.25fr .6fr .6fr 1.1fr; }
.grid.bottom { grid-template-columns: 1fr 2fr; margin-top: 22px; align-items: start; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  overflow: hidden;
}
.card.soft-green { background: linear-gradient(135deg, #f1fff9, #ebfff7); }
.card.orange { background: linear-gradient(135deg, #ff6848, #ff874d); color: white; }
.card-title { font-size: 15px; color: var(--muted); font-weight: 800; margin-bottom: 10px; }
.card.orange .card-title { color: rgba(255,255,255,.8); }
.big-number { font-size: 34px; font-weight: 950; letter-spacing: -.8px; }
.mid-number { font-size: 25px; font-weight: 950; }
.kicker { font-size: 12px; color: var(--muted); margin-top: 8px; }
.card.orange .kicker { color: rgba(255,255,255,.8); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 7px 10px; border-radius: 999px; background: #eef2ff; color: var(--blue); font-size: 12px; font-weight: 900; }
.pill.green { background: #e8fff6; color: var(--green); }
.pill.red { background: #fff0f3; color: var(--red); }
.pill.orange { background: #fff2ec; color: var(--orange); }

.split-card { display: grid; gap: 12px; margin-top: 18px; }
.stat-line { display: flex; justify-content: space-between; align-items: center; padding: 14px; background: #f9fafc; border-radius: 14px; }
.click-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.click-box { background: #fafbfe; border-radius: 16px; padding: 14px; }
.click-box strong { display: block; font-size: 18px; margin: 8px 0 2px; }
.mini-progress { height: 4px; background: #e8edf5; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.mini-progress span { display: block; height: 100%; background: var(--orange); border-radius: 99px; }
.mini-progress.blue span { background: #3b82f6; }

 .bars { height: 210px; display: flex; align-items: end; gap: 14px; padding-top: 22px; border-bottom: 1px solid var(--line); }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: end; height: 100%; gap: 8px; position: relative; }
.bar { width: 100%; max-width: 38px; min-height: 4px; background: #35cdbd; border-radius: 7px 7px 0 0; }
.bar-label { font-size: 11px; color: var(--muted); white-space: nowrap; }

.profit-bars {
  align-items: stretch;
  border-bottom: 0;
  padding-top: 8px;
  padding-bottom: 2px;
}
.profit-wrap {
  justify-content: flex-end;
}
.bar-stack {
  position: relative;
  width: 100%;
  height: 178px;
  display: block;
}
.bar-zero {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: #d8deea;
}
.profit-bar {
  position: absolute;
  left: 50%;
  width: min(70%, 38px);
  min-height: 5px;
  transform: translateX(-50%);
  border-radius: 9px 9px 0 0;
  transition: opacity .15s ease, transform .15s ease;
}
.profit-bar.win {
  background: #35cdbd;
}
.profit-bar.loss {
  background: #ff5470;
  border-radius: 0 0 9px 9px;
}
.bar-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 18px);
  transform: translate(-50%, -6px);
  width: max-content;
  max-width: 260px;
  display: none;
  background: #0f172a;
  color: white;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .22);
  z-index: 6;
  pointer-events: none;
  font-size: 11px;
  line-height: 1.35;
}
.bar-tooltip strong,
.bar-tooltip span {
  display: block;
}
.bar-tooltip span {
  margin-top: 3px;
  color: rgba(255,255,255,.84);
  font-weight: 800;
}
.profit-wrap:hover .bar-tooltip {
  display: block;
}
.profit-wrap:hover .profit-bar {
  opacity: .82;
  transform: translateX(-50%) scaleX(1.08);
}

.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.section-head h2 { margin: 0; font-size: 20px; }
.winning-list { display: grid; gap: 14px; }
.win-row { display: grid; grid-template-columns: 1fr auto; gap: 14px; font-weight: 800; }
.win-row small { color: var(--muted); font-weight: 700; }
.win-bar { grid-column: 1 / -1; height: 5px; background: #f0f2f7; border-radius: 99px; overflow: hidden; margin-top: -8px; }
.win-bar span { display: block; height: 100%; background: var(--orange); border-radius: 99px; }

.table-card { padding: 0; }
.table-actions { display: flex; gap: 8px; align-items: center; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th { color: var(--muted); background: #fafbfe; text-align: left; font-size: 12px; letter-spacing: .6px; padding: 16px 18px; }
td { padding: 16px 18px; border-top: 1px solid var(--line); font-weight: 750; }
tr.highlight { background: #eef6ff; color: #00368f; }
.check-cell { width: 44px; }
.tag-cell { display: flex; align-items: center; gap: 10px; }
.expand-btn { border: 0; background: #f0f3f9; width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-weight: 900; }
.subtable-row td { padding: 0 18px 18px 58px; background: #fbfdff; }
.subtable { min-width: auto; border-left: 2px solid #93c5fd; margin: 12px 0; }
.subtable th, .subtable td { padding: 10px 14px; font-size: 12px; }

.detail-top { margin-bottom: 22px; }
.backline { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.detail-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.detail-cards .card { padding: 20px; }

.modal { position: fixed; inset: 0; background: rgba(5,9,18,.45); backdrop-filter: blur(8px); display: none; align-items: center; justify-content: center; z-index: 20; padding: 24px; }
.modal.show { display: flex; }
.modal-card { width: min(560px, 100%); background: white; border-radius: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.22); padding: 26px; position: relative; }
.modal-card h2 { margin: 0 0 18px; }
.modal-close { position: absolute; right: 18px; top: 16px; border: 0; background: transparent; font-size: 26px; cursor: pointer; }
.upload-form { display: grid; gap: 11px; }
.upload-form label { font-size: 13px; color: #4b5568; font-weight: 900; }
.file-grid { display: grid; gap: 12px; margin: 4px 0 12px; }
.file-box { border: 1.5px dashed #ff9a86; border-radius: 16px; padding: 16px; background: #fff8f6; display: grid; gap: 6px; cursor: pointer; }
.file-box span { color: var(--muted); font-size: 12px; }
.file-box input { margin-top: 8px; }
.small-note { color: var(--muted); font-size: 12px; line-height: 1.4; }
.empty { padding: 42px; text-align: center; color: var(--muted); }
.alert { padding: 14px 16px; border-radius: 16px; margin-bottom: 18px; font-weight: 800; }
.alert.error { background: #fff0f3; color: var(--red); }
.alert.success { background: #e9fff7; color: var(--green); }

@media (max-width: 1100px) {
  .sidebar { position: static; width: auto; border-radius: 0; margin: 0; inset: auto; }
  .main { margin-left: 0; padding: 22px; }
  .grid.cards, .grid.bottom, .detail-cards { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
}

/* V3: gabungan laporan bisa expand per tag seperti Open9 */
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #fbfdff; }
.drag-icon { color: #8b95a7; font-size: 16px; width: 28px; text-align: center; display: inline-block; }
.history-box { border-left: 2px solid #93c5fd; padding: 10px 0 6px 18px; margin: 8px 0 4px; }
.history-title { color: #2563eb; font-weight: 900; font-size: 13px; margin: 0 0 10px; }
.sold-detail { color: #ff6a3d; font-weight: 900; font-size: 13px; margin-top: 12px; display: inline-flex; align-items: center; gap: 10px; }
.sold-detail span { background: #f2f5fa; color: #8b95a7; padding: 5px 9px; border-radius: 8px; font-size: 11px; }
.subtable { width: 100%; min-width: 780px; border-collapse: collapse; background: white; }
.subtable th { background: white; color: #98a1b2; font-size: 11px; padding: 12px 14px; }
.subtable td { background: white; padding: 12px 14px; font-size: 13px; }
.subtable small { color: #98a1b2; margin-left: 6px; font-weight: 700; }

/* V4: edit nama laporan */
.action-cell { white-space: nowrap; display: flex; gap: 8px; align-items: center; }
.detail-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* V5: rapikan Produk Winning dan naikkan Riwayat Laporan */
.grid.bottom {
  align-items: stretch;
  margin-top: 18px;
}
.winning-card,
.stat-card {
  height: 318px;
  display: flex;
  flex-direction: column;
}
.winning-card .section-head,
.stat-card .section-head {
  flex: 0 0 auto;
  margin-bottom: 12px;
}
.winning-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 8px;
  gap: 9px;
}
.winning-list::-webkit-scrollbar {
  width: 6px;
}
.winning-list::-webkit-scrollbar-track {
  background: #f0f2f7;
  border-radius: 99px;
}
.winning-list::-webkit-scrollbar-thumb {
  background: #c8cfdd;
  border-radius: 99px;
}
.win-row {
  row-gap: 6px;
  font-size: 14px;
}
.win-bar {
  height: 4px;
  margin-top: -4px;
}
.stat-card .bars {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  padding-top: 10px;
}
.report-history-block {
  margin-top: 16px;
}
@media (max-width: 1100px) {
  .winning-card,
  .stat-card {
    height: auto;
    min-height: 280px;
  }
  .winning-list {
    max-height: 260px;
  }
}

/* V6: edit tanggal laporan + filter/centang semua untuk gabungan */
.history-head {
  padding: 24px 24px 0;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.combine-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.combine-caption {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .4px;
}
.compact-select {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  min-height: 34px;
}
.date-line {
  display: inline-block;
  margin-top: 3px;
  color: #2563eb;
  font-weight: 900;
}
.check-cell input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--orange);
}
.table-card table {
  min-width: 1050px;
}
@media (max-width: 1100px) {
  .history-head {
    padding: 20px 20px 0;
  }
  .combine-toolbar {
    justify-content: flex-start;
  }
}

/* V9: Agen Analisa Marketing Pro */
.agent-card {
  margin-top: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.pro-agent {
  border: 1px solid #dfe7f3;
}
.agent-head {
  align-items: flex-start;
  gap: 14px;
}
.agent-head p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
  font-weight: 700;
}
.agent-executive {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 14px;
}
.agent-score {
  display: grid;
  place-items: center;
  text-align: center;
  border-radius: 20px;
  background: linear-gradient(135deg, #eef6ff, #f3f7ff);
  color: #1d4ed8;
  border: 1px solid #dbeafe;
  padding: 18px;
  font-weight: 900;
}
.pro-score span {
  font-size: 12px;
  letter-spacing: .4px;
  text-transform: uppercase;
}
.pro-score strong {
  font-size: 34px;
  line-height: 1.1;
}
.executive-copy {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: white;
  padding: 18px;
}
.executive-copy strong {
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
}
.executive-copy p {
  color: #334155;
  line-height: 1.55;
  font-weight: 750;
}
.executive-points {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.executive-points span {
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #eef2f7;
  border-radius: 999px;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}
.agent-pro-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin: 14px 0;
}
.agent-kpi-card {
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 4px;
  min-height: 96px;
}
.agent-kpi-card span,
.agent-buckets small,
.agent-table small,
.mini-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
}
.agent-kpi-card strong {
  font-size: 18px;
  font-weight: 950;
  color: #0f172a;
}
.agent-kpi-card small {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}
.agent-kpi-card.green-soft {
  background: #effdf6;
  border-color: #dcfce7;
}
.agent-kpi-card.danger-soft {
  background: #fff4f4;
  border-color: #ffe1e1;
}
.agent-actions,
.pro-actions {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 18px;
  padding: 18px;
}
.agent-actions h3,
.mini-head h3 {
  margin: 0;
  font-size: 16px;
}
.agent-actions ol {
  margin: 12px 0 0;
  padding-left: 20px;
  color: #334155;
  font-weight: 800;
  line-height: 1.55;
}
.agent-actions li + li { margin-top: 8px; }
.agent-buckets,
.pro-buckets {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.bucket-card {
  border: 1px solid #eef2f7;
  background: #f8fafc;
  border-radius: 16px;
  padding: 12px;
  display: grid;
  gap: 5px;
  text-align: left;
  cursor: pointer;
  transition: .15s ease;
  font-family: inherit;
}
.bucket-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15,23,42,.08);
}
.bucket-card.active {
  background: #fff;
  border-color: #ff9a86;
  box-shadow: 0 10px 24px rgba(255, 90, 61, .12);
}
.bucket-card strong {
  font-size: 20px;
  font-weight: 950;
  color: #0f172a;
}
.bucket-card small {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.25;
}
.agent-table-wrap {
  margin-top: 16px;
}
.agent-tools {
  margin-bottom: 10px;
  align-items: flex-end;
  gap: 12px;
}
.agent-tool-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.agent-table-scroll {
  max-height: 560px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}
.pro-scroll {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}
.agent-table-scroll::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
.agent-table-scroll::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 999px;
}
.agent-table-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}
.agent-table {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
  background: white;
  border: 0;
  border-radius: 0;
  overflow: hidden;
}
.agent-table th {
  background: #f5f8fc;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.agent-table td {
  font-size: 12px;
  vertical-align: top;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.pro-table td:nth-child(10),
.next-action-cell {
  min-width: 0;
  white-space: normal;
}
.next-action-cell small {
  display: block;
  line-height: 1.5;
}
.sale-badge,
.shopee-click-badge,
.meta-click-badge {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  margin: 0 0 6px;
  padding: 6px 9px;
  border-radius: 999px;
  font-weight: 950;
  line-height: 1.2;
  white-space: normal;
}
.sale-badge {
  background: #e8fff6;
  color: var(--green);
}
.shopee-click-badge {
  background: #fff2ec;
  color: var(--orange);
}
.meta-click-badge {
  background: #eef6ff;
  color: var(--blue);
}
.agent-product {
  display: inline-block;
  margin-top: 3px;
  max-width: 100%;
}
.agent-empty {
  padding: 20px;
  text-align: left;
}
.pill.blue { background: #eef2ff; color: var(--blue); }
@media (max-width: 1280px) {
  .agent-pro-grid,
  .agent-buckets,
  .pro-buckets {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 1100px) {
  .agent-executive,
  .agent-pro-grid,
  .agent-buckets,
  .pro-buckets {
    grid-template-columns: 1fr;
  }
  .agent-card {
    padding: 18px;
  }
  .agent-tool-actions {
    justify-content: flex-start;
  }
}

/* V10.4: filter seleksi tag pada mode gabungan */
.tag-filter-box {
  margin: 14px 24px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfdff;
  display: grid;
  gap: 10px;
}
.tag-filter-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tag-filter-select {
  min-width: min(520px, 100%);
  flex: 1 1 360px;
}
.tag-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tag-chip {
  border: 1px solid #dbeafe;
  background: #eef6ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 8px 10px;
  font-weight: 900;
  font-size: 12px;
  cursor: pointer;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag-chip span {
  margin-left: 6px;
  color: #ef4444;
}
.tag-filter-note {
  color: var(--muted);
  font-weight: 800;
}
@media (max-width: 900px) {
  .tag-filter-main {
    align-items: stretch;
  }
  .tag-filter-select,
  .tag-filter-main .btn {
    width: 100%;
  }
}


/* =========================================
   FITUR COLLAPSIBLE SIDEBAR (BUKA-TUTUP)
========================================= */
.sidebar {
  transition: transform 0.3s ease, width 0.3s ease, padding 0.3s ease;
}

/* Kelas saat sidebar disembunyikan */
.sidebar.collapsed {
  transform: translateX(-100%);
  width: 0;
  padding: 0;
  overflow: hidden;
  border: none;
}

.main {
  transition: margin-left 0.3s ease, width 0.3s ease;
}

/* Kelas saat area utama melebar 100% */
.main.expanded {
  margin-left: 0;
  width: 100%;
}

.sidebar-toggle-btn {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
  color: #0f172a;
  padding: 6px 14px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
  background: #e2e8f0;
  transform: scale(1.05);
}
