/* =====================================================================
   SIPIUTANG — Gaya Antarmuka
   Sistem Informasi Piutang & Penagihan — Roto-Rooter Indonesia
   ===================================================================== */

:root {
  --sp-navy:      #1f3864;
  --sp-navy-700:  #16294a;
  --sp-navy-300:  #35548f;
  --sp-accent:    #0d6efd;
  --sp-bg:        #f4f6fa;
  --sp-surface:   #ffffff;
  --sp-border:    #e3e8f0;
  --sp-text:      #1c2434;
  --sp-muted:     #6b7385;
  --sp-sidebar-w: 246px;
  --sp-topbar-h:  62px;
  --sp-radius:    10px;
  --sp-shadow:    0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
  --sp-shadow-lg: 0 8px 24px rgba(16,24,40,.12);
}

* { -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--sp-bg);
  color: var(--sp-text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ------------------------------------------------------------ SIDEBAR */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sp-sidebar-w);
  background: var(--sp-navy); color: #cfd8ea;
  display: flex; flex-direction: column; z-index: 1045;
  transition: transform .22s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .5rem;
  padding: .85rem 1rem; border-bottom: 1px solid rgba(255,255,255,.09);
  min-height: var(--sp-topbar-h);
}
.sidebar-brand a { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: #fff; flex: 1; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
  background: linear-gradient(140deg, #4b7bd6, #1f3864);
  display: grid; place-items: center; font-weight: 800; font-size: 17px; color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; letter-spacing: .3px; line-height: 1.1; }
.brand-text small { font-size: 10.5px; color: #9db0d4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-close { color: #cfd8ea; }

.sidebar-menu { list-style: none; margin: 0; padding: .5rem .5rem 1rem; overflow-y: auto; flex: 1; }
.sidebar-menu::-webkit-scrollbar { width: 6px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 3px; }
.sidebar-menu > li > a,
.sidebar-menu ul li a {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .7rem; border-radius: 8px; color: #cfd8ea;
  text-decoration: none; font-size: 13.5px; transition: background .13s, color .13s;
}
.sidebar-menu > li > a i:first-child { font-size: 16px; width: 20px; text-align: center; flex: 0 0 20px; }
.sidebar-menu > li > a:hover,
.sidebar-menu ul li a:hover { background: rgba(255,255,255,.09); color: #fff; }
.sidebar-menu > li.active > a { background: rgba(255,255,255,.15); color: #fff; font-weight: 600; }
.sidebar-menu ul { list-style: none; padding: .15rem 0 .3rem 2.05rem; margin: 0; }
.sidebar-menu ul li a { padding: .4rem .65rem; font-size: 12.8px; }
.sidebar-menu ul li.active a { color: #fff; background: rgba(255,255,255,.12); font-weight: 600; }
.sidebar-menu .chev { margin-left: auto; font-size: 11px; transition: transform .18s; }
.sidebar-menu a[aria-expanded="true"] .chev { transform: rotate(180deg); }
.sidebar-footer { padding: .6rem 1rem; border-top: 1px solid rgba(255,255,255,.09); font-size: 11px; color: #8ea2c8; }
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 1044;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

/* ------------------------------------------------------------ MAIN */
.main { margin-left: var(--sp-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 1030;
  display: flex; align-items: center; gap: .75rem;
  min-height: var(--sp-topbar-h); padding: .5rem 1.15rem;
  background: var(--sp-surface); border-bottom: 1px solid var(--sp-border);
}
.topbar-title { min-width: 0; }
.topbar-title h1 { font-size: 17px; font-weight: 700; margin: 0; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { font-size: 12px; color: var(--sp-muted); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-search { position: relative; margin-left: 1.5rem; max-width: 380px; flex: 1; }
.topbar-search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--sp-muted); font-size: 13px; }
.topbar-search input { padding-left: 32px; background: var(--sp-bg); border-color: var(--sp-border); font-size: 13px; height: 36px; }
.topbar-search input:focus { background: #fff; }

.user-btn { display: flex; align-items: center; gap: .55rem; border: 0; background: transparent; padding: .25rem .4rem; }
.user-btn:hover { background: var(--sp-bg); border-radius: 8px; }
.user-btn strong { display: block; font-size: 13px; line-height: 1.15; }
.user-btn small { display: block; font-size: 11px; color: var(--sp-muted); line-height: 1.15; }
.avatar {
  width: 33px; height: 33px; border-radius: 50%; flex: 0 0 33px;
  background: linear-gradient(140deg, #4b7bd6, #1f3864); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; text-transform: uppercase;
}

.content { padding: 1.15rem; flex: 1; }
.footer {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1.15rem; border-top: 1px solid var(--sp-border);
  font-size: 11.5px; color: var(--sp-muted); background: var(--sp-surface);
}

/* ------------------------------------------------------------ KOMPONEN */
.card { border: 1px solid var(--sp-border); border-radius: var(--sp-radius); box-shadow: var(--sp-shadow); }
.card-header {
  background: var(--sp-surface); border-bottom: 1px solid var(--sp-border);
  font-weight: 650; font-size: 13.5px; padding: .7rem 1rem;
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  border-radius: var(--sp-radius) var(--sp-radius) 0 0 !important;
}
.card-header .card-actions { margin-left: auto; display: flex; gap: .4rem; flex-wrap: wrap; }

/* Kartu KPI */
.kpi-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); }
.kpi {
  background: var(--sp-surface); border: 1px solid var(--sp-border); border-radius: var(--sp-radius);
  padding: .8rem .9rem; box-shadow: var(--sp-shadow);
  display: flex; flex-direction: column; gap: .15rem; position: relative; overflow: hidden;
  text-decoration: none; color: inherit; transition: transform .12s, box-shadow .12s;
}
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--sp-shadow-lg); color: inherit; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--bs-primary); }
.kpi.kpi-success::before { background: var(--bs-success); }
.kpi.kpi-danger::before  { background: var(--bs-danger); }
.kpi.kpi-warning::before { background: var(--bs-warning); }
.kpi.kpi-info::before    { background: var(--bs-info); }
.kpi.kpi-dark::before    { background: #495057; }
.kpi.kpi-secondary::before { background: var(--bs-secondary); }
.kpi-label { font-size: 11.5px; color: var(--sp-muted); text-transform: uppercase; letter-spacing: .3px; font-weight: 600; }
.kpi-value { font-size: 19px; font-weight: 750; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-value.sm { font-size: 16px; }
.kpi-sub { font-size: 11.5px; color: var(--sp-muted); }
.kpi-icon { position: absolute; right: .6rem; top: .6rem; font-size: 22px; opacity: .1; }

/* Tabel */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { font-size: 13px; margin: 0; }
.table > thead > tr > th {
  background: #f8fafc; border-bottom: 2px solid var(--sp-border);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .25px;
  font-weight: 700; color: #4a5568; white-space: nowrap; padding: .55rem .6rem; vertical-align: middle;
}
.table > tbody > tr > td { padding: .5rem .6rem; vertical-align: middle; }
.table-sticky thead th { position: sticky; top: 0; z-index: 5; }
.table-hover > tbody > tr:hover > * { background: #f1f5fb; }
.table tfoot td { background: #eef3fb; font-weight: 700; border-top: 2px solid var(--sp-navy); }
.num  { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ctr  { text-align: center; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.text-negative { color: var(--bs-danger); font-weight: 600; }
.cell-strong { font-weight: 650; }

/* Filter */
.filter-bar {
  background: var(--sp-surface); border: 1px solid var(--sp-border); border-radius: var(--sp-radius);
  padding: .8rem; margin-bottom: .9rem; box-shadow: var(--sp-shadow);
}
.filter-bar .form-label { font-size: 11.5px; font-weight: 650; color: #4a5568; margin-bottom: .2rem; text-transform: uppercase; letter-spacing: .2px; }
.filter-bar .form-control, .filter-bar .form-select { font-size: 13px; }

.form-label { font-size: 12.5px; font-weight: 600; margin-bottom: .25rem; }
.form-control, .form-select { border-color: #d7dfeb; }
.form-control:focus, .form-select:focus { border-color: var(--sp-navy-300); box-shadow: 0 0 0 .18rem rgba(31,56,100,.12); }
.form-control-sm, .form-select-sm { font-size: 12.5px; }
.required::after { content: " *"; color: var(--bs-danger); }
.form-text { font-size: 11.5px; }

.btn { font-size: 13.5px; border-radius: 7px; }
.btn-sm { font-size: 12.5px; }
.btn-primary { background: var(--sp-navy); border-color: var(--sp-navy); }
.btn-primary:hover, .btn-primary:focus { background: var(--sp-navy-700); border-color: var(--sp-navy-700); }
.btn-outline-primary { color: var(--sp-navy); border-color: var(--sp-navy); }
.btn-outline-primary:hover { background: var(--sp-navy); border-color: var(--sp-navy); }

.badge { font-weight: 600; font-size: 11px; padding: .3em .55em; }

/* Chart */
.chart-box { position: relative; height: 268px; }
.chart-box.sm { height: 210px; }
.chart-box.lg { height: 330px; }

/* Halaman & status */
.pagination { font-size: 13px; margin: 0; }
.page-link { color: var(--sp-navy); }
.page-item.active .page-link { background: var(--sp-navy); border-color: var(--sp-navy); }

.empty-state { text-align: center; padding: 2.6rem 1rem; color: var(--sp-muted); }
.empty-state i { font-size: 42px; opacity: .3; display: block; margin-bottom: .6rem; }

.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,.72); backdrop-filter: blur(2px);
  display: none; place-content: center; text-align: center; z-index: 2000;
}
.loading-overlay.show { display: grid; }
.loading-overlay p { margin-top: .7rem; color: var(--sp-muted); font-size: 13px; }

/* Timeline riwayat */
.timeline { position: relative; padding-left: 1.6rem; }
.timeline::before { content: ""; position: absolute; left: .42rem; top: .25rem; bottom: .25rem; width: 2px; background: var(--sp-border); }
.timeline-item { position: relative; padding-bottom: .95rem; }
.timeline-item::before {
  content: ""; position: absolute; left: -1.32rem; top: .3rem;
  width: 10px; height: 10px; border-radius: 50%; background: var(--sp-navy); box-shadow: 0 0 0 3px #fff;
}
.timeline-item.success::before { background: var(--bs-success); }
.timeline-item.danger::before  { background: var(--bs-danger); }
.timeline-item.warning::before { background: var(--bs-warning); }
.timeline-time { font-size: 11.5px; color: var(--sp-muted); }

/* Aging bar */
.aging-bar { display: flex; height: 9px; border-radius: 5px; overflow: hidden; background: var(--sp-border); }
.aging-bar span { display: block; height: 100%; }

/* Report builder */
.rb-field-list { max-height: 380px; overflow-y: auto; border: 1px solid var(--sp-border); border-radius: 8px; }
.rb-field-list .list-group-item { padding: .35rem .6rem; font-size: 12.5px; cursor: pointer; border-left: 0; border-right: 0; }
.rb-field-list .list-group-item:hover { background: #eef3fb; }
.rb-chip {
  display: inline-flex; align-items: center; gap: .35rem; background: #eef3fb;
  border: 1px solid #cfdcf0; border-radius: 20px; padding: .16rem .55rem; font-size: 12px; margin: .12rem;
}
.rb-chip button { border: 0; background: transparent; line-height: 1; padding: 0 0 0 .15rem; color: var(--sp-muted); }
.rb-row { display: grid; gap: .4rem; align-items: center; margin-bottom: .4rem; }
.rb-row.cols   { grid-template-columns: 1fr 150px 130px 34px; }
.rb-row.filters{ grid-template-columns: 76px 1fr 165px 1fr 1fr 34px; }
@media (max-width: 991.98px) {
  .rb-row.cols, .rb-row.filters { grid-template-columns: 1fr; }
}

/* Wizard */
.wizard-steps { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1rem; }
.wizard-step {
  flex: 1; min-width: 105px; padding: .5rem .6rem; border-radius: 8px; font-size: 12px;
  background: var(--sp-surface); border: 1px solid var(--sp-border); color: var(--sp-muted);
  display: flex; align-items: center; gap: .45rem;
}
.wizard-step .n {
  width: 21px; height: 21px; border-radius: 50%; background: var(--sp-border); color: #5a6478;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: 0 0 21px;
}
.wizard-step.active { border-color: var(--sp-navy); color: var(--sp-navy); font-weight: 650; background: #eef3fb; }
.wizard-step.active .n { background: var(--sp-navy); color: #fff; }
.wizard-step.done { border-color: var(--bs-success); color: var(--bs-success); }
.wizard-step.done .n { background: var(--bs-success); color: #fff; }

/* Detail list */
.dl-grid { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; gap: .3rem .9rem; font-size: 13px; }
.dl-grid dt { color: var(--sp-muted); font-weight: 500; }
.dl-grid dd { margin: 0; font-weight: 550; }

.stat-strip { display: flex; flex-wrap: wrap; gap: 1.4rem; padding: .7rem 1rem; background: #f8fafc; border-bottom: 1px solid var(--sp-border); }
.stat-strip .s { display: flex; flex-direction: column; }
.stat-strip .s .lbl { font-size: 11px; color: var(--sp-muted); text-transform: uppercase; letter-spacing: .25px; font-weight: 600; }
.stat-strip .s .val { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Login */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 1.2rem;
  background: linear-gradient(140deg, #1f3864 0%, #2d4d85 45%, #16294a 100%);
}
.login-card {
  width: 100%; max-width: 412px; background: #fff; border-radius: 14px;
  box-shadow: 0 18px 46px rgba(0,0,0,.28); overflow: hidden;
}
.login-head { padding: 1.7rem 1.7rem 1.1rem; text-align: center; }
.login-head .brand-mark { width: 52px; height: 52px; font-size: 26px; margin: 0 auto .7rem; border-radius: 13px; }
.login-head h1 { font-size: 20px; font-weight: 750; margin: 0; }
.login-head p { font-size: 12.5px; color: var(--sp-muted); margin: .2rem 0 0; }
.login-body { padding: 0 1.7rem 1.4rem; }
.login-foot { background: #f6f8fc; padding: .85rem 1.7rem; font-size: 11.5px; color: var(--sp-muted); text-align: center; border-top: 1px solid var(--sp-border); }
.demo-accounts { font-size: 11.5px; }
.demo-accounts code { font-size: 11px; }

/* Responsif */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .content { padding: .85rem; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
  .kpi-value { font-size: 17px; }
}
@media (max-width: 575.98px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .table { font-size: 12px; }
  .topbar-title h1 { font-size: 15px; }
  .dl-grid { grid-template-columns: 1fr; gap: .05rem .5rem; }
  .dl-grid dt { margin-top: .45rem; font-size: 11.5px; }
}

/* Cetak */
@media print {
  .sidebar, .topbar, .footer, .filter-bar, .no-print, .btn, .pagination, .sidebar-backdrop { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; }
  .card { border: 0; box-shadow: none; }
  body { background: #fff; font-size: 11px; }
  .table { font-size: 10.5px; }
  a[href]::after { content: ""; }
}
