* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: #f4f6f9;
    color: #26323d;
    font-size: 14px;
}
a { color: inherit; text-decoration: none; }

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

.sidebar {
    width: 230px;
    background: #ffffff;
    border-right: 1px solid #e3e7ec;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}
.sidebar .brand {
    padding: 18px 16px;
    font-weight: 700;
    font-size: 16px;
    border-bottom: 1px solid #e3e7ec;
    color: #1d3557;
}
.sidebar nav { padding: 10px 0; }
.sidebar .group-label {
    padding: 14px 16px 6px;
    font-size: 11px;
    letter-spacing: .05em;
    color: #8a97a6;
    font-weight: 700;
}
.sidebar a.nav-link {
    display: block;
    padding: 9px 16px;
    color: #44515f;
    border-left: 3px solid transparent;
}
.sidebar a.nav-link:hover { background: #f4f6f9; }
.sidebar a.nav-link.active {
    background: #eef3fb;
    border-left-color: #2563eb;
    color: #2563eb;
    font-weight: 600;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e3e7ec;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}
.topbar .user { font-weight: 600; color: #44515f; }
.topbar .user a { color: #b42318; margin-left: 12px; font-size: 13px; font-weight: 500; }

.content { padding: 20px; }
.breadcrumb { color: #8a97a6; font-size: 13px; margin-bottom: 14px; }
.breadcrumb b { color: #26323d; }

h1.page-title { font-size: 20px; margin: 0 0 16px; color: #1d3557; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat-card {
    border-radius: 8px;
    padding: 16px 18px;
    color: #fff;
}
.stat-card .label { font-size: 13px; opacity: .9; margin-bottom: 8px; }
.stat-card .value { font-size: 22px; font-weight: 700; }
.stat-card.red { background: #e5484d; }
.stat-card.green { background: #30a46c; }
.stat-card.orange { background: #f5a524; }
.stat-card.blue { background: #2563eb; }

.panel {
    background: #fff;
    border: 1px solid #e3e7ec;
    border-radius: 8px;
    padding: 16px;
}
.panel h2 { font-size: 15px; margin: 0 0 12px; color: #1d3557; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th, table.data-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #eef1f4;
    text-align: left;
    white-space: nowrap;
}
table.data-table th {
    background: #1d3557;
    color: #fff;
    position: sticky;
    top: 0;
}
table.data-table tbody tr:hover { background: #f8fafc; }
.table-wrap { overflow: auto; max-height: 70vh; border: 1px solid #e3e7ec; border-radius: 6px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=text] {
    padding: 8px 10px;
    border: 1px solid #cfd8e3;
    border-radius: 6px;
    min-width: 260px;
    font-size: 13px;
}
.toolbar .count { color: #8a97a6; font-size: 13px; margin-left: auto; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tabs a {
    padding: 8px 16px;
    border-radius: 6px 6px 0 0;
    background: #eef1f4;
    color: #44515f;
    font-weight: 600;
    font-size: 13px;
}
.tabs a.active { background: #1d3557; color: #fff; }

.pagination { display: flex; gap: 6px; margin-top: 14px; align-items: center; }
.pagination a, .pagination span {
    padding: 6px 11px;
    border: 1px solid #cfd8e3;
    border-radius: 6px;
    font-size: 13px;
    color: #44515f;
}
.pagination .current { background: #1d3557; color: #fff; border-color: #1d3557; }
.pagination .disabled { opacity: .4; }

.badge { padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.y { background: #dcfce7; color: #166534; }
.badge.t { background: #fee2e2; color: #991b1b; }

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1d3557;
}
.login-box {
    background: #fff;
    width: 340px;
    padding: 30px 28px;
    border-radius: 10px;
}
.login-box h1 { font-size: 18px; margin: 0 0 4px; color: #1d3557; }
.login-box p.sub { color: #8a97a6; font-size: 13px; margin: 0 0 20px; }
.login-box label { display: block; font-size: 13px; margin-bottom: 6px; color: #44515f; font-weight: 600; }
.login-box input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cfd8e3;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 14px;
}
.login-box button {
    width: 100%;
    padding: 11px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.login-box .error { background: #fee2e2; color: #991b1b; padding: 8px 10px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }

/* ---- Form transaksi (Penjualan/Pembelian) ---- */
.text-right { text-align: right; }
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 16px; margin-bottom: 16px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid .span3 { grid-column: span 3; }
.form-grid .span4 { grid-column: span 4; }
.form-field label { display: block; font-size: 12px; font-weight: 600; color: #44515f; margin-bottom: 4px; }
.form-field input, .form-field select, .form-field textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #cfd8e3; border-radius: 6px; font-size: 13px;
}
.form-field input[readonly] { background: #f4f6f9; color: #6b7785; }

.item-grid-wrap { overflow-x: auto; border: 1px solid #e3e7ec; border-radius: 6px; margin-bottom: 14px; }
table.item-grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.item-grid th, table.item-grid td { padding: 6px 8px; border-bottom: 1px solid #eef1f4; }
table.item-grid th { background: #1d3557; color: #fff; white-space: nowrap; text-align: left; }
table.item-grid input, table.item-grid select { padding: 5px 6px; border: 1px solid #cfd8e3; border-radius: 4px; font-size: 12.5px; }

.lookup-box div:hover { background: #eef3fb; }

.faktur-footer { display: flex; justify-content: flex-end; }
.faktur-footer table { border-collapse: collapse; min-width: 320px; }
.faktur-footer td { padding: 5px 8px; font-size: 13px; }
.faktur-footer td:first-child { color: #44515f; }
.faktur-footer td:last-child { text-align: right; font-weight: 600; }
.faktur-footer tr.grand td { font-size: 17px; font-weight: 700; color: #1d3557; border-top: 2px solid #1d3557; padding-top: 8px; }
.faktur-footer input[type=number] { width: 80px; padding: 4px 6px; border: 1px solid #cfd8e3; border-radius: 4px; text-align: right; }

.btn { display: inline-block; padding: 9px 18px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-secondary { background: #eef1f4; color: #44515f; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-add { background: #eef3fb; color: #2563eb; border: 1px dashed #2563eb; padding: 7px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; margin-bottom: 14px; }

.status-pill { padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.status-pill.lunas { background: #dcfce7; color: #166534; }
.status-pill.belum_lunas { background: #fee2e2; color: #991b1b; }

/* ===== Cetak laporan: sembunyikan menu, filter & tombol; tampilkan kop ===== */
.print-only { display: none; }
.num { text-align: right; white-space: nowrap; }
@media print {
    .sidebar, .topbar, form.toolbar, .no-print { display: none !important; }
    .print-only { display: block !important; }
    .app, .main { display: block; }
    body { background: #fff; }
    .table-wrap { max-height: none !important; overflow: visible !important; border: none; }
    .data-table { font-size: 10.5px; }
    .data-table th { background: #e5e7eb !important; color: #111 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .page-title, .breadcrumb { display: none; }
    a { color: inherit; text-decoration: none; }
}
/* grid input: baris kosong otomatis di bawah (autoBarisKosong) -- tombol hapus disembunyikan */
tr.baris-kosong .f-remove { visibility: hidden; }

/* ---- Filter bar list + tombol export (layout/filter_bar.php) ---- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end; background: #fff; border: 1px solid #e3e7ec; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.filter-bar .ff { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; font-weight: 600; color: #44515f; }
.filter-bar .ff-aksi { display: flex; gap: 6px; }
.list-actions { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.list-actions .count { color: #8a97a6; font-size: 13px; margin-right: auto; }
.btn-export { padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 600; text-decoration: none; border: 1px solid; white-space: nowrap; cursor: pointer; }
.btn-export.xlsx { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-export.pdf { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-export.cetak { background: #fff; border-color: #cfd8e3; color: #44515f; }

/* ---- Menu samping: grup bisa dilipat (default tertutup, lihat script di layout/header.php) ---- */
.sidebar .group-label { cursor: pointer; user-select: none; display: flex; justify-content: space-between; align-items: center; padding-right: 14px; }
.sidebar .group-label:hover { color: #44515f; }
.sidebar .group-label::after { content: '\25B8'; font-size: 11px; transition: transform .15s; }
.sidebar .group-label.open::after { transform: rotate(90deg); }
.sidebar .group-label:focus-visible { outline: 2px solid #2563eb; outline-offset: -2px; }
.topbar .user { margin-left: auto; }
.nav-toggle { display: none; background: none; border: 1px solid #cfd8e3; border-radius: 6px; font-size: 20px; line-height: 1; padding: 6px 10px; cursor: pointer; color: #1d3557; }
.nav-backdrop { display: none; }

/* ---- Tablet & HP ---- */
@media (max-width: 1024px) {
    .nav-toggle { display: inline-block; }
    .sidebar { position: fixed; left: 0; top: 0; z-index: 1000; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 2px 0 12px rgba(0,0,0,.12); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 999; }
    .content { padding: 16px; }
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid .span3, .form-grid .span4 { grid-column: span 2; }
}
@media (max-width: 640px) {
    body { font-size: 13.5px; }
    .content { padding: 12px; }
    .topbar { padding: 0 12px; height: 52px; }
    .topbar .user { font-size: 13px; }
    .topbar .user a { margin-left: 8px; }
    h1.page-title { font-size: 18px; margin-bottom: 12px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span2, .form-grid .span3, .form-grid .span4 { grid-column: auto; }
    .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
    .stat-card { padding: 12px; }
    .stat-card .value { font-size: 16px; word-break: break-word; }
    .stat-card .label { font-size: 12px; }
    .filter-bar { padding: 10px; }
    .filter-bar .ff { flex: 1 1 140px; }
    .filter-bar .ff input, .filter-bar .ff select { width: 100%; min-width: 0 !important; }
    .filter-bar .ff-aksi { flex: 1 1 100%; }
    .filter-bar .ff-aksi .btn { flex: 1; text-align: center; }
    .toolbar input[type=text] { min-width: 0; flex: 1 1 100%; }
    .table-wrap { max-height: none; }
    .pagination { flex-wrap: wrap; }
    .panel { padding: 12px; }
}
@media (max-width: 1024px) {
    .panel { overflow-x: auto; max-width: 100%; }
    .card-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)) !important; }
}
@media (max-width: 768px) {
    /* grid 2-3 kolom yg ditulis inline di view (panel berdampingan) -> ditumpuk */
    .content [style*="grid-template-columns"]:not(.card-grid) { grid-template-columns: 1fr !important; }
}

/* Log Aktivitas: daftar perubahan nilai lama -> baru */
.log-ubah { font-size: 12px; margin: 4px 0; padding: 6px 8px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; white-space: normal; }
.log-ubah .lama { color: #b42318; text-decoration: line-through; }
.log-ubah .baru { color: #166534; font-weight: 600; }
.riwayat-link { float: right; font-size: 12px; color: #6b7785; margin: -2px 0 8px 12px; }
.riwayat-link a { color: #2563eb; font-weight: 600; }
@media (max-width: 640px) { .riwayat-link { float: none; margin: 0 0 8px; } }
.btn-export.formal { background: #1d3557; border-color: #1d3557; color: #fff; }

/* tombol Refresh (baca ulang data terbaru) di list & laporan */
.btn-export.refresh { background: #fff; border-color: #2563eb; color: #2563eb; }
.btn-export.refresh:hover { background: #eff6ff; }
.refresh-jam { color: #8a97a6; font-size: 11.5px; white-space: nowrap; }
