:root{
  --bg:#f5f7fb;
  --card:#ffffff;
  --border:#e6eaf2;
  --text:#0f172a;
  --muted:#64748b;
  --primary:#2563eb;
  --primary-2:#1d4ed8;
  --good:#16a34a;
  --warn:#f59e0b;
  --danger:#ef4444;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background:var(--bg);
  color:var(--text);
}

.topbar{
  position:sticky;
  top:0;
  z-index:100;
  background:rgba(255,255,255,.9);
  backdrop-filter: blur(10px);
  border-bottom:1px solid var(--border);
}
.topbar-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 18px;
  gap:12px;
}
.brand-title{
  font-weight:800;
  font-size:18px;
  letter-spacing:.2px;
}
.brand-sub{
  font-size:12px;
  color:var(--muted);
  margin-top:2px;
}
.topbar-actions{
  display:flex;
  align-items:flex-end;
  gap:10px;
  flex-wrap:wrap;
}
.month-wrap label{
  display:block;
  font-size:11px;
  color:var(--muted);
  margin-bottom:4px;
}
.month-wrap input{
  border:1px solid var(--border);
  background:#fff;
  padding:8px 10px;
  border-radius:10px;
  font-size:13px;
  outline:none;
}
.btn{
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  padding:9px 12px;
  border-radius:10px;
  font-size:13px;
  cursor:pointer;
}
.btn-sm{padding:7px 10px;font-size:12px;border-radius:10px}
.btn:hover{border-color:#cfd7e6}
.btn:active{transform: translateY(1px)}
.btn-ghost{background:transparent}
.user-pill{
  display:flex;
  align-items:center;
  gap:8px;
  border:1px solid var(--border);
  background:#fff;
  padding:8px 10px;
  border-radius:999px;
  font-size:13px;
}
.user-pill .dot{
  width:10px;height:10px;border-radius:999px;background:var(--good);
  box-shadow:0 0 0 3px rgba(22,163,74,.12);
}

.wrap{max-width:1280px;margin:0 auto;padding:18px}
.grid{display:grid;gap:14px}
.grid-2{grid-template-columns: 1.35fr 1fr}
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}
.card-span-2{grid-column:1 / -1}
.card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding:14px 14px 10px 14px;
  border-bottom:1px solid var(--border);
}
.card-title{font-weight:800}
.card-sub{font-size:12px;color:var(--muted);margin-top:2px}
.card-body{padding:14px}

.badge-row{display:flex;gap:8px;flex-wrap:wrap}
.badge{
  font-size:11px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#f8fafc;
}
.b-closing{border-color:rgba(37,99,235,.25); background:rgba(37,99,235,.06); color:var(--primary)}
.b-herreg{border-color:rgba(22,163,74,.25); background:rgba(22,163,74,.06); color:var(--good)}
.b-cb{border-color:rgba(245,158,11,.30); background:rgba(245,158,11,.08); color:var(--warn)}

.seg{
  display:flex;
  border:1px solid var(--border);
  border-radius:12px;
  overflow:hidden;
}
.seg-btn{
  border:0;
  background:#fff;
  padding:8px 10px;
  font-size:12px;
  cursor:pointer;
  color:var(--muted);
}
.seg-btn.is-active{
  background:rgba(37,99,235,.08);
  color:var(--primary);
  font-weight:700;
}

.kpi-mini{font-family:var(--mono);font-size:12px;color:var(--muted);padding-top:6px}
.skeleton{
  padding:12px;
  border:1px dashed var(--border);
  border-radius:12px;
  color:var(--muted);
  font-size:13px;
}

/* Calendar */
.cal-wrap{overflow:auto}
.cal-table{
  border-collapse:separate;
  border-spacing:0;
  width:max-content;
  min-width:100%;
  font-size:12px;
}
.cal-table th,.cal-table td{
  border-bottom:1px solid var(--border);
  padding:8px 10px;
  white-space:nowrap;
}
.cal-table thead th{
  position:sticky;
  top:0;
  background:#fff;
  z-index:2;
  font-weight:800;
  color:#0b1220;
}
.cal-table th:first-child,
.cal-table td:first-child{
  position:sticky;
  left:0;
  background:#fff;
  z-index:3;
  font-weight:700;
}
.cal-table td{
  text-align:center;
  min-width:40px;
}
.cal-cell{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:30px;height:26px;
  border-radius:8px;
  border:1px solid transparent;
  user-select:none;
}
.cal-cell.has{
  background:rgba(37,99,235,.08);
  color:var(--primary-2);
  border-color:rgba(37,99,235,.18);
  cursor:pointer;
}
.cal-cell.has:hover{background:rgba(37,99,235,.12)}
.cal-cell.zero{color:#cbd5e1}
.cal-row-total td{background:#fafafa;font-weight:800}

/* FU column in Calendar */
.th-inline{display:flex;align-items:center;gap:8px}
.fu-edit{
  display:inline-flex;align-items:center;justify-content:center;
  width:28px;height:28px;border-radius:10px;
  border:1px solid var(--border);background:rgba(15,23,42,.04);
  text-decoration:none;color:#0b1220;font-size:14px
}
.fu-edit:hover{background:rgba(37,99,235,.10);border-color:rgba(37,99,235,.25)}
.cal-table th.fu-col,.cal-table td.fu-col{min-width:140px}
.cal-cell.fu{
  width:auto;min-width:56px;padding:0 10px;
  font-family:var(--mono);font-weight:900;
  background:rgba(16,185,129,.10);color:#065f46;
  border-color:rgba(16,185,129,.25)
}

/* Rank list */
.rank-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 10px;
  border:1px solid var(--border);
  border-radius:12px;
  margin-bottom:10px;
}
.rank-left{min-width:42px;text-align:center;color:var(--muted);font-family:var(--mono)}
.rank-mid{flex:1;min-width:0}
.rank-name{
  font-weight:800;
  cursor:pointer;
}
.rank-name:hover{text-decoration:underline}
.rank-sub{font-size:12px;color:var(--muted);margin-top:2px}
.rank-bar{
  height:10px;border-radius:999px;background:#eef2ff;overflow:hidden;border:1px solid var(--border);
  margin-top:8px;
}
.rank-fill{height:100%}
.fill-closing{background:var(--primary)}
.fill-herreg{background:var(--good)}
.rank-right{font-family:var(--mono);font-weight:800}

/* Trend */
.trend-item{display:flex;gap:10px;align-items:center;padding:10px;border:1px solid var(--border);border-radius:12px;margin-bottom:10px}
.trend-name{font-weight:800;max-width:240px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.trend-meta{font-size:12px;color:var(--muted)}
.trend-bar{flex:1;height:10px;border-radius:999px;background:#f1f5f9;border:1px solid var(--border);overflow:hidden}
.trend-fill{height:100%;background:var(--primary)}
.trend-right{font-family:var(--mono);font-weight:800}

/* Program donut */
.prog-grid{display:grid;grid-template-columns: 160px 1fr;gap:14px;align-items:center}
.donut{
  width:150px;height:150px;border-radius:999px;
  background: conic-gradient(var(--primary) 0deg, var(--primary) 120deg, var(--good) 120deg, var(--good) 220deg, var(--warn) 220deg, var(--warn) 360deg);
  position:relative;
  border:1px solid var(--border);
  box-shadow: inset 0 0 0 10px rgba(255,255,255,.9);
}
.donut::after{
  content:"";
  position:absolute;inset:28px;
  border-radius:999px;
  background:#fff;
  border:1px solid var(--border);
}
.prog-legend .leg{
  display:flex;justify-content:space-between;gap:10px;
  padding:10px 10px;
  border:1px solid var(--border);
  border-radius:12px;
  margin-bottom:10px;
}
.prog-legend .leg-left{display:flex;align-items:center;gap:10px}
.swatch{width:10px;height:10px;border-radius:3px}
.muted{color:var(--muted)}

/* Table */
.table-wrap{overflow:auto}
.table{width:100%;border-collapse:separate;border-spacing:0;font-size:13px}
.table th,.table td{padding:10px 10px;border-bottom:1px solid var(--border);text-align:left;vertical-align:top}
.table thead th{position:sticky;top:0;background:#fff;z-index:1;font-weight:800}
.table tbody tr:hover{background:#fafafa}
.pill{
  font-size:11px;padding:6px 10px;border-radius:999px;border:1px solid var(--border);display:inline-flex;gap:6px;align-items:center
}
.pill.good{background:rgba(22,163,74,.08);border-color:rgba(22,163,74,.22);color:var(--good)}
.pill.primary{background:rgba(37,99,235,.08);border-color:rgba(37,99,235,.22);color:var(--primary)}
.pill.warn{background:rgba(245,158,11,.10);border-color:rgba(245,158,11,.26);color:var(--warn)}
a.link{color:var(--primary);text-decoration:none}
a.link:hover{text-decoration:underline}
.input{
  border:1px solid var(--border);
  background:#fff;
  padding:9px 10px;
  border-radius:10px;
  font-size:13px;
  outline:none;
  min-width: 160px;
}
.filters{display:flex;gap:10px;flex-wrap:wrap}

/* Modals */
.modal{
  position:fixed;inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background: rgba(15,23,42,.55);
  z-index:9999;
  padding:18px;
}
.modal.is-open{display:flex}
.modal-card{
  width:min(720px, 100%);
  background:#fff;
  border-radius:16px;
  border:1px solid var(--border);
  box-shadow: 0 20px 60px rgba(15,23,42,.30);
  overflow:hidden;
  max-height:88vh;
  display:flex;
  flex-direction:column;
}
.modal-wide{width:min(980px, 100%)}
.modal-head{
  display:flex;align-items:flex-start;justify-content:space-between;gap:10px;
  padding:14px 14px 10px 14px;border-bottom:1px solid var(--border);
}
.modal-title{font-weight:900}
.modal-sub{font-size:12px;color:var(--muted);margin-top:2px}
.modal-body{padding:14px; overflow:auto; flex:1 1 auto}
.icon-btn{
  border:1px solid var(--border);
  background:#fff;
  border-radius:12px;
  padding:8px 10px;
  cursor:pointer;
}
.icon-btn:hover{border-color:#cfd7e6}
.list .row{
  display:flex;justify-content:space-between;gap:12px;
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px;
  margin-bottom:10px;
}
.list .row .left{min-width:0}
.list .row .title{font-weight:900;cursor:pointer}
.list .row .title:hover{text-decoration:underline}
.list .row .meta{font-size:12px;color:var(--muted);margin-top:2px}
.list .row .right{text-align:right;font-family:var(--mono);font-weight:900}

.readmore{
  display:flex;
  justify-content:center;
  padding:8px 0 0 0;
}
.link-btn{
  border:0;
  background:transparent;
  color:var(--primary);
  font-weight:900;
  cursor:pointer;
  font-size:12px;
}
.link-btn:hover{text-decoration:underline}

.pager{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 4px 0 4px;
  flex-wrap:wrap;
}
.pager .pager-left,
.pager .pager-right{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.pager .pager-info{font-size:12px;color:var(--muted)}

.detail-kpi{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:12px}
.kpi{
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px;
}
.kpi .k{font-size:11px;color:var(--muted)}
.kpi .v{font-size:18px;font-weight:900;margin-top:4px}
.detail-prodi{margin-bottom:12px}

@media (max-width: 1020px){
  .grid-2{grid-template-columns:1fr}
  .detail-kpi{grid-template-columns:repeat(2,1fr)}
  .prog-grid{grid-template-columns:1fr}
  .donut{margin:0 auto}
}

.card-head-actions{
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:8px;
}
.cal-cell.fu-grand{
  cursor:pointer;
}
.cal-cell.fu-grand:hover{
  background:rgba(37,99,235,.10);
  color:var(--primary-2);
  border-color:rgba(37,99,235,.25);
}
.fu-breakdown-table th:first-child,
.fu-breakdown-table td:first-child{
  width:48px;
  text-align:center;
}
.fu-breakdown-table td:nth-child(n+3){
  font-family:var(--mono);
  font-weight:800;
}


.mini-refresh{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:22px;
  height:22px;
  margin-left:6px;
  border:1px solid var(--border);
  border-radius:999px;
  background:#fff;
  color:var(--primary-2);
  font-weight:900;
  line-height:1;
  cursor:pointer;
  vertical-align:middle;
}
.mini-refresh:hover{
  background:rgba(37,99,235,.10);
  border-color:rgba(37,99,235,.30);
}
.mini-refresh:disabled{
  cursor:not-allowed;
  opacity:.65;
}
.mini-refresh.is-loading{
  animation:spinTiny .9s linear infinite;
}
@keyframes spinTiny{to{transform:rotate(360deg)}}

@media (max-width: 720px){
  .card-head{flex-direction:column;align-items:stretch}
  .card-head-actions{align-items:stretch}
  .seg{width:100%;overflow:auto}
  .seg-btn{white-space:nowrap;flex:1}
}

/* Clickable analysis titles */
.title-action{
  appearance:none;
  border:0;
  background:transparent;
  padding:0;
  margin:0;
  color:inherit;
  font:inherit;
  text-align:left;
  cursor:pointer;
}
.title-action:hover{
  color:var(--primary);
  text-decoration:underline;
  text-underline-offset:3px;
}
.summary-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom:12px;
}
.summary-hint{
  font-size:12px;
  color:var(--muted);
}
.summary-table th:first-child,
.summary-table td:first-child{
  width:58px;
  text-align:center;
}
.summary-table th:nth-child(n+3),
.summary-table td:nth-child(n+3){
  text-align:right;
  white-space:nowrap;
}
.summary-name{
  font-weight:800;
  color:var(--text);
}
.summary-table .num{
  font-weight:800;
}
.summary-table .num.is-focus{
  color:var(--primary);
}
