/* ============================================================
   PORTAL MITRA KARANGMUKTI — Design System
   Basis: ungu #6D28D9 → biru #2563EB, aksen pink #F04860
   ============================================================ */

:root {
  --primary: #6D28D9;
  --primary-2: #2563EB;
  --grad: linear-gradient(135deg, #7C3AED 0%, #4F46E5 55%, #2563EB 100%);
  --pink: #F04860;
  --dark: #1E1B4B;
  --bg: #F1F5F9;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --muted: #64748B;
  --green: #16A34A;
  --green-bg: #DCFCE7;
  --amber: #D97706;
  --amber-bg: #FEF3C7;
  --red: #DC2626;
  --red-bg: #FEE2E2;
  --gray-bg: #F1F5F9;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(30,27,75,.06), 0 8px 24px -12px rgba(30,27,75,.12);
  --shadow-lg: 0 20px 50px -20px rgba(30,27,75,.35);
  --sidebar-w: 250px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #1E1B4B 0%, #312E81 100%);
  color: #E0E7FF;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  transition: transform .25s ease;
}
.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo {
  width: 100%;
  height: auto;
  max-height: 46px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.25));
}
.sidebar-nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin-bottom: 4px;
  color: #C7D2FE; border-radius: 10px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item .ic { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(124,58,237,.6);
}
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }

.sidebar-overlay { display: none; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.page-title { font-size: 19px; font-weight: 700; color: var(--dark); }
.burger {
  display: none;
  background: var(--gray-bg); border: 1px solid var(--border);
  border-radius: 8px; width: 38px; height: 38px; font-size: 17px; cursor: pointer; color: var(--dark);
}
.topbar-right { margin-left: auto; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { font-size: 13px; color: var(--dark); }
.role-badge {
  display: inline-block; margin-top: 2px;
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
  padding: 1px 8px; border-radius: 20px; width: fit-content;
}
.role-admin { background: var(--purple-bg, #EDE9FE); color: var(--primary); }
.role-mitra { background: var(--blue-bg, #DBEAFE); color: var(--primary-2); }

.content { padding: 26px 28px 40px; max-width: none; width: 100%; }

/* ---------- Cards & stats ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--dark); margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  position: relative; overflow: hidden;
}
.stat-card .stat-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; color: var(--dark); margin-top: 6px; }
.stat-card .stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-card .stat-icon {
  position: absolute; right: 14px; top: 14px;
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.stat-card .stat-icon .ic { width: 20px; height: 20px; }
.stat-purple { background: #EDE9FE; color: var(--primary); }
.stat-blue { background: #DBEAFE; color: var(--primary-2); }
.stat-green { background: var(--green-bg); color: var(--green); }
.stat-amber { background: var(--amber-bg); color: var(--amber); }
.stat-pink { background: #FCE7F3; color: #DB2777; }
.stat-slate { background: var(--gray-bg); color: var(--muted); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: #F8FAFC; font-weight: 700; }
table.data tbody tr:hover { background: #F8FAFC; }
table.data td.num, table.data th.num { text-align: right; }
table.data .sub { color: var(--muted); font-size: 12px; }

/* ---------- Badge ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-gray { background: var(--gray-bg); color: var(--muted); }
.badge-purple { background: #EDE9FE; color: var(--primary); }
.badge-blue { background: #DBEAFE; color: var(--primary-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: filter .15s, transform .05s, background .15s;
}
.btn .ic { width: 15px; height: 15px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 16px -6px rgba(79,70,229,.55); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--gray-bg); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #FECACA; }
.btn-green { background: var(--green-bg); color: var(--green); }
.btn-green:hover { background: #BBF7D0; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Form ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--dark); margin-bottom: 6px; }
.field .req { color: var(--pink); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 13.5px; font-family: inherit; color: var(--text);
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(109,40,217,.12);
}
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.field .err { font-size: 11.5px; color: var(--red); margin-top: 4px; display: none; }
.field.invalid input { border-color: var(--red); }
.field.invalid .err { display: block; }
.field.checkbox { display: flex; align-items: center; gap: 8px; }
.field.checkbox input { width: auto; }

.paket-add-link {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px; font-size: 12.5px; font-weight: 600; color: var(--primary);
  cursor: pointer; background: none; border: none; padding: 0;
}
.paket-add-link .ic { width: 14px; height: 14px; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.search-box { position: relative; }
.search-box .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.search-box input {
  padding: 9px 12px 9px 34px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 13px; min-width: 230px; background: #fff;
}
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109,40,217,.12); }
select.select { padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 10px; font-size: 13px; background: #fff; }
select.select:focus { outline: none; border-color: var(--primary); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 18px; backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}
.modal.modal-sm { max-width: 400px; }
.modal.modal-lg { max-width: 760px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; color: var(--dark); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 8px; }
.modal-close:hover { background: var(--gray-bg); color: var(--dark); }
.modal-close .ic { width: 18px; height: 18px; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--dark); color: #fff; padding: 12px 22px; border-radius: 12px;
  font-weight: 600; font-size: 13.5px; z-index: 300;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease; max-width: 90vw;
}
.toast.ok { background: #166534; }
.toast.err { background: #991B1B; }
.toast.info { background: var(--dark); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .ic { width: 42px; height: 42px; color: #CBD5E1; margin-bottom: 10px; }
.empty p { font-size: 13.5px; }

/* ---------- Detail grid ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.detail-item .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.detail-item .v { font-size: 14px; font-weight: 600; color: var(--dark); margin-top: 2px; }

/* ---------- Rekap ---------- */
.rekap-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.rekap-card { border-radius: var(--radius); padding: 16px 18px; color: #fff; box-shadow: var(--shadow); }
.rekap-card .rk-label { font-size: 11.5px; opacity: .85; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.rekap-card .rk-value { font-size: 22px; font-weight: 800; margin-top: 5px; }
.rk-dpp { background: linear-gradient(135deg,#6D28D9,#4F46E5); }
.rk-ppn { background: linear-gradient(135deg,#DB2777,#F04860); }
.rk-bhp { background: linear-gradient(135deg,#2563EB,#0EA5E9); }
.rk-uso { background: linear-gradient(135deg,#0891B2,#06B6D4); }
.rk-total { background: linear-gradient(135deg,#16A34A,#22C55E); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 10px 18px; font-size: 13.5px; font-weight: 600; color: var(--muted);
  border: none; background: none; cursor: pointer;
  border-bottom: 2.5px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--dark); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; border: 1px solid var(--border); background: #fff;
  font-size: 13px; color: var(--text); font-weight: 600;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--grad); color: #fff; border-color: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 90; }
  .main { margin-left: 0; }
  .burger { display: inline-flex; align-items: center; justify-content: center; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 12px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .user-meta { display: none; }
  .search-box input { min-width: 160px; }
}
@media (max-width: 480px) {
  .stat-value { font-size: 21px; }
  .topbar .page-title { font-size: 16px; }
  .modal { max-height: 96vh; }
}

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: flex; }
.login-left {
  flex: 1.1; background: linear-gradient(160deg, #1E1B4B 0%, #312E81 45%, #4F46E5 80%, #2563EB 100%);
  color: #fff; padding: 56px 60px; display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
}
.login-left::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.14) 1.5px, transparent 1.5px);
  background-size: 26px 26px; opacity: .5;
}
.login-left::after {
  content: ''; position: absolute; width: 380px; height: 380px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.15); right: -120px; bottom: -120px;
  box-shadow: 0 0 0 46px rgba(255,255,255,.05), 0 0 0 92px rgba(255,255,255,.04);
}
.login-logo-chip {
  background: transparent; border-radius: 16px; padding: 14px 20px; width: fit-content;
  box-shadow: none;
  display: flex; align-items: center;
}
.login-logo-chip img { height: 156px; max-width: 100%; width: auto; object-fit: contain; }
.login-left h2 { font-size: 30px; font-weight: 800; margin-top: 30px; line-height: 1.2; max-width: 460px; }
.login-left p.tag { color: #C7D2FE; margin-top: 12px; font-size: 15px; max-width: 420px; }
.login-feats { margin-top: 34px; display: flex; flex-direction: column; gap: 14px; max-width: 400px; position: relative; z-index: 2; }
.login-feat { display: flex; gap: 12px; align-items: flex-start; }
.login-feat .fi {
  width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.14);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.login-feat .fi .ic { width: 17px; height: 17px; }
.login-feat b { display: block; font-size: 14px; }
.login-feat span { font-size: 12.5px; color: #C7D2FE; }

.login-right { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.login-box { width: 100%; max-width: 400px; }
.login-box h1 { font-size: 24px; font-weight: 800; color: var(--dark); }
.login-box p { color: var(--muted); margin: 8px 0 26px; font-size: 14px; }
.login-form .field { margin-bottom: 16px; }
.login-form .btn { width: 100%; padding: 12px; justify-content: center; font-size: 14.5px; }
.login-error {
  background: var(--red-bg); color: var(--red); padding: 11px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 600; margin-bottom: 16px; display: none;
}
.login-error.show { display: block; }
.login-secure { display: flex; align-items: center; gap: 7px; margin-top: 18px; color: var(--muted); font-size: 12.5px; justify-content: center; }
.login-secure .ic { width: 14px; height: 14px; }

@media (max-width: 820px) {
  .login-page { flex-direction: column; }
  .login-left { padding: 34px 26px; flex: none; }
  .login-left h2 { font-size: 22px; margin-top: 20px; }
  .login-feats { margin-top: 20px; }
  .login-right { padding: 30px 20px; }
}

/* ---------- Misc ---------- */
.flex { display: flex; align-items: center; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.section-gap { margin-bottom: 20px; }
