@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: #0a0e1a;
    color: #e2e8f0;
    -webkit-tap-highlight-color: transparent;
}

.app {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* ─── HEADER ─── */
header {
    margin-bottom: 20px;
}
header h1 {
    font-size: 1.4rem;
    color: #fff;
}
header p {
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 2px;
}

/* ─── SUMMARY CARDS ─── */
.summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 24px;
}

.s-card {
    background: #111827;
    border-radius: 12px;
    padding: 14px;
    border: 1px solid #1e293b;
}

.s-card .s-label {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.s-card .s-value {
    display: block;
    font-size: 1.15rem;
    font-weight: 700;
}

.s-sisa {
    grid-column: 1 / 3;
    background: linear-gradient(135deg, #1a1025, #1e1145);
    border-color: #7c3aed33;
}
.s-sisa .s-value { color: #f87171; font-size: 1.4rem; }
.s-tagihan .s-value { color: #a78bfa; }
.s-masuk .s-value { color: #34d399; }

/* ─── SECTION HEADER ─── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.section-header h2 {
    font-size: 1.1rem;
    color: #fff;
}

.btn-add {
    background: #7c3aed;
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-add:hover { background: #6d28d9; }
.btn-add:active { transform: scale(0.97); }

/* ─── FILTERS ─── */
.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filters input,
.filters select {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    background: #111827;
    border: 1px solid #1e293b;
    border-radius: 10px;
    color: #e2e8f0;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.filters input:focus,
.filters select:focus {
    border-color: #7c3aed;
}

.filters select option {
    background: #111827;
}

.filters input[type="date"] {
    flex: 0.7;
}

.btn-reset {
    background: #1e293b;
    color: #94a3b8;
    border: 1px solid #334155;
    width: 40px;
    min-width: 40px;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-reset:hover { background: #334155; color: #fff; }

/* ─── PIUTANG CARDS ─── */
#list-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.piutang-card {
    background: #111827;
    border: 1px solid #1e293b;
    border-radius: 14px;
    padding: 14px;
    transition: border-color 0.2s;
}
.piutang-card:hover {
    border-color: #334155;
}

.pc-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.pc-nama {
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    flex: 1;
    margin-right: 10px;
}

.pc-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.pc-badge.belum_lunas { background: #f8717122; color: #f87171; }
.pc-badge.sebagian { background: #fb923c22; color: #fb923c; }
.pc-badge.lunas { background: #34d39922; color: #34d399; }

.pc-ket {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 10px;
    line-height: 1.4;
}

.pc-tanggal {
    font-size: 0.75rem;
    color: #475569;
    margin-bottom: 10px;
}

.pc-numbers {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
    background: #0a0e1a;
    border-radius: 10px;
    padding: 10px;
}

.pc-num-item {
    text-align: center;
}

.pc-num-label {
    display: block;
    font-size: 0.65rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

.pc-num-val {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
}

.pc-num-val.nominal { color: #a78bfa; }
.pc-num-val.dibayar { color: #34d399; }
.pc-num-val.kurang { color: #f87171; }

.pc-actions {
    display: flex;
    gap: 8px;
}

.pc-actions button {
    flex: 1;
    padding: 9px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: 0.2s;
}

.btn-bayar {
    background: #059669;
    color: #fff;
}
.btn-bayar:hover { background: #047857; }

.btn-hapus {
    background: #1e293b;
    color: #f87171;
    border: 1px solid #334155 !important;
}
.btn-hapus:hover { background: #334155; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #475569;
    font-size: 0.9rem;
}

/* ─── MODAL ─── */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    align-items: flex-end;
    justify-content: center;
}
.overlay.active { display: flex; }

.modal {
    background: #111827;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding: 24px 20px 30px;
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.modal-top h2 {
    font-size: 1.15rem;
    color: #fff;
}

.modal-close {
    background: #1e293b;
    border: none;
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close:hover { background: #334155; color: #fff; }

.modal label {
    display: block;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 6px;
    margin-top: 14px;
    font-weight: 600;
}
.modal label:first-of-type { margin-top: 0; }

.modal input,
.modal textarea {
    width: 100%;
    padding: 12px 14px;
    background: #0a0e1a;
    border: 1px solid #1e293b;
    border-radius: 10px;
    color: #e2e8f0;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}
.modal input:focus,
.modal textarea:focus {
    border-color: #7c3aed;
}
.modal textarea {
    resize: vertical;
    min-height: 60px;
}

.btn-submit {
    margin-top: 20px;
    width: 100%;
    padding: 14px;
    background: #7c3aed;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}
.btn-submit:hover { background: #6d28d9; }
.btn-submit:active { transform: scale(0.98); }

.btn-green { background: #059669; }
.btn-green:hover { background: #047857; }

.pay-info {
    background: #0a0e1a;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #94a3b8;
}
.pay-info strong {
    color: #fff;
}
.pay-info .pay-sisa {
    color: #f87171;
    font-weight: 700;
    font-size: 1.1rem;
}

/* ─── DESKTOP ─── */
@media (min-width: 768px) {
    .app { padding: 30px 24px 50px; }
    header h1 { font-size: 1.6rem; }

    .summary {
        grid-template-columns: 1fr 1fr 1fr;
    }
    .s-sisa { grid-column: auto; }

    .filters { flex-wrap: nowrap; }
    .filters input[type="date"] { flex: 0.5; }

    .overlay { align-items: center; }
    .modal { border-radius: 20px; }
}
